aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLai Jiangshan <laijs@cn.fujitsu.com>2012-11-29 03:46:09 -0500
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2013-02-07 18:19:36 -0500
commit7a6b55e7108b3476d13ee9501ec69dbe1605d774 (patch)
tree9712b0a5f7c3b5d90f2625af369774cdb1334e6f
parent49271ca60645d64197b28c0835fed39f74b1a2d7 (diff)
srcu: use ACCESS_ONCE() to access sp->completed in srcu_read_lock()
The old SRCU implementation loads sp->completed within an RCU-sched section, courtesy of preempt_disable(). This was required due to the use of synchronize_sched() in the old implemenation's synchronize_srcu(). However, the new implementation does not rely on synchronize_sched(), so it in turn does not require the load of sp->completed and the ->c[] counter to be in a single preempt-disabled region of code. This commit therefore moves the sp->completed access outside of the preempt-disabled region and applies ACCESS_ONCE(). The resulting code is almost as the same as before, but it removes the now-misleading rcu_dereference_index_check() call. Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
-rw-r--r--kernel/srcu.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/srcu.c b/kernel/srcu.c
index e34f2991ed41..01d5ccb8bfe3 100644
--- a/kernel/srcu.c
+++ b/kernel/srcu.c
@@ -298,9 +298,8 @@ int __srcu_read_lock(struct srcu_struct *sp)
298{ 298{
299 int idx; 299 int idx;
300 300
301 idx = ACCESS_ONCE(sp->completed) & 0x1;
301 preempt_disable(); 302 preempt_disable();
302 idx = rcu_dereference_index_check(sp->completed,
303 rcu_read_lock_sched_held()) & 0x1;
304 ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1; 303 ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
305 smp_mb(); /* B */ /* Avoid leaking the critical section. */ 304 smp_mb(); /* B */ /* Avoid leaking the critical section. */
306 ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1; 305 ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;