Re: [PATCH 4/4] selftests: mm: test kmemleak's N-consecutive-scan leak confirmation

From: Catalin Marinas

Date: Wed Aug 12 2026 - 05:50:36 EST


On Mon, Jul 13, 2026 at 04:48:07AM -0700, Breno Leitao wrote:
> Add a functional test for the min_unref_scans kmemleak module parameter.
> Using samples/kmemleak's helper module it checks that min_unref_scans=1
> reports an orphan on the first scan, min_unref_scans=2 reports nothing on
> the first scan but does on the second, and that the parameter reads back
> what was written.
>
> It counts only the helper module's own orphans (matched by their
> [kmemleak_test] backtrace, with the module kept loaded so the symbols
> resolve) so unrelated leaks already present on the system do not perturb
> the result. The test skips when run as non-root, without
> CONFIG_DEBUG_KMEMLEAK / CONFIG_SAMPLE_KMEMLEAK, on a kernel without the
> parameter, or when the helper yields no detectable orphan.
>
> Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>

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