damos_get_node_memcg_used_bp() flushes the memcg stats before reading the LRU sizes of the goal's memcg on the goal's node. For the root memcg, that flushes every cgroup in the system. The flush is not ratelimited, which means it happens every time the goal is evaluated. lruvec_page_state() now reads the LRU sizes of the root memcg from the node counters, which are always up to date, so skip the flush for the root memcg. Reviewed-by: SJ Park Signed-off-by: Joanne Koong --- mm/damon/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 0a056949604f..14f2a36c1025 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -3057,7 +3057,12 @@ static unsigned long damos_get_node_memcg_used_bp( return 10000; } - mem_cgroup_flush_stats(memcg); + /* + * The root memcg's LRU sizes are read directly from the node counters + * (see lruvec_page_state()). + */ + if (!mem_cgroup_is_root(memcg)) + mem_cgroup_flush_stats(memcg); lruvec = mem_cgroup_lruvec(memcg, NODE_DATA(goal->nid)); used_pages = lruvec_page_state(lruvec, NR_ACTIVE_ANON); used_pages += lruvec_page_state(lruvec, NR_INACTIVE_ANON); -- 2.52.1