@@ -128,10 +128,9 @@ ____xchg(, volatile void *ptr, unsigned long x, int size)
128
128
* store NEW in MEM. Return the initial value in MEM. Success is
129
129
* indicated by comparing RETURN with OLD.
130
130
*
131
- * The memory barrier should be placed in SMP only when we actually
132
- * make the change. If we don't change anything (so if the returned
133
- * prev is equal to old) then we aren't acquiring anything new and
134
- * we don't need any memory barrier as far I can tell.
131
+ * The memory barrier is placed in SMP unconditionally, in order to
132
+ * guarantee that dependency ordering is preserved when a dependency
133
+ * is headed by an unsuccessful operation.
135
134
*/
136
135
137
136
static inline unsigned long
@@ -150,8 +149,8 @@ ____cmpxchg(_u8, volatile char *m, unsigned char old, unsigned char new)
150
149
" or %1,%2,%2\n"
151
150
" stq_c %2,0(%4)\n"
152
151
" beq %2,3f\n"
153
- __ASM__MB
154
152
"2:\n"
153
+ __ASM__MB
155
154
".subsection 2\n"
156
155
"3: br 1b\n"
157
156
".previous"
@@ -177,8 +176,8 @@ ____cmpxchg(_u16, volatile short *m, unsigned short old, unsigned short new)
177
176
" or %1,%2,%2\n"
178
177
" stq_c %2,0(%4)\n"
179
178
" beq %2,3f\n"
180
- __ASM__MB
181
179
"2:\n"
180
+ __ASM__MB
182
181
".subsection 2\n"
183
182
"3: br 1b\n"
184
183
".previous"
@@ -200,8 +199,8 @@ ____cmpxchg(_u32, volatile int *m, int old, int new)
200
199
" mov %4,%1\n"
201
200
" stl_c %1,%2\n"
202
201
" beq %1,3f\n"
203
- __ASM__MB
204
202
"2:\n"
203
+ __ASM__MB
205
204
".subsection 2\n"
206
205
"3: br 1b\n"
207
206
".previous"
@@ -223,8 +222,8 @@ ____cmpxchg(_u64, volatile long *m, unsigned long old, unsigned long new)
223
222
" mov %4,%1\n"
224
223
" stq_c %1,%2\n"
225
224
" beq %1,3f\n"
226
- __ASM__MB
227
225
"2:\n"
226
+ __ASM__MB
228
227
".subsection 2\n"
229
228
"3: br 1b\n"
230
229
".previous"
0 commit comments