]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - lib/percpu-refcount.c
percpu-refcount: Don't use silly cmpxchg()
[karo-tx-linux.git] / lib / percpu-refcount.c
index 6f0ffd702a0914579836c16886daf062de371295..1a17399fc7db30421759d2619fe8d8668a7db1e9 100644 (file)
@@ -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);
 }