memcg: manually inline __refill_stock

There are no more multiple callers of __refill_stock(), so simply inline
it to refill_stock().

Link: https://lkml.kernel.org/r/20250404013913.1663035-5-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Shakeel Butt
2025-04-03 18:39:08 -07:00
committed by Andrew Morton
parent 89f342af66
commit cbc091441d

View File

@@ -1871,30 +1871,10 @@ static void drain_local_stock(struct work_struct *dummy)
obj_cgroup_put(old);
}
/*
* Cache charges(val) to local per_cpu area.
* This will be consumed by consume_stock() function, later.
*/
static void __refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
{
struct memcg_stock_pcp *stock;
unsigned int stock_pages;
stock = this_cpu_ptr(&memcg_stock);
if (READ_ONCE(stock->cached) != memcg) { /* reset if necessary */
drain_stock(stock);
css_get(&memcg->css);
WRITE_ONCE(stock->cached, memcg);
}
stock_pages = READ_ONCE(stock->nr_pages) + nr_pages;
WRITE_ONCE(stock->nr_pages, stock_pages);
if (stock_pages > MEMCG_CHARGE_BATCH)
drain_stock(stock);
}
static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
{
unsigned long flags;
VM_WARN_ON_ONCE(mem_cgroup_is_root(memcg));
@@ -1907,7 +1887,19 @@ static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
memcg_uncharge(memcg, nr_pages);
return;
}
__refill_stock(memcg, nr_pages);
stock = this_cpu_ptr(&memcg_stock);
if (READ_ONCE(stock->cached) != memcg) { /* reset if necessary */
drain_stock(stock);
css_get(&memcg->css);
WRITE_ONCE(stock->cached, memcg);
}
stock_pages = READ_ONCE(stock->nr_pages) + nr_pages;
WRITE_ONCE(stock->nr_pages, stock_pages);
if (stock_pages > MEMCG_CHARGE_BATCH)
drain_stock(stock);
local_unlock_irqrestore(&memcg_stock.stock_lock, flags);
}