aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2013-10-11 13:17:39 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2013-12-12 15:19:08 -0500
commitac7c8e3dd2ed6489be1f6bc722029fb4855c3a34 (patch)
tree40b1cd4b40f3fee8104cbf666cf930b24531cc6d
parentdc1ccc48159d63eca5089e507c82c7d22ef60839 (diff)
rcu: Add comment on evaluate-once properties of rcu_assign_pointer().
The rcu_assign_pointer() macro, as with most cpp macros, must not evaluate its argument more than once. And it in fact does not. But this might not be obvious to the casual observer, because one of the arguments appears no less than three times. However, but one expansion is only visible to sparse (__CHECKER__), and one lives inside a typeof (where it will never be evaluated), so this is in fact safe. This commit therefore adds a comment making this explicit. Reported-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
-rw-r--r--include/linux/rcupdate.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 39cbb889e20d..00ad28168ef0 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -911,6 +911,14 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
911 * rcu_assign_pointer() is a very bad thing that results in 911 * rcu_assign_pointer() is a very bad thing that results in
912 * impossible-to-diagnose memory corruption. So please be careful. 912 * impossible-to-diagnose memory corruption. So please be careful.
913 * See the RCU_INIT_POINTER() comment header for details. 913 * See the RCU_INIT_POINTER() comment header for details.
914 *
915 * Note that rcu_assign_pointer() evaluates each of its arguments only
916 * once, appearances notwithstanding. One of the "extra" evaluations
917 * is in typeof() and the other visible only to sparse (__CHECKER__),
918 * neither of which actually execute the argument. As with most cpp
919 * macros, this execute-arguments-only-once property is important, so
920 * please be careful when making changes to rcu_assign_pointer() and the
921 * other macros that it invokes.
914 */ 922 */
915#define rcu_assign_pointer(p, v) \ 923#define rcu_assign_pointer(p, v) \
916 __rcu_assign_pointer((p), (v), __rcu) 924 __rcu_assign_pointer((p), (v), __rcu)