From: Enze Li <lienze@kylinos.cn>
To: sj@kernel.org, akpm@linux-foundation.org
Cc: damon@lists.linux.dev, linux-mm@kvack.org, enze.li@gmx.com,
Enze Li <lienze@kylinos.cn>
Subject: [RFC PATCH 2/2] mm/damon/sysfs: introduce priority sysfs interface
Date: Tue, 9 Dec 2025 22:50:26 +0800 [thread overview]
Message-ID: <20251209145026.3263754-3-lienze@kylinos.cn> (raw)
In-Reply-To: <20251209145026.3263754-1-lienze@kylinos.cn>
This patch extends the DAMON sysfs interface to support the
configuration of target priorities, enabling users to assign and adjust
the relative importance of monitored processes at runtime.
Signed-off-by: Enze Li <lienze@kylinos.cn>
---
mm/damon/sysfs.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index e2bd2d7becdd..224d9e89d967 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -213,6 +213,9 @@ struct damon_sysfs_target {
struct damon_sysfs_regions *regions;
int pid;
bool obsolete;
+#ifdef CONFIG_DAMON_AUTO_TUNING
+ int priority;
+#endif
};
static struct damon_sysfs_target *damon_sysfs_target_alloc(void)
@@ -298,9 +301,44 @@ static struct kobj_attribute damon_sysfs_target_pid_attr =
static struct kobj_attribute damon_sysfs_target_obsolete_attr =
__ATTR_RW_MODE(obsolete_target, 0600);
+#ifdef CONFIG_DAMON_AUTO_TUNING
+static ssize_t target_priority_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ struct damon_sysfs_target *target = container_of(kobj,
+ struct damon_sysfs_target, kobj);
+
+ return sysfs_emit(buf, "%d\n", target->priority);
+}
+
+static ssize_t target_priority_store(struct kobject *kobj,
+ struct kobj_attribute *attr, const char *buf, size_t count)
+{
+ int err, value;
+ struct damon_sysfs_target *target = container_of(kobj,
+ struct damon_sysfs_target, kobj);
+ err = kstrtoint(buf, 0, &value);
+ if (err)
+ return -EINVAL;
+
+ if (value > 0 && value <= 100)
+ target->priority = value;
+ else
+ return -EINVAL;
+
+ return count;
+}
+
+static struct kobj_attribute damon_sysfs_target_priority =
+ __ATTR_RW_MODE(target_priority, 0600);
+#endif
+
static struct attribute *damon_sysfs_target_attrs[] = {
&damon_sysfs_target_pid_attr.attr,
&damon_sysfs_target_obsolete_attr.attr,
+#ifdef CONFIG_DAMON_AUTO_TUNING
+ &damon_sysfs_target_priority.attr,
+#endif
NULL,
};
ATTRIBUTE_GROUPS(damon_sysfs_target);
@@ -1406,6 +1444,9 @@ static int damon_sysfs_add_target(struct damon_sysfs_target *sys_target,
return -EINVAL;
}
t->obsolete = sys_target->obsolete;
+#ifdef CONFIG_DAMON_AUTO_TUNING
+ t->priority = sys_target->priority;
+#endif
return damon_sysfs_set_regions(t, sys_target->regions, ctx->min_sz_region);
}
--
2.43.0
next prev parent reply other threads:[~2025-12-09 14:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 14:50 [RFC PATCH 0/2] mm/damon: Introduce basic auto-tuning framework with priority support Enze Li
2025-12-09 14:50 ` [RFC PATCH 1/2] mm/damon/auto-tuning: introduce DAMON-based auto-tunning module Enze Li
2025-12-09 14:50 ` Enze Li [this message]
2025-12-12 3:38 ` [RFC PATCH 0/2] mm/damon: Introduce basic auto-tuning framework with priority support 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=20251209145026.3263754-3-lienze@kylinos.cn \
--to=lienze@kylinos.cn \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=enze.li@gmx.com \
--cc=linux-mm@kvack.org \
--cc=sj@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