Skip to content

Commit

Permalink
percpu_counter: use this_cpu_ptr() instead of per_cpu_ptr()
Browse files Browse the repository at this point in the history
this_cpu_ptr() avoids an array lookup and can use the percpu offset of the
local cpu directly.

Signed-off-by: Christoph Lameter <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Tejun Heo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Christoph Lameter authored and torvalds committed Oct 26, 2010
1 parent 041b78f commit ea00c30
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/percpu_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
{
s64 count;
s32 *pcount;
int cpu = get_cpu();

pcount = per_cpu_ptr(fbc->counters, cpu);
preempt_disable();
pcount = this_cpu_ptr(fbc->counters);
count = *pcount + amount;
if (count >= batch || count <= -batch) {
spin_lock(&fbc->lock);
Expand All @@ -85,7 +85,7 @@ void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
} else {
*pcount = count;
}
put_cpu();
preempt_enable();
}
EXPORT_SYMBOL(__percpu_counter_add);

Expand Down

0 comments on commit ea00c30

Please sign in to comment.