aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-06-16 19:12:26 -0400
committerTejun Heo <tj@kernel.org>2013-06-16 19:12:26 -0400
commita4244454df1296e90cc961c1b636b1176ef0d9a0 (patch)
tree9be151f1e7a791dbf2d146fc5283ed246562d7f1
parentdbece3a0f1ef0b19aff1cc6ed0942fec9ab98de1 (diff)
percpu-refcount: use RCU-sched insted of normal RCU
percpu-refcount was incorrectly using preempt_disable/enable() for RCU critical sections against call_rcu(). 6a24474da8 ("percpu-refcount: consistently use plain (non-sched) RCU") fixed it by converting the preepmtion operations with rcu_read_[un]lock() citing that there isn't any advantage in using sched-RCU over using the usual one; however, rcu_read_[un]lock() for the preemptible RCU implementation - CONFIG_TREE_PREEMPT_RCU, chosen when CONFIG_PREEMPT - are slightly more expensive than preempt_disable/enable(). In a contrived microbench which repeats the followings, - percpu_ref_get() - copy 32 bytes of data into percpu buffer - percpu_put_get() - copy 32 bytes of data into percpu buffer rcu_read_[un]lock() used in percpu_ref_get/put() makes it go slower by about 15% when compared to using sched-RCU. As the RCU critical sections are extremely short, using sched-RCU shouldn't have any latency implications. Convert to RCU-sched. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Kent Overstreet <koverstreet@google.com> Acked-by: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Cc: Michal Hocko <mhocko@suse.cz> Cc: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r--include/linux/percpu-refcount.h12
-rw-r--r--lib/percpu-refcount.c2
2 files changed, 7 insertions, 7 deletions
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h
index dd2a08600453..95961f0bf62d 100644
--- a/include/linux/percpu-refcount.h
+++ b/include/linux/percpu-refcount.h
@@ -105,7 +105,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref)
105{ 105{
106 unsigned __percpu *pcpu_count; 106 unsigned __percpu *pcpu_count;
107 107
108 rcu_read_lock(); 108 rcu_read_lock_sched();
109 109
110 pcpu_count = ACCESS_ONCE(ref->pcpu_count); 110 pcpu_count = ACCESS_ONCE(ref->pcpu_count);
111 111
@@ -114,7 +114,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref)
114 else 114 else
115 atomic_inc(&ref->count); 115 atomic_inc(&ref->count);
116 116
117 rcu_read_unlock(); 117 rcu_read_unlock_sched();
118} 118}
119 119
120/** 120/**
@@ -134,7 +134,7 @@ static inline bool percpu_ref_tryget(struct percpu_ref *ref)
134 unsigned __percpu *pcpu_count; 134 unsigned __percpu *pcpu_count;
135 int ret = false; 135 int ret = false;
136 136
137 rcu_read_lock(); 137 rcu_read_lock_sched();
138 138
139 pcpu_count = ACCESS_ONCE(ref->pcpu_count); 139 pcpu_count = ACCESS_ONCE(ref->pcpu_count);
140 140
@@ -143,7 +143,7 @@ static inline bool percpu_ref_tryget(struct percpu_ref *ref)
143 ret = true; 143 ret = true;
144 } 144 }
145 145
146 rcu_read_unlock(); 146 rcu_read_unlock_sched();
147 147
148 return ret; 148 return ret;
149} 149}
@@ -159,7 +159,7 @@ static inline void percpu_ref_put(struct percpu_ref *ref)
159{ 159{
160 unsigned __percpu *pcpu_count; 160 unsigned __percpu *pcpu_count;
161 161
162 rcu_read_lock(); 162 rcu_read_lock_sched();
163 163
164 pcpu_count = ACCESS_ONCE(ref->pcpu_count); 164 pcpu_count = ACCESS_ONCE(ref->pcpu_count);
165 165
@@ -168,7 +168,7 @@ static inline void percpu_ref_put(struct percpu_ref *ref)
168 else if (unlikely(atomic_dec_and_test(&ref->count))) 168 else if (unlikely(atomic_dec_and_test(&ref->count)))
169 ref->release(ref); 169 ref->release(ref);
170 170
171 rcu_read_unlock(); 171 rcu_read_unlock_sched();
172} 172}
173 173
174#endif 174#endif
diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
index 8bf9e719cca0..7deeb6297a48 100644
--- a/lib/percpu-refcount.c
+++ b/lib/percpu-refcount.c
@@ -154,5 +154,5 @@ void percpu_ref_kill_and_confirm(struct percpu_ref *ref,
154 (((unsigned long) ref->pcpu_count)|PCPU_REF_DEAD); 154 (((unsigned long) ref->pcpu_count)|PCPU_REF_DEAD);
155 ref->confirm_kill = confirm_kill; 155 ref->confirm_kill = confirm_kill;
156 156
157 call_rcu(&ref->rcu, percpu_ref_kill_rcu); 157 call_rcu_sched(&ref->rcu, percpu_ref_kill_rcu);
158} 158}