* [PATCH] percpu_counter: __this_cpu_write doesn't need to be protected by spinlock
@ 2013-07-01 2:48 Fan Du
0 siblings, 0 replies; only message in thread
From: Fan Du @ 2013-07-01 2:48 UTC (permalink / raw)
To: viro; +Cc: linux-kernel
__this_cpu_write doesn't need to be protected by spinlock, AS we are doing
per cpu write with preempt disabled. And another reason to remove __this_cpu_write
outside of spinlock: __percpu_counter_sum is not a accurate counter.
Signed-off-by: Fan Du <fan.du@windriver.com>
---
lib/percpu_counter.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
index ba6085d..1fc23a3 100644
--- a/lib/percpu_counter.c
+++ b/lib/percpu_counter.c
@@ -80,8 +80,8 @@ void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
if (count >= batch || count <= -batch) {
raw_spin_lock(&fbc->lock);
fbc->count += count;
- __this_cpu_write(*fbc->counters, 0);
raw_spin_unlock(&fbc->lock);
+ __this_cpu_write(*fbc->counters, 0);
} else {
__this_cpu_write(*fbc->counters, count);
}
--
1.7.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-07-01 2:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-01 2:48 [PATCH] percpu_counter: __this_cpu_write doesn't need to be protected by spinlock Fan Du
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®