From: SeongJae Park <sj@kernel.org>
Cc: SeongJae Park <sj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Bijan Tabatabai <bijantabatab@micron.com>,
damon@lists.linux.dev, kernel-team@meta.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [RFC PATCH 4/4] mm/damon/sysfs-schemes: set damos->migrate_dest
Date: Sat, 21 Jun 2025 10:31:31 -0700 [thread overview]
Message-ID: <20250621173131.23917-5-sj@kernel.org> (raw)
In-Reply-To: <20250621173131.23917-1-sj@kernel.org>
Pass user-specified multiple DAMOS action destinations and their weights
to DAMON core API, so that user requests can really work.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs-schemes.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index e04cd8d592b8..158a2be3fd45 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2445,6 +2445,29 @@ void damos_sysfs_update_effective_quotas(
}
}
+static int damos_sysfs_add_migrate_dest(struct damos *scheme,
+ struct damos_sysfs_dests *sysfs_dests)
+{
+ struct damos_migrate_dest *dest = &scheme->migrate_dest;
+ int i;
+
+ dest->node_id_arr = kmalloc_array(sysfs_dests->nr,
+ sizeof(*dest->node_id_arr), GFP_KERNEL);
+ if (!dest->node_id_arr)
+ return -ENOMEM;
+ dest->weight_arr = kmalloc_array(sysfs_dests->nr,
+ sizeof(*dest->weight_arr), GFP_KERNEL);
+ if (!dest->weight_arr)
+ /* ->node_id_arr will be freed by scheme destruction */
+ return -ENOMEM;
+ for (i = 0; i < sysfs_dests->nr; i++) {
+ dest->node_id_arr[i] = sysfs_dests->dests_arr[i]->id;
+ dest->weight_arr[i] = sysfs_dests->dests_arr[i]->weight;
+ }
+ dest->nr_dests = sysfs_dests->nr;
+ return 0;
+}
+
static struct damos *damon_sysfs_mk_scheme(
struct damon_sysfs_scheme *sysfs_scheme)
{
@@ -2507,6 +2530,11 @@ static struct damos *damon_sysfs_mk_scheme(
damon_destroy_scheme(scheme);
return NULL;
}
+ err = damos_sysfs_add_migrate_dest(scheme, sysfs_scheme->dests);
+ if (err) {
+ damon_destroy_scheme(scheme);
+ return NULL;
+ }
return scheme;
}
--
2.39.5
next prev parent reply other threads:[~2025-06-21 17:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-21 17:31 [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights SeongJae Park
2025-06-21 17:31 ` [RFC PATCH 1/4] mm/damon: add struct damos_migrate_dest SeongJae Park
2025-07-01 22:43 ` Bijan Tabatabai
2025-07-02 0:25 ` SeongJae Park
2025-07-02 1:43 ` Bijan Tabatabai
2025-07-02 3:02 ` SeongJae Park
2025-06-21 17:31 ` [RFC PATCH 2/4] mm/damon/core: add damos->migrate_dest field SeongJae Park
2025-06-21 17:31 ` [RFC PATCH 3/4] mm/damon/sysfs-schemes: implement DAMOS action destinations directory SeongJae Park
2025-06-21 17:31 ` SeongJae Park [this message]
2025-07-01 22:39 ` [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights Bijan Tabatabai
2025-07-02 0:23 ` SeongJae Park
2025-07-02 5:23 ` 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=20250621173131.23917-5-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bijantabatab@micron.com \
--cc=damon@lists.linux.dev \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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).