Commit a7f75e25 authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds

vmstat: small revisions to refresh_cpu_vm_stats()

1. Add comments explaining how the function can be called.

2. Collect global diffs in a local array and only spill
   them once into the global counters when the zone scan
   is finished. This means that we only touch each global
   counter once instead of each time we fold cpu counters
   into zone counters.
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 08e7d9b5
...@@ -284,6 +284,10 @@ EXPORT_SYMBOL(dec_zone_page_state); ...@@ -284,6 +284,10 @@ EXPORT_SYMBOL(dec_zone_page_state);
/* /*
* Update the zone counters for one cpu. * Update the zone counters for one cpu.
* *
* The cpu specified must be either the current cpu or a processor that
* is not online. If it is the current cpu then the execution thread must
* be pinned to the current cpu.
*
* Note that refresh_cpu_vm_stats strives to only access * Note that refresh_cpu_vm_stats strives to only access
* node local memory. The per cpu pagesets on remote zones are placed * node local memory. The per cpu pagesets on remote zones are placed
* in the memory local to the processor using that pageset. So the * in the memory local to the processor using that pageset. So the
...@@ -299,7 +303,7 @@ void refresh_cpu_vm_stats(int cpu) ...@@ -299,7 +303,7 @@ void refresh_cpu_vm_stats(int cpu)
{ {
struct zone *zone; struct zone *zone;
int i; int i;
unsigned long flags; int global_diff[NR_VM_ZONE_STAT_ITEMS] = { 0, };
for_each_zone(zone) { for_each_zone(zone) {
struct per_cpu_pageset *p; struct per_cpu_pageset *p;
...@@ -311,15 +315,19 @@ void refresh_cpu_vm_stats(int cpu) ...@@ -311,15 +315,19 @@ void refresh_cpu_vm_stats(int cpu)
for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
if (p->vm_stat_diff[i]) { if (p->vm_stat_diff[i]) {
unsigned long flags;
int v;
local_irq_save(flags); local_irq_save(flags);
zone_page_state_add(p->vm_stat_diff[i], v = p->vm_stat_diff[i];
zone, i);
p->vm_stat_diff[i] = 0; p->vm_stat_diff[i] = 0;
local_irq_restore(flags);
atomic_long_add(v, &zone->vm_stat[i]);
global_diff[i] += v;
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
/* 3 seconds idle till flush */ /* 3 seconds idle till flush */
p->expire = 3; p->expire = 3;
#endif #endif
local_irq_restore(flags);
} }
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
/* /*
...@@ -351,6 +359,10 @@ void refresh_cpu_vm_stats(int cpu) ...@@ -351,6 +359,10 @@ void refresh_cpu_vm_stats(int cpu)
drain_zone_pages(zone, p->pcp + 1); drain_zone_pages(zone, p->pcp + 1);
#endif #endif
} }
for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
if (global_diff[i])
atomic_long_add(global_diff[i], &vm_stat[i]);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment