From: Breno Leitao <leitao@debian.org>
To: Catalin Marinas <catalin.marinas@arm.com>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: workflows@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Breno Leitao <leitao@debian.org>,
kernel-team@meta.com
Subject: [PATCH 2/3] Documentation: kmemleak: fix stale statements about scanning
Date: Thu, 17 Sep 2026 06:47:36 -0700 [thread overview]
Message-ID: <20260917-b4-kmemleak-doc-v1-2-84fde6d1f749@debian.org> (raw)
In-Reply-To: <20260917-b4-kmemleak-doc-v1-0-84fde6d1f749@debian.org>
Three statements in the "false positives/negatives" and "Limitations"
sections have never matched the code:
- task stack scanning is on by default (kmemleak_stack_scan = 1), as
the parameter list earlier in the same document already states;
- MSECS_MIN_AGE has been 5000, not 1000, since the initial commit;
- scanning is done by a periodic kthread. Reading the debugfs file
only lists what the last scan found; kmemleak_open() calls
seq_open() and never scans.
Fixes: 04f70336c80c ("kmemleak: Add documentation on the memory leak detector")
Fixes: e0a2a1601bec ("kmemleak: Enable task stacks scanning by default")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
Documentation/dev-tools/kmemleak.rst | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/Documentation/dev-tools/kmemleak.rst b/Documentation/dev-tools/kmemleak.rst
index 8dad7647742d3..b5fe7e671d0f8 100644
--- a/Documentation/dev-tools/kmemleak.rst
+++ b/Documentation/dev-tools/kmemleak.rst
@@ -190,7 +190,8 @@ reported by kmemleak because values found during the memory scanning
point to such objects. To reduce the number of false negatives, kmemleak
provides the kmemleak_ignore, kmemleak_scan_area, kmemleak_no_scan and
kmemleak_erase functions (see above). The task stacks also increase the
-amount of false negatives and their scanning is not enabled by default.
+amount of false negatives and their scanning is enabled by default; it
+can be turned off with ``stack=off``.
The false positives are objects wrongly reported as being memory leaks
(orphan). For objects known not to be leaks, kmemleak provides the
@@ -200,7 +201,7 @@ longer be scanned.
Some of the reported leaks are only transient, especially on SMP
systems, because of pointers temporarily stored in CPU registers or
-stacks. Kmemleak defines MSECS_MIN_AGE (defaulting to 1000) representing
+stacks. Kmemleak defines MSECS_MIN_AGE (defaulting to 5000) representing
the minimum age of an object to be reported as a memory leak.
The ``min_unref_scans`` module parameter requires an object to be seen
@@ -217,8 +218,10 @@ Limitations and Drawbacks
-------------------------
The main drawback is the reduced performance of memory allocation and
-freeing. To avoid other penalties, the memory scanning is only performed
-when the /sys/kernel/debug/kmemleak file is read. Anyway, this tool is
+freeing. To avoid other penalties, the memory scanning is performed by a
+periodic thread rather than on every allocation. Reading the
+/sys/kernel/debug/kmemleak file only lists the objects found by the last
+scan; writing ``scan`` to it triggers a new one. Anyway, this tool is
intended for debugging purposes where the performance might not be the
most important requirement.
--
2.53.0-Meta
next prev parent reply other threads:[~2026-09-17 13:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 13:47 [PATCH 0/3] kmemleak: fix stale documentation and raise the verbose default Breno Leitao
2026-09-17 13:47 ` [PATCH 1/3] Documentation: kmemleak: describe the metadata pool, not the early log Breno Leitao
2026-09-18 9:10 ` Catalin Marinas
2026-09-17 13:47 ` Breno Leitao [this message]
2026-09-18 9:11 ` [PATCH 2/3] Documentation: kmemleak: fix stale statements about scanning Catalin Marinas
2026-09-17 13:47 ` [PATCH 3/3] mm: kmemleak: raise min_unref_scans to 3 for verbose auto-scan Breno Leitao
2026-09-17 22:04 ` Andrew Morton
2026-09-18 9:21 ` Catalin Marinas
2026-09-18 10:20 ` Breno Leitao
2026-09-18 9:21 ` Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260917-b4-kmemleak-doc-v1-2-84fde6d1f749@debian.org \
--to=leitao@debian.org \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=kernel-team@meta.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=workflows@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox