[RFC PATCH v2 22/28] mm/damon/core: introduce DAMON_FILTER_TYPE_MEMCG
From: SeongJae Park
Date: Tue May 12 2026 - 11:33:13 EST
Belonging memory cgoup is another data attribute that can be useful to
monitor. Introduce a new DAMON filter type, namely
DAMON_FILTER_TYPE_MEMCG, for monitoring of this attribute.
Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
---
include/linux/damon.h | 6 ++++++
mm/damon/core.c | 7 +++++++
2 files changed, 13 insertions(+)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index e9ca40cdd9102..3dec0947b93f0 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -740,9 +740,11 @@ struct damon_intervals_goal {
* enum damon_filter_type - Type of &struct damon_filter
*
* @DAMON_FILTER_TYPE_ANON: Anonymous pages.
+ * @DAMON_FILTER_TYPE_MEMCG: Specific memcg's pages.
*/
enum damon_filter_type {
DAMON_FILTER_TYPE_ANON,
+ DAMON_FILTER_TYPE_MEMCG,
};
/**
@@ -751,12 +753,16 @@ enum damon_filter_type {
* @type: Type of the region.
* @matcing: Whether this filter is for the type-matching ones.
* @allow: Whether the @type-@matching ones should pass this filter.
+ * @memcg_id: Memcg id of the question if @type is DAMON_FILTER_MEMCG.
* @list: Siblings list.
*/
struct damon_filter {
enum damon_filter_type type;
bool matching;
bool allow;
+ union {
+ u64 memcg_id;
+ };
struct list_head list;
};
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 14b15c9876516..ef751898a3c06 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1430,6 +1430,13 @@ static void damon_commit_filter(struct damon_filter *dst,
dst->type = src->type;
dst->matching = src->matching;
dst->allow = src->allow;
+ switch (dst->type) {
+ case DAMON_FILTER_TYPE_MEMCG:
+ dst->memcg_id = src->memcg_id;
+ break;
+ default:
+ break;
+ }
}
static int damon_commit_filters(struct damon_probe *dst,
--
2.47.3