summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2013-06-03 23:02:29 (GMT)
committerTejun Heo <tj@kernel.org>2013-06-03 23:04:04 (GMT)
commitc1ae6e9b4db00023b9caed72af49a93abad46452 (patch)
tree3bd3a5c78af7a7a18d6f390f651b8f5dbaba4c0b /lib
parent215e262f2aeba378aa192da07c30770f9925a4bf (diff)
downloadlinux-c1ae6e9b4db00023b9caed72af49a93abad46452.tar.xz
percpu-refcount: Don't use silly cmpxchg()
The cmpxchg() was just to ensure the debug check didn't race, which was a bit excessive. The caller is supposed to do the appropriate synchronization, which means percpu_ref_kill() can just do a simple store. Signed-off-by: Kent Overstreet <koverstreet@google.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/percpu-refcount.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
index 6f0ffd7..1a17399f 100644
--- a/lib/percpu-refcount.c
+++ b/lib/percpu-refcount.c
@@ -107,22 +107,11 @@ static void percpu_ref_kill_rcu(struct rcu_head *rcu)
*/
void percpu_ref_kill(struct percpu_ref *ref)
{
- unsigned __percpu *pcpu_count, *old, *new;
+ WARN_ONCE(REF_STATUS(ref->pcpu_count) == PCPU_REF_DEAD,
+ "percpu_ref_kill() called more than once!\n");
- pcpu_count = ACCESS_ONCE(ref->pcpu_count);
-
- do {
- if (REF_STATUS(pcpu_count) == PCPU_REF_DEAD) {
- WARN(1, "percpu_ref_kill() called more than once!\n");
- return;
- }
-
- old = pcpu_count;
- new = (unsigned __percpu *)
- (((unsigned long) pcpu_count)|PCPU_REF_DEAD);
-
- pcpu_count = cmpxchg(&ref->pcpu_count, old, new);
- } while (pcpu_count != old);
+ ref->pcpu_count = (unsigned __percpu *)
+ (((unsigned long) ref->pcpu_count)|PCPU_REF_DEAD);
call_rcu(&ref->rcu, percpu_ref_kill_rcu);
}