locking, arch: use WRITE_ONCE()/READ_ONCE() in smp_store_release()/smp_load_acquire()
authorAndrey Konovalov <[email protected]>
Sun, 2 Aug 2015 15:11:04 +0000 (17:11 +0200)
committerIngo Molnar <[email protected]>
Mon, 3 Aug 2015 08:59:30 +0000 (10:59 +0200)
Replace ACCESS_ONCE() macro in smp_store_release() and smp_load_acquire()
with WRITE_ONCE() and READ_ONCE() on x86, arm, arm64, ia64, metag, mips,
powerpc, s390, sparc and asm-generic since ACCESS_ONCE() does not work
reliably on non-scalar types.

WRITE_ONCE() and READ_ONCE() were introduced in the following commits:

  230fa253df63 ("kernel: Provide READ_ONCE and ASSIGN_ONCE")
  43239cbe79fc ("kernel: Change ASSIGN_ONCE(val, x) to WRITE_ONCE(x, val)")

Signed-off-by: Andrey Konovalov <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Davidlohr Bueso <[email protected]>
Acked-by: Michael Ellerman <[email protected]> (powerpc)
Acked-by: Ralf Baechle <[email protected]>
Cc: Alexander Duyck <[email protected]>
Cc: Andre Przywara <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Fenghua Yu <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: James Hogan <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Russell King <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
arch/arm/include/asm/barrier.h
arch/arm64/include/asm/barrier.h
arch/ia64/include/asm/barrier.h
arch/metag/include/asm/barrier.h
arch/mips/include/asm/barrier.h
arch/powerpc/include/asm/barrier.h
arch/s390/include/asm/barrier.h
arch/sparc/include/asm/barrier_64.h
arch/x86/include/asm/barrier.h
include/asm-generic/barrier.h

