Skip to content

Commit

Permalink
vmstat: Use this_cpu_inc_return for vm statistics
Browse files Browse the repository at this point in the history
this_cpu_inc_return() saves us a memory access there. Code
size does not change.

V1->V2:
	- Fixed the location of the __per_cpu pointer attributes
	- Sparse checked
V2->V3:
	- Move fixes to __percpu attribute usage to earlier patch

Reviewed-by: Pekka Enberg <[email protected]>
Acked-by: H. Peter Anvin <[email protected]>
Signed-off-by: Christoph Lameter <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
  • Loading branch information
Christoph Lameter authored and htejun committed Dec 17, 2010
1 parent 275c8b9 commit 908ee0f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions mm/vmstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
s8 __percpu *p = pcp->vm_stat_diff + item;
s8 v, t;

__this_cpu_inc(*p);

v = __this_cpu_read(*p);
v = __this_cpu_inc_return(*p);
t = __this_cpu_read(pcp->stat_threshold);
if (unlikely(v > t)) {
s8 overstep = t >> 1;
Expand All @@ -251,9 +249,7 @@ void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
s8 __percpu *p = pcp->vm_stat_diff + item;
s8 v, t;

__this_cpu_dec(*p);

v = __this_cpu_read(*p);
v = __this_cpu_dec_return(*p);
t = __this_cpu_read(pcp->stat_threshold);
if (unlikely(v < - t)) {
s8 overstep = t >> 1;
Expand Down

0 comments on commit 908ee0f

Please sign in to comment.