From: Yosry Ahmed Date: Thu, 30 Mar 2023 19:18:01 +0000 (+0000) Subject: memcg: do not modify rstat tree for zero updates X-Git-Tag: v6.4-rc1~103^2~132 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f9d911ca49d7fb30dde4858f8751cf2534e78b47;p=tomoyo%2Ftomoyo-test1.git memcg: do not modify rstat tree for zero updates In some situations, we may end up calling memcg_rstat_updated() with a value of 0, which means the stat was not actually updated. An example is if we fail to reclaim any pages in shrink_folio_list(). Do not add the cgroup to the rstat updated tree in this case, to avoid unnecessarily flushing it. Link: https://lkml.kernel.org/r/20230330191801.1967435-9-yosryahmed@google.com Signed-off-by: Yosry Ahmed Acked-by: Shakeel Butt Acked-by: Johannes Weiner Acked-by: Michal Hocko Reviewed-by: Michal Koutný Cc: Jens Axboe Cc: Josef Bacik Cc: Michal Hocko Cc: Muchun Song Cc: Roman Gushchin Cc: Tejun Heo Cc: Vasily Averin Cc: Zefan Li Signed-off-by: Andrew Morton --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e9e79ceb9a11..3d040a5fa7a3 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -619,6 +619,9 @@ static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val) { unsigned int x; + if (!val) + return; + cgroup_rstat_updated(memcg->css.cgroup, smp_processor_id()); x = __this_cpu_add_return(stats_updates, abs(val));