Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move ACCESS_ONCE() to <linux/compiler.h>

It actually makes much more sense there, and we do tend to need it for
non-RCU usage too. Moving it to <linux/compiler.h> will allow some
other cases that have open-coded the same logic to use the same helper
function that RCU has used.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+12 -12
+12
include/linux/compiler.h
··· 182 182 # define __section(S) __attribute__ ((__section__(#S))) 183 183 #endif 184 184 185 + /* 186 + * Prevent the compiler from merging or refetching accesses. The compiler 187 + * is also forbidden from reordering successive instances of ACCESS_ONCE(), 188 + * but only when the compiler is aware of some particular ordering. One way 189 + * to make the compiler aware of ordering is to put the two invocations of 190 + * ACCESS_ONCE() in different C statements. 191 + * 192 + * This macro does absolutely -nothing- to prevent the CPU from reordering, 193 + * merging, or refetching absolutely anything at any time. 194 + */ 195 + #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) 196 + 185 197 #endif /* __LINUX_COMPILER_H */
-12
include/linux/rcupdate.h
··· 131 131 */ 132 132 #define rcu_read_unlock_bh() __rcu_read_unlock_bh() 133 133 134 - /* 135 - * Prevent the compiler from merging or refetching accesses. The compiler 136 - * is also forbidden from reordering successive instances of ACCESS_ONCE(), 137 - * but only when the compiler is aware of some particular ordering. One way 138 - * to make the compiler aware of ordering is to put the two invocations of 139 - * ACCESS_ONCE() in different C statements. 140 - * 141 - * This macro does absolutely -nothing- to prevent the CPU from reordering, 142 - * merging, or refetching absolutely anything at any time. 143 - */ 144 - #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) 145 - 146 134 /** 147 135 * rcu_dereference - fetch an RCU-protected pointer in an 148 136 * RCU read-side critical section. This pointer may later