From b6be1a36f7b19dcea16bb53b6eb980207c65215f Mon Sep 17 00:00:00 2001 From: "T.J. Mercier" Date: Fri, 26 Jan 2024 21:19:25 +0000 Subject: [PATCH] FROMGIT: mm: memcg: don't periodically flush stats when memcg is disabled The root memcg is onlined even when memcg is disabled. When it's onlined a 2 second periodic stat flush is started, but no stat flushing is required when memcg is disabled because there can be no child memcgs. Most calls to flush memcg stats are avoided when memcg is disabled as a result of the mem_cgroup_disabled check added in 7d7ef0a4686a ("mm: memcg: restore subtree stats flushing"), but the periodic flushing started in mem_cgroup_css_online is not. Skip it. Link: https://lkml.kernel.org/r/20240126211927.1171338-1-tjmercier@google.com Fixes: aa48e47e3906 ("memcg: infrastructure to flush memcg stats") Change-Id: Iae6aeb3091d349898ea4987a784a971d9b3c97f7 Signed-off-by: T.J. Mercier Acked-by: Shakeel Butt Acked-by: Johannes Weiner Acked-by: Chris Li Reported-by: Minchan Kim Cc: Michal Hocko Cc: Muchun Song Cc: Roman Gushchin Signed-off-by: Andrew Morton (cherry picked from commit 7e9bccbe57812f888f51d46d7cdbc6327eee24f3 https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/ mm-unstable) Signed-off-by: T.J. Mercier --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1127aba1752b..180f75846935 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5401,7 +5401,7 @@ static int mem_cgroup_css_online(struct cgroup_subsys_state *css) refcount_set(&memcg->id.ref, 1); css_get(css); - if (unlikely(mem_cgroup_is_root(memcg))) + if (unlikely(mem_cgroup_is_root(memcg)) && !mem_cgroup_disabled()) queue_delayed_work(system_unbound_wq, &stats_flush_dwork, 2UL*HZ); lru_gen_online_memcg(memcg);