diff options
author | Kent Overstreet <koverstreet@google.com> | 2013-06-03 23:02:29 (GMT) |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-06-03 23:04:04 (GMT) |
commit | c1ae6e9b4db00023b9caed72af49a93abad46452 (patch) | |
tree | 3bd3a5c78af7a7a18d6f390f651b8f5dbaba4c0b | |
parent | 215e262f2aeba378aa192da07c30770f9925a4bf (diff) | |
download | linux-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>
-rw-r--r-- | lib/percpu-refcount.c | 19 |
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); } |