Skip to content

Commit febe950

Browse files
author
Peter Zijlstra
committed
arch: Remove cmpxchg_double
No moar users, remove the monster. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Heiko Carstens <hca@linux.ibm.com> Tested-by: Mark Rutland <mark.rutland@arm.com> Link: https://lore.kernel.org/r/20230531132323.991907085@infradead.org
1 parent 6801be4 commit febe950

15 files changed

Lines changed: 5 additions & 371 deletions

File tree

‎Documentation/core-api/this_cpu_ops.rst‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ preemption and interrupts::
5353
this_cpu_add_return(pcp, val)
5454
this_cpu_xchg(pcp, nval)
5555
this_cpu_cmpxchg(pcp, oval, nval)
56-
this_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
5756
this_cpu_sub(pcp, val)
5857
this_cpu_inc(pcp)
5958
this_cpu_dec(pcp)
@@ -242,7 +241,6 @@ safe::
242241
__this_cpu_add_return(pcp, val)
243242
__this_cpu_xchg(pcp, nval)
244243
__this_cpu_cmpxchg(pcp, oval, nval)
245-
__this_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
246244
__this_cpu_sub(pcp, val)
247245
__this_cpu_inc(pcp)
248246
__this_cpu_dec(pcp)

‎arch/arm64/include/asm/atomic_ll_sc.h‎

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -294,39 +294,6 @@ __CMPXCHG_CASE( , , mb_, 64, dmb ish, , l, "memory", L)
294294

295295
#undef __CMPXCHG_CASE
296296

297-
#define __CMPXCHG_DBL(name, mb, rel, cl) \
298-
static __always_inline long \
299-
__ll_sc__cmpxchg_double##name(unsigned long old1, \
300-
unsigned long old2, \
301-
unsigned long new1, \
302-
unsigned long new2, \
303-
volatile void *ptr) \
304-
{ \
305-
unsigned long tmp, ret; \
306-
\
307-
asm volatile("// __cmpxchg_double" #name "\n" \
308-
" prfm pstl1strm, %2\n" \
309-
"1: ldxp %0, %1, %2\n" \
310-
" eor %0, %0, %3\n" \
311-
" eor %1, %1, %4\n" \
312-
" orr %1, %0, %1\n" \
313-
" cbnz %1, 2f\n" \
314-
" st" #rel "xp %w0, %5, %6, %2\n" \
315-
" cbnz %w0, 1b\n" \
316-
" " #mb "\n" \
317-
"2:" \
318-
: "=&r" (tmp), "=&r" (ret), "+Q" (*(__uint128_t *)ptr) \
319-
: "r" (old1), "r" (old2), "r" (new1), "r" (new2) \
320-
: cl); \
321-
\
322-
return ret; \
323-
}
324-
325-
__CMPXCHG_DBL( , , , )
326-
__CMPXCHG_DBL(_mb, dmb ish, l, "memory")
327-
328-
#undef __CMPXCHG_DBL
329-
330297
union __u128_halves {
331298
u128 full;
332299
struct {

‎arch/arm64/include/asm/atomic_lse.h‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -281,42 +281,6 @@ __CMPXCHG_CASE(x, , mb_, 64, al, "memory")
281281

282282
#undef __CMPXCHG_CASE
283283

284-
#define __CMPXCHG_DBL(name, mb, cl...) \
285-
static __always_inline long \
286-
__lse__cmpxchg_double##name(unsigned long old1, \
287-
unsigned long old2, \
288-
unsigned long new1, \
289-
unsigned long new2, \
290-
volatile void *ptr) \
291-
{ \
292-
unsigned long oldval1 = old1; \
293-
unsigned long oldval2 = old2; \
294-
register unsigned long x0 asm ("x0") = old1; \
295-
register unsigned long x1 asm ("x1") = old2; \
296-
register unsigned long x2 asm ("x2") = new1; \
297-
register unsigned long x3 asm ("x3") = new2; \
298-
register unsigned long x4 asm ("x4") = (unsigned long)ptr; \
299-
\
300-
asm volatile( \
301-
__LSE_PREAMBLE \
302-
" casp" #mb "\t%[old1], %[old2], %[new1], %[new2], %[v]\n"\
303-
" eor %[old1], %[old1], %[oldval1]\n" \
304-
" eor %[old2], %[old2], %[oldval2]\n" \
305-
" orr %[old1], %[old1], %[old2]" \
306-
: [old1] "+&r" (x0), [old2] "+&r" (x1), \
307-
[v] "+Q" (*(__uint128_t *)ptr) \
308-
: [new1] "r" (x2), [new2] "r" (x3), [ptr] "r" (x4), \
309-
[oldval1] "r" (oldval1), [oldval2] "r" (oldval2) \
310-
: cl); \
311-
\
312-
return x0; \
313-
}
314-
315-
__CMPXCHG_DBL( , )
316-
__CMPXCHG_DBL(_mb, al, "memory")
317-
318-
#undef __CMPXCHG_DBL
319-
320284
#define __CMPXCHG128(name, mb, cl...) \
321285
static __always_inline u128 \
322286
__lse__cmpxchg128##name(volatile u128 *ptr, u128 old, u128 new) \

‎arch/arm64/include/asm/cmpxchg.h‎

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,6 @@ __CMPXCHG_CASE(mb_, 64)
130130

131131
#undef __CMPXCHG_CASE
132132

133-
#define __CMPXCHG_DBL(name) \
134-
static inline long __cmpxchg_double##name(unsigned long old1, \
135-
unsigned long old2, \
136-
unsigned long new1, \
137-
unsigned long new2, \
138-
volatile void *ptr) \
139-
{ \
140-
return __lse_ll_sc_body(_cmpxchg_double##name, \
141-
old1, old2, new1, new2, ptr); \
142-
}
143-
144-
__CMPXCHG_DBL( )
145-
__CMPXCHG_DBL(_mb)
146-
147-
#undef __CMPXCHG_DBL
148-
149133
#define __CMPXCHG128(name) \
150134
static inline u128 __cmpxchg128##name(volatile u128 *ptr, \
151135
u128 old, u128 new) \
@@ -211,36 +195,6 @@ __CMPXCHG_GEN(_mb)
211195
#define arch_cmpxchg64 arch_cmpxchg
212196
#define arch_cmpxchg64_local arch_cmpxchg_local
213197

