summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2019-09-23 18:34:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-24 18:54:07 -0400
commitc5665868183fec689dbab9fb8505188b2c4f0757 (patch)
tree55c3277578a7444491e77fb3887e9783d3679e82 /lib
parent0647398a8c7bd55e0b7565c5076e86b7c3c204c5 (diff)
mm: kmemleak: use the memory pool for early allocations
Currently kmemleak uses a static early_log buffer to trace all memory allocation/freeing before the slab allocator is initialised. Such early log is replayed during kmemleak_init() to properly initialise the kmemleak metadata for objects allocated up that point. With a memory pool that does not rely on the slab allocator, it is possible to skip this early log entirely. In order to remove the early logging, consider kmemleak_enabled == 1 by default while the kmem_cache availability is checked directly on the object_cache and scan_area_cache variables. The RCU callback is only invoked after object_cache has been initialised as we wouldn't have any concurrent list traversal before this. In order to reduce the number of callbacks before kmemleak is fully initialised, move the kmemleak_init() call to mm_init(). [akpm@linux-foundation.org: coding-style fixes] [akpm@linux-foundation.org: remove WARN_ON(), per Catalin] Link: http://lkml.kernel.org/r/20190812160642.52134-4-catalin.marinas@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Michal Hocko <mhocko@kernel.org> Cc: Qian Cai <cai@lca.pw> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig.debug11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 3c88e54da86c..c6975cded461 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -576,17 +576,18 @@ config DEBUG_KMEMLEAK
576 In order to access the kmemleak file, debugfs needs to be 576 In order to access the kmemleak file, debugfs needs to be
577 mounted (usually at /sys/kernel/debug). 577 mounted (usually at /sys/kernel/debug).
578 578
579config DEBUG_KMEMLEAK_EARLY_LOG_SIZE 579config DEBUG_KMEMLEAK_MEM_POOL_SIZE
580 int "Maximum kmemleak early log entries" 580 int "Kmemleak memory pool size"
581 depends on DEBUG_KMEMLEAK 581 depends on DEBUG_KMEMLEAK
582 range 200 40000 582 range 200 40000
583 default 16000 583 default 16000
584 help 584 help
585 Kmemleak must track all the memory allocations to avoid 585 Kmemleak must track all the memory allocations to avoid
586 reporting false positives. Since memory may be allocated or 586 reporting false positives. Since memory may be allocated or
587 freed before kmemleak is initialised, an early log buffer is 587 freed before kmemleak is fully initialised, use a static pool
588 used to store these actions. If kmemleak reports "early log 588 of metadata objects to track such callbacks. After kmemleak is
589 buffer exceeded", please increase this value. 589 fully initialised, this memory pool acts as an emergency one
590 if slab allocations fail.
590 591
591config DEBUG_KMEMLEAK_TEST 592config DEBUG_KMEMLEAK_TEST
592 tristate "Simple test for the kernel memory leak detector" 593 tristate "Simple test for the kernel memory leak detector"