Skip to content

Commit

Permalink
this_cpu: Use this_cpu ops for VM statistics
Browse files Browse the repository at this point in the history
Using per cpu atomics for the vm statistics reduces their overhead.
And in the case of x86 we are guaranteed that they will never race even
in the lax form used for vm statistics.

Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Christoph Lameter authored and Tejun Heo committed Oct 3, 2009
1 parent 0b44f48 commit 4dac3e9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions include/linux/vmstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,22 @@ DECLARE_PER_CPU(struct vm_event_state, vm_event_states);

static inline void __count_vm_event(enum vm_event_item item)
{
__get_cpu_var(vm_event_states).event[item]++;
__this_cpu_inc(per_cpu_var(vm_event_states).event[item]);
}

static inline void count_vm_event(enum vm_event_item item)
{
get_cpu_var(vm_event_states).event[item]++;
put_cpu();
this_cpu_inc(per_cpu_var(vm_event_states).event[item]);
}

static inline void __count_vm_events(enum vm_event_item item, long delta)
{
__get_cpu_var(vm_event_states).event[item] += delta;
__this_cpu_add(per_cpu_var(vm_event_states).event[item], delta);
}

static inline void count_vm_events(enum vm_event_item item, long delta)
{
get_cpu_var(vm_event_states).event[item] += delta;
put_cpu();
this_cpu_add(per_cpu_var(vm_event_states).event[item], delta);
}

extern void all_vm_events(unsigned long *);
Expand Down

0 comments on commit 4dac3e9

Please sign in to comment.