Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: kmemleak: add CONFIG_DEBUG_KMEMLEAK_VERBOSE build option

Add a Kconfig option to default kmemleak verbose mode on at build time.
This option depends on DEBUG_KMEMLEAK_AUTO_SCAN since verbose reporting is
only meaningful when the automatic scanning thread is running.

When enabled, kmemleak prints full details (backtrace, hex dump, address)
of unreferenced objects to dmesg as they are detected during scanning,
removing the need to manually read /sys/kernel/debug/kmemleak.

Making this a compile-time option rather than a boot parameter allows
debug kernel flavors to enable verbose kmemleak reporting by default
without requiring changes to boot arguments. A machine can simply swap to
a debug kernel and benefit from kmemleak reporting automatically.

By surfacing leak reports directly in dmesg, they are automatically
forwarded through any kernel logging infrastructure and can be easily
captured by log aggregation tooling, making it practical to monitor memory
leaks across large fleets.

The verbose setting can still be toggled at runtime via
/sys/module/kmemleak/parameters/verbose.

Link: https://lore.kernel.org/20260323-kmemleak_report-v1-1-ba2cdd9c11b9@debian.org
Signed-off-by: Breno Leitao <leitao@debian.org>
Acked-by: SeongJae Park <sj@kernel.org>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Breno Leitao and committed by
Andrew Morton
e9d973ef 34c45804

+12 -1
+11
mm/Kconfig.debug
··· 297 297 298 298 If unsure, say Y. 299 299 300 + config DEBUG_KMEMLEAK_VERBOSE 301 + bool "Default kmemleak to verbose mode" 302 + depends on DEBUG_KMEMLEAK_AUTO_SCAN 303 + help 304 + Say Y here to have kmemleak print unreferenced object details 305 + (backtrace, hex dump, address) to dmesg when new memory leaks are 306 + detected during automatic scanning. This can also be toggled at 307 + runtime via /sys/module/kmemleak/parameters/verbose. 308 + 309 + If unsure, say N. 310 + 300 311 config PER_VMA_LOCK_STATS 301 312 bool "Statistics for per-vma locks" 302 313 depends on PER_VMA_LOCK
+1 -1
mm/kmemleak.c
··· 241 241 /* If there are leaks that can be reported */ 242 242 static bool kmemleak_found_leaks; 243 243 244 - static bool kmemleak_verbose; 244 + static bool kmemleak_verbose = IS_ENABLED(CONFIG_DEBUG_KMEMLEAK_VERBOSE); 245 245 module_param_named(verbose, kmemleak_verbose, bool, 0600); 246 246 247 247 static void kmemleak_disable(void);