diff options
author | Christoph Lameter <cl@linux.com> | 2010-10-26 17:23:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 19:52:19 -0400 |
commit | ea00c30b5b31baa91be29bee966204eccc15e9d3 (patch) | |
tree | de5ad33475f3234048cc07d4676d963b8b4f314e /lib | |
parent | 041b78f232bb87b2de8ca3fed50384bc7dc9c2de (diff) |
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')
-rw-r--r-- | lib/percpu_counter.c | 6 |
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) | |||
73 | { | 73 | { |
74 | s64 count; | 74 | s64 count; |
75 | s32 *pcount; | 75 | s32 *pcount; |
76 | int cpu = get_cpu(); | ||
77 | 76 | ||
78 | pcount = per_cpu_ptr(fbc->counters, cpu); | 77 | preempt_disable(); |
78 | pcount = this_cpu_ptr(fbc->counters); | ||
79 | count = *pcount + amount; | 79 | count = *pcount + amount; |
80 | if (count >= batch || count <= -batch) { | 80 | if (count >= batch || count <= -batch) { |
81 | spin_lock(&fbc->lock); | 81 | spin_lock(&fbc->lock); |
@@ -85,7 +85,7 @@ void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch) | |||
85 | } else { | 85 | } else { |
86 | *pcount = count; | 86 | *pcount = count; |
87 | } | 87 | } |
88 | put_cpu(); | 88 | preempt_enable(); |
89 | } | 89 | } |
90 | EXPORT_SYMBOL(__percpu_counter_add); | 90 | EXPORT_SYMBOL(__percpu_counter_add); |
91 | 91 | ||