From: SeongJae Park <sj@kernel.org>
To: Cheng Nie <niecheng1@uniontech.com>
Cc: SeongJae Park <sj@kernel.org>,
shuah@kernel.org, damon@lists.linux.dev, linux-mm@kvack.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel@uniontech.com
Subject: Re: [PATCH v2 2/2] selftests/damon/sysfs.py: validate memcg_path staging readback
Date: Fri, 29 May 2026 08:00:56 -0700 [thread overview]
Message-ID: <20260529150057.84753-1-sj@kernel.org> (raw)
In-Reply-To: <FF9A1552C03B7C88+20260529092131.1703337-1-niecheng1@uniontech.com>
On Fri, 29 May 2026 17:21:31 +0800 Cheng Nie <niecheng1@uniontech.com> wrote:
> Add a dedicated test at the end of main() that writes memcg_path to
> sysfs and checks the readback path. Validate the readback rather than
> a derived memcg_id so the test stays focused on DAMON sysfs behavior
> and avoids depending on the local userspace cgroup mount layout.
Nice addition of a test, thank you!
>
> Signed-off-by: Cheng Nie <niecheng1@uniontech.com>
> ---
> tools/testing/selftests/damon/sysfs.py | 39 ++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
> index aa03a1187489..0f20bc9c46b7 100755
> --- a/tools/testing/selftests/damon/sysfs.py
> +++ b/tools/testing/selftests/damon/sysfs.py
> @@ -250,6 +250,43 @@ def assert_ctxs_committed(kdamonds):
> if ctx in ctxs_paused_for_dump:
> ctx.pause = False
>
> +def test_memcg_filter_memcg_path_staging():
> + global kdamonds
> + memcg_filter = _damon_sysfs.DamosFilter(
> + type_='memcg', matching=True, allow=True, memcg_path='/')
> + kdamonds = _damon_sysfs.Kdamonds(
> + [_damon_sysfs.Kdamond(
> + contexts=[_damon_sysfs.DamonCtx(
> + targets=[_damon_sysfs.DamonTarget(pid=-1)],
> + schemes=[_damon_sysfs.Damos()],
> + )])])
> + err = kdamonds.start()
> + if err is not None:
> + fail('memcg_path staging: kdamond start', {'error': err})
I'd prefer the error message to be in form of something like "'memcg_path
staging: kdamond start (%s)' % err" for consistency.
> +
> + context = _damon_sysfs.DamonCtx(
> + targets=[_damon_sysfs.DamonTarget(pid=-1)],
> + schemes=[_damon_sysfs.Damos(ops_filters=[memcg_filter])])
> + context.idx = 0
> + context.kdamond = kdamonds.kdamonds[0]
> + kdamonds.kdamonds[0].contexts = [context]
> +
> + err = kdamonds.kdamonds[0].commit()
> + if err is not None:
> + fail('memcg_path staging: kdamond commit', {'error': err})
It seems we don't really need to do commit(). As Sashiko mentioned [1], it
also depends on CONFIG_MEMCG and active cgroup configuration. It would be
suffice to simply 'stage'. We don't have stage() method on Kdamonds, though.
What about setting all parameters including the memcg filter at the beginning,
do 'kdamonds.start()', but ignore the failure, and check the content of the
memcg_path file?
[1] https://lore.kernel.org/20260529094327.6D5031F00893@smtp.kernel.org
Thanks,
SJ
[...]
prev parent reply other threads:[~2026-05-29 15:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 9:08 [PATCH v2 0/2] selftests/damon: fix memcg_path staging handling Cheng Nie
2026-05-29 9:19 ` [PATCH v2 1/2] selftests/damon/_damon_sysfs.py: fix memcg_path assignment Cheng Nie
2026-05-29 14:52 ` SeongJae Park
2026-05-29 9:21 ` [PATCH v2 2/2] selftests/damon/sysfs.py: validate memcg_path staging readback Cheng Nie
2026-05-29 15:00 ` SeongJae Park [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=20260529150057.84753-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=damon@lists.linux.dev \
--cc=kernel@uniontech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=niecheng1@uniontech.com \
--cc=shuah@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