[RFC PATCH v3 26/28] mm/damon/sysfs: setup damon_filter->memcg_id from path
From: SeongJae Park
Date: Sat May 16 2026 - 14:42:51 EST
Find and set the memcg_id for damon_filter from the user-passed memory
cgroup path when updating the DAMON input parameters.
Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
---
include/linux/damon.h | 1 +
mm/damon/core.c | 2 +-
mm/damon/sysfs.c | 11 +++++++++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 56a76781fde22..cd0c352a777dc 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -976,6 +976,7 @@ static inline unsigned long damon_sz_region(struct damon_region *r)
struct damon_filter *damon_new_filter(enum damon_filter_type type,
bool matching, bool allow);
void damon_add_filter(struct damon_probe *probe, struct damon_filter *f);
+void damon_destroy_filter(struct damon_filter *f);
struct damon_probe *damon_new_probe(void);
void damon_add_probe(struct damon_ctx *ctx, struct damon_probe *probe);
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 332d13d9f8603..b8fe4320c3da8 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -139,7 +139,7 @@ static void damon_free_filter(struct damon_filter *f)
kfree(f);
}
-static void damon_destroy_filter(struct damon_filter *f)
+void damon_destroy_filter(struct damon_filter *f)
{
damon_del_filter(f);
damon_free_filter(f);
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 2df1d670ee77d..8f927e3dba827 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1897,6 +1897,17 @@ static int damon_sysfs_set_probes(struct damon_ctx *ctx,
sys_filter->allow);
if (!filter)
return -ENOMEM;
+ if (filter->type == DAMON_FILTER_TYPE_MEMCG) {
+ int err;
+
+ err = damon_sysfs_memcg_path_to_id(
+ sys_filter->path,
+ &filter->memcg_id);
+ if (err) {
+ damon_destroy_filter(filter);
+ return err;
+ }
+ }
damon_add_filter(c, filter);
}
}
--
2.47.3