Re: [PATCH] mm: kmemleak: add CONFIG_DEBUG_KMEMLEAK_VERBOSE build option

From: Catalin Marinas

Date: Wed Mar 25 2026 - 13:28:24 EST


On Mon, Mar 23, 2026 at 04:12:13AM -0700, Breno Leitao wrote:
> 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.
>
> Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>

Acked-by: Catalin Marinas <catalin.marinas@xxxxxxx>