Skip to contentSkip to conversation

mm: memcontrol: update state_local when flushing NMI stats

PATCH Applied Guopeng Zhang 4 participants 5 messages Jul 13 – Jul 14

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: memcontrol: update state_local when flushing NMI stats

From: Guopeng Zhang <[email protected]>

flush_nmi_stats() updates state[] for kmem and slab counters but leaves the corresponding state_local[] counters unchanged. Local kmem and slab statistics therefore miss updates collected through the NMI-safe atomic path.

Update state_local[] together with state[].

Fixes 940b01fc8dc1 ("memcg: nmi safe memcg stats for specific archs")
---
 mm/memcontrol.c | 5 +++++
 1 file changed, 5 insertions(+)
mm/memcontrol.c +5 -0
index 22f55aeb94f3..02599b8b6bd5 100644
@@ -4443,6 +4443,7 @@ static void flush_nmi_stats(struct mem_cgroup *memcg, struct mem_cgroup *parent,
 		int index = memcg_stats_index(MEMCG_KMEM);
 
 		memcg->vmstats->state[index] += kmem;
+		memcg->vmstats->state_local[index] += kmem;
 		if (parent)
 			parent->vmstats->state_pending[index] += kmem;
 	}
@@ -4460,9 +4461,11 @@ 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;
+			lstats->state_local[index] += slab;
 			if (plstats)
 				plstats->state_pending[index] += slab;
 			memcg->vmstats->state[index] += slab;
+			memcg->vmstats->state_local[index] += slab;
 			if (parent)
 				parent->vmstats->state_pending[index] += slab;
 		}
@@ -4471,9 +4474,11 @@ static void flush_nmi_stats(struct mem_cgroup *memcg, struct mem_cgroup *parent,
 			int index = memcg_stats_index(NR_SLAB_UNRECLAIMABLE_B);
 
 			lstats->state[index] += slab;
+			lstats->state_local[index] += slab;
 			if (plstats)
 				plstats->state_pending[index] += slab;
 			memcg->vmstats->state[index] += slab;
+			memcg->vmstats->state_local[index] += slab;
 			if (parent)
 				parent->vmstats->state_pending[index] += slab;
 		}
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 41 lines · Guopeng Zhang

From: Guopeng Zhang <[email protected]>

flush_nmi_stats() updates state[] for kmem and slab counters but leaves the corresponding state_local[] counters unchanged. Local kmem and slab statistics therefore miss updates collected through the NMI-safe atomic path.

Update state_local[] together with state[].

Fixes 940b01fc8dc1 ("memcg: nmi safe memcg stats for specific archs")
---
 mm/memcontrol.c | 5 +++++
 1 file changed, 5 insertions(+)
mm/memcontrol.c +3 -0
index 22f55aeb94f3..02599b8b6bd5 100644
@@ -4443,6 +4443,7 @@ static void flush_nmi_stats(struct mem_cgroup *memcg, struct mem_cgroup *parent,
 		int index = memcg_stats_index(MEMCG_KMEM);
 
 		memcg->vmstats->state[index] += kmem;
+		memcg->vmstats->state_local[index] += kmem;
 		if (parent)
 			parent->vmstats->state_pending[index] += kmem;
 	}
@@ -4460,9 +4461,11 @@ 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;
+			lstats->state_local[index] += slab;
 			if (plstats)
 				plstats->state_pending[index] += slab;
 			memcg->vmstats->state[index] += slab;
+			memcg->vmstats->state_local[index] += slab;
 			if (parent)
 				parent->vmstats->state_pending[index] += slab;
 		}
@@ -4471,9 +4474,11 @@ static void flush_nmi_stats(struct mem_cgroup *memcg, struct mem_cgroup *parent,
 			int index = memcg_stats_index(NR_SLAB_UNRECLAIMABLE_B);

mm/memcontrol.c static void flush_nmi_stats(struct mem_cgroup *memcg, struct mem_cgroup *parent, · line 4484

Quoted 10 lines
mm/memcontrol.c +2 -0
 
 			lstats->state[index] += slab;
+			lstats->state_local[index] += slab;
 			if (plstats)
 				plstats->state_pending[index] += slab;
 			memcg->vmstats->state[index] += slab;
+			memcg->vmstats->state_local[index] += slab;
 			if (parent)
 				parent->vmstats->state_pending[index] += slab;
 		}

Looks correct — state_local[] mirrors state[] for this cgroup's own NMI-accounted kmem/slab charges, and pending→local is properly left untouched.

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Guopeng Zhang
Quoted 11 lines · Guopeng Zhang

From: Guopeng Zhang <[email protected]>

flush_nmi_stats() updates state[] for kmem and slab counters but leaves the corresponding state_local[] counters unchanged. Local kmem and slab statistics therefore miss updates collected through the NMI-safe atomic path.

Update state_local[] together with state[].

Fixes 940b01fc8dc1 ("memcg: nmi safe memcg stats for specific archs")

This issue affects memcg1 but also the workingset shrinker.

And we should probably CC: stable # 6.15. Shakeel?

maintainer
#3 lore raw
Quoted 10 lines · Johannes Weiner
Quoted 9 lines · Guopeng Zhang

From: Guopeng Zhang <[email protected]>

flush_nmi_stats() updates state[] for kmem and slab counters but leaves the corresponding state_local[] counters unchanged. Local kmem and slab statistics therefore miss updates collected through the NMI-safe atomic path.

Update state_local[] together with state[].

Quoted 8 lines
Quoted 2 lines
Fixes 940b01fc8dc1 ("memcg: nmi safe memcg stats for specific archs")

This issue affects memcg1 but also the workingset shrinker.

And we should probably CC: stable # 6.15. Shakeel?

Yes it makes sense.

maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Guopeng Zhang
Quoted 11 lines · Guopeng Zhang

From: Guopeng Zhang <[email protected]>

flush_nmi_stats() updates state[] for kmem and slab counters but leaves the corresponding state_local[] counters unchanged. Local kmem and slab statistics therefore miss updates collected through the NMI-safe atomic path.

Update state_local[] together with state[].

Fixes 940b01fc8dc1 ("memcg: nmi safe memcg stats for specific archs")