From: SeongJae Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: SeongJae Park <sj@kernel.org>, Shuah Khan <shuah@kernel.org>,
damon@lists.linux.dev, kernel-team@meta.com,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-mm@kvack.org
Subject: [PATCH 06/22] selftests/damon/_damon_sysfs: support DAMOS action dests setup
Date: Sun, 20 Jul 2025 10:16:36 -0700 [thread overview]
Message-ID: <20250720171652.92309-7-sj@kernel.org> (raw)
In-Reply-To: <20250720171652.92309-1-sj@kernel.org>
_damon_sysfs.py contains code for test-purpose DAMON sysfs interface
control. Add support of DAMOS action destinations setup for more tests.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
tools/testing/selftests/damon/_damon_sysfs.py | 56 ++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py
index 23de9202b4e3..2d95ab564885 100644
--- a/tools/testing/selftests/damon/_damon_sysfs.py
+++ b/tools/testing/selftests/damon/_damon_sysfs.py
@@ -319,6 +319,52 @@ class DamosFilters:
return err
return None
+class DamosDest:
+ id = None
+ weight = None
+ idx = None
+ dests = None # owner dests
+
+ def __init__(self, id=0, weight=0):
+ self.id = id
+ self.weight = weight
+
+ def sysfs_dir(self):
+ return os.path.join(self.dests.sysfs_dir(), '%d' % self.idx)
+
+ def stage(self):
+ err = write_file(os.path.join(self.sysfs_dir(), 'id'), self.id)
+ if err is not None:
+ return err
+ err = write_file(os.path.join(self.sysfs_dir(), 'weight'), self.weight)
+ if err is not None:
+ return err
+ return None
+
+class DamosDests:
+ dests = None
+ scheme = None # owner scheme
+
+ def __init__(self, dests=[]):
+ self.dests = dests
+ for idx, dest in enumerate(self.dests):
+ dest.idx = idx
+ dest.dests = self
+
+ def sysfs_dir(self):
+ return os.path.join(self.scheme.sysfs_dir(), 'dests')
+
+ def stage(self):
+ err = write_file(os.path.join(self.sysfs_dir(), 'nr_dests'),
+ len(self.dests))
+ if err is not None:
+ return err
+ for dest in self.dests:
+ err = dest.stage()
+ if err is not None:
+ return err
+ return None
+
class DamosStats:
nr_tried = None
sz_tried = None
@@ -349,6 +395,7 @@ class Damos:
ops_filters = None
filters = None
apply_interval_us = None
+ dests = None
idx = None
context = None
tried_bytes = None
@@ -358,7 +405,7 @@ class Damos:
def __init__(self, action='stat', access_pattern=DamosAccessPattern(),
quota=DamosQuota(), watermarks=DamosWatermarks(),
core_filters=[], ops_filters=[], filters=[],
- apply_interval_us=0):
+ dests=DamosDests(), apply_interval_us=0):
self.action = action
self.access_pattern = access_pattern
self.access_pattern.scheme = self
@@ -376,6 +423,9 @@ class Damos:
self.filters = DamosFilters(name='filters', filters=filters)
self.filters.scheme = self
+ self.dests = dests
+ self.dests.scheme = self
+
self.apply_interval_us = apply_interval_us
def sysfs_dir(self):
@@ -412,6 +462,10 @@ class Damos:
if err is not None:
return err
+ err = self.dests.stage()
+ if err is not None:
+ return err
+
class DamonTarget:
pid = None
# todo: Support target regions if test is made
--
2.39.5
next prev parent reply other threads:[~2025-07-20 17:17 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-20 17:16 [PATCH 00/22] selftests/damon/sysfs.py: test all parameters SeongJae Park
2025-07-20 17:16 ` [PATCH 01/22] selftests/damon/_damon_sysfs: support DAMOS watermarks setup SeongJae Park
2025-07-20 17:16 ` [PATCH 02/22] selftests/damon/_damon_sysfs: support DAMOS filters setup SeongJae Park
2025-07-20 17:16 ` [PATCH 03/22] selftests/damon/_damon_sysfs: support monitoring intervals goal setup SeongJae Park
2025-07-20 17:16 ` [PATCH 04/22] selftests/damon/_damon_sysfs: support DAMOS quota weights setup SeongJae Park
2025-07-20 17:16 ` [PATCH 05/22] selftests/damon/_damon_sysfs: support DAMOS quota goal nid setup SeongJae Park
2025-07-20 17:16 ` SeongJae Park [this message]
2025-07-20 17:16 ` [PATCH 07/22] selftests/damon/_damon_sysfs: support DAMOS target_nid setup SeongJae Park
2025-07-20 17:16 ` [PATCH 08/22] selftests/damon/_damon_sysfs: use 2**32 - 1 as max nr_accesses and age SeongJae Park
2025-07-20 17:16 ` [PATCH 09/22] selftests/damon/drgn_dump_damon_status: dump damos->migrate_dests SeongJae Park
2025-07-20 17:16 ` [PATCH 10/22] selftests/damon/drgn_dump_damon_status: dump ctx->ops.id SeongJae Park
2025-07-20 17:16 ` [PATCH 11/22] selftests/damon/drgn_dump_damon_status: dump DAMOS filters SeongJae Park
2025-07-20 17:16 ` [PATCH 12/22] selftests/damon/sysfs.py: generalize DAMOS Watermarks commit assertion SeongJae Park
2025-07-20 17:16 ` [PATCH 13/22] selftests/damon/sysfs.py: generalize DamosQuota " SeongJae Park
2025-07-20 17:16 ` [PATCH 14/22] selftests/damon/sysfs.py: test quota goal commitment SeongJae Park
2025-07-20 17:16 ` [PATCH 15/22] selftests/damon/sysfs.py: test DAMOS destinations commitment SeongJae Park
2025-07-20 17:16 ` [PATCH 16/22] selftests/damon/sysfs.py: generalize DAMOS schemes commit assertion SeongJae Park
2025-07-22 3:09 ` Andrew Morton
2025-07-22 4:04 ` SeongJae Park
2025-07-20 17:16 ` [PATCH 17/22] selftests/damon/sysfs.py: test DAMOS filters commitment SeongJae Park
2025-07-20 17:16 ` [PATCH 18/22] selftests/damon/sysfs.py: generalize DAMOS schemes commit assertion SeongJae Park
2025-07-20 17:16 ` [PATCH 19/22] selftests/damon/sysfs.py: generalize monitoring attributes " SeongJae Park
2025-07-20 17:16 ` [PATCH 20/22] selftests/damon/sysfs.py: generalize DAMON context " SeongJae Park
2025-07-20 17:16 ` [PATCH 21/22] selftests/damon/sysfs.py: test non-default parameters runtime commit SeongJae Park
2025-07-20 17:16 ` [PATCH 22/22] selftests/damon/sysfs.py: test runtime reduction of DAMON parameters 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=20250720171652.92309-7-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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;
as well as URLs for NNTP newsgroup(s).