aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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}