index 6c2327e1c7323d79831af30bb296c55a9409e9bd..70393574e0fa6f9c0b0e3fc7eab6f9abb4b54441 100644 (file)
 do {                                                                   \
        compiletime_assert_atomic_type(*p);                             \
        smp_mb();                                                       \
-       ACCESS_ONCE(*p) = (v);                                          \
+       WRITE_ONCE(*p, v);                                              \
 } while (0)
 
 #define smp_load_acquire(p)                                            \
 ({                                                                     \
-       typeof(*p) ___p1 = ACCESS_ONCE(*p);                             \
+       typeof(*p) ___p1 = READ_ONCE(*p);                               \
        compiletime_assert_atomic_type(*p);                             \
        smp_mb();                                                       \
        ___p1;                                                          \
index 0fa47c4275cb561af6292761ee9645c9dbef0e59..ef93b20bc964ea2933c04aad4f82644febf1f659 100644 (file)
 do {                                                                   \
        compiletime_assert_atomic_type(*p);                             \
        barrier();                                                      \
-       ACCESS_ONCE(*p) = (v);                                          \
+       WRITE_ONCE(*p, v);                                              \
 } while (0)
 
 #define smp_load_acquire(p)                                            \
 ({                                                                     \
-       typeof(*p) ___p1 = ACCESS_ONCE(*p);                             \
+       typeof(*p) ___p1 = READ_ONCE(*p);                               \
        compiletime_assert_atomic_type(*p);                             \
        barrier();                                                      \
        ___p1;                                                          \
index 843ba435e43bc285f20da4b5c47e262d7714525f..df896a1c41d348e60641bb0f89aece2d5ba95f93 100644 (file)
 do {                                                                   \
        compiletime_assert_atomic_type(*p);                             \
        barrier();                                                      \
-       ACCESS_ONCE(*p) = (v);                                          \
+       WRITE_ONCE(*p, v);                                              \
 } while (0)
 
 #define smp_load_acquire(p)                                            \
 ({                                                                     \
-       typeof(*p) ___p1 = ACCESS_ONCE(*p);                             \
+       typeof(*p) ___p1 = READ_ONCE(*p);                               \
        compiletime_assert_atomic_type(*p);                             \
        barrier();                                                      \
        ___p1;                                                          \
index 5a696e50793034bfdecefec781f95a402196c99a..172b7e5efc53f99145f18eccc90d3beb72d0a435 100644 (file)
@@ -90,12 +90,12 @@ static inline void fence(void)
 do {                                                                   \
        compiletime_assert_atomic_type(*p);                             \
        smp_mb();                                                       \
-       ACCESS_ONCE(*p) = (v);                                          \
+       WRITE_ONCE(*p, v);                                              \
 } while (0)
 
 #define smp_load_acquire(p)                                            \
 ({                                                                     \
-       typeof(*p) ___p1 = ACCESS_ONCE(*p);                             \
+       typeof(*p) ___p1 = READ_ONCE(*p);                               \
        compiletime_assert_atomic_type(*p);                             \
        smp_mb();                                                       \
        ___p1;                                                          \
index 7ecba84656d4951a4196622344338c842997fb0f..752e0b86c171005882be2f25df45aecd246cd2a7 100644 (file)
 do {                                                                   \
        compiletime_assert_atomic_type(*p);                             \
        smp_mb();                                                       \
-       ACCESS_ONCE(*p) = (v);                                          \
+       WRITE_ONCE(*p, v);                                              \
 } while (0)
 
 #define smp_load_acquire(p)                                            \
 ({                                                                     \
-       typeof(*p) ___p1 = ACCESS_ONCE(*p);                             \
+       typeof(*p) ___p1 = READ_ONCE(*p);                               \
        compiletime_assert_atomic_type(*p);                             \
        smp_mb();                                                       \
        ___p1;                                                          \
index 51ccc7232042e9f415c26580cca3a83d02175625..0eca6efc0631d52adcdd3bd66ad88bb7d33f830d 100644 (file)
 do {                                                                   \
        compiletime_assert_atomic_type(*p);                             \
        smp_lwsync();                                                   \
-       ACCESS_ONCE(*p) = (v);                                          \
+       WRITE_ONCE(*p, v);                                              \
 } while (0)
 
 #define smp_load_acquire(p)                                            \
 ({                                                                     \
-       typeof(*p) ___p1 = ACCESS_ONCE(*p);                             \
+       typeof(*p) ___p1 = READ_ONCE(*p);                               \
        compiletime_assert_atomic_type(*p);                             \
        smp_lwsync();                                                   \
        ___p1;                                                          \
index e6f8615a11eb5c72ed84576de97924f5481031ae..d48fe0162331600c09ac630ad45f99e468a07d02 100644 (file)
 do {                                                                   \
        compiletime_assert_atomic_type(*p);                             \
        barrier();                                                      \
-       ACCESS_ONCE(*p) = (v);                                          \
+       WRITE_ONCE(*p, v);                                              \
 } while (0)
 
 #define smp_load_acquire(p)                                            \
 ({                                                                     \
-       typeof(*p) ___p1 = ACCESS_ONCE(*p);                             \
+       typeof(*p) ___p1 = READ_ONCE(*p);                               \
        compiletime_assert_atomic_type(*p);                             \
        barrier();                                                      \
        ___p1;                                                          \
index 809941e33e1217489b1c88caa4c000cf55a08b62..14a928601657da55bce01e1ef37043f3dd35d379 100644 (file)
@@ -60,12 +60,12 @@ do {        __asm__ __volatile__("ba,pt     %%xcc, 1f\n\t" \
 do {                                                                   \
        compiletime_assert_atomic_type(*p);                             \
        barrier();                                                      \
-       ACCESS_ONCE(*p) = (v);                                          \
+       WRITE_ONCE(*p, v);                                              \
 } while (0)
 
 #define smp_load_acquire(p)                                            \
 ({                                                                     \
-       typeof(*p) ___p1 = ACCESS_ONCE(*p);                             \
+       typeof(*p) ___p1 = READ_ONCE(*p);                               \
        compiletime_assert_atomic_type(*p);                             \
        barrier();                                                      \
        ___p1;                                                          \
index e51a8f803f55e30df69a6a02a20a86f9ed7ebdad..d2bcfbed11c309c9ad6ec5f9d100d0ee52a150a4 100644 (file)
 do {                                                                   \
        compiletime_assert_atomic_type(*p);                             \
        smp_mb();                                                       \
-       ACCESS_ONCE(*p) = (v);                                          \
+       WRITE_ONCE(*p, v);                                              \
 } while (0)
 
 #define smp_load_acquire(p)                                            \
 ({                                                                     \
-       typeof(*p) ___p1 = ACCESS_ONCE(*p);                             \
+       typeof(*p) ___p1 = READ_ONCE(*p);                               \
        compiletime_assert_atomic_type(*p);                             \
        smp_mb();                                                       \
        ___p1;                                                          \
@@ -74,12 +74,12 @@ do {                                                                        \
 do {                                                                   \
        compiletime_assert_atomic_type(*p);                             \
        barrier();                                                      \
-       ACCESS_ONCE(*p) = (v);                                          \
+       WRITE_ONCE(*p, v);                                              \
 } while (0)
 
 #define smp_load_acquire(p)                                            \
 ({                                                                     \
-       typeof(*p) ___p1 = ACCESS_ONCE(*p);                             \
+       typeof(*p) ___p1 = READ_ONCE(*p);                               \
        compiletime_assert_atomic_type(*p);                             \
        barrier();                                                      \
        ___p1;                                                          \
index 55e3abc2d027270b0e6e1c554b9f376d3cd355f1..b42afada1280e08534d6e98fbf9364b3dcae9d8a 100644 (file)
 do {                                                                   \
        compiletime_assert_atomic_type(*p);                             \
        smp_mb();                                                       \
-       ACCESS_ONCE(*p) = (v);                                          \
+       WRITE_ONCE(*p, v);                                              \
 } while (0)
 
 #define smp_load_acquire(p)                                            \
 ({                                                                     \
-       typeof(*p) ___p1 = ACCESS_ONCE(*p);                             \
+       typeof(*p) ___p1 = READ_ONCE(*p);                               \
        compiletime_assert_atomic_type(*p);                             \
        smp_mb();                                                       \
        ___p1;                                                          \