aboutsummaryrefslogtreecommitdiffstats
path: root/mm/vmstat.c
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux.com>2013-09-11 17:21:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:57:31 -0400
commit4edb0748b23887140578d68f5f4e6e2de337a481 (patch)
treee10b862f2c94b6da38a10dd0ddf376298a579577 /mm/vmstat.c
parent2bb921e526656556e68f99f5f15a4a1bf2691844 (diff)
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)
414EXPORT_SYMBOL(dec_zone_page_state); 414EXPORT_SYMBOL(dec_zone_page_state);
415#endif 415#endif
416 416
417static inline void fold_diff(int *diff)
418{
419 int i;
420
421 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
422 if (diff[i])
423 atomic_long_add(diff[i], &vm_stat[i]);
424}
425
417/* 426/*
418 * Update the zone counters for the current cpu. 427 * Update the zone counters for the current cpu.
419 * 428 *
@@ -483,10 +492,7 @@ static void refresh_cpu_vm_stats(int cpu)
483 drain_zone_pages(zone, &p->pcp); 492 drain_zone_pages(zone, &p->pcp);
484#endif 493#endif
485 } 494 }
486 495 fold_diff(global_diff);
487 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
488 if (global_diff[i])
489 atomic_long_add(global_diff[i], &vm_stat[i]);
490} 496}
491 497
492/* 498/*
@@ -516,9 +522,7 @@ void cpu_vm_stats_fold(int cpu)
516 } 522 }
517 } 523 }
518 524
519 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) 525 fold_diff(global_diff);
520 if (global_diff[i])
521 atomic_long_add(global_diff[i], &vm_stat[i]);
522} 526}
523 527
524/* 528/*