diff options
author | Mark Rutland <mark.rutland@arm.com> | 2017-11-27 05:38:23 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-12-12 07:22:10 -0500 |
commit | b899a850431e2dd0943205a63a68573f3e312d0d (patch) | |
tree | a17356f3905a111d05756d2ebdfee053450af706 /include/linux/compiler.h | |
parent | 2a22f692bbe0a7933acbd50045479ffc0fdf11f7 (diff) |
compiler.h: Remove ACCESS_ONCE()
There are no longer any kernelspace uses of ACCESS_ONCE(), so we can
remove the definition from <linux/compiler.h>.
This patch removes the ACCESS_ONCE() definition, and updates comments
which referred to it. At the same time, some inconsistent and redundant
whitespace is removed from comments.
Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: apw@canonical.com
Link: http://lkml.kernel.org/r/20171127103824.36526-4-mark.rutland@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/compiler.h')
-rw-r--r-- | include/linux/compiler.h | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 188ed9f65517..52e611ab9a6c 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -220,21 +220,21 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s | |||
220 | /* | 220 | /* |
221 | * Prevent the compiler from merging or refetching reads or writes. The | 221 | * Prevent the compiler from merging or refetching reads or writes. The |
222 | * compiler is also forbidden from reordering successive instances of | 222 | * compiler is also forbidden from reordering successive instances of |
223 | * READ_ONCE, WRITE_ONCE and ACCESS_ONCE (see below), but only when the | 223 | * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some |
224 | * compiler is aware of some particular ordering. One way to make the | 224 | * particular ordering. One way to make the compiler aware of ordering is to |
225 | * compiler aware of ordering is to put the two invocations of READ_ONCE, | 225 | * put the two invocations of READ_ONCE or WRITE_ONCE in different C |
226 | * WRITE_ONCE or ACCESS_ONCE() in different C statements. | 226 | * statements. |
227 | * | 227 | * |
228 | * In contrast to ACCESS_ONCE these two macros will also work on aggregate | 228 | * These two macros will also work on aggregate data types like structs or |
229 | * data types like structs or unions. If the size of the accessed data | 229 | * unions. If the size of the accessed data type exceeds the word size of |
230 | * type exceeds the word size of the machine (e.g., 32 bits or 64 bits) | 230 | * the machine (e.g., 32 bits or 64 bits) READ_ONCE() and WRITE_ONCE() will |
231 | * READ_ONCE() and WRITE_ONCE() will fall back to memcpy(). There's at | 231 | * fall back to memcpy(). There's at least two memcpy()s: one for the |
232 | * least two memcpy()s: one for the __builtin_memcpy() and then one for | 232 | * __builtin_memcpy() and then one for the macro doing the copy of variable |
233 | * the macro doing the copy of variable - '__u' allocated on the stack. | 233 | * - '__u' allocated on the stack. |
234 | * | 234 | * |
235 | * Their two major use cases are: (1) Mediating communication between | 235 | * Their two major use cases are: (1) Mediating communication between |
236 | * process-level code and irq/NMI handlers, all running on the same CPU, | 236 | * process-level code and irq/NMI handlers, all running on the same CPU, |
237 | * and (2) Ensuring that the compiler does not fold, spindle, or otherwise | 237 | * and (2) Ensuring that the compiler does not fold, spindle, or otherwise |
238 | * mutilate accesses that either do not require ordering or that interact | 238 | * mutilate accesses that either do not require ordering or that interact |
239 | * with an explicit memory barrier or atomic instruction that provides the | 239 | * with an explicit memory barrier or atomic instruction that provides the |
240 | * required ordering. | 240 | * required ordering. |
@@ -327,29 +327,4 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s | |||
327 | compiletime_assert(__native_word(t), \ | 327 | compiletime_assert(__native_word(t), \ |
328 | "Need native word sized stores/loads for atomicity.") | 328 | "Need native word sized stores/loads for atomicity.") |
329 | 329 | ||
330 | /* | ||
331 | * Prevent the compiler from merging or refetching accesses. The compiler | ||
332 | * is also forbidden from reordering successive instances of ACCESS_ONCE(), | ||
333 | * but only when the compiler is aware of some particular ordering. One way | ||
334 | * to make the compiler aware of ordering is to put the two invocations of | ||
335 | * ACCESS_ONCE() in different C statements. | ||
336 | * | ||
337 | * ACCESS_ONCE will only work on scalar types. For union types, ACCESS_ONCE | ||
338 | * on a union member will work as long as the size of the member matches the | ||
339 | * size of the union and the size is smaller than word size. | ||
340 | * | ||
341 | * The major use cases of ACCESS_ONCE used to be (1) Mediating communication | ||
342 | * between process-level code and irq/NMI handlers, all running on the same CPU, | ||
343 | * and (2) Ensuring that the compiler does not fold, spindle, or otherwise | ||
344 | * mutilate accesses that either do not require ordering or that interact | ||
345 | * with an explicit memory barrier or atomic instruction that provides the | ||
346 | * required ordering. | ||
347 | * | ||
348 | * If possible use READ_ONCE()/WRITE_ONCE() instead. | ||
349 | */ | ||
350 | #define __ACCESS_ONCE(x) ({ \ | ||
351 | __maybe_unused typeof(x) __var = (__force typeof(x)) 0; \ | ||
352 | (volatile typeof(x) *)&(x); }) | ||
353 | #define ACCESS_ONCE(x) (*__ACCESS_ONCE(x)) | ||
354 | |||
355 | #endif /* __LINUX_COMPILER_H */ | 330 | #endif /* __LINUX_COMPILER_H */ |