aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYosry Ahmed <[email protected]>2023-03-30 19:18:01 +0000
committerAndrew Morton <[email protected]>2023-04-18 16:29:50 -0700
commitf9d911ca49d7fb30dde4858f8751cf2534e78b47 (patch)
tree9684de35012e1f87d3ed0fe1becddf2cd7d9b79e
parent0d856cfedd6bc0cb8e19c1e70d400e79b655cfdd (diff)
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/[email protected] Signed-off-by: Yosry Ahmed <[email protected]> Acked-by: Shakeel Butt <[email protected]> Acked-by: Johannes Weiner <[email protected]> Acked-by: Michal Hocko <[email protected]> Reviewed-by: Michal Koutný <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Josef Bacik <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Muchun Song <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Vasily Averin <[email protected]> Cc: Zefan Li <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r--mm/memcontrol.c3
1 files changed, 3 insertions, 0 deletions
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));