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

From: Shakeel Butt

Date: Mon May 11 2026 - 18:50:05 EST


On Mon, May 11, 2026 at 10:20:36PM +0200, Alexandre Ghiti wrote:
> 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,

I think the above sentence needs clarification. Something like "For non nmi
case, account_slab_nmi_safe() calls mod_memcg_lruvec_state() which updates both
per-node lruvec_stats and memcg-level vmstats, so flush_nmi_stats() needs to
flush to per-node lruvec_stats as well as memcg-level vmstats but at the moment
the memcg-level vmstats flushing is missing. Fix that".

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

Nit: please keep all three code lines additions together.

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

Same here.

> }
> }
> }

With the commit message fixed and nits addressed, you can add:

Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>

and thanks for catching this issue.