Skip to content

Commit 79d4424

Browse files
andrea-parriIngo Molnar
authored andcommitted
locking/xchg/alpha: Clean up barrier usage by using smp_mb() in place of __ASM__MB
Replace each occurrence of __ASM__MB with a (trailing) smp_mb() in xchg(), cmpxchg(), and remove the now unused __ASM__MB definitions; this improves readability, with no additional synchronization cost. Suggested-by: Will Deacon <[email protected]> Signed-off-by: Andrea Parri <[email protected]> Acked-by: Paul E. McKenney <[email protected]> Cc: Alan Stern <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Matt Turner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent cb13b42 commit 79d4424

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

arch/alpha/include/asm/cmpxchg.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* Atomic exchange routines.
77
*/
88

9-
#define __ASM__MB
109
#define ____xchg(type, args...) __xchg ## type ## _local(args)
1110
#define ____cmpxchg(type, args...) __cmpxchg ## type ## _local(args)
1211
#include <asm/xchg.h>
@@ -33,10 +32,6 @@
3332
cmpxchg_local((ptr), (o), (n)); \
3433
})
3534

36-
#ifdef CONFIG_SMP
37-
#undef __ASM__MB
38-
#define __ASM__MB "\tmb\n"
39-
#endif
4035
#undef ____xchg
4136
#undef ____cmpxchg
4237
#define ____xchg(type, args...) __xchg ##type(args)
@@ -64,7 +59,6 @@
6459
cmpxchg((ptr), (o), (n)); \
6560
})
6661

67-
#undef __ASM__MB
6862
#undef ____cmpxchg
6963

7064
#endif /* _ALPHA_CMPXCHG_H */

arch/alpha/include/asm/xchg.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ ____xchg(_u8, volatile char *m, unsigned long val)
2828
" or %1,%2,%2\n"
2929
" stq_c %2,0(%3)\n"
3030
" beq %2,2f\n"
31-
__ASM__MB
3231
".subsection 2\n"
3332
"2: br 1b\n"
3433
".previous"
3534
: "=&r" (ret), "=&r" (val), "=&r" (tmp), "=&r" (addr64)
3635
: "r" ((long)m), "1" (val) : "memory");
36+
smp_mb();
3737

3838
return ret;
3939
}
@@ -52,12 +52,12 @@ ____xchg(_u16, volatile short *m, unsigned long val)
5252
" or %1,%2,%2\n"
5353
" stq_c %2,0(%3)\n"
5454
" beq %2,2f\n"
55-
__ASM__MB
5655
".subsection 2\n"
5756
"2: br 1b\n"
5857
".previous"
5958
: "=&r" (ret), "=&r" (val), "=&r" (tmp), "=&r" (addr64)
6059
: "r" ((long)m), "1" (val) : "memory");
60+
smp_mb();
6161

6262
return ret;
6363
}
@@ -72,12 +72,12 @@ ____xchg(_u32, volatile int *m, unsigned long val)
7272
" bis $31,%3,%1\n"
7373
" stl_c %1,%2\n"
7474
" beq %1,2f\n"
75-
__ASM__MB
7675
".subsection 2\n"
7776
"2: br 1b\n"
7877
".previous"
7978
: "=&r" (val), "=&r" (dummy), "=m" (*m)
8079
: "rI" (val), "m" (*m) : "memory");
80+
smp_mb();
8181

8282
return val;
8383
}
@@ -92,12 +92,12 @@ ____xchg(_u64, volatile long *m, unsigned long val)
9292
" bis $31,%3,%1\n"
9393
" stq_c %1,%2\n"
9494
" beq %1,2f\n"
95-
__ASM__MB
9695
".subsection 2\n"
9796
"2: br 1b\n"
9897
".previous"
9998
: "=&r" (val), "=&r" (dummy), "=m" (*m)
10099
: "rI" (val), "m" (*m) : "memory");
100+
smp_mb();
101101

102102
return val;
103103
}
@@ -150,12 +150,12 @@ ____cmpxchg(_u8, volatile char *m, unsigned char old, unsigned char new)
150150
" stq_c %2,0(%4)\n"
151151
" beq %2,3f\n"
152152
"2:\n"
153-
__ASM__MB
154153
".subsection 2\n"
155154
"3: br 1b\n"
156155
".previous"
157156
: "=&r" (prev), "=&r" (new), "=&r" (tmp), "=&r" (cmp), "=&r" (addr64)
158157
: "r" ((long)m), "Ir" (old), "1" (new) : "memory");
158+
smp_mb();
159159

160160
return prev;
161161
}
@@ -177,12 +177,12 @@ ____cmpxchg(_u16, volatile short *m, unsigned short old, unsigned short new)
177177
" stq_c %2,0(%4)\n"
178178
" beq %2,3f\n"
179179
"2:\n"
180-
__ASM__MB
181180
".subsection 2\n"
182181
"3: br 1b\n"
183182
".previous"
184183
: "=&r" (prev), "=&r" (new), "=&r" (tmp), "=&r" (cmp), "=&r" (addr64)
185184
: "r" ((long)m), "Ir" (old), "1" (new) : "memory");
185+
smp_mb();
186186

187187
return prev;
188188
}
@@ -200,12 +200,12 @@ ____cmpxchg(_u32, volatile int *m, int old, int new)
200200
" stl_c %1,%2\n"
201201
" beq %1,3f\n"
202202
"2:\n"
203-
__ASM__MB
204203
".subsection 2\n"
205204
"3: br 1b\n"
206205
".previous"
207206
: "=&r"(prev), "=&r"(cmp), "=m"(*m)
208207
: "r"((long) old), "r"(new), "m"(*m) : "memory");
208+
smp_mb();
209209

210210
return prev;
211211
}
@@ -223,12 +223,12 @@ ____cmpxchg(_u64, volatile long *m, unsigned long old, unsigned long new)
223223
" stq_c %1,%2\n"
224224
" beq %1,3f\n"
225225
"2:\n"
226-
__ASM__MB
227226
".subsection 2\n"
228227
"3: br 1b\n"
229228
".previous"
230229
: "=&r"(prev), "=&r"(cmp), "=m"(*m)
231230
: "r"((long) old), "r"(new), "m"(*m) : "memory");
231+
smp_mb();
232232

233233
return prev;
234234
}

0 commit comments

Comments
 (0)