From: Sang-Heon Jeon <ekffu200098@gmail.com>
To: sj@kernel.org, honggyu.kim@sk.com
Cc: damon@lists.linux.dev, linux-mm@kvack.org
Subject: Re: [PATCH v3] selftests/damon: test no-op commit broke DAMON status
Date: Sun, 10 Aug 2025 21:58:43 +0900 [thread overview]
Message-ID: <CABFDxMGHz_DJJncoE=ZUkBJwyph=_3WTfgd7H-0XyAdtuKtWJg@mail.gmail.com> (raw)
In-Reply-To: <20250810124354.16456-1-ekffu200098@gmail.com>
On Sun, Aug 10, 2025 at 9:44 PM Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
>
> Add test to verify that DAMON status is not changed after a no-op
> commit.
>
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> ---
I just forgot to add change logs.
Changes from v1 [1]:
1. Fix code and commit message style.
2. Merge patch set into one patch.
3. Add fixes and cc section for backporting.
Changes from v2 [2]:
1. Separate the patch into two parts(code modifications and tests) And
this is part of test
2. Improve warning message on dump failure.
[1] https://lore.kernel.org/damon/20250808195518.563053-1-ekffu200098@gmail.com/
[2] https://lore.kernel.org/damon/20250809130756.637304-1-ekffu200098@gmail.com/
> tools/testing/selftests/damon/Makefile | 1 +
> .../damon/sysfs_no_op_commit_break.py | 72 +++++++++++++++++++
> 2 files changed, 73 insertions(+)
> create mode 100755 tools/testing/selftests/damon/sysfs_no_op_commit_break.py
>
> diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile
> index 5b230deb19e8..44a4a819df55 100644
> --- a/tools/testing/selftests/damon/Makefile
> +++ b/tools/testing/selftests/damon/Makefile
> @@ -17,6 +17,7 @@ TEST_PROGS += reclaim.sh lru_sort.sh
> TEST_PROGS += sysfs_update_removed_scheme_dir.sh
> TEST_PROGS += sysfs_update_schemes_tried_regions_hang.py
> TEST_PROGS += sysfs_memcg_path_leak.sh
> +TEST_PROGS += sysfs_no_op_commit_break.py
>
> EXTRA_CLEAN = __pycache__
>
> diff --git a/tools/testing/selftests/damon/sysfs_no_op_commit_break.py b/tools/testing/selftests/damon/sysfs_no_op_commit_break.py
> new file mode 100755
> index 000000000000..f557587ebc81
> --- /dev/null
> +++ b/tools/testing/selftests/damon/sysfs_no_op_commit_break.py
> @@ -0,0 +1,72 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: GPL-2.0
> +
> +import json
> +import os
> +import subprocess
> +import sys
> +
> +import _damon_sysfs
> +
> +def dump_damon_status_dict(pid):
> + try:
> + subprocess.check_output(['which', 'drgn'], stderr=subprocess.DEVNULL)
> + except:
> + return None, 'drgn not found'
> + file_dir = os.path.dirname(os.path.abspath(__file__))
> + dump_script = os.path.join(file_dir, 'drgn_dump_damon_status.py')
> + rc = subprocess.call(['drgn', dump_script, pid, 'damon_dump_output'],
> + stderr=subprocess.DEVNULL)
> +
> + if rc != 0:
> + return None, f'drgn fail: return code({rc})'
> + try:
> + with open('damon_dump_output', 'r') as f:
> + return json.load(f), None
> + except Exception as e:
> + return None, 'json.load fail (%s)' % e
> +
> +def main():
> + kdamonds = _damon_sysfs.Kdamonds(
> + [_damon_sysfs.Kdamond(
> + contexts=[_damon_sysfs.DamonCtx(
> + schemes=[_damon_sysfs.Damos(
> + ops_filters=[
> + _damon_sysfs.DamosFilter(
> + type_='anon',
> + matching=True,
> + allow=True,
> + )
> + ]
> + )],
> + )])]
> + )
> +
> + err = kdamonds.start()
> + if err is not None:
> + 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)
> +
> + 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.dump(before_commit_status, indent=2)}')
> + print(f'after: {json.dump(after_commit_status, indent=2)}')
> + exit(1)
> +
> + kdamonds.stop()
> +
> +if __name__ == '__main__':
> + main()
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-08-10 12:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-10 12:43 Sang-Heon Jeon
2025-08-10 12:58 ` Sang-Heon Jeon [this message]
2025-08-10 16:44 ` SeongJae Park
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='CABFDxMGHz_DJJncoE=ZUkBJwyph=_3WTfgd7H-0XyAdtuKtWJg@mail.gmail.com' \
--to=ekffu200098@gmail.com \
--cc=damon@lists.linux.dev \
--cc=honggyu.kim@sk.com \
--cc=linux-mm@kvack.org \
--cc=sj@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