Re: [PATCH 3/3] mm: kmemleak: raise min_unref_scans to 3 for verbose auto-scan

From: Catalin Marinas

Date: Fri Sep 18 2026 - 05:33:15 EST


On Thu, Sep 17, 2026 at 06:47:37AM -0700, Breno Leitao wrote:
> CONFIG_DEBUG_KMEMLEAK_VERBOSE sends every report to the console, so a
> transient false positive there is broadcast to whatever collects the
> kernel log rather than sitting in the debugfs file until someone looks.
> That asymmetry justifies being more conservative than the general case.
>
> Require one more consecutive unreferenced scan before reporting. The
> only cost is that a genuine leak is reported one scan interval later
> (600s by default); the value stays writable at run time through the
> module parameter.
>
> Kernels without CONFIG_DEBUG_KMEMLEAK_VERBOSE keep reporting on the
> first unreferenced scan.
>
> I've been running constant upstream kernel with
> CONFIG_DEBUG_KMEMLEAK_VERBOSE set, and I am still seeing some rare false
> positive, that goes away with min_unref_scans=3, so, making it the
> default based on my heuristic.
>
> Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>

Until someone comes up with a better idea to reduce the false positives,

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