Skip to content

Commit 6c1c280

Browse files
shakeelbtorvalds
authored andcommitted
mm: memcontrol: fix percpu vmstats and vmevents flush
Instead of using raw_cpu_read() use per_cpu() to read the actual data of the corresponding cpu otherwise we will be reading the data of the current cpu for the number of online CPUs. Link: http://lkml.kernel.org/r/[email protected] Fixes: bb65f89 ("mm: memcontrol: flush percpu vmevents before releasing memcg") Fixes: c350a99 ("mm: memcontrol: flush percpu vmstats before releasing memcg") Signed-off-by: Shakeel Butt <[email protected]> Acked-by: Roman Gushchin <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Vladimir Davydov <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d2e5fb9 commit 6c1c280

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mm/memcontrol.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3278,7 +3278,7 @@ static void memcg_flush_percpu_vmstats(struct mem_cgroup *memcg, bool slab_only)
32783278

32793279
for_each_online_cpu(cpu)
32803280
for (i = min_idx; i < max_idx; i++)
3281-
stat[i] += raw_cpu_read(memcg->vmstats_percpu->stat[i]);
3281+
stat[i] += per_cpu(memcg->vmstats_percpu->stat[i], cpu);
32823282

32833283
for (mi = memcg; mi; mi = parent_mem_cgroup(mi))
32843284
for (i = min_idx; i < max_idx; i++)
@@ -3296,8 +3296,8 @@ static void memcg_flush_percpu_vmstats(struct mem_cgroup *memcg, bool slab_only)
32963296

32973297
for_each_online_cpu(cpu)
32983298
for (i = min_idx; i < max_idx; i++)
3299-
stat[i] += raw_cpu_read(
3300-
pn->lruvec_stat_cpu->count[i]);
3299+
stat[i] += per_cpu(
3300+
pn->lruvec_stat_cpu->count[i], cpu);
33013301

33023302
for (pi = pn; pi; pi = parent_nodeinfo(pi, node))
33033303
for (i = min_idx; i < max_idx; i++)
@@ -3316,8 +3316,8 @@ static void memcg_flush_percpu_vmevents(struct mem_cgroup *memcg)
33163316

33173317
for_each_online_cpu(cpu)
33183318
for (i = 0; i < NR_VM_EVENT_ITEMS; i++)
3319-
events[i] += raw_cpu_read(
3320-
memcg->vmstats_percpu->events[i]);
3319+
events[i] += per_cpu(memcg->vmstats_percpu->events[i],
3320+
cpu);
33213321

33223322
for (mi = memcg; mi; mi = parent_mem_cgroup(mi))
33233323
for (i = 0; i < NR_VM_EVENT_ITEMS; i++)

0 commit comments

Comments
 (0)