Re: [PATCH 2.6.28-rc5 03/11] kmemleak: Add the memoryallocation/freeing hooks

From: Catalin Marinas
Date: Fri Nov 21 2008 - 06:07:36 EST


Hi Pekka,

On Thu, 2008-11-20 at 21:30 +0200, Pekka Enberg wrote:
> > @@ -2610,6 +2611,9 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
> > /* Slab management obj is off-slab. */
> > slabp = kmem_cache_alloc_node(cachep->slabp_cache,
> > local_flags & ~GFP_THISNODE, nodeid);
> > + /* only scan the list member to avoid false negatives */
> > + memleak_scan_area(slabp, offsetof(struct slab, list),
> > + sizeof(struct list_head));
>
> I find this comment somewhat confusing. Does it mean we _must_ scan
> the list members to avoid false negatives (i.e. leaks that happened
> but were not reported) or that if we scan the whole of struct slab, we
> get false negatives?

It's been some time since I first added this and I may not remember the
full details but it's the latter case - it should avoid scanning
slabp->s_mem because (my understanding) is that it may contain a pointer
to an allocated block. Kmemleak only allows adding what sections to
scan, so in this case only the list_head is relevant.

Let me know if my understanding is correct and I'll make the comment
more clear.

Thanks.

--
Catalin

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/