mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-19 13:38:24 -05:00
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/20250709005952.17776-5-bijan311@gmail.com Signed-off-by: SeongJae Park <sj@kernel.org> Signed-off-by: Bijan Tabatabai <bijantabatab@micron.com> Reviewed-by: SeongJae Park <sj@kernel.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Ravi Shankar Jonnalagadda <ravis.opensrc@micron.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
2cd0bf85a2
commit
9106d46753
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user