arch: use WRITE_ONCE/READ_ONCE in smp_store_release/smp_load_acquire
Subsystems (8)
PATCH v2 1/1 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 commits 230fa253df63 ("kernel: Provide READ_ONCE and ASSIGN_ONCE") and 43239cbe79fc ("kernel:
Change ASSIGN_ONCE(val, x) to WRITE_ONCE(x, val)").
---
Changed in v2:
- Other archs besides x86.
arch/arm/include/asm/barrier.h | 4 ++-- arch/arm64/include/asm/barrier.h | 4 ++-- arch/ia64/include/asm/barrier.h | 4 ++-- arch/metag/include/asm/barrier.h | 4 ++-- arch/mips/include/asm/barrier.h | 4 ++-- arch/powerpc/include/asm/barrier.h | 4 ++-- arch/s390/include/asm/barrier.h | 4 ++-- arch/sparc/include/asm/barrier_64.h | 4 ++-- arch/x86/include/asm/barrier.h | 8 ++++---- include/asm-generic/barrier.h | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-)
arch/arm/include/asm/barrier.h +2 -2
@@ -67,12 +67,12 @@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; \
arch/arm64/include/asm/barrier.h +2 -2
@@ -44,12 +44,12 @@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; \
arch/ia64/include/asm/barrier.h +2 -2
@@ -66,12 +66,12 @@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; \
arch/metag/include/asm/barrier.h +2 -2
@@ -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; \
arch/mips/include/asm/barrier.h +2 -2
@@ -133,12 +133,12 @@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; \
arch/powerpc/include/asm/barrier.h +2 -2
@@ -76,12 +76,12 @@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; \
arch/s390/include/asm/barrier.h +2 -2
@@ -42,12 +42,12 @@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; \
arch/sparc/include/asm/barrier_64.h +2 -2
@@ -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; \
arch/x86/include/asm/barrier.h +4 -4
@@ -57,12 +57,12 @@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; \
include/asm-generic/barrier.h +2 -2
@@ -108,12 +108,12 @@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; \
Signature · 1 line
2.5.0.rc2.392.g76e840b
Quoted 10 lines · Andrey Konovalov
Replace
ACCESS_ONCE()macro insmp_store_release()andsmp_load_acquire()withWRITE_ONCE()andREAD_ONCE()on x86, arm, arm64, ia64, metag, mips, powerpc, s390, sparc and asm-generic sinceACCESS_ONCEdoes not work reliably on non-scalar types.
WRITE_ONCE()andREAD_ONCE()were introduced in the commits230fa253df63("kernel: ProvideREAD_ONCEandASSIGN_ONCE") and43239cbe79fc("kernel:
ChangeASSIGN_ONCE(val, x)toWRITE_ONCE(x, val)").Signed-off-by Andrey Konovalov <[email protected]>
Thanks!
Quoted 10 lines · Andrey Konovalov
Replace
ACCESS_ONCE()macro insmp_store_release()andsmp_load_acquire()withWRITE_ONCE()andREAD_ONCE()on x86, arm, arm64, ia64, metag, mips, powerpc, s390, sparc and asm-generic sinceACCESS_ONCEdoes not work reliably on non-scalar types.
WRITE_ONCE()andREAD_ONCE()were introduced in the commits230fa253df63("kernel: ProvideREAD_ONCEandASSIGN_ONCE") and43239cbe79fc("kernel:
ChangeASSIGN_ONCE(val, x)toWRITE_ONCE(x, val)").Signed-off-by Andrey Konovalov <[email protected]>
Quoted 4 lines · Andrey Konovalov
Replace
ACCESS_ONCE()macro insmp_store_release()andsmp_load_acquire()withWRITE_ONCE()andREAD_ONCE()on x86, arm, arm64, ia64, metag, mips, powerpc, s390, sparc and asm-generic sinceACCESS_ONCEdoes not work reliably on non-scalar types.
.. and there are no restrictions on the argument to smp_load_acquire(), so it may be a non-scalar type.
Though from a quick grep it looks like no one is doing that at the moment?
Quoted 20 lines
WRITE_ONCE()andREAD_ONCE()were introduced in the commits230fa253df63("kernel: ProvideREAD_ONCEandASSIGN_ONCE") and43239cbe79fc("kernel:
ChangeASSIGN_ONCE(val, x)toWRITE_ONCE(x, val)").Signed-off-by Andrey Konovalov <[email protected]>---
Changed in v2:
- Other archs besides x86.arch/powerpc/include/asm/barrier.h | 4 ++--arch/powerpc/include/asm/barrier.h +0
-1@@ -76,12 +76,12 @@ do { \ compiletime_assert_atomic_type(*p); \ smp_lwsync(); \ - ACCESS_ONCE(*p) = (v); \
arch/powerpc/include/asm/barrier.h line 87
Quoted 10 lines
arch/powerpc/include/asm/barrier.h +2
-1+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; \
cheers
Quoted 9 lines · Andrey Konovalov
arch/mips/include/asm/barrier.h +0
-1@@ -133,12 +133,12 @@ do { \ compiletime_assert_atomic_type(*p); \ smp_mb(); \ - ACCESS_ONCE(*p) = (v); \
arch/mips/include/asm/barrier.h line 144
Quoted 10 lines
arch/mips/include/asm/barrier.h +2
-1+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; \
Ralf
tip-bot for Andrey Konovalov
merge bot[tip:locking/core] locking, arch: use WRITE_ONCE()/READ_ONCE() in smp_store_release()/smp_load_acquire()
In reply to Andrey Konovalovlocking, arch: use WRITE_ONCE()/READ_ONCE() in smp_store_release()/smp_load_acquire()
Commit-ID: 76695af20c015206cffb84b15912be6797d0cca2 Gitweb: http://git.kernel.org/tip/76695af20c015206cffb84b15912be6797d0cca2 Author: Andrey Konovalov <[email protected]> AuthorDate: Sun, 2 Aug 2015 17:11:04 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 3 Aug 2015 10:59:30 +0200
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:
230fa253df63 ("kernel: Provide READ_ONCE and ASSIGN_ONCE") 43239cbe79fc ("kernel: Change ASSIGN_ONCE(val, x) to WRITE_ONCE(x, val)")
--- arch/arm/include/asm/barrier.h | 4 ++-- arch/arm64/include/asm/barrier.h | 4 ++-- arch/ia64/include/asm/barrier.h | 4 ++-- arch/metag/include/asm/barrier.h | 4 ++-- arch/mips/include/asm/barrier.h | 4 ++-- arch/powerpc/include/asm/barrier.h | 4 ++-- arch/s390/include/asm/barrier.h | 4 ++-- arch/sparc/include/asm/barrier_64.h | 4 ++-- arch/x86/include/asm/barrier.h | 8 ++++---- include/asm-generic/barrier.h | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-)
arch/arm/include/asm/barrier.h +2 -2
@@ -67,12 +67,12 @@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; \
arch/arm64/include/asm/barrier.h +2 -2
@@ -44,12 +44,12 @@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; \
arch/ia64/include/asm/barrier.h +2 -2
@@ -66,12 +66,12 @@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; \
arch/metag/include/asm/barrier.h +2 -2
@@ -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; \
arch/mips/include/asm/barrier.h +2 -2
@@ -133,12 +133,12 @@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; \
arch/powerpc/include/asm/barrier.h +2 -2
@@ -76,12 +76,12 @@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; \
arch/s390/include/asm/barrier.h +2 -2
@@ -42,12 +42,12 @@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; \
arch/sparc/include/asm/barrier_64.h +2 -2
@@ -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; \
arch/x86/include/asm/barrier.h +4 -4
@@ -57,12 +57,12 @@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; \
include/asm-generic/barrier.h +2 -2
@@ -108,12 +108,12 @@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; \