mm: consider the number in local CPUs when reading NUMA stats
Subsystems (2)
[email protected]
maintainerPATCH 37/126 mm: consider the number in local CPUs when reading NUMA stats
From: Kemi Wang <[email protected]>
Subject: mm: consider the number in local CPUs when reading NUMA stats
To avoid deviation, the per cpu number of NUMA stats in vm_numa_stat_diff[] is included when a user *reads* the NUMA stats.
Since NUMA stats does not be read by users frequently, and kernel does not need it to make a decision, it will not be a problem to make the readers more expensive.
Signed-off-by Kemi Wang <[email protected]>
Reported-by Jesper Dangaard Brouer <[email protected]>
Acked-by Mel Gorman <[email protected]>
Cc Aaron Lu <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Christopher Lameter <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Tim Chen <[email protected]>
Cc Ying Huang <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
include/linux/vmstat.h | 6 +++++- mm/vmstat.c | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-)
include/linux/vmstat.h renamed from include/linux/vmstat.h~mm-consider-the-number-in-local-cpus-when-reads-numa-stats +5 -1
@@ -125,10 +125,14 @@ static inline unsigned long global_numa_return x; } -static inline unsigned long zone_numa_state (struct zone *zone, +static inline unsigned long zone_numa_state_snapshot (struct zone *zone,enum numa_stat_item item) {long x =atomic_long_read (&zone->vm_numa_stat[item]); +int cpu; + +for_each_online_cpu (cpu) + x +=per_cpu_ptr (zone->pageset, cpu)->vm_numa_stat_diff[item];return x; }
mm/vmstat.c renamed from mm/vmstat.c~mm-consider-the-number-in-local-cpus-when-reads-numa-stats +7 -2
@@ -897,6 +897,10 @@ unsigned long sum_zone_node_page_state(ireturn count; } +/* +* Determine the per node value of a numa stat item. To avoid deviation, +* the per cpu stat number in vm_numa_stat_diff[] is also included. +*/ unsigned long sum_zone_numa_state (int node,enum numa_stat_item item) {
@@ -905,7 +909,7 @@ unsigned long sum_zone_numa_state(int nounsigned long count =0 ;for (i =0 ; i <MAX_NR_ZONES ; i++) - count +=zone_numa_state (zones + i, item); + count +=zone_numa_state_snapshot (zones + i, item);return count; }
@@ -1536,7 +1540,7 @@ static void zoneinfo_show_print(struct sfor (i =0 ; i <NR_VM_NUMA_STAT_ITEMS ; i++)seq_printf (m,"\n %-12s %lu" , vmstat_text[i +NR_VM_ZONE_STAT_ITEMS ], -zone_numa_state (zone, i)); +zone_numa_state_snapshot (zone, i));#endif seq_printf (m,"\n pagesets" );
@@ -1792,6 +1796,7 @@ static bool need_update(int cpu)#ifdef CONFIG_NUMA BUILD_BUG_ON (sizeof (p->vm_numa_stat_diff[0 ]) !=2 );#endif +/* * The fast way of checking if there are any vmstat diffs. * This works because the diffs are byte sized items.
_