diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2015-02-02 22:46:33 +0300 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2015-03-03 22:16:47 +0300 |
commit | b826565aaf8809df146666c03d1acbb7febbd13e (patch) | |
tree | cb5224792ca8c92abe2e695fcef61ecc49d83631 /scripts/sortextable.c | |
parent | a3bd2c09adcc80946262fd15e63868de1f0f4963 (diff) | |
download | linux-b826565aaf8809df146666c03d1acbb7febbd13e.tar.xz |
rcu: Reverse rcu_dereference_check() conditions
The rcu_dereference_check() family of primitives evaluates the RCU
lockdep expression first, and only then evaluates the expression passed
in. This works fine normally, but can potentially fail in environments
(such as NMI handlers) where lockdep cannot be invoked. The problem is
that even if the expression passed in is "1", the compiler would need to
prove that the RCU lockdep expression (rcu_read_lock_held(), for example)
is free of side effects in order to be able to elide it. Given that
rcu_read_lock_held() is sometimes separately compiled, the compiler cannot
always use this optimization.
This commit therefore reverse the order of evaluation, so that the
expression passed in is evaluated first, and the RCU lockdep expression is
evaluated only if the passed-in expression evaluated to false, courtesy
of the C-language short-circuit boolean evaluation rules. This compells
the compiler to forego executing the RCU lockdep expression in cases
where the passed-in expression evaluates to "1" at compile time, so that
(for example) rcu_dereference_raw() can be guaranteed to execute safely
within an NMI handler.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Diffstat (limited to 'scripts/sortextable.c')
0 files changed, 0 insertions, 0 deletions