rcu: only one evaluation of arg in rcu_dereference_check() unless sparse
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Tue, 14 Sep 2010 00:24:21 +0000 (17:24 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Thu, 23 Sep 2010 16:15:01 +0000 (09:15 -0700)
commit53ecfba259f54b6967a35d19f4a564e3bc07997f
treeeaaeebe2a38abe1a401a0d2d40181abaefa80d48
parent829f8ed2c963df7c23d1c644db6c4387eb1601fa
rcu: only one evaluation of arg in rcu_dereference_check() unless sparse

The current version of the __rcu_access_pointer(), __rcu_dereference_check(),
and __rcu_dereference_protected() macros evaluate their "p" argument
three times, not counting typeof()s.  This is bad news if that argument
contains a side effect.  This commit therefore evaluates this argument
only once in normal kernel builds.  However, the straightforward approach
defeats sparse's RCU-pointer checking, so when __CHECKER__ is defined,
the additional pair of evaluations of the "p" argument are performed in
order to permit sparse to detect misuse of RCU-protected pointers.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
include/linux/rcupdate.h