diff options
author | Christoph Lameter <cl@linux.com> | 2013-09-11 17:21:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-11 18:57:31 -0400 |
commit | 4edb0748b23887140578d68f5f4e6e2de337a481 (patch) | |
tree | e10b862f2c94b6da38a10dd0ddf376298a579577 /mm/vmstat.c | |
parent | 2bb921e526656556e68f99f5f15a4a1bf2691844 (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.c | 18 |
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) | |||
414 | EXPORT_SYMBOL(dec_zone_page_state); | 414 | EXPORT_SYMBOL(dec_zone_page_state); |
415 | #endif | 415 | #endif |
416 | 416 | ||
417 | static 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 | /* |