[PATCH v2 1/9] memcg: remove root memcg check from refill_stock
From: Shakeel Butt
Date: Thu Apr 03 2025 - 21:39:58 EST
refill_stock can not be called with root memcg, so there is no need to
check it. Instead add a warning if root is ever passed to it.
Reviewed-by: Roman Gushchin <roman.gushchin@xxxxxxxxx>
Acked-by: Vlastimil Babka <vbabka@xxxxxxx>
Signed-off-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>
---
mm/memcontrol.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b16b5b807d7c..ae1e953cead7 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1893,13 +1893,13 @@ static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
{
unsigned long flags;
+ VM_WARN_ON_ONCE(mem_cgroup_is_root(memcg));
+
if (!local_trylock_irqsave(&memcg_stock.stock_lock, flags)) {
/*
* In case of unlikely failure to lock percpu stock_lock
* uncharge memcg directly.
*/
- if (mem_cgroup_is_root(memcg))
- return;
page_counter_uncharge(&memcg->memory, nr_pages);
if (do_memsw_account())
page_counter_uncharge(&memcg->memsw, nr_pages);
--
2.47.1