summaryrefslogtreecommitdiffstats
path: root/lib/percpu_counter.c
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux.com>2010-10-26 23:23:09 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-27 01:52:19 +0200
commitea00c30b5b31baa91be29bee966204eccc15e9d3 (patch)
treede5ad33475f3234048cc07d4676d963b8b4f314e /lib/percpu_counter.c
parentlib/list_sort: test: check element addresses (diff)
downloadlinux-ea00c30b5b31baa91be29bee966204eccc15e9d3.tar.xz
linux-ea00c30b5b31baa91be29bee966204eccc15e9d3.zip
percpu_counter: use this_cpu_ptr() instead of per_cpu_ptr()
this_cpu_ptr() avoids an array lookup and can use the percpu offset of the local cpu directly. Signed-off-by: Christoph Lameter <cl@linux.com> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/percpu_counter.c')
-rw-r--r--lib/percpu_counter.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
index 1d954ea72331..604678d7d06d 100644
--- a/lib/percpu_counter.c
+++ b/lib/percpu_counter.c
@@ -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);
@@ -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);