Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755068AbZGGHIz (ORCPT ); Tue, 7 Jul 2009 03:08:55 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752750AbZGGHIs (ORCPT ); Tue, 7 Jul 2009 03:08:48 -0400 Received: from courier.cs.helsinki.fi ([128.214.9.1]:51543 "EHLO mail.cs.helsinki.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751615AbZGGHIs (ORCPT ); Tue, 7 Jul 2009 03:08:48 -0400 Subject: Re: [RFC PATCH 2/3] kmemleak: Add callbacks to the bootmem allocator From: Pekka Enberg To: Catalin Marinas Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ingo Molnar , hannes@cmpxchg.org In-Reply-To: <20090706105155.16051.59597.stgit@pc1117.cambridge.arm.com> References: <20090706104654.16051.44029.stgit@pc1117.cambridge.arm.com> <20090706105155.16051.59597.stgit@pc1117.cambridge.arm.com> Date: Tue, 07 Jul 2009 10:08:50 +0300 Message-Id: <1246950530.24285.7.camel@penberg-laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Mailer: Evolution 2.24.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4694 Lines: 133 On Mon, 2009-07-06 at 11:51 +0100, Catalin Marinas wrote: > This patch adds kmemleak_alloc/free callbacks to the bootmem allocator. > This would allow scanning of such blocks and help avoiding a whole class > of false positives and more kmemleak annotations. > > Signed-off-by: Catalin Marinas > Cc: Ingo Molnar > Cc: Pekka Enberg Looks good to me! Acked-by: Pekka Enberg But lets cc Johannes on this too. > --- > mm/bootmem.c | 36 +++++++++++++++++++++++++++++------- > 1 files changed, 29 insertions(+), 7 deletions(-) > > diff --git a/mm/bootmem.c b/mm/bootmem.c > index d2a9ce9..18858ad 100644 > --- a/mm/bootmem.c > +++ b/mm/bootmem.c > @@ -335,6 +335,8 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, > { > unsigned long start, end; > > + kmemleak_free(__va(physaddr)); > + > start = PFN_UP(physaddr); > end = PFN_DOWN(physaddr + size); > > @@ -354,6 +356,8 @@ void __init free_bootmem(unsigned long addr, unsigned long size) > { > unsigned long start, end; > > + kmemleak_free_part(__va(addr), size); > + > start = PFN_UP(addr); > end = PFN_DOWN(addr + size); > > @@ -597,7 +601,9 @@ restart: > void * __init __alloc_bootmem_nopanic(unsigned long size, unsigned long align, > unsigned long goal) > { > - return ___alloc_bootmem_nopanic(size, align, goal, 0); > + void *ptr = ___alloc_bootmem_nopanic(size, align, goal, 0); > + kmemleak_alloc(ptr, size, 1, GFP_KERNEL); > + return ptr; > } > > static void * __init ___alloc_bootmem(unsigned long size, unsigned long align, > @@ -631,7 +637,9 @@ static void * __init ___alloc_bootmem(unsigned long size, unsigned long align, > void * __init __alloc_bootmem(unsigned long size, unsigned long align, > unsigned long goal) > { > - return ___alloc_bootmem(size, align, goal, 0); > + void *ptr = ___alloc_bootmem(size, align, goal, 0); > + kmemleak_alloc(ptr, size, 1, GFP_KERNEL); > + return ptr; > } > > static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata, > @@ -669,10 +677,14 @@ static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata, > void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, > unsigned long align, unsigned long goal) > { > + void *ptr; > + > if (WARN_ON_ONCE(slab_is_available())) > return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); > > - return ___alloc_bootmem_node(pgdat->bdata, size, align, goal, 0); > + ptr = ___alloc_bootmem_node(pgdat->bdata, size, align, goal, 0); > + kmemleak_alloc(ptr, size, 1, GFP_KERNEL); > + return ptr; > } > > #ifdef CONFIG_SPARSEMEM > @@ -707,14 +719,18 @@ void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size, > return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); > > ptr = alloc_arch_preferred_bootmem(pgdat->bdata, size, align, goal, 0); > + kmemleak_alloc(ptr, size, 1, GFP_KERNEL); > if (ptr) > return ptr; > > ptr = alloc_bootmem_core(pgdat->bdata, size, align, goal, 0); > + kmemleak_alloc(ptr, size, 1, GFP_KERNEL); > if (ptr) > return ptr; > > - return __alloc_bootmem_nopanic(size, align, goal); > + ptr = __alloc_bootmem_nopanic(size, align, goal); > + kmemleak_alloc(ptr, size, 1, GFP_KERNEL); > + return ptr; > } > > #ifndef ARCH_LOW_ADDRESS_LIMIT > @@ -737,7 +753,9 @@ void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size, > void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, > unsigned long goal) > { > - return ___alloc_bootmem(size, align, goal, ARCH_LOW_ADDRESS_LIMIT); > + void *ptr = ___alloc_bootmem(size, align, goal, ARCH_LOW_ADDRESS_LIMIT); > + kmemleak_alloc(ptr, size, 1, GFP_KERNEL); > + return ptr; > } > > /** > @@ -758,9 +776,13 @@ void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, > void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size, > unsigned long align, unsigned long goal) > { > + void *ptr; > + > if (WARN_ON_ONCE(slab_is_available())) > return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); > > - return ___alloc_bootmem_node(pgdat->bdata, size, align, > - goal, ARCH_LOW_ADDRESS_LIMIT); > + ptr = ___alloc_bootmem_node(pgdat->bdata, size, align, > + goal, ARCH_LOW_ADDRESS_LIMIT); > + kmemleak_alloc(ptr, size, 1, GFP_KERNEL); > + return ptr; > } > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/