From: SJ Park <sj@kernel.org>
Cc: SJ Park <sj@kernel.org>, Shuah Khan <shuah@kernel.org>,
damon@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-mm@kvack.org
Subject: [RFC PATCH 4/6] selftests/damon/drgn_dump_damon_status: dump probes
Date: Wed, 29 Jul 2026 07:47:35 -0700 [thread overview]
Message-ID: <20260729144738.90895-5-sj@kernel.org> (raw)
In-Reply-To: <20260729144738.90895-1-sj@kernel.org>
Extend drgn_dump_damon_status.py to dump damon_ctx->probes. It will be
used to see if in-kernel DAMON status are changed as the user sets the
probes via sysfs.
Signed-off-by: SJ Park <sj@kernel.org>
---
.../selftests/damon/drgn_dump_damon_status.py | 32 +++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/tools/testing/selftests/damon/drgn_dump_damon_status.py b/tools/testing/selftests/damon/drgn_dump_damon_status.py
index 09552e91bc782..4622046fd0118 100755
--- a/tools/testing/selftests/damon/drgn_dump_damon_status.py
+++ b/tools/testing/selftests/damon/drgn_dump_damon_status.py
@@ -48,6 +48,37 @@ def attrs_to_dict(attrs):
['max_nr_regions', int],
])
+def filter_to_dict(damon_filter):
+ filter_type_keyword = {
+ 0: 'anon',
+ 1: 'memcg',
+ }
+ dict_ = {
+ 'type': filter_type_keyword[int(damon_filter.type)],
+ 'matching': bool(damon_filter.matching),
+ 'allow': bool(damon_filter.allow),
+ }
+ type_ = dict_['type']
+ if type_ == 'memcg':
+ dict_['memcg_id'] = int(damon_filter.memcg_id)
+ return dict_
+
+def filters_to_list(filters):
+ return [filter_to_dict(f)
+ for f in list_for_each_entry(
+ 'struct damon_filter', filters.address_of_(), 'list')]
+
+def probe_to_dict(probe):
+ return to_dict(probe, [
+ ['weight', int],
+ ['filters', filters_to_list],
+ ])
+
+def probes_to_list(probes):
+ return [probe_to_dict(p)
+ for p in list_for_each_entry(
+ 'struct damon_probe', probes.address_of_(), 'list')]
+
def addr_range_to_dict(addr_range):
return to_dict(addr_range, [
['start', int],
@@ -199,6 +230,7 @@ def damon_ctx_to_dict(ctx):
return to_dict(ctx, [
['ops', ops_to_dict],
['attrs', attrs_to_dict],
+ ['probes', probes_to_list],
['adaptive_targets', targets_to_list],
['schemes', schemes_to_list],
['pause', bool],
--
2.47.3
next prev parent reply other threads:[~2026-07-29 14:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 14:47 [RFC PATCH 0/6] mm/damon: add kunit and selftests for probes and probe weights SJ Park
2026-07-29 14:47 ` [RFC PATCH 1/6] mm/damon/tests/core-kunit: test damon_commit_filter() SJ Park
2026-07-29 14:47 ` [RFC PATCH 2/6] mm/damon/tests/core-kunit: add damon_commit_probes() test SJ Park
2026-07-29 14:47 ` [RFC PATCH 3/6] selftests/damon/_damon_sysfs: implement DamonProbes SJ Park
2026-07-29 14:47 ` SJ Park [this message]
2026-07-29 14:47 ` [RFC PATCH 5/6] selftests/damon/sysfs.py: extend commit assertion function for probes SJ Park
2026-07-29 14:47 ` [RFC PATCH 6/6] selftests/damon/sysfs.py: test damon probes SJ 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=20260729144738.90895-5-sj@kernel.org \
--to=sj@kernel.org \
--cc=damon@lists.linux.dev \
--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