Commit 80dcf60e6b97c7363971e7a0a788d8484d35f8a6

Authored by Paul E. McKenney
1 parent 7b0b759b65

rcu: apply TINY_PREEMPT_RCU read-side speedup to TREE_PREEMPT_RCU

Replace one of the ACCESS_ONCE() calls in each of __rcu_read_lock()
and __rcu_read_unlock() with barrier() as suggested by Steve Rostedt in
order to avoid the potential compiler-optimization-induced bug noted by
Mathieu Desnoyers.

Located-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Showing 1 changed file with 4 additions and 2 deletions Side-by-side Diff

kernel/rcutree_plugin.h
... ... @@ -201,7 +201,7 @@
201 201 */
202 202 void __rcu_read_lock(void)
203 203 {
204   - ACCESS_ONCE(current->rcu_read_lock_nesting)++;
  204 + current->rcu_read_lock_nesting++;
205 205 barrier(); /* needed if we ever invoke rcu_read_lock in rcutree.c */
206 206 }
207 207 EXPORT_SYMBOL_GPL(__rcu_read_lock);
... ... @@ -344,7 +344,9 @@
344 344 struct task_struct *t = current;
345 345  
346 346 barrier(); /* needed if we ever invoke rcu_read_unlock in rcutree.c */
347   - if (--ACCESS_ONCE(t->rcu_read_lock_nesting) == 0 &&
  347 + --t->rcu_read_lock_nesting;
  348 + barrier(); /* decrement before load of ->rcu_read_unlock_special */
  349 + if (t->rcu_read_lock_nesting == 0 &&
348 350 unlikely(ACCESS_ONCE(t->rcu_read_unlock_special)))
349 351 rcu_read_unlock_special(t);
350 352 #ifdef CONFIG_PROVE_LOCKING