mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-03-01 14:14:47 +07:00
percpu-refcount: consistently use plain (non-sched) RCU
percpu_ref_get/put() are using preempt_disable/enable() while percpu_ref_kill() is using plain call_rcu() instead of call_rcu_sched(). This is buggy as grace periods of the two may not match. Fix it by using plain RCU in percpu_ref_get/put(). (I suggested using sched RCU in the first place but there's no actual benefit in doing so unless we're gonna introduce different variants of get/put to be called while preemption is alredy disabled, which we definitely shouldn't.) Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Rusty Russell <rusty@rustcorp.com.au> Acked-by: Kent Overstreet <koverstreet@google.com>
This commit is contained in:
parent
c1ae6e9b4d
commit
6a24474da8
@ -85,7 +85,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref)
|
|||||||
{
|
{
|
||||||
unsigned __percpu *pcpu_count;
|
unsigned __percpu *pcpu_count;
|
||||||
|
|
||||||
preempt_disable();
|
rcu_read_lock();
|
||||||
|
|
||||||
pcpu_count = ACCESS_ONCE(ref->pcpu_count);
|
pcpu_count = ACCESS_ONCE(ref->pcpu_count);
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref)
|
|||||||
else
|
else
|
||||||
atomic_inc(&ref->count);
|
atomic_inc(&ref->count);
|
||||||
|
|
||||||
preempt_enable();
|
rcu_read_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,7 +107,7 @@ static inline void percpu_ref_put(struct percpu_ref *ref)
|
|||||||
{
|
{
|
||||||
unsigned __percpu *pcpu_count;
|
unsigned __percpu *pcpu_count;
|
||||||
|
|
||||||
preempt_disable();
|
rcu_read_lock();
|
||||||
|
|
||||||
pcpu_count = ACCESS_ONCE(ref->pcpu_count);
|
pcpu_count = ACCESS_ONCE(ref->pcpu_count);
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ static inline void percpu_ref_put(struct percpu_ref *ref)
|
|||||||
else if (unlikely(atomic_dec_and_test(&ref->count)))
|
else if (unlikely(atomic_dec_and_test(&ref->count)))
|
||||||
ref->release(ref);
|
ref->release(ref);
|
||||||
|
|
||||||
preempt_enable();
|
rcu_read_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user