]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm: memcontrol: propagate NMI slab stats to memcg vmstats
authorAlexandre Ghiti <alex@ghiti.fr>
Mon, 18 May 2026 08:28:19 +0000 (10:28 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 22 May 2026 02:06:12 +0000 (19:06 -0700)
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.

Link: https://lore.kernel.org/20260518082830.599102-1-alex@ghiti.fr
Fixes: 940b01fc8dc1 ("memcg: nmi safe memcg stats for specific archs")
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Harry Yoo (Oracle) <harry@kernel.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memcontrol.c

index c03d4787d466803db49cdaa90e6d6ba426b7afe2..507be1cca39234d7220bedb79068bfda52502fe9 100644 (file)
@@ -4352,6 +4352,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);
@@ -4360,6 +4363,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;
                }
        }
 }