aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeongJae Park <[email protected]>2025-07-09 00:59:34 +0000
committerAndrew Morton <[email protected]>2025-07-20 01:59:49 +0000
commit9106d467533db0f042f2ddbf304620fa3fd54b1d (patch)
tree2fcfbf36eb845a1736d59bff073bd9b71efc6f14
parentmm/damon/sysfs-schemes: implement DAMOS action destinations directory (diff)
downloadkernel-9106d467533db0f042f2ddbf304620fa3fd54b1d.tar.gz
kernel-9106d467533db0f042f2ddbf304620fa3fd54b1d.zip
mm/damon/sysfs-schemes: set damos->migrate_dests
Pass user-specified multiple DAMOS action destinations and their weights to DAMON core API, so that user requests can really work. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: SeongJae Park <[email protected]> Signed-off-by: Bijan Tabatabai <[email protected]> Reviewed-by: SeongJae Park <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Ravi Shankar Jonnalagadda <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r--mm/damon/sysfs-schemes.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index b9434cdaacdc..74056bcd6a2c 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2576,6 +2576,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_dests *dests = &scheme->migrate_dests;
+ int i;
+
+ dests->node_id_arr = kmalloc_array(sysfs_dests->nr,
+ sizeof(*dests->node_id_arr), GFP_KERNEL);
+ if (!dests->node_id_arr)
+ return -ENOMEM;
+ dests->weight_arr = kmalloc_array(sysfs_dests->nr,
+ sizeof(*dests->weight_arr), GFP_KERNEL);
+ if (!dests->weight_arr)
+ /* ->node_id_arr will be freed by scheme destruction */
+ return -ENOMEM;
+ for (i = 0; i < sysfs_dests->nr; i++) {
+ dests->node_id_arr[i] = sysfs_dests->dests_arr[i]->id;
+ dests->weight_arr[i] = sysfs_dests->dests_arr[i]->weight;
+ }
+ dests->nr_dests = sysfs_dests->nr;
+ return 0;
+}
+
static struct damos *damon_sysfs_mk_scheme(
struct damon_sysfs_scheme *sysfs_scheme)
{
@@ -2638,6 +2661,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;
}