locking, arch: use WRITE_ONCE()/READ_ONCE() in smp_store_release()/smp_load_acquire()
authorAndrey Konovalov <andreyknvl@google.com>
Sun, 2 Aug 2015 15:11:04 +0000 (17:11 +0200)
committerIngo Molnar <mingo@kernel.org>
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 <andreyknvl@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Davidlohr Bueso <dbueso@suse.de>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Cc: Alexander Duyck <alexander.h.duyck@redhat.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arch@vger.kernel.org
Link: http://lkml.kernel.org/r/1438528264-714-1-git-send-email-andreyknvl@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
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;                                                          \