x86: use WRITE_ONCE/READ_ONCE in smp_store_release/smp_load_acquire
PATCH 1/1 x86: use WRITE_ONCE/READ_ONCE in smp_store_release/smp_load_acquire
Replace ACCESS_ONCE() macro in smp_store_release() and smp_load_acquire() from arch/x86/include/asm/barrier.h with WRITE_ONCE() and READ_ONCE() 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)").
--- arch/x86/include/asm/barrier.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
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; \
Signature · 1 line
2.5.0.rc2.392.g76e840b
Quoted 7 lines · Andrey Konovalov
Replace
ACCESS_ONCE()macro insmp_store_release()andsmp_load_acquire()fromarch/x86/include/asm/barrier.hwithWRITE_ONCE()andREAD_ONCE()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)").
You actually forgot to CC the author. Let me add some more people to CC, in addition.
Quoted 42 lines
Signed-off-by Andrey Konovalov <[email protected]>--- arch/x86/include/asm/barrier.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)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; \Signature · 1 line
2.5.0.rc2.392.g76e840b
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Quoted 7 lines · Andrey Konovalov
Replace
ACCESS_ONCE()macro insmp_store_release()andsmp_load_acquire()fromarch/x86/include/asm/barrier.hwithWRITE_ONCE()andREAD_ONCE()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)").
Please do all relevant archs.