From 216c04b0d848fa3db04fc240d9cdc1d2cc1e9574 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Wed, 17 Jun 2009 18:29:02 +0100 Subject: kmemleak: Only use GFP_KERNEL|GFP_ATOMIC for the internal allocations Kmemleak allocates memory for pointer tracking and it tries to avoid using GFP_ATOMIC if the caller doesn't require it. However other gfp flags may be passed by the caller which aren't required by kmemleak. This patch filters the gfp flags so that only GFP_KERNEL | GFP_ATOMIC are used. Signed-off-by: Catalin Marinas Acked-by: Pekka Enberg --- mm/kmemleak.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mm') diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 58ec86c9e58..25e203474d1 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -109,6 +109,9 @@ #define BYTES_PER_POINTER sizeof(void *) +/* GFP bitmask for kmemleak internal allocations */ +#define GFP_KMEMLEAK_MASK (GFP_KERNEL | GFP_ATOMIC) + /* scanning area inside a memory block */ struct kmemleak_scan_area { struct hlist_node node; @@ -462,7 +465,7 @@ static void create_object(unsigned long ptr, size_t size, int min_count, struct prio_tree_node *node; struct stack_trace trace; - object = kmem_cache_alloc(object_cache, gfp & ~GFP_SLAB_BUG_MASK); + object = kmem_cache_alloc(object_cache, gfp & GFP_KMEMLEAK_MASK); if (!object) { kmemleak_panic("kmemleak: Cannot allocate a kmemleak_object " "structure\n"); @@ -636,7 +639,7 @@ static void add_scan_area(unsigned long ptr, unsigned long offset, return; } - area = kmem_cache_alloc(scan_area_cache, gfp & ~GFP_SLAB_BUG_MASK); + area = kmem_cache_alloc(scan_area_cache, gfp & GFP_KMEMLEAK_MASK); if (!area) { kmemleak_warn("kmemleak: Cannot allocate a scan area\n"); goto out; -- cgit v1.2.3 From 000814f44e56122ea22e1f1422e16df36a1bb396 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Wed, 17 Jun 2009 18:29:03 +0100 Subject: kmemleak: Rename kmemleak_panic to kmemleak_stop This is to avoid the confusion created by the "panic" word. Signed-off-by: Catalin Marinas Acked-by: Pekka Enberg --- mm/kmemleak.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'mm') diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 25e203474d1..c1f538e63b1 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -251,7 +251,7 @@ static void kmemleak_disable(void); * recovered from. Kkmemleak will be disabled and further allocation/freeing * tracing no longer available. */ -#define kmemleak_panic(x...) do { \ +#define kmemleak_stop(x...) do { \ kmemleak_warn(x); \ kmemleak_disable(); \ } while (0) @@ -467,8 +467,8 @@ static void create_object(unsigned long ptr, size_t size, int min_count, object = kmem_cache_alloc(object_cache, gfp & GFP_KMEMLEAK_MASK); if (!object) { - kmemleak_panic("kmemleak: Cannot allocate a kmemleak_object " - "structure\n"); + kmemleak_stop("kmemleak: Cannot allocate a kmemleak_object " + "structure\n"); return; } @@ -527,8 +527,8 @@ static void create_object(unsigned long ptr, size_t size, int min_count, if (node != &object->tree_node) { unsigned long flags; - kmemleak_panic("kmemleak: Cannot insert 0x%lx into the object " - "search tree (already existing)\n", ptr); + kmemleak_stop("kmemleak: Cannot insert 0x%lx into the object " + "search tree (already existing)\n", ptr); object = lookup_object(ptr, 1); spin_lock_irqsave(&object->lock, flags); dump_object_info(object); @@ -699,7 +699,7 @@ static void log_early(int op_type, const void *ptr, size_t size, struct early_log *log; if (crt_early_log >= ARRAY_SIZE(early_log)) { - kmemleak_panic("kmemleak: Early log buffer exceeded\n"); + kmemleak_stop("kmemleak: Early log buffer exceeded\n"); return; } -- cgit v1.2.3 From 2030117d2761c4c955e1a0683fa96ab62e4b197b Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Wed, 17 Jun 2009 18:29:04 +0100 Subject: kmemleak: Fix some typos in comments Signed-off-by: Catalin Marinas --- mm/kmemleak.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mm') diff --git a/mm/kmemleak.c b/mm/kmemleak.c index c1f538e63b1..ec759b60077 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -202,9 +202,9 @@ static DEFINE_MUTEX(kmemleak_mutex); static int reported_leaks; /* - * Early object allocation/freeing logging. Kkmemleak is initialized after the + * Early object allocation/freeing logging. Kmemleak is initialized after the * kernel allocator. However, both the kernel allocator and kmemleak may - * allocate memory blocks which need to be tracked. Kkmemleak defines an + * allocate memory blocks which need to be tracked. Kmemleak defines an * arbitrary buffer to hold the allocation/freeing information before it is * fully initialized. */ @@ -248,7 +248,7 @@ static void kmemleak_disable(void); /* * Macro invoked when a serious kmemleak condition occured and cannot be - * recovered from. Kkmemleak will be disabled and further allocation/freeing + * recovered from. Kmemleak will be disabled and further allocation/freeing * tracing no longer available. */ #define kmemleak_stop(x...) do { \ @@ -1407,7 +1407,7 @@ static int kmemleak_boot_config(char *str) early_param("kmemleak", kmemleak_boot_config); /* - * Kkmemleak initialization. + * Kmemleak initialization. */ void __init kmemleak_init(void) { -- cgit v1.2.3