Commit 76695af2 authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Ingo Molnar

locking, arch: use WRITE_ONCE()/READ_ONCE() in smp_store_release()/smp_load_acquire()

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:

  230fa253 ("kernel: Provide READ_ONCE and ASSIGN_ONCE")
  43239cbe ("kernel: Change ASSIGN_ONCE(val, x) to WRITE_ONCE(x, val)")
Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarDavidlohr Bueso <dbueso@suse.de>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Acked-by: default avatarRalf 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.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 75d22702
...@@ -67,12 +67,12 @@ ...@@ -67,12 +67,12 @@
do { \ do { \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_mb(); \ smp_mb(); \
ACCESS_ONCE(*p) = (v); \ WRITE_ONCE(*p, v); \
} while (0) } while (0)
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_mb(); \ smp_mb(); \
___p1; \ ___p1; \
......
...@@ -44,12 +44,12 @@ ...@@ -44,12 +44,12 @@
do { \ do { \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
barrier(); \ barrier(); \
ACCESS_ONCE(*p) = (v); \ WRITE_ONCE(*p, v); \
} while (0) } while (0)
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
barrier(); \ barrier(); \
___p1; \ ___p1; \
......
...@@ -66,12 +66,12 @@ ...@@ -66,12 +66,12 @@
do { \ do { \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
barrier(); \ barrier(); \
ACCESS_ONCE(*p) = (v); \ WRITE_ONCE(*p, v); \
} while (0) } while (0)
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
barrier(); \ barrier(); \
___p1; \ ___p1; \
......
...@@ -90,12 +90,12 @@ static inline void fence(void) ...@@ -90,12 +90,12 @@ static inline void fence(void)
do { \ do { \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_mb(); \ smp_mb(); \
ACCESS_ONCE(*p) = (v); \ WRITE_ONCE(*p, v); \
} while (0) } while (0)
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_mb(); \ smp_mb(); \
___p1; \ ___p1; \
......
...@@ -133,12 +133,12 @@ ...@@ -133,12 +133,12 @@
do { \ do { \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_mb(); \ smp_mb(); \
ACCESS_ONCE(*p) = (v); \ WRITE_ONCE(*p, v); \
} while (0) } while (0)
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_mb(); \ smp_mb(); \
___p1; \ ___p1; \
......
...@@ -76,12 +76,12 @@ ...@@ -76,12 +76,12 @@
do { \ do { \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_lwsync(); \ smp_lwsync(); \
ACCESS_ONCE(*p) = (v); \ WRITE_ONCE(*p, v); \
} while (0) } while (0)
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_lwsync(); \ smp_lwsync(); \
___p1; \ ___p1; \
......
...@@ -42,12 +42,12 @@ ...@@ -42,12 +42,12 @@
do { \ do { \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
barrier(); \ barrier(); \
ACCESS_ONCE(*p) = (v); \ WRITE_ONCE(*p, v); \
} while (0) } while (0)
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
barrier(); \ barrier(); \
___p1; \ ___p1; \
......
...@@ -60,12 +60,12 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \ ...@@ -60,12 +60,12 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
do { \ do { \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
barrier(); \ barrier(); \
ACCESS_ONCE(*p) = (v); \ WRITE_ONCE(*p, v); \
} while (0) } while (0)
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
barrier(); \ barrier(); \
___p1; \ ___p1; \
......
...@@ -57,12 +57,12 @@ ...@@ -57,12 +57,12 @@
do { \ do { \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_mb(); \ smp_mb(); \
ACCESS_ONCE(*p) = (v); \ WRITE_ONCE(*p, v); \
} while (0) } while (0)
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_mb(); \ smp_mb(); \
___p1; \ ___p1; \
...@@ -74,12 +74,12 @@ do { \ ...@@ -74,12 +74,12 @@ do { \
do { \ do { \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
barrier(); \ barrier(); \
ACCESS_ONCE(*p) = (v); \ WRITE_ONCE(*p, v); \
} while (0) } while (0)
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
barrier(); \ barrier(); \
___p1; \ ___p1; \
......
...@@ -108,12 +108,12 @@ ...@@ -108,12 +108,12 @@
do { \ do { \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_mb(); \ smp_mb(); \
ACCESS_ONCE(*p) = (v); \ WRITE_ONCE(*p, v); \
} while (0) } while (0)
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
smp_mb(); \ smp_mb(); \
___p1; \ ___p1; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment