Skip to content

Commit 76695af

Browse files
xairyIngo Molnar
authored andcommitted
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: 230fa25 ("kernel: Provide READ_ONCE and ASSIGN_ONCE") 43239cb ("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]>
1 parent 75d2270 commit 76695af

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

arch/arm/include/asm/barrier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@
6767
do { \
6868
compiletime_assert_atomic_type(*p); \
6969
smp_mb(); \
70-
ACCESS_ONCE(*p) = (v); \
70+
WRITE_ONCE(*p, v); \
7171
} while (0)
7272

7373
#define smp_load_acquire(p) \
7474
({ \
75-
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
75+
typeof(*p) ___p1 = READ_ONCE(*p); \
7676
compiletime_assert_atomic_type(*p); \
7777
smp_mb(); \
7878
___p1; \

arch/arm64/include/asm/barrier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444
do { \
4545
compiletime_assert_atomic_type(*p); \
4646
barrier(); \
47-
ACCESS_ONCE(*p) = (v); \
47+
WRITE_ONCE(*p, v); \
4848
} while (0)
4949

5050
#define smp_load_acquire(p) \
5151
({ \
52-
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
52+
typeof(*p) ___p1 = READ_ONCE(*p); \
5353
compiletime_assert_atomic_type(*p); \
5454
barrier(); \
5555
___p1; \

arch/ia64/include/asm/barrier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@
6666
do { \
6767
compiletime_assert_atomic_type(*p); \
6868
barrier(); \
69-
ACCESS_ONCE(*p) = (v); \
69+
WRITE_ONCE(*p, v); \
7070
} while (0)
7171

7272
#define smp_load_acquire(p) \
7373
({ \
74-
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
74+
typeof(*p) ___p1 = READ_ONCE(*p); \
7575
compiletime_assert_atomic_type(*p); \
7676
barrier(); \
7777
___p1; \

arch/metag/include/asm/barrier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ static inline void fence(void)
9090
do { \
9191
compiletime_assert_atomic_type(*p); \
9292
smp_mb(); \
93-
ACCESS_ONCE(*p) = (v); \
93+
WRITE_ONCE(*p, v); \
9494
} while (0)
9595

9696
#define smp_load_acquire(p) \
9797
({ \
98-
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
98+
typeof(*p) ___p1 = READ_ONCE(*p); \
9999
compiletime_assert_atomic_type(*p); \
100100
smp_mb(); \
101101
___p1; \

arch/mips/include/asm/barrier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@
133133
do { \
134134
compiletime_assert_atomic_type(*p); \
135135
smp_mb(); \
136-
ACCESS_ONCE(*p) = (v); \
136+
WRITE_ONCE(*p, v); \
137137
} while (0)
138138

139139
#define smp_load_acquire(p) \
140140
({ \
141-
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
141+
typeof(*p) ___p1 = READ_ONCE(*p); \
142142
compiletime_assert_atomic_type(*p); \
143143
smp_mb(); \
144144
___p1; \

arch/powerpc/include/asm/barrier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@
7676
do { \
7777
compiletime_assert_atomic_type(*p); \
7878
smp_lwsync(); \
79-
ACCESS_ONCE(*p) = (v); \
79+
WRITE_ONCE(*p, v); \
8080
} while (0)
8181

8282
#define smp_load_acquire(p) \
8383
({ \
84-
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
84+
typeof(*p) ___p1 = READ_ONCE(*p); \
8585
compiletime_assert_atomic_type(*p); \
8686
smp_lwsync(); \
8787
___p1; \

arch/s390/include/asm/barrier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
do { \
4343
compiletime_assert_atomic_type(*p); \
4444
barrier(); \
45-
ACCESS_ONCE(*p) = (v); \
45+
WRITE_ONCE(*p, v); \
4646
} while (0)
4747

4848
#define smp_load_acquire(p) \
4949
({ \
50-
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
50+
typeof(*p) ___p1 = READ_ONCE(*p); \
5151
compiletime_assert_atomic_type(*p); \
5252
barrier(); \
5353
___p1; \

arch/sparc/include/asm/barrier_64.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
6060
do { \
6161
compiletime_assert_atomic_type(*p); \
6262
barrier(); \
63-
ACCESS_ONCE(*p) = (v); \
63+
WRITE_ONCE(*p, v); \
6464
} while (0)
6565

6666
#define smp_load_acquire(p) \
6767
({ \
68-
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
68+
typeof(*p) ___p1 = READ_ONCE(*p); \
6969
compiletime_assert_atomic_type(*p); \
7070
barrier(); \
7171
___p1; \

arch/x86/include/asm/barrier.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@
5757
do { \
5858
compiletime_assert_atomic_type(*p); \
5959
smp_mb(); \
60-
ACCESS_ONCE(*p) = (v); \
60+
WRITE_ONCE(*p, v); \
6161
} while (0)
6262

6363
#define smp_load_acquire(p) \
6464
({ \
65-
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
65+
typeof(*p) ___p1 = READ_ONCE(*p); \
6666
compiletime_assert_atomic_type(*p); \
6767
smp_mb(); \
6868
___p1; \
@@ -74,12 +74,12 @@ do { \
7474
do { \
7575
compiletime_assert_atomic_type(*p); \
7676
barrier(); \
77-
ACCESS_ONCE(*p) = (v); \
77+
WRITE_ONCE(*p, v); \
7878
} while (0)
7979

8080
#define smp_load_acquire(p) \
8181
({ \
82-
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
82+
typeof(*p) ___p1 = READ_ONCE(*p); \
8383
compiletime_assert_atomic_type(*p); \
8484
barrier(); \
8585
___p1; \

include/asm-generic/barrier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@
108108
do { \
109109
compiletime_assert_atomic_type(*p); \
110110
smp_mb(); \
111-
ACCESS_ONCE(*p) = (v); \
111+
WRITE_ONCE(*p, v); \
112112
} while (0)
113113

114114
#define smp_load_acquire(p) \
115115
({ \
116-
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
116+
typeof(*p) ___p1 = READ_ONCE(*p); \
117117
compiletime_assert_atomic_type(*p); \
118118
smp_mb(); \
119119
___p1; \

0 commit comments

Comments
 (0)