Re: [PATCH] Fix two potential mem leaks in MPT Fusion (mpt_attach())

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/08/07, Andrew Morton <[email protected]> wrote:
> On Fri, 3 Aug 2007 00:53:44 +0200
> Jesper Juhl <[email protected]> wrote:
>
> > On Thursday 02 August 2007 10:20:47 Jesper Juhl wrote:
> > > On 02/08/07, Andrew Morton <[email protected]> wrote:
> > [snip]
> > > > y'know, we could have a debug option which will spit warnings if someone
> > > > does a !__GFP_WAIT allocation while !in_atomic() (only works if
> > > > CONFIG_PREEMPT).
> > > >
> > > > But please, make it depend on !CONFIG_AKPM.  I shudder to think about all
> > > > the stuff it would pick up.
> > > >
> > >
> > > I can try to cook up something like that tonight...
> > >
> >
> > Ok, so I did a quick hack and I'm drowning in dmesg WARN_ON() traces
> > with my usual config.
> >
> > This is what I added :
> >
> > diff --git a/mm/slub.c b/mm/slub.c
> > index 6c6d74f..e60dd9e 100644
> > --- a/mm/slub.c
> > +++ b/mm/slub.c
> > @@ -20,6 +20,7 @@
> >  #include <linux/mempolicy.h>
> >  #include <linux/ctype.h>
> >  #include <linux/kallsyms.h>
> > +#include <linux/hardirq.h>
> >
> >  /*
> >   * Lock order:
> > @@ -1568,6 +1569,10 @@ static void __always_inline *slab_alloc(struct kmem_cache *s,
> >
> >  void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags)
> >  {
> > +#ifdef CONFIG_PREEMPT
> > +     WARN_ON( !in_atomic() && !(gfpflags & __GFP_WAIT) );
> > +#endif
> > +
> >       return slab_alloc(s, gfpflags, -1, __builtin_return_address(0));
> >  }
> >  EXPORT_SYMBOL(kmem_cache_alloc);
> > @@ -2370,6 +2375,10 @@ void *__kmalloc(size_t size, gfp_t flags)
> >  {
> >       struct kmem_cache *s = get_slab(size, flags);
> >
> > +#ifdef CONFIG_PREEMPT
> > +     WARN_ON( !in_atomic() && !(flags & __GFP_WAIT) );
> > +#endif
> > +
> >       if (ZERO_OR_NULL_PTR(s))
> >               return s;
> >
> >
> >
> > And this is what I'm getting heaps of :
> >
> > ...
> > [  165.128607]  =======================
> > [  165.128609] WARNING: at mm/slub.c:1573 kmem_cache_alloc()
> > [  165.128611]  [<c010400a>] show_trace_log_lvl+0x1a/0x30
> > [  165.128614]  [<c0104cd2>] show_trace+0x12/0x20
> > [  165.128616]  [<c0104cf6>] dump_stack+0x16/0x20
> > [  165.128619]  [<c0175ad3>] kmem_cache_alloc+0xe3/0x110
> > [  165.128622]  [<c015b10e>] mempool_alloc_slab+0xe/0x10
> > [  165.128625]  [<c015b211>] mempool_alloc+0x31/0xf0
>
> I said you would.
>
Hehe, I know you did. I'm not complaining, simply stating facts
(confirming what you said actually).

> > So, where do we go from here?
>
> Where I said ;) Add a new __GFP_ flag which suppresses the warning, add
> that flag to known-to-be-OK callsites, such as mempool_alloc().
>
Ok, I'll try to play around with this some more, try to filter out
false positives and see what I'm left with (if anything - I'm pretty
limited hardware-wise, so I can only test a small subset of drivers,
archs etc) - I'll keep you informed, but expect a few days to pass
before I have any news...


-- 
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux