summaryrefslogtreecommitdiff
path: root/mm/vmstat.c
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux.com>2013-09-11 14:21:31 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 15:57:31 -0700
commit4edb0748b23887140578d68f5f4e6e2de337a481 (patch)
treee10b862f2c94b6da38a10dd0ddf376298a579577 /mm/vmstat.c
parent2bb921e526656556e68f99f5f15a4a1bf2691844 (diff)
downloadlwn-4edb0748b23887140578d68f5f4e6e2de337a481.tar.gz
lwn-4edb0748b23887140578d68f5f4e6e2de337a481.zip
vmstat: create fold_diff
Both functions that update global counters use the same mechanism. Create a function that contains the common code. Signed-off-by: Christoph Lameter <cl@linux.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> CC: Tejun Heo <tj@kernel.org> Cc: Joonsoo Kim <js1304@gmail.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmstat.c')
-rw-r--r--mm/vmstat.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/mm/vmstat.c b/mm/vmstat.c
index aaee66330e01..158ca6494bc6 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -414,6 +414,15 @@ void dec_zone_page_state(struct page *page, enum zone_stat_item item)
EXPORT_SYMBOL(dec_zone_page_state);
#endif
+static inline void fold_diff(int *diff)
+{
+ int i;
+
+ for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
+ if (diff[i])
+ atomic_long_add(diff[i], &vm_stat[i]);
+}
+
/*
* Update the zone counters for the current cpu.
*
@@ -483,10 +492,7 @@ static void refresh_cpu_vm_stats(int cpu)
drain_zone_pages(zone, &p->pcp);
#endif
}
-
- for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
- if (global_diff[i])
- atomic_long_add(global_diff[i], &vm_stat[i]);
+ fold_diff(global_diff);
}
/*
@@ -516,9 +522,7 @@ void cpu_vm_stats_fold(int cpu)
}
}
- for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
- if (global_diff[i])
- atomic_long_add(global_diff[i], &vm_stat[i]);
+ fold_diff(global_diff);
}
/*