rcu: Restore barrier() to rcu_read_lock() and rcu_read_unlock()
authorPaul E. McKenney <paulmck@linux.ibm.com>
Tue, 4 Jun 2019 21:05:52 +0000 (14:05 -0700)
committerPaul E. McKenney <paulmck@linux.ibm.com>
Thu, 1 Aug 2019 21:05:51 +0000 (14:05 -0700)
commit1f3ebc8253ee56bfaa883c5114fb5569c56f6197
tree2744ef2b9aa4417d00525bb50fefb930bf4af241
parentb55bd585551ed2220eefdab96b31e6f935310eec
rcu: Restore barrier() to rcu_read_lock() and rcu_read_unlock()

Commit bb73c52bad36 ("rcu: Don't disable preemption for Tiny and Tree
RCU readers") removed the barrier() calls from rcu_read_lock() and
rcu_write_lock() in CONFIG_PREEMPT=n&&CONFIG_PREEMPT_COUNT=n kernels.
Within RCU, this commit was OK, but it failed to account for things like
get_user() that can pagefault and that can be reordered by the compiler.
Lack of the barrier() calls in rcu_read_lock() and rcu_read_unlock()
can cause these page faults to migrate into RCU read-side critical
sections, which in CONFIG_PREEMPT=n kernels could result in too-short
grace periods and arbitrary misbehavior.  Please see commit 386afc91144b
("spinlocks and preemption points need to be at least compiler barriers")
and Linus's commit 66be4e66a7f4 ("rcu: locking and unlocking need to
always be at least barriers"), this last of which restores the barrier()
call to both rcu_read_lock() and rcu_read_unlock().

This commit removes barrier() calls that are no longer needed given that
the addition of them in Linus's commit noted above.  The combination of
this commit and Linus's commit effectively reverts commit bb73c52bad36
("rcu: Don't disable preemption for Tiny and Tree RCU readers").

Reported-by: Herbert Xu <herbert@gondor.apana.org.au>
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
[ paulmck: Fix embarrassing typo located by Alan Stern. ]
Documentation/RCU/Design/Requirements/Requirements.html
kernel/rcu/tree_plugin.h