Skip to content

Commit 7c34b72

Browse files
committed
memcg: drain obj stock on cpu hotplug teardown
commit 9f01b49 Author: Shakeel Butt <[email protected]> Date: Mon Mar 10 16:09:34 2025 -0700 memcg: drain obj stock on cpu hotplug teardown Currently on cpu hotplug teardown, only memcg stock is drained but we need to drain the obj stock as well otherwise we will miss the stats accumulated on the target cpu as well as the nr_bytes cached. The stats include MEMCG_KMEM, NR_SLAB_RECLAIMABLE_B & NR_SLAB_UNRECLAIMABLE_B. In addition we are leaking reference to struct obj_cgroup object. Link: https://lkml.kernel.org/r/[email protected] Fixes: bf4f059 ("mm: memcg/slab: obj_cgroup API") Signed-off-by: Shakeel Butt <[email protected]> Reviewed-by: Roman Gushchin <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Muchun Song <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> JIRA: https://issues.redhat.com/browse/RHEL-77742 Signed-off-by: Nico Pache <[email protected]>
1 parent bc2d33b commit 7c34b72

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mm/memcontrol.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,9 +1938,18 @@ void drain_all_stock(struct mem_cgroup *root_memcg)
19381938
static int memcg_hotplug_cpu_dead(unsigned int cpu)
19391939
{
19401940
struct memcg_stock_pcp *stock;
1941+
struct obj_cgroup *old;
1942+
unsigned long flags;
19411943

19421944
stock = &per_cpu(memcg_stock, cpu);
1945+
1946+
/* drain_obj_stock requires stock_lock */
1947+
local_lock_irqsave(&memcg_stock.stock_lock, flags);
1948+
old = drain_obj_stock(stock);
1949+
local_unlock_irqrestore(&memcg_stock.stock_lock, flags);
1950+
19431951
drain_stock(stock);
1952+
obj_cgroup_put(old);
19441953

19451954
return 0;
19461955
}

0 commit comments

Comments
 (0)