selftests/damon: stop kdamond on error exits of no-op commit test
Subsystems (3)
PATCH 1/1 selftests/damon: stop kdamond on error exits of no-op commit test
From: "Zenghui Yu (Huawei)" <[email protected]>
The sysfs_no_op_commit_break test starts a kdamond via sysfs, but its error paths (e.g., drgn not installed) exit without stopping it. The leaked kdamond then makes subsequent tests, e.g. lru_sort.sh and reclaim.sh, skip with "Another kdamond is running".
Wrap the post-start logic in try-finally so that kdamonds.stop() is executed on every exit path.
--- .../damon/sysfs_no_op_commit_break.py | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-)
tools/testing/selftests/damon/sysfs_no_op_commit_break.py +18 -17
@@ -47,26 +47,27 @@ def main(): print('kdamond start failed: %s' % err) exit(1) - before_commit_status, err = \ - dump_damon_status_dict(kdamonds.kdamonds[0].pid) - if err is not None: - print('before-commit status dump failed: %s' % err) - exit(1) + try: + before_commit_status, err = \ + dump_damon_status_dict(kdamonds.kdamonds[0].pid) + if err is not None: + print('before-commit status dump failed: %s' % err) + exit(1) - kdamonds.kdamonds[0].commit() + kdamonds.kdamonds[0].commit() - after_commit_status, err = \ - dump_damon_status_dict(kdamonds.kdamonds[0].pid) - if err is not None: - print('after-commit status dump failed: %s' % err) - exit(1) - - if before_commit_status != after_commit_status: - print(f'before: {json.dumps(before_commit_status, indent=2)}') - print(f'after: {json.dumps(after_commit_status, indent=2)}') - exit(1) + after_commit_status, err = \ + dump_damon_status_dict(kdamonds.kdamonds[0].pid) + if err is not None: + print('after-commit status dump failed: %s' % err) + exit(1) - kdamonds.stop() + if before_commit_status != after_commit_status: + print(f'before: {json.dumps(before_commit_status, indent=2)}') + print(f'after: {json.dumps(after_commit_status, indent=2)}') + exit(1) + finally: + kdamonds.stop() if __name__ == '__main__': main()
Signature · 1 line
2.53.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines
From: "Zenghui Yu (Huawei)" <[email protected]>
The
sysfs_no_op_commit_breaktest starts a kdamond via sysfs, but its error paths (e.g., drgn not installed) exit without stopping it. The leaked kdamond then makes subsequent tests, e.g.lru_sort.shandreclaim.sh, skip with "Another kdamond is running".
Quoted 6 lines
Wrap the post-start logic in try-finally so that
kdamonds.stop()is executed on every exit path.Fixes 10725cd2b09a ("selftests/damon: test no-op commit broke DAMON status")Assisted-by GLM-5.3 OpenCodeSigned-off-by Zenghui Yu (Huawei) <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 9 lines · On Mon, 7 Sep 2026 20:34:55 +0800 Zenghui Yu <[email protected]> wrote:
From: "Zenghui Yu (Huawei)" <[email protected]>
The
sysfs_no_op_commit_breaktest starts a kdamond via sysfs, but its error paths (e.g., drgn not installed) exit without stopping it. The leaked kdamond then makes subsequent tests, e.g.lru_sort.shandreclaim.sh, skip with "Another kdamond is running".Wrap the post-start logic in try-finally so that
kdamonds.stop()is executed on every exit path.
Looks good to me, thank you for fixing this, Zenghui.
Quoted 4 lines
Fixes 10725cd2b09a ("selftests/damon: test no-op commit broke DAMON status")Assisted-by GLM-5.3 OpenCodeSigned-off-by Zenghui Yu (Huawei) <[email protected]>
This patch is applied to damon/next [1] tree. If this patch is not added to mm.git in short term (~1 week?), I will ask mm.git maintainer (Andrew Morton) to pick this. So, no action from your side is needed for now. If it seems I also forgot doing that or you cannot wait for my action, please feel free to directly ask that to Andrew.
[1] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees
Thanks,
SJ
[...]