[PATCH 1/8] mm: memcontrol: propagate NMI slab stats to memcg vmstats

From: Alexandre Ghiti

Date: Mon May 11 2026 - 16:25:34 EST


flush_nmi_stats() drains per-node NMI slab atomics into the per-node
lruvec_stats, but does not propagate them to the memcg-level vmstats.

This is inconsistent with account_slab_nmi_safe() which updates both,
so fix this by propagating the NMI slab stats to the memcg-level vmstats.

Fixes: 940b01fc8dc1 ("memcg: nmi safe memcg stats for specific archs")
Signed-off-by: Alexandre Ghiti <alex@xxxxxxxx>
---
mm/memcontrol.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c3d98ab41f1f..d81a76654b2c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4341,16 +4341,22 @@ static void flush_nmi_stats(struct mem_cgroup *memcg, struct mem_cgroup *parent,
int index = memcg_stats_index(NR_SLAB_RECLAIMABLE_B);

lstats->state[index] += slab;
+ memcg->vmstats->state[index] += slab;
if (plstats)
plstats->state_pending[index] += slab;
+ if (parent)
+ parent->vmstats->state_pending[index] += slab;
}
if (atomic_read(&pn->slab_unreclaimable)) {
int slab = atomic_xchg(&pn->slab_unreclaimable, 0);
int index = memcg_stats_index(NR_SLAB_UNRECLAIMABLE_B);

lstats->state[index] += slab;
+ memcg->vmstats->state[index] += slab;
if (plstats)
plstats->state_pending[index] += slab;
+ if (parent)
+ parent->vmstats->state_pending[index] += slab;
}
}
}
--
2.54.0