diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/percpu_counter.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c index 604678d7d06d..28f2c33c6b53 100644 --- a/lib/percpu_counter.c +++ b/lib/percpu_counter.c | |||
@@ -72,18 +72,16 @@ EXPORT_SYMBOL(percpu_counter_set); | |||
72 | void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch) | 72 | void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch) |
73 | { | 73 | { |
74 | s64 count; | 74 | s64 count; |
75 | s32 *pcount; | ||
76 | 75 | ||
77 | preempt_disable(); | 76 | preempt_disable(); |
78 | pcount = this_cpu_ptr(fbc->counters); | 77 | count = __this_cpu_read(*fbc->counters) + amount; |
79 | count = *pcount + amount; | ||
80 | if (count >= batch || count <= -batch) { | 78 | if (count >= batch || count <= -batch) { |
81 | spin_lock(&fbc->lock); | 79 | spin_lock(&fbc->lock); |
82 | fbc->count += count; | 80 | fbc->count += count; |
83 | *pcount = 0; | 81 | __this_cpu_write(*fbc->counters, 0); |
84 | spin_unlock(&fbc->lock); | 82 | spin_unlock(&fbc->lock); |
85 | } else { | 83 | } else { |
86 | *pcount = count; | 84 | __this_cpu_write(*fbc->counters, count); |
87 | } | 85 | } |
88 | preempt_enable(); | 86 | preempt_enable(); |
89 | } | 87 | } |