* [RFC PATCH 0/4] selftests/damon: add a test for obsolete_target sysfs file
@ 2025-10-18 20:44 SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 1/4] selftests/damon/_damon_sysfs: support obsolete_target file SeongJae Park
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: SeongJae Park @ 2025-10-18 20:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, Shuah Khan, damon,
linux-kernel, linux-kselftest, linux-mm
An RFC patch series [1] that add a new DAMON sysfs file for arbitrary
targets removal is under review. Add a selftest for the feature. The
new test uses the feature using the python wrapper of DAMON sysfs
interface, and confirm the expected internal data structure change is
made using drgn.
So this patch series may better to be a part of the other one [1] that
introduces the obsolete_target file. But, because no significant change
is requested on the series so far, I'm posting this as an individual
RFC.
In the next version, I may merge the two series into one, to add all
related changes at one step.
[1] https://lore.kernel.org/20251016214736.84286-1-sj@kernel.org
SeongJae Park (4):
selftests/damon/_damon_sysfs: support obsolete_target file
drgn_dump_damon_status: dump damon_target->obsolete
sysfs.py: extend assert_ctx_committed() for monitoring targets
selftests/damon/sysfs: add obsolete_target test
tools/testing/selftests/damon/_damon_sysfs.py | 11 ++++-
.../selftests/damon/drgn_dump_damon_status.py | 1 +
tools/testing/selftests/damon/sysfs.py | 48 +++++++++++++++++++
3 files changed, 58 insertions(+), 2 deletions(-)
base-commit: 1aba8bd57e6aaa1c9e699c8de66bcc931d4b1116
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH 1/4] selftests/damon/_damon_sysfs: support obsolete_target file
2025-10-18 20:44 [RFC PATCH 0/4] selftests/damon: add a test for obsolete_target sysfs file SeongJae Park
@ 2025-10-18 20:44 ` SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 2/4] drgn_dump_damon_status: dump damon_target->obsolete SeongJae Park
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2025-10-18 20:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, Shuah Khan, damon,
linux-kernel, linux-kselftest, linux-mm
A DAMON sysfs file, namely obsolete_target, has newly introduced. Add a
support of that file to _damon_sysfs.py so that DAMON selftests for the
file can be easily written.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
tools/testing/selftests/damon/_damon_sysfs.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py
index a0e6290833fb..748778b563cd 100644
--- a/tools/testing/selftests/damon/_damon_sysfs.py
+++ b/tools/testing/selftests/damon/_damon_sysfs.py
@@ -475,12 +475,14 @@ class Damos:
class DamonTarget:
pid = None
+ obsolete = None
# todo: Support target regions if test is made
idx = None
context = None
- def __init__(self, pid):
+ def __init__(self, pid, obsolete=False):
self.pid = pid
+ self.obsolete = obsolete
def sysfs_dir(self):
return os.path.join(
@@ -491,8 +493,13 @@ class DamonTarget:
os.path.join(self.sysfs_dir(), 'regions', 'nr_regions'), '0')
if err is not None:
return err
- return write_file(
+ err = write_file(
os.path.join(self.sysfs_dir(), 'pid_target'), self.pid)
+ if err is not None:
+ return err
+ return write_file(
+ os.path.join(self.sysfs_dir(), 'obsolete_target'),
+ 'Y' if self.obsolete else 'N')
class IntervalsGoal:
access_bp = None
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH 2/4] drgn_dump_damon_status: dump damon_target->obsolete
2025-10-18 20:44 [RFC PATCH 0/4] selftests/damon: add a test for obsolete_target sysfs file SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 1/4] selftests/damon/_damon_sysfs: support obsolete_target file SeongJae Park
@ 2025-10-18 20:44 ` SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 3/4] sysfs.py: extend assert_ctx_committed() for monitoring targets SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 4/4] selftests/damon/sysfs: add obsolete_target test SeongJae Park
3 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2025-10-18 20:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, Shuah Khan, damon,
linux-kernel, linux-kselftest, linux-mm
A new field of damon_target for pin-point target removal, namely
obsolete has newly been added. Extend drgn_dump_damon_status.py to dump
it, for easily writing a future DAMON selftests of it.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
tools/testing/selftests/damon/drgn_dump_damon_status.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/damon/drgn_dump_damon_status.py b/tools/testing/selftests/damon/drgn_dump_damon_status.py
index 7233369a3a44..cb4fdbe68acb 100755
--- a/tools/testing/selftests/damon/drgn_dump_damon_status.py
+++ b/tools/testing/selftests/damon/drgn_dump_damon_status.py
@@ -73,6 +73,7 @@ def target_to_dict(target):
['pid', int],
['nr_regions', int],
['regions_list', regions_to_list],
+ ['obsolete', bool],
])
def targets_to_list(targets):
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH 3/4] sysfs.py: extend assert_ctx_committed() for monitoring targets
2025-10-18 20:44 [RFC PATCH 0/4] selftests/damon: add a test for obsolete_target sysfs file SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 1/4] selftests/damon/_damon_sysfs: support obsolete_target file SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 2/4] drgn_dump_damon_status: dump damon_target->obsolete SeongJae Park
@ 2025-10-18 20:44 ` SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 4/4] selftests/damon/sysfs: add obsolete_target test SeongJae Park
3 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2025-10-18 20:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, Shuah Khan, damon,
linux-kernel, linux-kselftest, linux-mm
assert_ctx_committed() is not asserting monitoring targets commitment,
since all existing callers of the function assumes no target changes.
Extend it for future usage.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
tools/testing/selftests/damon/sysfs.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
index 2666c6f0f1a5..fd8d3698326e 100755
--- a/tools/testing/selftests/damon/sysfs.py
+++ b/tools/testing/selftests/damon/sysfs.py
@@ -164,6 +164,16 @@ def assert_monitoring_attrs_committed(attrs, dump):
assert_true(dump['max_nr_regions'] == attrs.max_nr_regions,
'max_nr_regions', dump)
+def assert_monitoring_target_committed(target, dump):
+ # target.pid is the pid "number", while dump['pid'] is 'struct pid'
+ # pointer, and hence cannot be compared.
+ assert_true(dump['obsolete'] == target.obsolete, 'target obsolete', dump)
+
+def assert_monitoring_targets_committed(targets, dump):
+ assert_true(len(targets) == len(dump), 'len_targets', dump)
+ for idx, target in enumerate(targets):
+ assert_monitoring_target_committed(target, dump[idx])
+
def assert_ctx_committed(ctx, dump):
ops_val = {
'vaddr': 0,
@@ -172,6 +182,7 @@ def assert_ctx_committed(ctx, dump):
}
assert_true(dump['ops']['id'] == ops_val[ctx.ops], 'ops_id', dump)
assert_monitoring_attrs_committed(ctx.monitoring_attrs, dump['attrs'])
+ assert_monitoring_targets_committed(ctx.targets, dump['adaptive_targets'])
assert_schemes_committed(ctx.schemes, dump['schemes'])
def assert_ctxs_committed(ctxs, dump):
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH 4/4] selftests/damon/sysfs: add obsolete_target test
2025-10-18 20:44 [RFC PATCH 0/4] selftests/damon: add a test for obsolete_target sysfs file SeongJae Park
` (2 preceding siblings ...)
2025-10-18 20:44 ` [RFC PATCH 3/4] sysfs.py: extend assert_ctx_committed() for monitoring targets SeongJae Park
@ 2025-10-18 20:44 ` SeongJae Park
3 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2025-10-18 20:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, Shuah Khan, damon,
linux-kernel, linux-kselftest, linux-mm
A new DAMON sysfs file for pin-point target removal, namely
obsolete_target, has been added. Add a test for the functionality. It
starts DAMON with three monitoring target processes, mark one in the
middle as obsolete, commit it, and confirm the internal DAMON status is
updated to remove the target in the middle.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
tools/testing/selftests/damon/sysfs.py | 37 ++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
index fd8d3698326e..b34aea0a6775 100755
--- a/tools/testing/selftests/damon/sysfs.py
+++ b/tools/testing/selftests/damon/sysfs.py
@@ -279,5 +279,42 @@ def main():
kdamonds.stop()
+ # test obsolete_target.
+ proc1 = subprocess.Popen(['sh'], stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ proc2 = subprocess.Popen(['sh'], stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ proc3 = subprocess.Popen(['sh'], stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ kdamonds = _damon_sysfs.Kdamonds(
+ [_damon_sysfs.Kdamond(
+ contexts=[_damon_sysfs.DamonCtx(
+ ops='vaddr',
+ targets=[
+ _damon_sysfs.DamonTarget(pid=proc1.pid),
+ _damon_sysfs.DamonTarget(pid=proc2.pid),
+ _damon_sysfs.DamonTarget(pid=proc3.pid),
+ ],
+ schemes=[_damon_sysfs.Damos()],
+ )])])
+ err = kdamonds.start()
+ if err is not None:
+ print('kdamond start failed: %s' % err)
+ exit(1)
+ kdamonds.kdamonds[0].contexts[0].targets[1].obsolete = True
+ kdamonds.kdamonds[0].commit()
+
+ status, err = dump_damon_status_dict(kdamonds.kdamonds[0].pid)
+ if err is not None:
+ print(err)
+ kdamonds.stop()
+ exit(1)
+
+ del kdamonds.kdamonds[0].contexts[0].targets[1]
+
+ assert_ctxs_committed(kdamonds.kdamonds[0].contexts, status['contexts'])
+
+ kdamonds.stop()
+
if __name__ == '__main__':
main()
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-18 20:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-18 20:44 [RFC PATCH 0/4] selftests/damon: add a test for obsolete_target sysfs file SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 1/4] selftests/damon/_damon_sysfs: support obsolete_target file SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 2/4] drgn_dump_damon_status: dump damon_target->obsolete SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 3/4] sysfs.py: extend assert_ctx_committed() for monitoring targets SeongJae Park
2025-10-18 20:44 ` [RFC PATCH 4/4] selftests/damon/sysfs: add obsolete_target test SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox