diff options
author | Tejun Heo <tj@kernel.org> | 2013-06-12 23:43:06 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-06-12 23:43:06 -0400 |
commit | 6a24474da83ea7c8b7d32f05f858b1259994067a (patch) | |
tree | 88633b53318c1adb8f648eaf5edcabac8f81b01b /include/linux/percpu-refcount.h | |
parent | c1ae6e9b4db00023b9caed72af49a93abad46452 (diff) |
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>
Diffstat (limited to 'include/linux/percpu-refcount.h')
-rw-r--r-- | include/linux/percpu-refcount.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index 24b31ef15932..abe141172d96 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) | |||
85 | { | 85 | { |
86 | unsigned __percpu *pcpu_count; | 86 | unsigned __percpu *pcpu_count; |
87 | 87 | ||
88 | preempt_disable(); | 88 | rcu_read_lock(); |
89 | 89 | ||
90 | pcpu_count = ACCESS_ONCE(ref->pcpu_count); | 90 | pcpu_count = ACCESS_ONCE(ref->pcpu_count); |
91 | 91 | ||
@@ -94,7 +94,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref) | |||
94 | else | 94 | else |
95 | atomic_inc(&ref->count); | 95 | atomic_inc(&ref->count); |
96 | 96 | ||
97 | preempt_enable(); | 97 | rcu_read_unlock(); |
98 | } | 98 | } |
99 | 99 | ||
100 | /** | 100 | /** |
@@ -107,7 +107,7 @@ static inline void percpu_ref_put(struct percpu_ref *ref) | |||
107 | { | 107 | { |
108 | unsigned __percpu *pcpu_count; | 108 | unsigned __percpu *pcpu_count; |
109 | 109 | ||
110 | preempt_disable(); | 110 | rcu_read_lock(); |
111 | 111 | ||
112 | pcpu_count = ACCESS_ONCE(ref->pcpu_count); | 112 | pcpu_count = ACCESS_ONCE(ref->pcpu_count); |
113 | 113 | ||
@@ -116,7 +116,7 @@ static inline void percpu_ref_put(struct percpu_ref *ref) | |||
116 | else if (unlikely(atomic_dec_and_test(&ref->count))) | 116 | else if (unlikely(atomic_dec_and_test(&ref->count))) |
117 | ref->release(ref); | 117 | ref->release(ref); |
118 | 118 | ||
119 | preempt_enable(); | 119 | rcu_read_unlock(); |
120 | } | 120 | } |
121 | 121 | ||
122 | #endif | 122 | #endif |