]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
memcg: avoid refill_stock for root memcg
authorShakeel Butt <shakeel.butt@linux.dev>
Thu, 13 Mar 2025 05:48:12 +0000 (22:48 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 22 Mar 2025 05:03:11 +0000 (22:03 -0700)
commit20d6c17252282c3af261d1cde8e34def1b2458c8
tree30e14178be86238c745cdc59c859c7fd6748e3eb
parentb4f65dbdf87812056c224fd8d2c66318b2140ab5
memcg: avoid refill_stock for root memcg

We never charge the page counters of root memcg, so there is no need to
put root memcg in the memcg stock.  At the moment, refill_stock() can be
called from try_charge_memcg(), obj_cgroup_uncharge_pages() and
mem_cgroup_uncharge_skmem().

The try_charge_memcg() and mem_cgroup_uncharge_skmem() are never called
with root memcg, so those are fine.  However obj_cgroup_uncharge_pages()
can potentially call refill_stock() with root memcg if the objcg object
has been reparented over to the root memcg.  Let's just avoid
refill_stock() from obj_cgroup_uncharge_pages() for root memcg.

Link: https://lkml.kernel.org/r/20250313054812.2185900-1-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Michal Hocko <mhockoc@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memcontrol.c