mm/damon/sysfs-schemes: support DAMOS_QUOTA_NODE_MEMCG_USED_BP

Add support of DAMOS_QUOTA_NODE_MEMCG_USED_BP.  For this, extend quota
goal metric inputs for the new metric, and update DAMOS core layer request
construction logic to set the target cgroup, which is specified by the
user, via the 'path' file.

Link: https://lkml.kernel.org/r/20251017212706.183502-6-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
SeongJae Park
2025-10-17 14:26:57 -07:00
committed by Andrew Morton
parent c41e253a41
commit a1d1df78ac

View File

@@ -1030,6 +1030,10 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgoal_metric_names[] = {
.metric = DAMOS_QUOTA_NODE_MEM_FREE_BP,
.name = "node_mem_free_bp",
},
{
.metric = DAMOS_QUOTA_NODE_MEMCG_USED_BP,
.name = "node_memcg_used_bp",
},
};
static ssize_t target_metric_show(struct kobject *kobj,
@@ -2526,7 +2530,7 @@ static int damos_sysfs_add_quota_score(
struct damos_quota *quota)
{
struct damos_quota_goal *goal;
int i;
int i, err;
for (i = 0; i < sysfs_goals->nr; i++) {
struct damos_sysfs_quota_goal *sysfs_goal =
@@ -2547,6 +2551,15 @@ static int damos_sysfs_add_quota_score(
case DAMOS_QUOTA_NODE_MEM_FREE_BP:
goal->nid = sysfs_goal->nid;
break;
case DAMOS_QUOTA_NODE_MEMCG_USED_BP:
err = damon_sysfs_memcg_path_to_id(
sysfs_goal->path, &goal->memcg_id);
if (err) {
damos_destroy_quota_goal(goal);
return err;
}
goal->nid = sysfs_goal->nid;
break;
default:
break;
}