Skip to content

Commit 20d6c17

Browse files
shakeelbakpm00
authored andcommitted
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/[email protected] Signed-off-by: Shakeel Butt <[email protected]> Acked-by: Michal Hocko <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: Muchun Song <[email protected]> Cc: Roman Gushchin <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b4f65db commit 20d6c17

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mm/memcontrol.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2643,7 +2643,8 @@ static void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg,
26432643

26442644
mod_memcg_state(memcg, MEMCG_KMEM, -nr_pages);
26452645
memcg1_account_kmem(memcg, -nr_pages);
2646-
refill_stock(memcg, nr_pages);
2646+
if (!mem_cgroup_is_root(memcg))
2647+
refill_stock(memcg, nr_pages);
26472648

26482649
css_put(&memcg->css);
26492650
}

0 commit comments

Comments
 (0)