214-
/* cmpxchg_double */
215-
#define system_has_cmpxchg_double() 1
216-
217-
#define __cmpxchg_double_check(ptr1, ptr2) \
218-
({ \
219-
if (sizeof(*(ptr1)) != 8) \
220-
BUILD_BUG(); \
221-
VM_BUG_ON((unsigned long *)(ptr2) - (unsigned long *)(ptr1) != 1); \
222-
})
223-
224-
#define arch_cmpxchg_double(ptr1, ptr2, o1, o2, n1, n2) \
225-
({ \
226-
int __ret; \
227-
__cmpxchg_double_check(ptr1, ptr2); \
228-
__ret = !__cmpxchg_double_mb((unsigned long)(o1), (unsigned long)(o2), \
229-
(unsigned long)(n1), (unsigned long)(n2), \
230-
ptr1); \
231-
__ret; \
232-
})
233-
234-
#define arch_cmpxchg_double_local(ptr1, ptr2, o1, o2, n1, n2) \
235-
({ \
236-
int __ret; \
237-
__cmpxchg_double_check(ptr1, ptr2); \
238-
__ret = !__cmpxchg_double((unsigned long)(o1), (unsigned long)(o2), \
239-
(unsigned long)(n1), (unsigned long)(n2), \
240-
ptr1); \
241-
__ret; \
242-
})
243-
244198
/* cmpxchg128 */
245199
#define system_has_cmpxchg128() 1
246200

‎arch/arm64/include/asm/percpu.h‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,6 @@ PERCPU_RET_OP(add, add, ldadd)
145145
* preemption point when TIF_NEED_RESCHED gets set while preemption is
146146
* disabled.
147147
*/
148-
#define this_cpu_cmpxchg_double_8(ptr1, ptr2, o1, o2, n1, n2) \
149-
({ \
150-
int __ret; \
151-
preempt_disable_notrace(); \
152-
__ret = cmpxchg_double_local( raw_cpu_ptr(&(ptr1)), \
153-
raw_cpu_ptr(&(ptr2)), \
154-
o1, o2, n1, n2); \
155-
preempt_enable_notrace(); \
156-
__ret; \
157-
})
158148

159149
#define _pcp_protect(op, pcp, ...) \
160150
({ \

‎arch/s390/include/asm/cmpxchg.h‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -190,40 +190,6 @@ static __always_inline unsigned long __cmpxchg(unsigned long address,
190190
#define arch_cmpxchg_local arch_cmpxchg
191191
#define arch_cmpxchg64_local arch_cmpxchg
192192

193-
#define system_has_cmpxchg_double() 1
194-
195-
static __always_inline int __cmpxchg_double(unsigned long p1, unsigned long p2,
196-
unsigned long o1, unsigned long o2,
197-
unsigned long n1, unsigned long n2)
198-
{
199-
union register_pair old = { .even = o1, .odd = o2, };
200-
union register_pair new = { .even = n1, .odd = n2, };
201-
int cc;
202-
203-
asm volatile(
204-
" cdsg %[old],%[new],%[ptr]\n"
205-
" ipm %[cc]\n"
206-
" srl %[cc],28\n"
207-
: [cc] "=&d" (cc), [old] "+&d" (old.pair)
208-
: [new] "d" (new.pair),
209-
[ptr] "QS" (*(unsigned long *)p1), "Q" (*(unsigned long *)p2)
210-
: "memory", "cc");
211-
return !cc;
212-
}
213-
214-
#define arch_cmpxchg_double(p1, p2, o1, o2, n1, n2) \
215-
({ \
216-
typeof(p1) __p1 = (p1); \
217-
typeof(p2) __p2 = (p2); \
218-
\
219-
BUILD_BUG_ON(sizeof(*(p1)) != sizeof(long)); \
220-
BUILD_BUG_ON(sizeof(*(p2)) != sizeof(long)); \
221-
VM_BUG_ON((unsigned long)((__p1) + 1) != (unsigned long)(__p2));\
222-
__cmpxchg_double((unsigned long)__p1, (unsigned long)__p2, \
223-
(unsigned long)(o1), (unsigned long)(o2), \
224-
(unsigned long)(n1), (unsigned long)(n2)); \
225-
})
226-
227193
#define system_has_cmpxchg128() 1
228194

229195
static __always_inline u128 arch_cmpxchg128(volatile u128 *ptr, u128 old, u128 new)

‎arch/s390/include/asm/percpu.h‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,24 +180,6 @@
180180
#define this_cpu_xchg_4(pcp, nval) arch_this_cpu_xchg(pcp, nval)
181181
#define this_cpu_xchg_8(pcp, nval) arch_this_cpu_xchg(pcp, nval)
182182

183-
#define arch_this_cpu_cmpxchg_double(pcp1, pcp2, o1, o2, n1, n2) \
184-
({ \
185-
typeof(pcp1) *p1__; \
186-
typeof(pcp2) *p2__; \
187-
int ret__; \
188-
\
189-
preempt_disable_notrace(); \
190-
p1__ = raw_cpu_ptr(&(pcp1)); \
191-
p2__ = raw_cpu_ptr(&(pcp2)); \
192-
ret__ = __cmpxchg_double((unsigned long)p1__, (unsigned long)p2__, \
193-
(unsigned long)(o1), (unsigned long)(o2), \
194-
(unsigned long)(n1), (unsigned long)(n2)); \
195-
preempt_enable_notrace(); \
196-
ret__; \
197-
})
198-
199-
#define this_cpu_cmpxchg_double_8 arch_this_cpu_cmpxchg_double
200-
201183
#include <asm-generic/percpu.h>
202184

203185
#endif /* __ARCH_S390_PERCPU__ */

‎arch/x86/include/asm/cmpxchg.h‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -239,29 +239,4 @@ extern void __add_wrong_size(void)
239239
#define __xadd(ptr, inc, lock) __xchg_op((ptr), (inc), xadd, lock)
240240
#define xadd(ptr, inc) __xadd((ptr), (inc), LOCK_PREFIX)
241241

242-
#define __cmpxchg_double(pfx, p1, p2, o1, o2, n1, n2) \
243-
({ \
244-
bool __ret; \
245-
__typeof__(*(p1)) __old1 = (o1), __new1 = (n1); \
246-
__typeof__(*(p2)) __old2 = (o2), __new2 = (n2); \
247-
BUILD_BUG_ON(sizeof(*(p1)) != sizeof(long)); \
248-
BUILD_BUG_ON(sizeof(*(p2)) != sizeof(long)); \
249-
VM_BUG_ON((unsigned long)(p1) % (2 * sizeof(long))); \
250-
VM_BUG_ON((unsigned long)((p1) + 1) != (unsigned long)(p2)); \
251-
asm volatile(pfx "cmpxchg%c5b %1" \
252-
CC_SET(e) \
253-
: CC_OUT(e) (__ret), \
254-
"+m" (*(p1)), "+m" (*(p2)), \
255-
"+a" (__old1), "+d" (__old2) \
256-
: "i" (2 * sizeof(long)), \
257-
"b" (__new1), "c" (__new2)); \
258-
__ret; \
259-
})
260-
261-
#define arch_cmpxchg_double(p1, p2, o1, o2, n1, n2) \
262-
__cmpxchg_double(LOCK_PREFIX, p1, p2, o1, o2, n1, n2)
263-
264-
#define arch_cmpxchg_double_local(p1, p2, o1, o2, n1, n2) \
265-
__cmpxchg_double(, p1, p2, o1, o2, n1, n2)
266-
267242
#endif /* ASM_X86_CMPXCHG_H */

‎arch/x86/include/asm/cmpxchg_32.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ static inline bool __try_cmpxchg64(volatile u64 *ptr, u64 *pold, u64 new)
103103

104104
#endif
105105

106-
#define system_has_cmpxchg_double() boot_cpu_has(X86_FEATURE_CX8)
107106
#define system_has_cmpxchg64() boot_cpu_has(X86_FEATURE_CX8)
108107

109108
#endif /* _ASM_X86_CMPXCHG_32_H */

‎arch/x86/include/asm/cmpxchg_64.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ static __always_inline bool arch_try_cmpxchg128_local(volatile u128 *ptr, u128 *
8181
return __arch_try_cmpxchg128(ptr, oldp, new,);
8282
}
8383

84-
#define system_has_cmpxchg_double() boot_cpu_has(X86_FEATURE_CX16)
8584
#define system_has_cmpxchg128() boot_cpu_has(X86_FEATURE_CX16)
8685

8786
#endif /* _ASM_X86_CMPXCHG_64_H */

0 commit comments

Comments
 (0)