|author||Catalin Marinas <email@example.com>||2019-09-23 15:34:05 -0700|
|committer||Linus Torvalds <firstname.lastname@example.org>||2019-09-24 15:54:07 -0700|
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(). [email@example.com: coding-style fixes] [firstname.lastname@example.org: remove WARN_ON(), per Catalin] Link: http://email@example.com Signed-off-by: Catalin Marinas <firstname.lastname@example.org> Cc: Matthew Wilcox <email@example.com> Cc: Michal Hocko <firstname.lastname@example.org> Cc: Qian Cai <email@example.com> Signed-off-by: Andrew Morton <firstname.lastname@example.org> Signed-off-by: Linus Torvalds <email@example.com>
Diffstat (limited to 'lib')
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 3c88e54da86c..c6975cded461 100644
@@ -576,17 +576,18 @@ config DEBUG_KMEMLEAK
In order to access the kmemleak file, debugfs needs to be
mounted (usually at /sys/kernel/debug).
- int "Maximum kmemleak early log entries"
+ int "Kmemleak memory pool size"
depends on DEBUG_KMEMLEAK
range 200 40000
Kmemleak must track all the memory allocations to avoid
reporting false positives. Since memory may be allocated or
- freed before kmemleak is initialised, an early log buffer is
- used to store these actions. If kmemleak reports "early log
- buffer exceeded", please increase this value.
+ freed before kmemleak is fully initialised, use a static pool
+ of metadata objects to track such callbacks. After kmemleak is
+ fully initialised, this memory pool acts as an emergency one
+ if slab allocations fail.
tristate "Simple test for the kernel memory leak detector"