]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/vmstat: use xchg in cpu_vm_stats_fold
authorMarcelo Tosatti <mtosatti@redhat.com>
Mon, 20 Mar 2023 18:03:42 +0000 (15:03 -0300)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 28 Mar 2023 23:25:09 +0000 (16:25 -0700)
In preparation to switch vmstat shepherd to flush per-CPU counters
remotely, use xchg instead of a pair of read/write instructions.

Link: https://lkml.kernel.org/r/20230320180745.783045641@redhat.com
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Aaron Tomlin <atomlin@atomlin.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmstat.c

index 60f4967cd72c3e51a8e40c8d31f3c5b96b2f1893..c93c87d9d7307cf5316b699247eef1d87bc47ba2 100644 (file)
@@ -924,7 +924,7 @@ static int refresh_cpu_vm_stats(bool do_pagesets)
 }
 
 /*
- * Fold the data for an offline cpu into the global array.
+ * Fold the data for a cpu into the global array.
  * There cannot be any access by the offline cpu and therefore
  * synchronization is simplified.
  */
@@ -945,8 +945,7 @@ void cpu_vm_stats_fold(int cpu)
                        if (pzstats->vm_stat_diff[i]) {
                                int v;
 
-                               v = pzstats->vm_stat_diff[i];
-                               pzstats->vm_stat_diff[i] = 0;
+                               v = xchg(&pzstats->vm_stat_diff[i], 0);
                                atomic_long_add(v, &zone->vm_stat[i]);
                                global_zone_diff[i] += v;
                        }
@@ -956,8 +955,7 @@ void cpu_vm_stats_fold(int cpu)
                        if (pzstats->vm_numa_event[i]) {
                                unsigned long v;
 
-                               v = pzstats->vm_numa_event[i];
-                               pzstats->vm_numa_event[i] = 0;
+                               v = xchg(&pzstats->vm_numa_event[i], 0);
                                zone_numa_event_add(v, zone, i);
                        }
                }
@@ -973,8 +971,7 @@ void cpu_vm_stats_fold(int cpu)
                        if (p->vm_node_stat_diff[i]) {
                                int v;
 
-                               v = p->vm_node_stat_diff[i];
-                               p->vm_node_stat_diff[i] = 0;
+                               v = xchg(&p->vm_node_stat_diff[i], 0);
                                atomic_long_add(v, &pgdat->vm_stat[i]);
                                global_node_diff[i] += v;
                        }