Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] mm: memcontrol: propagate NMI slab stats to memcg vmstats
@ 2026-05-18  8:28 Alexandre Ghiti
  2026-05-18 13:21 ` Johannes Weiner
  2026-05-19 11:22 ` Harry Yoo
  0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Ghiti @ 2026-05-18  8:28 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Vlastimil Babka, stable, linux-mm, linux-kernel,
	cgroups, Alexandre Ghiti

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.

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.

So fix this by flushing to the memcg-level vmstats for NMI too.

Fixes: 940b01fc8dc1 ("memcg: nmi safe memcg stats for specific archs")
Cc: stable@vger.kernel.org
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
 mm/memcontrol.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c3d98ab41f1f..953a3c0556a5 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4343,6 +4343,9 @@ static void flush_nmi_stats(struct mem_cgroup *memcg, struct mem_cgroup *parent,
 			lstats->state[index] += slab;
 			if (plstats)
 				plstats->state_pending[index] += slab;
+			memcg->vmstats->state[index] += slab;
+			if (parent)
+				parent->vmstats->state_pending[index] += slab;
 		}
 		if (atomic_read(&pn->slab_unreclaimable)) {
 			int slab = atomic_xchg(&pn->slab_unreclaimable, 0);
@@ -4351,6 +4354,9 @@ static void flush_nmi_stats(struct mem_cgroup *memcg, struct mem_cgroup *parent,
 			lstats->state[index] += slab;
 			if (plstats)
 				plstats->state_pending[index] += slab;
+			memcg->vmstats->state[index] += slab;
+			if (parent)
+				parent->vmstats->state_pending[index] += slab;
 		}
 	}
 }
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: memcontrol: propagate NMI slab stats to memcg vmstats
  2026-05-18  8:28 [PATCH] mm: memcontrol: propagate NMI slab stats to memcg vmstats Alexandre Ghiti
@ 2026-05-18 13:21 ` Johannes Weiner
  2026-05-19 11:22 ` Harry Yoo
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Weiner @ 2026-05-18 13:21 UTC (permalink / raw)
  To: Alexandre Ghiti
  Cc: Andrew Morton, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Vlastimil Babka, stable, linux-mm, linux-kernel,
	cgroups

On Mon, May 18, 2026 at 10:28:19AM +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.
> 
> 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.
> 
> So fix this by flushing to the memcg-level vmstats for NMI too.
> 
> Fixes: 940b01fc8dc1 ("memcg: nmi safe memcg stats for specific archs")
> Cc: stable@vger.kernel.org
> Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>

Acked-by: Johannes Weiner <hannes@cmpxchg.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: memcontrol: propagate NMI slab stats to memcg vmstats
  2026-05-18  8:28 [PATCH] mm: memcontrol: propagate NMI slab stats to memcg vmstats Alexandre Ghiti
  2026-05-18 13:21 ` Johannes Weiner
@ 2026-05-19 11:22 ` Harry Yoo
  1 sibling, 0 replies; 3+ messages in thread
From: Harry Yoo @ 2026-05-19 11:22 UTC (permalink / raw)
  To: Alexandre Ghiti, Andrew Morton
  Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Vlastimil Babka, stable, linux-mm, linux-kernel,
	cgroups



On 5/18/26 5:28 PM, 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.
> 
> 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.
> 
> So fix this by flushing to the memcg-level vmstats for NMI too.
> 
> Fixes: 940b01fc8dc1 ("memcg: nmi safe memcg stats for specific archs")
> Cc: stable@vger.kernel.org
> Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
> ---

Looks good to me,
Reviewed-by: Harry Yoo (Oracle) <harry@kernel.org>

-- 
Cheers,
Harry / Hyeonggon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-19 11:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-18  8:28 [PATCH] mm: memcontrol: propagate NMI slab stats to memcg vmstats Alexandre Ghiti
2026-05-18 13:21 ` Johannes Weiner
2026-05-19 11:22 ` Harry Yoo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox