diff options
author | Andrea Parri <parri.andrea@gmail.com> | 2018-02-20 13:45:56 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-02-21 04:12:29 -0500 |
commit | cb13b424e986aed68d74cbaec3449ea23c50e167 (patch) | |
tree | 853b0d99f04da0e569ea74f016686f0b7d51800e | |
parent | 88e77dc6a354095ddaaae715bc0d3b55702fa3db (diff) |
locking/xchg/alpha: Add unconditional memory barrier to cmpxchg()
Continuing along with the fight against smp_read_barrier_depends() [1]
(or rather, against its improper use), add an unconditional barrier to
cmpxchg. This guarantees that dependency ordering is preserved when a
dependency is headed by an unsuccessful cmpxchg. As it turns out, the
change could enable further simplification of LKMM as proposed in [2].
[1] https://marc.info/?l=linux-kernel&m=150884953419377&w=2
https://marc.info/?l=linux-kernel&m=150884946319353&w=2
https://marc.info/?l=linux-kernel&m=151215810824468&w=2
https://marc.info/?l=linux-kernel&m=151215816324484&w=2
[2] https://marc.info/?l=linux-kernel&m=151881978314872&w=2
Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-alpha@vger.kernel.org
Link: http://lkml.kernel.org/r/1519152356-4804-1-git-send-email-parri.andrea@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/alpha/include/asm/xchg.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/arch/alpha/include/asm/xchg.h b/arch/alpha/include/asm/xchg.h index 68dfb3cb7145..e2660866ce97 100644 --- a/arch/alpha/include/asm/xchg.h +++ b/arch/alpha/include/asm/xchg.h | |||
@@ -128,10 +128,9 @@ ____xchg(, volatile void *ptr, unsigned long x, int size) | |||
128 | * store NEW in MEM. Return the initial value in MEM. Success is | 128 | * store NEW in MEM. Return the initial value in MEM. Success is |
129 | * indicated by comparing RETURN with OLD. | 129 | * indicated by comparing RETURN with OLD. |
130 | * | 130 | * |
131 | * The memory barrier should be placed in SMP only when we actually | 131 | * The memory barrier is placed in SMP unconditionally, in order to |
132 | * make the change. If we don't change anything (so if the returned | 132 | * guarantee that dependency ordering is preserved when a dependency |
133 | * prev is equal to old) then we aren't acquiring anything new and | 133 | * is headed by an unsuccessful operation. |
134 | * we don't need any memory barrier as far I can tell. | ||
135 | */ | 134 | */ |
136 | 135 | ||
137 | static inline unsigned long | 136 | static inline unsigned long |
@@ -150,8 +149,8 @@ ____cmpxchg(_u8, volatile char *m, unsigned char old, unsigned char new) | |||
150 | " or %1,%2,%2\n" | 149 | " or %1,%2,%2\n" |
151 | " stq_c %2,0(%4)\n" | 150 | " stq_c %2,0(%4)\n" |
152 | " beq %2,3f\n" | 151 | " beq %2,3f\n" |
153 | __ASM__MB | ||
154 | "2:\n" | 152 | "2:\n" |
153 | __ASM__MB | ||
155 | ".subsection 2\n" | 154 | ".subsection 2\n" |
156 | "3: br 1b\n" | 155 | "3: br 1b\n" |
157 | ".previous" | 156 | ".previous" |
@@ -177,8 +176,8 @@ ____cmpxchg(_u16, volatile short *m, unsigned short old, unsigned short new) | |||
177 | " or %1,%2,%2\n" | 176 | " or %1,%2,%2\n" |
178 | " stq_c %2,0(%4)\n" | 177 | " stq_c %2,0(%4)\n" |
179 | " beq %2,3f\n" | 178 | " beq %2,3f\n" |
180 | __ASM__MB | ||
181 | "2:\n" | 179 | "2:\n" |
180 | __ASM__MB | ||
182 | ".subsection 2\n" | 181 | ".subsection 2\n" |
183 | "3: br 1b\n" | 182 | "3: br 1b\n" |
184 | ".previous" | 183 | ".previous" |
@@ -200,8 +199,8 @@ ____cmpxchg(_u32, volatile int *m, int old, int new) | |||
200 | " mov %4,%1\n" | 199 | " mov %4,%1\n" |
201 | " stl_c %1,%2\n" | 200 | " stl_c %1,%2\n" |
202 | " beq %1,3f\n" | 201 | " beq %1,3f\n" |
203 | __ASM__MB | ||
204 | "2:\n" | 202 | "2:\n" |
203 | __ASM__MB | ||
205 | ".subsection 2\n" | 204 | ".subsection 2\n" |
206 | "3: br 1b\n" | 205 | "3: br 1b\n" |
207 | ".previous" | 206 | ".previous" |
@@ -223,8 +222,8 @@ ____cmpxchg(_u64, volatile long *m, unsigned long old, unsigned long new) | |||
223 | " mov %4,%1\n" | 222 | " mov %4,%1\n" |
224 | " stq_c %1,%2\n" | 223 | " stq_c %1,%2\n" |
225 | " beq %1,3f\n" | 224 | " beq %1,3f\n" |
226 | __ASM__MB | ||
227 | "2:\n" | 225 | "2:\n" |
226 | __ASM__MB | ||
228 | ".subsection 2\n" | 227 | ".subsection 2\n" |
229 | "3: br 1b\n" | 228 | "3: br 1b\n" |
230 | ".previous" | 229 | ".previous" |