aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2013-06-03 19:02:29 -0400
committerTejun Heo <tj@kernel.org>2013-06-03 19:04:04 -0400
commitc1ae6e9b4db00023b9caed72af49a93abad46452 (patch)
tree3bd3a5c78af7a7a18d6f390f651b8f5dbaba4c0b /lib
parent215e262f2aeba378aa192da07c30770f9925a4bf (diff)
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 6f0ffd702a09..1a17399fc7db 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)
107 */ 107 */
108void percpu_ref_kill(struct percpu_ref *ref) 108void percpu_ref_kill(struct percpu_ref *ref)
109{ 109{
110 unsigned __percpu *pcpu_count, *old, *new; 110 WARN_ONCE(REF_STATUS(ref->pcpu_count) == PCPU_REF_DEAD,
111 "percpu_ref_kill() called more than once!\n");
111 112
112 pcpu_count = ACCESS_ONCE(ref->pcpu_count); 113 ref->pcpu_count = (unsigned __percpu *)
113 114 (((unsigned long) ref->pcpu_count)|PCPU_REF_DEAD);
114 do {
115 if (REF_STATUS(pcpu_count) == PCPU_REF_DEAD) {
116 WARN(1, "percpu_ref_kill() called more than once!\n");
117 return;
118 }
119
120 old = pcpu_count;
121 new = (unsigned __percpu *)
122 (((unsigned long) pcpu_count)|PCPU_REF_DEAD);
123
124 pcpu_count = cmpxchg(&ref->pcpu_count, old, new);
125 } while (pcpu_count != old);
126 115
127 call_rcu(&ref->rcu, percpu_ref_kill_rcu); 116 call_rcu(&ref->rcu, percpu_ref_kill_rcu);
128} 117}