* [PATCH percpu/for-3.11] percpu-refcount: consistently use plain (non-sched) RCU
@ 2013-06-12 20:40 Tejun Heo
2013-06-12 20:55 ` Kent Overstreet
2013-06-13 3:48 ` Tejun Heo
0 siblings, 2 replies; 3+ messages in thread
From: Tejun Heo @ 2013-06-12 20:40 UTC (permalink / raw)
To: Kent Overstreet
Cc: linux-kernel, Rusty Russell, Oleg Nesterov, Christoph Lameter
>From e96262150a513ce3d54ff221d4ace8aeec96e0bf Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Wed, 12 Jun 2013 13:37:42 -0700
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>
---
include/linux/percpu-refcount.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h
index 24b31ef..abe1411 100644
--- a/include/linux/percpu-refcount.h
+++ b/include/linux/percpu-refcount.h
@@ -85,7 +85,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref)
{
unsigned __percpu *pcpu_count;
- preempt_disable();
+ rcu_read_lock();
pcpu_count = ACCESS_ONCE(ref->pcpu_count);
@@ -94,7 +94,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref)
else
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;
- preempt_disable();
+ rcu_read_lock();
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)))
ref->release(ref);
- preempt_enable();
+ rcu_read_unlock();
}
#endif
--
1.8.2.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH percpu/for-3.11] percpu-refcount: consistently use plain (non-sched) RCU
2013-06-12 20:40 [PATCH percpu/for-3.11] percpu-refcount: consistently use plain (non-sched) RCU Tejun Heo
@ 2013-06-12 20:55 ` Kent Overstreet
2013-06-13 3:48 ` Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Kent Overstreet @ 2013-06-12 20:55 UTC (permalink / raw)
To: Tejun Heo; +Cc: linux-kernel, Rusty Russell, Oleg Nesterov, Christoph Lameter
On Wed, Jun 12, 2013 at 01:40:32PM -0700, Tejun Heo wrote:
> From e96262150a513ce3d54ff221d4ace8aeec96e0bf Mon Sep 17 00:00:00 2001
> From: Tejun Heo <tj@kernel.org>
> Date: Wed, 12 Jun 2013 13:37:42 -0700
>
> 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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH percpu/for-3.11] percpu-refcount: consistently use plain (non-sched) RCU
2013-06-12 20:40 [PATCH percpu/for-3.11] percpu-refcount: consistently use plain (non-sched) RCU Tejun Heo
2013-06-12 20:55 ` Kent Overstreet
@ 2013-06-13 3:48 ` Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2013-06-13 3:48 UTC (permalink / raw)
To: Tejun Heo
Cc: Kent Overstreet, linux-kernel, Rusty Russell, Oleg Nesterov,
Christoph Lameter
On Wed, Jun 12, 2013 at 01:40:32PM -0700, Tejun Heo wrote:
> From e96262150a513ce3d54ff221d4ace8aeec96e0bf Mon Sep 17 00:00:00 2001
> From: Tejun Heo <tj@kernel.org>
> Date: Wed, 12 Jun 2013 13:37:42 -0700
>
> 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>
Applied to percpu/for-3.11.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-06-13 3:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-12 20:40 [PATCH percpu/for-3.11] percpu-refcount: consistently use plain (non-sched) RCU Tejun Heo
2013-06-12 20:55 ` Kent Overstreet
2013-06-13 3:48 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox