mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 13:53:33 +00:00
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>
This commit is contained in:
parent
215e262f2a
commit
c1ae6e9b4d
1 changed files with 4 additions and 15 deletions
|
@ -107,22 +107,11 @@ static void percpu_ref_kill_rcu(struct rcu_head *rcu)
|
||||||
*/
|
*/
|
||||||
void percpu_ref_kill(struct percpu_ref *ref)
|
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);
|
ref->pcpu_count = (unsigned __percpu *)
|
||||||
|
(((unsigned long) ref->pcpu_count)|PCPU_REF_DEAD);
|
||||||
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);
|
|
||||||
|
|
||||||
call_rcu(&ref->rcu, percpu_ref_kill_rcu);
|
call_rcu(&ref->rcu, percpu_ref_kill_rcu);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue