Commit 216c04b0d848fa3db04fc240d9cdc1d2cc1e9574

Authored by Catalin Marinas
1 parent 65795efbd3

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 <catalin.marinas@arm.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>

Showing 1 changed file with 5 additions and 2 deletions Side-by-side Diff

... ... @@ -109,6 +109,9 @@
109 109  
110 110 #define BYTES_PER_POINTER sizeof(void *)
111 111  
  112 +/* GFP bitmask for kmemleak internal allocations */
  113 +#define GFP_KMEMLEAK_MASK (GFP_KERNEL | GFP_ATOMIC)
  114 +
112 115 /* scanning area inside a memory block */
113 116 struct kmemleak_scan_area {
114 117 struct hlist_node node;
... ... @@ -462,7 +465,7 @@
462 465 struct prio_tree_node *node;
463 466 struct stack_trace trace;
464 467  
465   - object = kmem_cache_alloc(object_cache, gfp & ~GFP_SLAB_BUG_MASK);
  468 + object = kmem_cache_alloc(object_cache, gfp & GFP_KMEMLEAK_MASK);
466 469 if (!object) {
467 470 kmemleak_panic("kmemleak: Cannot allocate a kmemleak_object "
468 471 "structure\n");
... ... @@ -636,7 +639,7 @@
636 639 return;
637 640 }
638 641  
639   - area = kmem_cache_alloc(scan_area_cache, gfp & ~GFP_SLAB_BUG_MASK);
  642 + area = kmem_cache_alloc(scan_area_cache, gfp & GFP_KMEMLEAK_MASK);
640 643 if (!area) {
641 644 kmemleak_warn("kmemleak: Cannot allocate a scan area\n");
642 645 goto out;