From: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: Nilay Shroff <nilay@linux.ibm.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"yi.zhang@redhat.com" <yi.zhang@redhat.com>,
"gjoyce@ibm.com" <gjoyce@ibm.com>
Subject: Re: [PATCH blktests] check: add kmemleak support to blktests
Date: Fri, 16 Jan 2026 10:19:11 +0000 [thread overview]
Message-ID: <aWoOpqVO9iqoxS9t@shinmob> (raw)
In-Reply-To: <20260113095134.1818646-1-nilay@linux.ibm.com>
On Jan 13, 2026 / 15:21, Nilay Shroff wrote:
> Running blktests can also help uncover kernel memory leaks when the
> kernel is built with CONFIG_DEBUG_KMEMLEAK. However, until now the
> blktests framework had no way to automatically detect or report such
> leaks. Users typically had to manually setup kmemleak and trigger
> scans after running tests[1][2].
>
> This change integrates kmemleak support directly into the blktests
> framework. Before running each test, the framework checks for the
> presence of /sys/kernel/debug/kmemleak to determine whether kmemleak
> is enabled for the running kernel. If available, before running a test,
> any existing kmemleak reports are cleared to avoid false positives
> from previous tests. After the test completes, the framework explicitly
> triggers a kmemleak scan. If memory leaks are detected, they are written
> to a per-test file at, "results/.../.../<test>.kmemleak" and the
> corresponding test is marked as FAIL. Users can then inspect the
> <test>.kmemleak file to analyze the reported leaks.
>
> With this enhancement, blktests can automatically detect kernel memory
> leaks (if kerel is configured with CONFIG_DEBUG_KMEMLEAK support) on
> a per-test basis, removing the need for manual kmemleak setup and scans.
> This should make it easier and faster to identify memory leaks
> introduced by individual tests.
>
> [1] https://lore.kernel.org/all/CAHj4cs8oJFvz=daCvjHM5dYCNQH4UXwSySPPU4v-WHce_kZXZA@mail.gmail.com/
> [2] https://lore.kernel.org/all/CAHj4cs9wv3SdPo+N01Fw2SHBYDs9tj2M_e1-GdQOkRy=DsBB1w@mail.gmail.com/
>
> Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Nilay, thank you very much. This idea is excellent, and the patch looks good
except one nit comment below. I also did trial runs, and confirmed memory leaks
can be detected and reported as test case failures. Great :)
> diff --git a/check b/check
> index 6d77d8e..3a6e837 100755
> --- a/check
> +++ b/check
[...]
> @@ -451,6 +486,18 @@ _call_test() {
> print \" \" \$0
> }" "${seqres}.dmesg"
> ;;
> + kmemleak)
> + echo " kmemleak detected:"
> + awk "
> + {
> + if (NR > 10) {
> + print \" ...\"
> + print \" (See '${seqres}.kmemleak' for the entire message)\"
> + exit
> + }
> + print \" \" \$0
> + }" "${seqres}.kmemleak"
> + ;;
Nit: the hunk above uses spaces for indent. Assuming there is no other review
comments on this patch, I will replace the spaces with tabs when I apply it. I
will wait a few more days to see someone makes comments or not. Thanks.
next prev parent reply other threads:[~2026-01-16 10:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-13 9:51 [PATCH blktests] check: add kmemleak support to blktests Nilay Shroff
2026-01-14 11:31 ` Johannes Thumshirn
2026-01-16 10:19 ` Shinichiro Kawasaki [this message]
2026-01-16 11:14 ` Yi Zhang
2026-01-19 9:54 ` Daniel Wagner
2026-01-22 4:06 ` Shinichiro Kawasaki
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=aWoOpqVO9iqoxS9t@shinmob \
--to=shinichiro.kawasaki@wdc.com \
--cc=gjoyce@ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=nilay@linux.ibm.com \
--cc=yi.zhang@redhat.com \
/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