DAMON development mailing list
 help / color / mirror / Atom feed
* [PATCH v5 0/2] selftests/damon: fix memcg_path staging handling
@ 2026-06-29 14:48 SJ Park
  2026-06-29 14:48 ` [PATCH v5 1/2] selftests/damon/_damon_sysfs.py: fix memcg_path assignment SJ Park
  2026-06-29 14:48 ` [PATCH v5 2/2] selftests/damon/sysfs.py: validate memcg_path staging readback SJ Park
  0 siblings, 2 replies; 3+ messages in thread
From: SJ Park @ 2026-06-29 14:48 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SJ Park, Shuah Khan, damon, linux-kernel, linux-kselftest,
	linux-mm

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 v4:
- v4: https://lore.kernel.org/7E6EAB7C1BE04DEA+20260601090119.238457-1-niecheng1@uniontech.com
- Collect R-b: from SJ.
- Rebase to latest mm-new.
Changes from v3:
- v3: https://lore.kernel.org/E4B88E7D4879D1B1+20260601074250.203583-1-niecheng1@uniontech.com
- call stop() for cleanup without checking its return value
Changes from v2:
- v2: https://lore.kernel.org/4CDA28DC581FDCF8+20260529090845.1696845-1-niecheng1@uniontech.com
- configure memcg filter before start(), remove commit(), ignore
  start() failure, verify memcg_path staging readback only
- use print-style error messages as suggested
Changes from v1:
- v1: https://lore.kernel.org/406BD1BA0F6AE326+20260528081039.1192194-3-niecheng1@uniontech.com
- unknown.

Cheng Nie (2):
  selftests/damon/_damon_sysfs.py: fix memcg_path assignment
  selftests/damon/sysfs.py: validate memcg_path staging readback

 tools/testing/selftests/damon/_damon_sysfs.py |  2 +-
 tools/testing/selftests/damon/sysfs.py        | 31 +++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)


base-commit: 544856bcdccf456fc27f85e5d5b0a49f7b8e6019
-- 
2.47.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v5 1/2] selftests/damon/_damon_sysfs.py: fix memcg_path assignment
  2026-06-29 14:48 [PATCH v5 0/2] selftests/damon: fix memcg_path staging handling SJ Park
@ 2026-06-29 14:48 ` SJ Park
  2026-06-29 14:48 ` [PATCH v5 2/2] selftests/damon/sysfs.py: validate memcg_path staging readback SJ Park
  1 sibling, 0 replies; 3+ messages in thread
From: SJ Park @ 2026-06-29 14:48 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Cheng Nie, SJ Park, Shuah Khan, damon, linux-kernel,
	linux-kselftest, linux-mm

From: Cheng Nie <niecheng1@uniontech.com>

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.

Link: https://lore.kernel.org/464AE12D4BC6B6F4+20260601090519.240482-1-niecheng1@uniontech.com
Signed-off-by: Cheng Nie <niecheng1@uniontech.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ 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 f6127081dfb2e..c197ab99bcc0a 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.47.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v5 2/2] selftests/damon/sysfs.py: validate memcg_path staging readback
  2026-06-29 14:48 [PATCH v5 0/2] selftests/damon: fix memcg_path staging handling SJ Park
  2026-06-29 14:48 ` [PATCH v5 1/2] selftests/damon/_damon_sysfs.py: fix memcg_path assignment SJ Park
@ 2026-06-29 14:48 ` SJ Park
  1 sibling, 0 replies; 3+ messages in thread
From: SJ Park @ 2026-06-29 14:48 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Cheng Nie, SJ Park, Shuah Khan, damon, linux-kernel,
	linux-kselftest, linux-mm

From: Cheng Nie <niecheng1@uniontech.com>

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.

Link: https://lore.kernel.org/D2B37130D38E09AC+20260601090634.241864-1-niecheng1@uniontech.com
Signed-off-by: Cheng Nie <niecheng1@uniontech.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
 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 99412f0d31f37..3ffa054b63867 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.47.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-29 14:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 14:48 [PATCH v5 0/2] selftests/damon: fix memcg_path staging handling SJ Park
2026-06-29 14:48 ` [PATCH v5 1/2] selftests/damon/_damon_sysfs.py: fix memcg_path assignment SJ Park
2026-06-29 14:48 ` [PATCH v5 2/2] selftests/damon/sysfs.py: validate memcg_path staging readback SJ Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox