From: sashiko-bot@kernel.org
To: "Sailesh Nandanavanam" <saileshnandanavanam@gmail.com>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH] selftests/damon: add regression test for damos_walk() vs kdamond exit race
Date: Sun, 24 May 2026 09:37:05 +0000 [thread overview]
Message-ID: <20260524093706.0FCCE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260524091812.35283-1-saileshnandanavanam@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] The script hardcodes the sysfs state path and suppresses exceptions with a bare `except` block, yielding a false pass if path resolution fails.
- [Medium] The script's custom timeout logic is incapable of detecting the kernel deadlock because it blocks synchronously on the system call.
- [Low] The new test script `sysfs_damos_walk_kdamond_exit_race.py` lacks execute permissions.
--
commit c1a389c100306b9715b021c992e2707ecc7ffc39
Author: Sailesh Nandanavanam <saileshnandanavanam@gmail.com>
selftests/damon: add regression test for damos_walk() vs kdamond exit race
This commit adds a regression test to verify that damos_walk() does not
deadlock when racing with the kdamond_fn() exit path. It starts kdamond
monitoring a short-lived process, waits for termination, and then rapidly
calls update_schemes_tried_regions to hit the race window.
> diff --git a/tools/testing/selftests/damon/sysfs_damos_walk_kdamond_exit_race.py b/tools/testing/selftests/damon/sysfs_damos_walk_kdamond_exit_race.py
> new file mode 100644
> index 0000000000000..9b9d66a23f512
> --- /dev/null
> +++ b/tools/testing/selftests/damon/sysfs_damos_walk_kdamond_exit_race.py
[Severity: Low]
Should this file be created with executable permissions (100755)? Since the
script is added to TEST_PROGS in the Makefile, the kselftest framework expects
it to be directly executable. Without the execute bit, it can cause warnings
during test execution.
> @@ -0,0 +1,47 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: GPL-2.0
[ ... ]
> + proc.wait()
> + completed = False
> + timeout = time.time() + 5
> + while time.time() < timeout:
> + err = kdamonds.kdamonds[0].update_schemes_tried_regions()
[Severity: Medium]
If the kernel deadlock bug occurs, update_schemes_tried_regions() will
trigger an uninterruptible wait in the kernel. Doesn't this mean the Python
script will block indefinitely on the system call in the D state?
Since the script is single-threaded, the while loop condition would never be
re-evaluated, making the internal timeout and failure message unreachable.
Instead, the test would just hang until the global kselftest timeout kills it.
> + if err is not None:
> + completed = True
> + break
> + try:
> + with open('/sys/kernel/mm/damon/admin/kdamonds/0/state') as f:
> + state = f.read().strip()
> + if state == 'off':
> + completed = True
> + break
> + except:
> + completed = True
> + break
[Severity: Medium]
Is it safe to hardcode the sysfs state path and use a bare except block here?
If sysfs is mounted at a non-standard location or another file error occurs,
open() will raise an exception. The bare except block will catch this,
incorrectly set completed to True, and exit the loop immediately. This results
in a false pass on the very first iteration, completely missing the race
window it is intended to test.
Could the script dynamically resolve the path using the kdamonds object
instead of suppressing all exceptions?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260524091812.35283-1-saileshnandanavanam@gmail.com?part=1
prev parent reply other threads:[~2026-05-24 9:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-24 9:18 [PATCH] selftests/damon: add regression test for damos_walk() vs kdamond exit race Sailesh Nandanavanam
2026-05-24 9:37 ` sashiko-bot [this message]
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=20260524093706.0FCCE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=saileshnandanavanam@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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