diff mbox series

[v2,1/9] memcg: remove root memcg check from refill_stock

Message ID 20250404013913.1663035-2-shakeel.butt@linux.dev (mailing list archive)
State New
Headers show
Series memcg: cleanup per-cpu stock | expand

Commit Message

Shakeel Butt April 4, 2025, 1:39 a.m. UTC
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@linux.dev>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

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);