* [PATCH v4 1/2] selftests/damon/_damon_sysfs.py: fix memcg_path assignment
2026-06-01 9:01 [PATCH v4 0/2] selftests/damon: fix memcg_path staging handling Cheng Nie
@ 2026-06-01 9:05 ` Cheng Nie
2026-06-01 9:06 ` [PATCH v4 2/2] selftests/damon/sysfs.py: validate memcg_path staging readback Cheng Nie
2026-06-01 14:55 ` [PATCH v4 0/2] selftests/damon: fix memcg_path staging handling SeongJae Park
2 siblings, 0 replies; 6+ messages in thread
From: Cheng Nie @ 2026-06-01 9:05 UTC (permalink / raw)
To: niecheng1; +Cc: damon, linux-kernel, linux-kselftest, linux-mm, shuah, sj
DamosFilter stores memcg_path for sysfs staging, but the constructor
assigns it with a trailing comma and therefore turns it into a tuple.
Fix the assignment so memcg_path is stored as the intended string.
This makes memcg filter staging and follow-up validation use the
written path correctly.
Signed-off-by: Cheng Nie <niecheng1@uniontech.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
---
tools/testing/selftests/damon/_damon_sysfs.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py
index 8b12cc048440..43075892215e 100644
--- a/tools/testing/selftests/damon/_damon_sysfs.py
+++ b/tools/testing/selftests/damon/_damon_sysfs.py
@@ -271,7 +271,7 @@ class DamosFilter:
self.type_ = type_
self.matching = matching
self.allow = allow
- self.memcg_path = memcg_path,
+ self.memcg_path = memcg_path
self.addr_start = addr_start
self.addr_end = addr_end
self.target_idx = target_idx
--
2.51.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v4 2/2] selftests/damon/sysfs.py: validate memcg_path staging readback
2026-06-01 9:01 [PATCH v4 0/2] selftests/damon: fix memcg_path staging handling Cheng Nie
2026-06-01 9:05 ` [PATCH v4 1/2] selftests/damon/_damon_sysfs.py: fix memcg_path assignment Cheng Nie
@ 2026-06-01 9:06 ` Cheng Nie
2026-06-01 14:39 ` SeongJae Park
2026-06-01 14:55 ` [PATCH v4 0/2] selftests/damon: fix memcg_path staging handling SeongJae Park
2 siblings, 1 reply; 6+ messages in thread
From: Cheng Nie @ 2026-06-01 9:06 UTC (permalink / raw)
To: niecheng1; +Cc: damon, linux-kernel, linux-kselftest, linux-mm, shuah, sj
Add a dedicated test at the end of main() that stages memcg_path via
sysfs and verifies its readback. Configure the memcg filter before
start(), do not call commit(), and ignore start() failures so the test
does not depend on CONFIG_MEMCG or cgroup layout. Call stop() for
cleanup without checking its return value.
Signed-off-by: Cheng Nie <niecheng1@uniontech.com>
---
tools/testing/selftests/damon/sysfs.py | 31 ++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
index aa03a1187489..35be32cf49ac 100755
--- a/tools/testing/selftests/damon/sysfs.py
+++ b/tools/testing/selftests/damon/sysfs.py
@@ -250,6 +250,35 @@ 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(
+ ops_filters=[memcg_filter])],
+ )])])
+ kdamonds.start()
+
+ shown, rd_err = _damon_sysfs.read_file(
+ os.path.join(memcg_filter.sysfs_dir(), 'memcg_path'))
+ if rd_err is not None:
+ print('memcg_path staging: sysfs read (%s)' % rd_err)
+ kdamonds.stop()
+ exit(1)
+ if shown.rstrip('\n') != memcg_filter.memcg_path:
+ print('memcg_path staging: memcg_path readback '
+ '(shown=%s, expected=%s)' %
+ (shown.rstrip('\n'), memcg_filter.memcg_path))
+ kdamonds.stop()
+ exit(1)
+
+ kdamonds.stop()
+ kdamonds = None
+
def main():
global kdamonds
kdamonds = _damon_sysfs.Kdamonds(
@@ -356,5 +385,7 @@ def main():
assert_ctxs_committed(kdamonds)
kdamonds.stop()
+ test_memcg_filter_memcg_path_staging()
+
if __name__ == '__main__':
main()
--
2.51.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v4 2/2] selftests/damon/sysfs.py: validate memcg_path staging readback
2026-06-01 9:06 ` [PATCH v4 2/2] selftests/damon/sysfs.py: validate memcg_path staging readback Cheng Nie
@ 2026-06-01 14:39 ` SeongJae Park
0 siblings, 0 replies; 6+ messages in thread
From: SeongJae Park @ 2026-06-01 14:39 UTC (permalink / raw)
To: Cheng Nie
Cc: SeongJae Park, damon, linux-kernel, linux-kselftest, linux-mm,
shuah
On Mon, 1 Jun 2026 17:06:33 +0800 Cheng Nie <niecheng1@uniontech.com> wrote:
> Add a dedicated test at the end of main() that stages memcg_path via
> sysfs and verifies its readback. Configure the memcg filter before
> start(), do not call commit(), and ignore start() failures so the test
> does not depend on CONFIG_MEMCG or cgroup layout. Call stop() for
> cleanup without checking its return value.
Looks good to me, thank you!
>
> Signed-off-by: Cheng Nie <niecheng1@uniontech.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 0/2] selftests/damon: fix memcg_path staging handling
2026-06-01 9:01 [PATCH v4 0/2] selftests/damon: fix memcg_path staging handling Cheng Nie
2026-06-01 9:05 ` [PATCH v4 1/2] selftests/damon/_damon_sysfs.py: fix memcg_path assignment Cheng Nie
2026-06-01 9:06 ` [PATCH v4 2/2] selftests/damon/sysfs.py: validate memcg_path staging readback Cheng Nie
@ 2026-06-01 14:55 ` SeongJae Park
2026-06-03 5:04 ` SeongJae Park
2 siblings, 1 reply; 6+ messages in thread
From: SeongJae Park @ 2026-06-01 14:55 UTC (permalink / raw)
To: Cheng Nie
Cc: SeongJae Park, shuah, damon, linux-mm, linux-kselftest,
linux-kernel, Andrew Morton
On Mon, 1 Jun 2026 17:01:19 +0800 Cheng Nie <niecheng1@uniontech.com> wrote:
Having a sentence for the cover letter would be nice. E.g.,
'''
Fix a bug in _damon_sysfs.py for damos_filter memcg_path setup, and add a test
case of it in sysfs.py.
'''
> Changes from v3:
> - call stop() for cleanup without checking its return value
>
> Changes from v2:
> - configure memcg filter before start(), remove commit(), ignore
> start() failure, verify memcg_path staging readback only
> - use print-style error messages as suggested
>
> Cheng Nie (2):
> selftests/damon/_damon_sysfs.py: fix memcg_path assignment
> selftests/damon/sysfs.py: validate memcg_path staging readback
From the next time, please add links to the previous revisions [1].
For other readers,
v3: https://lore.kernel.org/E4B88E7D4879D1B1+20260601074250.203583-1-niecheng1@uniontech.com
v2: https://lore.kernel.org/4CDA28DC581FDCF8+20260529090845.1696845-1-niecheng1@uniontech.com
v1: https://lore.kernel.org/406BD1BA0F6AE326+20260528081039.1192194-3-niecheng1@uniontech.com
I applied this series with the cover letter sentence change to damon/next [2]
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.
Andrew might want us to repost this series after next rc1, though, as we are
apparently wanting to make mm.git more stabilized at this point. Andrew, pleae
let me know if so.
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://docs.kernel.org/process/submitting-patches.html#commentary
[2] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 0/2] selftests/damon: fix memcg_path staging handling
2026-06-01 14:55 ` [PATCH v4 0/2] selftests/damon: fix memcg_path staging handling SeongJae Park
@ 2026-06-03 5:04 ` SeongJae Park
0 siblings, 0 replies; 6+ messages in thread
From: SeongJae Park @ 2026-06-03 5:04 UTC (permalink / raw)
To: SeongJae Park
Cc: Cheng Nie, shuah, damon, linux-mm, linux-kselftest, linux-kernel,
Andrew Morton
On Mon, 1 Jun 2026 07:55:00 -0700 SeongJae Park <sj@kernel.org> wrote:
> On Mon, 1 Jun 2026 17:01:19 +0800 Cheng Nie <niecheng1@uniontech.com> wrote:
>
> Having a sentence for the cover letter would be nice. E.g.,
>
> '''
> Fix a bug in _damon_sysfs.py for damos_filter memcg_path setup, and add a test
> case of it in sysfs.py.
> '''
>
> > Changes from v3:
> > - call stop() for cleanup without checking its return value
> >
> > Changes from v2:
> > - configure memcg filter before start(), remove commit(), ignore
> > start() failure, verify memcg_path staging readback only
> > - use print-style error messages as suggested
> >
> > Cheng Nie (2):
> > selftests/damon/_damon_sysfs.py: fix memcg_path assignment
> > selftests/damon/sysfs.py: validate memcg_path staging readback
>
> From the next time, please add links to the previous revisions [1].
>
> For other readers,
> v3: https://lore.kernel.org/E4B88E7D4879D1B1+20260601074250.203583-1-niecheng1@uniontech.com
> v2: https://lore.kernel.org/4CDA28DC581FDCF8+20260529090845.1696845-1-niecheng1@uniontech.com
> v1: https://lore.kernel.org/406BD1BA0F6AE326+20260528081039.1192194-3-niecheng1@uniontech.com
>
> I applied this series with the cover letter sentence change to damon/next [2]
> 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.
>
> Andrew might want us to repost this series after next rc1, though, as we are
> apparently wanting to make mm.git more stabilized at this point. Andrew, pleae
> let me know if so.
Apparently that's the case. That is, we are now quite close to next merge
window. We want to focus on making mm.git more stabilized and therefore ready
for the next merge window, rather than adding more changes that no really
urgent. I understand this series is not really urgent. Hence, I will request
adding this to mm.git after next -rc1 release. Let me know if you think this
is really urgent.
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 6+ messages in thread