History

Merge tag 'locking-core-2023-06-27' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull locking updates from Ingo Molnar: - Introduce cmpxchg128() -- aka. the demise of cmpxchg_double() The cmpxchg128() family of functions is basically & functionally the same as cmpxchg_double(), but with a saner interface. Instead of a 6-parameter horror that forced u128 - u64/u64-halves layout details on the interface and exposed users to complexity, fragility & bugs, use a natural 3-parameter interface with u128 types. - Restructure the generated atomic headers, and add kerneldoc comments for all of the generic atomic{,64,_long}_t operations. The generated definitions are much cleaner now, and come with documentation. - Implement lock_set_cmp_fn() on lockdep, for defining an ordering when taking multiple locks of the same type. This gets rid of one use of lockdep_set_novalidate_class() in the bcache code. - Fix raw_cpu_generic_try_cmpxchg() bug due to an unintended variable shadowing generating garbage code on Clang on certain ARM builds. * tag 'locking-core-2023-06-27' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (43 commits) locking/atomic: scripts: fix ${atomic}_dec_if_positive() kerneldoc percpu: Fix self-assignment of __old in raw_cpu_generic_try_cmpxchg() locking/atomic: treewide: delete arch_atomic_*() kerneldoc locking/atomic: docs: Add atomic operations to the driver basic API documentation locking/atomic: scripts: generate kerneldoc comments docs: scripts: kernel-doc: accept bitwise negation like ~@var locking/atomic: scripts: simplify raw_atomic*() definitions locking/atomic: scripts: simplify raw_atomic_long*() definitions locking/atomic: scripts: split pfx/name/sfx/order locking/atomic: scripts: restructure fallback ifdeffery locking/atomic: scripts: build raw_atomic_long*() directly locking/atomic: treewide: use raw_atomic*_<op>() locking/atomic: scripts: add trivial raw_atomic*_<op>() locking/atomic: scripts: factor out order template generation locking/atomic: scripts: remove leftover "${mult}" locking/atomic: scripts: remove bogus order parameter locking/atomic: xtensa: add preprocessor symbols locking/atomic: x86: add preprocessor symbols locking/atomic: sparc: add preprocessor symbols locking/atomic: sh: add preprocessor symbols ...

Linus Torvalds committed 3 years ago

Commit bc6cb4d2 parents ed3b792 b33eb50136 files · +9922 −4161Browse files

Unified · Split

136 files
  1. Documentation/core-api/this_cpu_ops.rst +0 −2
  2. Documentation/driver-api/basics.rst +7 −1
  3. arch/alpha/include/asm/atomic.h +0 −35
  4. arch/arc/include/asm/atomic-spinlock.h +9 −0
  5. arch/arc/include/asm/atomic.h +0 −24
  6. arch/arc/include/asm/atomic64-arcv2.h +2 −17
  7. arch/arm/include/asm/assembler.h +17 −0
  8. arch/arm/include/asm/atomic.h +11 −4
  9. arch/arm/include/asm/sync_bitops.h +25 −4
  10. arch/arm/lib/bitops.h +11 −3
  11. arch/arm/lib/testchangebit.S +4 −0
  12. arch/arm/lib/testclearbit.S +4 −0
  13. arch/arm/lib/testsetbit.S +4 −0
  14. arch/arm64/include/asm/atomic.h +0 −28
  15. arch/arm64/include/asm/atomic_ll_sc.h +32 −24
  16. arch/arm64/include/asm/atomic_lse.h +17 −22
  17. arch/arm64/include/asm/cmpxchg.h +14 −34
  18. arch/arm64/include/asm/percpu.h +20 −10
  19. arch/csky/include/asm/atomic.h +0 −35
  20. arch/hexagon/include/asm/atomic.h +9 −60
  21. arch/ia64/include/asm/atomic.h +0 −7
  22. arch/loongarch/include/asm/atomic.h +0 −56
  23. arch/m68k/include/asm/atomic.h +12 −6
  24. arch/mips/include/asm/atomic.h +0 −11
  25. arch/openrisc/include/asm/atomic.h +0 −3
  26. arch/parisc/include/asm/atomic.h +18 −9
  27. arch/powerpc/include/asm/atomic.h +0 −24
  28. arch/powerpc/kernel/smp.c +6 −6
  29. arch/riscv/include/asm/atomic.h +0 −72
  30. arch/s390/include/asm/cmpxchg.h +6 −26
  31. arch/s390/include/asm/cpu_mf.h +1 −1
  32. arch/s390/include/asm/percpu.h +16 −18
  33. arch/s390/kernel/perf_cpum_sf.c +3 −13
  34. arch/sh/include/asm/atomic-grb.h +9 −0
  35. arch/sh/include/asm/atomic-irq.h +9 −0
  36. arch/sh/include/asm/atomic-llsc.h +9 −0
  37. arch/sh/include/asm/atomic.h +0 −3
  38. arch/sparc/include/asm/atomic_32.h +16 −2
  39. arch/sparc/include/asm/atomic_64.h +18 −11
  40. arch/x86/include/asm/atomic.h +0 −87
  41. arch/x86/include/asm/atomic64_32.h +0 −76
  42. arch/x86/include/asm/atomic64_64.h +0 −81
  43. arch/x86/include/asm/cmpxchg.h +0 −25
  44. arch/x86/include/asm/cmpxchg_32.h +1 −1
  45. arch/x86/include/asm/cmpxchg_64.h +66 −1
  46. arch/x86/include/asm/percpu.h +61 −41
  47. arch/x86/kernel/alternative.c +2 −2
  48. arch/x86/kernel/cpu/mce/core.c +8 −8
  49. arch/x86/kernel/nmi.c +1 −1
  50. arch/x86/kernel/pvclock.c +2 −2
  51. arch/x86/kvm/x86.c +1 −1
  52. arch/x86/lib/Makefile +2 −1
  53. arch/x86/lib/cmpxchg16b_emu.S +25 −18
  54. arch/x86/lib/cmpxchg8b_emu.S +53 −14
  55. arch/xtensa/include/asm/atomic.h +9 −3
  56. drivers/iommu/amd/amd_iommu_types.h +7 −2
  57. drivers/iommu/amd/iommu.c +4 −6
  58. drivers/iommu/intel/irq_remapping.c +2 −6
  59. drivers/md/bcache/btree.c +22 −1
  60. drivers/md/bcache/btree.h +2 −2
  61. include/asm-generic/atomic.h +0 −3
  62. include/asm-generic/bitops/atomic.h +6 −6
  63. include/asm-generic/bitops/lock.h +4 −4
  64. include/asm-generic/percpu.h +152 −49
  65. include/crypto/b128ops.h +3 −11
  66. include/linux/atomic/atomic-arch-fallback.h +3576 −1587
  67. include/linux/atomic/atomic-instrumented.h +3194 −361
  68. include/linux/atomic/atomic-long.h +1435 −687
  69. include/linux/context_tracking.h +2 −2
  70. include/linux/context_tracking_state.h +1 −1
  71. include/linux/cpumask.h +1 −1
  72. include/linux/dmar.h +66 −59
  73. include/linux/jump_label.h +1 −1
  74. include/linux/lockdep.h +8 −0
  75. include/linux/lockdep_types.h +8 −0
  76. include/linux/percpu-defs.h +13 −32
  77. include/linux/slub_def.h +9 −3
  78. include/linux/types.h +5 −0
  79. include/uapi/linux/types.h +4 −0
  80. kernel/context_tracking.c +6 −6
  81. kernel/locking/lockdep.c +87 −31
  82. kernel/sched/clock.c +1 −1
  83. lib/crypto/curve25519-hacl64.c +0 −2
  84. lib/crypto/poly1305-donna64.c +0 −2
  85. mm/slab.h +46 −7
  86. mm/slub.c +82 −57
  87. scripts/atomic/atomic-tbl.sh +108 −4
  88. scripts/atomic/atomics.tbl +1 −1
  89. scripts/atomic/fallbacks/acquire +0 −4
  90. scripts/atomic/fallbacks/add_negative +1 −13
  91. scripts/atomic/fallbacks/add_unless +1 −14
  92. scripts/atomic/fallbacks/andnot +1 −5
  93. scripts/atomic/fallbacks/cmpxchg +3 −0
  94. scripts/atomic/fallbacks/dec +1 −5
  95. scripts/atomic/fallbacks/dec_and_test +1 −13
  96. scripts/atomic/fallbacks/dec_if_positive +2 −6
  97. scripts/atomic/fallbacks/dec_unless_positive +2 −6
  98. scripts/atomic/fallbacks/fence +0 −4
  99. scripts/atomic/fallbacks/fetch_add_unless +2 −15
  100. scripts/atomic/fallbacks/inc +1 −5
  101. scripts/atomic/fallbacks/inc_and_test +1 −13
  102. scripts/atomic/fallbacks/inc_not_zero +1 −12
  103. scripts/atomic/fallbacks/inc_unless_negative +2 −6
  104. scripts/atomic/fallbacks/read_acquire +1 −5
  105. scripts/atomic/fallbacks/release +0 −4
  106. scripts/atomic/fallbacks/set_release +1 −5
  107. scripts/atomic/fallbacks/sub_and_test +1 −14
  108. scripts/atomic/fallbacks/try_cmpxchg +1 −5
  109. scripts/atomic/fallbacks/xchg +3 −0
  110. scripts/atomic/gen-atomic-fallback.sh +175 −91
  111. scripts/atomic/gen-atomic-instrumented.sh +16 −26
  112. scripts/atomic/gen-atomic-long.sh +18 −20
  113. scripts/atomic/kerneldoc/add +13 −0
  114. scripts/atomic/kerneldoc/add_negative +13 −0
  115. scripts/atomic/kerneldoc/add_unless +18 −0
  116. scripts/atomic/kerneldoc/and +13 −0
  117. scripts/atomic/kerneldoc/andnot +13 −0
  118. scripts/atomic/kerneldoc/cmpxchg +14 −0
  119. scripts/atomic/kerneldoc/dec +12 −0
  120. scripts/atomic/kerneldoc/dec_and_test +12 −0
  121. scripts/atomic/kerneldoc/dec_if_positive +12 −0
  122. scripts/atomic/kerneldoc/dec_unless_positive +12 −0
  123. scripts/atomic/kerneldoc/inc +12 −0
  124. scripts/atomic/kerneldoc/inc_and_test +12 −0
  125. scripts/atomic/kerneldoc/inc_not_zero +12 −0
  126. scripts/atomic/kerneldoc/inc_unless_negative +12 −0
  127. scripts/atomic/kerneldoc/or +13 −0
  128. scripts/atomic/kerneldoc/read +12 −0
  129. scripts/atomic/kerneldoc/set +13 −0
  130. scripts/atomic/kerneldoc/sub +13 −0
  131. scripts/atomic/kerneldoc/sub_and_test +13 −0
  132. scripts/atomic/kerneldoc/try_cmpxchg +15 −0
  133. scripts/atomic/kerneldoc/xchg +13 −0
  134. scripts/atomic/kerneldoc/xor +13 −0
  135. scripts/kernel-doc +1 −1
  136. scripts/min-tool-version.sh +5 −1
Documentation/core-api/this_cpu_ops.rst+0−2
@@ -53,7 +53,6 @@ preemption and interrupts:: · 52 unmodified lines
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:: · 182 unmodified lines
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)
Documentation/driver-api/basics.rst+7−1
@@ -84,7 +84,13 @@ Reference counting · 83 unmodified lines
8484 Atomics
8585 -------
8686
87−.. kernel-doc:: arch/x86/include/asm/atomic.h
87+.. kernel-doc:: include/linux/atomic/atomic-instrumented.h
88+ :internal:
89+
90+.. kernel-doc:: include/linux/atomic/atomic-arch-fallback.h
91+ :internal:
92+
93+.. kernel-doc:: include/linux/atomic/atomic-long.h
8894 :internal:
8995
9096 Kernel objects manipulation
arch/alpha/include/asm/atomic.h+0−35
@@ -200,25 +200,6 @@ ATOMIC_OPS(xor, xor) · 199 unmodified lines
200200 #undef ATOMIC_OP_RETURN
201201 #undef ATOMIC_OP
202202
203−#define arch_atomic64_cmpxchg(v, old, new) \
204− (arch_cmpxchg(&((v)->counter), old, new))
205−#define arch_atomic64_xchg(v, new) \
206− (arch_xchg(&((v)->counter), new))
207−
208−#define arch_atomic_cmpxchg(v, old, new) \
209− (arch_cmpxchg(&((v)->counter), old, new))
210−#define arch_atomic_xchg(v, new) \
211− (arch_xchg(&((v)->counter), new))
212−
213−/**
214− * arch_atomic_fetch_add_unless - add unless the number is a given value
215− * @v: pointer of type atomic_t
216− * @a: the amount to add to v...
217− * @u: ...unless v is equal to u.
218− *
219− * Atomically adds @a to @v, so long as it was not @u.
220− * Returns the old value of @v.
221− */
222203 static __inline__ int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u)
223204 {
224205 int c, new, old;
@@ -242,15 +223,6 @@ static __inline__ int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u) · 17 unmodified lines
242223 }
243224 #define arch_atomic_fetch_add_unless arch_atomic_fetch_add_unless
244225
245−/**
246− * arch_atomic64_fetch_add_unless - add unless the number is a given value
247− * @v: pointer of type atomic64_t
248− * @a: the amount to add to v...
249− * @u: ...unless v is equal to u.
250− *
251− * Atomically adds @a to @v, so long as it was not @u.
252− * Returns the old value of @v.
253− */
254226 static __inline__ s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u)
255227 {
256228 s64 c, new, old;
@@ -274,13 +246,6 @@ static __inline__ s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u · 17 unmodified lines
274246 }
275247 #define arch_atomic64_fetch_add_unless arch_atomic64_fetch_add_unless
276248
277−/*
278− * arch_atomic64_dec_if_positive - decrement by 1 if old value positive
279− * @v: pointer of type atomic_t
280− *
281− * The function returns the old value of *v minus 1, even if
282− * the atomic variable, v, was not decremented.
283− */
284249 static inline s64 arch_atomic64_dec_if_positive(atomic64_t *v)
285250 {
286251 s64 old, tmp;
arch/arc/include/asm/atomic-spinlock.h+9−0
@@ -81,6 +81,11 @@ static inline int arch_atomic_fetch_##op(int i, atomic_t *v) \ · 80 unmodified lines
8181 ATOMIC_OPS(add, +=, add)
8282 ATOMIC_OPS(sub, -=, sub)
8383
84+#define arch_atomic_fetch_add arch_atomic_fetch_add
85+#define arch_atomic_fetch_sub arch_atomic_fetch_sub
86+#define arch_atomic_add_return arch_atomic_add_return
87+#define arch_atomic_sub_return arch_atomic_sub_return
88+
8489 #undef ATOMIC_OPS
8590 #define ATOMIC_OPS(op, c_op, asm_op) \
8691 ATOMIC_OP(op, c_op, asm_op) \
@@ -92,7 +97,11 @@ ATOMIC_OPS(or, |=, or) · 5 unmodified lines
9297 ATOMIC_OPS(xor, ^=, xor)
9398
9499 #define arch_atomic_andnot arch_atomic_andnot
100+
101+#define arch_atomic_fetch_and arch_atomic_fetch_and
95102 #define arch_atomic_fetch_andnot arch_atomic_fetch_andnot
103+#define arch_atomic_fetch_or arch_atomic_fetch_or
104+#define arch_atomic_fetch_xor arch_atomic_fetch_xor
96105
97106 #undef ATOMIC_OPS
98107 #undef ATOMIC_FETCH_OP
arch/arc/include/asm/atomic.h+0−24
@@ -22,30 +22,6 @@ · 21 unmodified lines
2222 #include <asm/atomic-spinlock.h>
2323 #endif
2424
25−#define arch_atomic_cmpxchg(v, o, n) \
26−({ \
27− arch_cmpxchg(&((v)->counter), (o), (n)); \
28−})
29−
30−#ifdef arch_cmpxchg_relaxed
31−#define arch_atomic_cmpxchg_relaxed(v, o, n) \
32−({ \
33− arch_cmpxchg_relaxed(&((v)->counter), (o), (n)); \
34−})
35−#endif
36−
37−#define arch_atomic_xchg(v, n) \
38−({ \
39− arch_xchg(&((v)->counter), (n)); \
40−})
41−
42−#ifdef arch_xchg_relaxed
43−#define arch_atomic_xchg_relaxed(v, n) \
44−({ \
45− arch_xchg_relaxed(&((v)->counter), (n)); \
46−})
47−#endif
48−
4925 /*
5026 * 64-bit atomics
5127 */
arch/arc/include/asm/atomic64-arcv2.h+2−17
@@ -159,6 +159,7 @@ arch_atomic64_cmpxchg(atomic64_t *ptr, s64 expected, s64 new) · 158 unmodified lines
159159
160160 return prev;
161161 }
162+#define arch_atomic64_cmpxchg arch_atomic64_cmpxchg
162163
163164 static inline s64 arch_atomic64_xchg(atomic64_t *ptr, s64 new)
164165 {
@@ -179,14 +180,7 @@ static inline s64 arch_atomic64_xchg(atomic64_t *ptr, s64 new) · 14 unmodified lines
179180
180181 return prev;
181182 }
182−
183−/**
184− * arch_atomic64_dec_if_positive - decrement by 1 if old value positive
185− * @v: pointer of type atomic64_t
186− *
187− * The function returns the old value of *v minus 1, even if
188− * the atomic variable, v, was not decremented.
189− */
183+#define arch_atomic64_xchg arch_atomic64_xchg
190184
191185 static inline s64 arch_atomic64_dec_if_positive(atomic64_t *v)
192186 {
@@ -212,15 +206,6 @@ static inline s64 arch_atomic64_dec_if_positive(atomic64_t *v) · 19 unmodified lines
212206 }
213207 #define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive
214208
215−/**
216− * arch_atomic64_fetch_add_unless - add unless the number is a given value
217− * @v: pointer of type atomic64_t
218− * @a: the amount to add to v...
219− * @u: ...unless v is equal to u.
220− *
221− * Atomically adds @a to @v, if it was not @u.
222− * Returns the old value of @v
223− */
224209 static inline s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u)
225210 {
226211 s64 old, temp;
arch/arm/include/asm/assembler.h+17−0
@@ -394,6 +394,23 @@ ALT_UP_B(.L0_\@) · 393 unmodified lines
394394 #endif
395395 .endm
396396
397+/*
398+ * Raw SMP data memory barrier
399+ */
400+ .macro __smp_dmb mode
401+#if __LINUX_ARM_ARCH__ >= 7
402+ .ifeqs "\mode","arm"
403+ dmb ish
404+ .else
405+ W(dmb) ish
406+ .endif
407+#elif __LINUX_ARM_ARCH__ == 6
408+ mcr p15, 0, r0, c7, c10, 5 @ dmb
409+#else
410+ .error "Incompatible SMP platform"
411+#endif
412+ .endm
413+
397414 #if defined(CONFIG_CPU_V7M)
398415 /*
399416 * setmode is used to assert to be in svc mode during boot. For v7-M
arch/arm/include/asm/atomic.h+11−4
@@ -197,6 +197,16 @@ static inline int arch_atomic_fetch_##op(int i, atomic_t *v) \ · 196 unmodified lines
197197 return val; \
198198 }
199199
200+#define arch_atomic_add_return arch_atomic_add_return
201+#define arch_atomic_sub_return arch_atomic_sub_return
202+#define arch_atomic_fetch_add arch_atomic_fetch_add
203+#define arch_atomic_fetch_sub arch_atomic_fetch_sub
204+
205+#define arch_atomic_fetch_and arch_atomic_fetch_and
206+#define arch_atomic_fetch_andnot arch_atomic_fetch_andnot
207+#define arch_atomic_fetch_or arch_atomic_fetch_or
208+#define arch_atomic_fetch_xor arch_atomic_fetch_xor
209+
200210 static inline int arch_atomic_cmpxchg(atomic_t *v, int old, int new)
201211 {
202212 int ret;
@@ -210,8 +220,7 @@ static inline int arch_atomic_cmpxchg(atomic_t *v, int old, int new) · 7 unmodified lines
210220
211221 return ret;
212222 }
213−
214−#define arch_atomic_fetch_andnot arch_atomic_fetch_andnot
223+#define arch_atomic_cmpxchg arch_atomic_cmpxchg
215224
216225 #endif /* __LINUX_ARM_ARCH__ */
217226
@@ -240,8 +249,6 @@ ATOMIC_OPS(xor, ^=, eor) · 22 unmodified lines
240249 #undef ATOMIC_OP_RETURN
241250 #undef ATOMIC_OP
242251
243−#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), new))
244−
245252 #ifndef CONFIG_GENERIC_ATOMIC64
246253 typedef struct {
247254 s64 counter;
arch/arm/include/asm/sync_bitops.h+25−4
@@ -14,14 +14,35 @@ · 13 unmodified lines
1414 * ops which are SMP safe even on a UP kernel.
1515 */
1616
17+/*
18+ * Unordered
19+ */
20+
1721 #define sync_set_bit(nr, p) _set_bit(nr, p)
1822 #define sync_clear_bit(nr, p) _clear_bit(nr, p)
1923 #define sync_change_bit(nr, p) _change_bit(nr, p)
20−#define sync_test_and_set_bit(nr, p) _test_and_set_bit(nr, p)
21−#define sync_test_and_clear_bit(nr, p) _test_and_clear_bit(nr, p)
22−#define sync_test_and_change_bit(nr, p) _test_and_change_bit(nr, p)
2324 #define sync_test_bit(nr, addr) test_bit(nr, addr)
24−#define arch_sync_cmpxchg arch_cmpxchg
2525
26+/*
27+ * Fully ordered
28+ */
29+
30+int _sync_test_and_set_bit(int nr, volatile unsigned long * p);
31+#define sync_test_and_set_bit(nr, p) _sync_test_and_set_bit(nr, p)
32+
33+int _sync_test_and_clear_bit(int nr, volatile unsigned long * p);
34+#define sync_test_and_clear_bit(nr, p) _sync_test_and_clear_bit(nr, p)
35+
36+int _sync_test_and_change_bit(int nr, volatile unsigned long * p);
37+#define sync_test_and_change_bit(nr, p) _sync_test_and_change_bit(nr, p)
38+
39+#define arch_sync_cmpxchg(ptr, old, new) \
40+({ \
41+ __typeof__(*(ptr)) __ret; \
42+ __smp_mb__before_atomic(); \
43+ __ret = arch_cmpxchg_relaxed((ptr), (old), (new)); \
44+ __smp_mb__after_atomic(); \
45+ __ret; \
46+})
2647
2748 #endif
arch/arm/lib/bitops.h+11−3
@@ -28,7 +28,7 @@ UNWIND( .fnend ) · 27 unmodified lines
2828 ENDPROC(\name )
2929 .endm
3030
31− .macro testop, name, instr, store
31+ .macro __testop, name, instr, store, barrier
3232 ENTRY( \name )
3333 UNWIND( .fnstart )
3434 ands ip, r1, #3
@@ -38,7 +38,7 @@ UNWIND( .fnstart ) · 3 unmodified lines
3838 mov r0, r0, lsr #5
3939 add r1, r1, r0, lsl #2 @ Get word offset
4040 mov r3, r2, lsl r3 @ create mask
41− smp_dmb
41+ \barrier
4242 #if __LINUX_ARM_ARCH__ >= 7 && defined(CONFIG_SMP)
4343 .arch_extension mp
4444 ALT_SMP(W(pldw) [r1])
@@ -50,13 +50,21 @@ UNWIND( .fnstart ) · 5 unmodified lines
5050 strex ip, r2, [r1]
5151 cmp ip, #0
5252 bne 1b
53− smp_dmb
53+ \barrier
5454 cmp r0, #0
5555 movne r0, #1
5656 2: bx lr
5757 UNWIND( .fnend )
5858 ENDPROC(\name )
5959 .endm
60+
61+ .macro testop, name, instr, store
62+ __testop \name, \instr, \store, smp_dmb
63+ .endm
64+
65+ .macro sync_testop, name, instr, store
66+ __testop \name, \instr, \store, __smp_dmb
67+ .endm
6068 #else
6169 .macro bitop, name, instr
6270 ENTRY( \name )
arch/arm/lib/testchangebit.S+4−0
@@ -10,3 +10,7 @@ · 9 unmodified lines
1010 .text
1111
1212 testop _test_and_change_bit, eor, str
13+
14+#if __LINUX_ARM_ARCH__ >= 6
15+sync_testop _sync_test_and_change_bit, eor, str
16+#endif
arch/arm/lib/testclearbit.S+4−0
@@ -10,3 +10,7 @@ · 9 unmodified lines
1010 .text
1111
1212 testop _test_and_clear_bit, bicne, strne
13+
14+#if __LINUX_ARM_ARCH__ >= 6
15+sync_testop _sync_test_and_clear_bit, bicne, strne
16+#endif
arch/arm/lib/testsetbit.S+4−0
@@ -10,3 +10,7 @@ · 9 unmodified lines
1010 .text
1111
1212 testop _test_and_set_bit, orreq, streq
13+
14+#if __LINUX_ARM_ARCH__ >= 6
15+sync_testop _sync_test_and_set_bit, orreq, streq
16+#endif
arch/arm64/include/asm/atomic.h+0−28
@@ -142,24 +142,6 @@ static __always_inline long arch_atomic64_dec_if_positive(atomic64_t *v) · 141 unmodified lines
142142 #define arch_atomic_fetch_xor_release arch_atomic_fetch_xor_release
143143 #define arch_atomic_fetch_xor arch_atomic_fetch_xor
144144
145−#define arch_atomic_xchg_relaxed(v, new) \
146− arch_xchg_relaxed(&((v)->counter), (new))
147−#define arch_atomic_xchg_acquire(v, new) \
148− arch_xchg_acquire(&((v)->counter), (new))
149−#define arch_atomic_xchg_release(v, new) \
150− arch_xchg_release(&((v)->counter), (new))
151−#define arch_atomic_xchg(v, new) \
152− arch_xchg(&((v)->counter), (new))
153−
154−#define arch_atomic_cmpxchg_relaxed(v, old, new) \
155− arch_cmpxchg_relaxed(&((v)->counter), (old), (new))
156−#define arch_atomic_cmpxchg_acquire(v, old, new) \
157− arch_cmpxchg_acquire(&((v)->counter), (old), (new))
158−#define arch_atomic_cmpxchg_release(v, old, new) \
159− arch_cmpxchg_release(&((v)->counter), (old), (new))
160−#define arch_atomic_cmpxchg(v, old, new) \
161− arch_cmpxchg(&((v)->counter), (old), (new))
162−
163145 #define arch_atomic_andnot arch_atomic_andnot
164146
165147 /*
@@ -209,16 +191,6 @@ static __always_inline long arch_atomic64_dec_if_positive(atomic64_t *v) · 43 unmodified lines
209191 #define arch_atomic64_fetch_xor_release arch_atomic64_fetch_xor_release
210192 #define arch_atomic64_fetch_xor arch_atomic64_fetch_xor
211193
212−#define arch_atomic64_xchg_relaxed arch_atomic_xchg_relaxed
213−#define arch_atomic64_xchg_acquire arch_atomic_xchg_acquire
214−#define arch_atomic64_xchg_release arch_atomic_xchg_release
215−#define arch_atomic64_xchg arch_atomic_xchg
216−
217−#define arch_atomic64_cmpxchg_relaxed arch_atomic_cmpxchg_relaxed
218−#define arch_atomic64_cmpxchg_acquire arch_atomic_cmpxchg_acquire
219−#define arch_atomic64_cmpxchg_release arch_atomic_cmpxchg_release
220−#define arch_atomic64_cmpxchg arch_atomic_cmpxchg
221−
222194 #define arch_atomic64_andnot arch_atomic64_andnot
223195
224196 #define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive
arch/arm64/include/asm/atomic_ll_sc.h+32−24
@@ -294,38 +294,46 @@ __CMPXCHG_CASE( , , mb_, 64, dmb ish, , l, "memory", L) · 293 unmodified lines
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) \
297+union __u128_halves {
298+ u128 full;
299+ struct {
300+ u64 low, high;
301+ };
302+};
303+
304+#define __CMPXCHG128(name, mb, rel, cl...) \
305+static __always_inline u128 \
306+__ll_sc__cmpxchg128##name(volatile u128 *ptr, u128 old, u128 new) \
304307 { \
305− unsigned long tmp, ret; \
308+ union __u128_halves r, o = { .full = (old) }, \
309+ n = { .full = (new) }; \
310+ unsigned int tmp; \
306311 \
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" \
312+ asm volatile("// __cmpxchg128" #name "\n" \
313+ " prfm pstl1strm, %[v]\n" \
314+ "1: ldxp %[rl], %[rh], %[v]\n" \
315+ " cmp %[rl], %[ol]\n" \
316+ " ccmp %[rh], %[oh], 0, eq\n" \
317+ " b.ne 2f\n" \
318+ " st" #rel "xp %w[tmp], %[nl], %[nh], %[v]\n" \
319+ " cbnz %w[tmp], 1b\n" \
316320 " " #mb "\n" \
317321 "2:" \
318− : "=&r" (tmp), "=&r" (ret), "+Q" (*(__uint128_t *)ptr) \
319− : "r" (old1), "r" (old2), "r" (new1), "r" (new2) \
320− : cl); \
322+ : [v] "+Q" (*(u128 *)ptr), \
323+ [rl] "=&r" (r.low), [rh] "=&r" (r.high), \
324+ [tmp] "=&r" (tmp) \
325+ : [ol] "r" (o.low), [oh] "r" (o.high), \
326+ [nl] "r" (n.low), [nh] "r" (n.high) \
327+ : "cc", ##cl); \
321328 \
322− return ret; \
329+ return r.full; \
323330 }
324331
325−__CMPXCHG_DBL( , , , )
326−__CMPXCHG_DBL(_mb, dmb ish, l, "memory")
332+__CMPXCHG128( , , )
333+__CMPXCHG128(_mb, dmb ish, l, "memory")
334+
335+#undef __CMPXCHG128
327336
328−#undef __CMPXCHG_DBL
329337 #undef K
330338
331339 #endif /* __ASM_ATOMIC_LL_SC_H */
arch/arm64/include/asm/atomic_lse.h+17−22
@@ -281,40 +281,35 @@ __CMPXCHG_CASE(x, , mb_, 64, al, "memory") · 280 unmodified lines
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) \
284+#define __CMPXCHG128(name, mb, cl...) \
285+static __always_inline u128 \
286+__lse__cmpxchg128##name(volatile u128 *ptr, u128 old, u128 new) \
291287 { \
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; \
288+ union __u128_halves r, o = { .full = (old) }, \
289+ n = { .full = (new) }; \
290+ register unsigned long x0 asm ("x0") = o.low; \
291+ register unsigned long x1 asm ("x1") = o.high; \
292+ register unsigned long x2 asm ("x2") = n.low; \
293+ register unsigned long x3 asm ("x3") = n.high; \
298294 register unsigned long x4 asm ("x4") = (unsigned long)ptr; \
299295 \
300296 asm volatile( \
301297 __LSE_PREAMBLE \
302298 " 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]" \
306299 : [old1] "+&r" (x0), [old2] "+&r" (x1), \
307− [v] "+Q" (*(__uint128_t *)ptr) \
300+ [v] "+Q" (*(u128 *)ptr) \
308301 : [new1] "r" (x2), [new2] "r" (x3), [ptr] "r" (x4), \
309− [oldval1] "r" (oldval1), [oldval2] "r" (oldval2) \
302+ [oldval1] "r" (o.low), [oldval2] "r" (o.high) \
310303 : cl); \
311304 \
312− return x0; \
305+ r.low = x0; r.high = x1; \
306+ \
307+ return r.full; \
313308 }
314309
315−__CMPXCHG_DBL( , )
316−__CMPXCHG_DBL(_mb, al, "memory")
310+__CMPXCHG128( , )
311+__CMPXCHG128(_mb, al, "memory")
317312
318−#undef __CMPXCHG_DBL
313+#undef __CMPXCHG128
319314
320315 #endif /* __ASM_ATOMIC_LSE_H */
arch/arm64/include/asm/cmpxchg.h+14−34
@@ -130,21 +130,18 @@ __CMPXCHG_CASE(mb_, 64) · 129 unmodified lines
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) \
133+#define __CMPXCHG128(name) \
134+static inline u128 __cmpxchg128##name(volatile u128 *ptr, \
135+ u128 old, u128 new) \
139136 { \
140− return __lse_ll_sc_body(_cmpxchg_double##name, \
141− old1, old2, new1, new2, ptr); \
137+ return __lse_ll_sc_body(_cmpxchg128##name, \
138+ ptr, old, new); \
142139 }
143140
144−__CMPXCHG_DBL( )
145−__CMPXCHG_DBL(_mb)
141+__CMPXCHG128( )
142+__CMPXCHG128(_mb)
146143
147−#undef __CMPXCHG_DBL
144+#undef __CMPXCHG128
148145
149146 #define __CMPXCHG_GEN(sfx) \
150147 static __always_inline unsigned long __cmpxchg##sfx(volatile void *ptr, \
@@ -198,34 +195,17 @@ __CMPXCHG_GEN(_mb) · 47 unmodified lines
198195 #define arch_cmpxchg64 arch_cmpxchg
199196 #define arch_cmpxchg64_local arch_cmpxchg_local
200197
201−/* cmpxchg_double */
202−#define system_has_cmpxchg_double() 1
203−
204−#define __cmpxchg_double_check(ptr1, ptr2) \
205−({ \
206− if (sizeof(*(ptr1)) != 8) \
207− BUILD_BUG(); \
208− VM_BUG_ON((unsigned long *)(ptr2) - (unsigned long *)(ptr1) != 1); \
209−})
198+/* cmpxchg128 */
199+#define system_has_cmpxchg128() 1
210200
211−#define arch_cmpxchg_double(ptr1, ptr2, o1, o2, n1, n2) \
201+#define arch_cmpxchg128(ptr, o, n) \
212202 ({ \
213− int __ret; \
214− __cmpxchg_double_check(ptr1, ptr2); \
215− __ret = !__cmpxchg_double_mb((unsigned long)(o1), (unsigned long)(o2), \
216− (unsigned long)(n1), (unsigned long)(n2), \
217− ptr1); \
218− __ret; \
203+ __cmpxchg128_mb((ptr), (o), (n)); \
219204 })
220205
221−#define arch_cmpxchg_double_local(ptr1, ptr2, o1, o2, n1, n2) \
206+#define arch_cmpxchg128_local(ptr, o, n) \
222207 ({ \
223− int __ret; \
224− __cmpxchg_double_check(ptr1, ptr2); \
225− __ret = !__cmpxchg_double((unsigned long)(o1), (unsigned long)(o2), \
226− (unsigned long)(n1), (unsigned long)(n2), \
227− ptr1); \
228− __ret; \
208+ __cmpxchg128((ptr), (o), (n)); \
229209 })
230210
231211 #define __CMPWAIT_CASE(w, sfx, sz) \
arch/arm64/include/asm/percpu.h+20−10
@@ -140,17 +140,11 @@ PERCPU_RET_OP(add, add, ldadd) · 139 unmodified lines
140140 * re-enabling preemption for preemptible kernels, but doing that in a way
141141 * which builds inside a module would mean messing directly with the preempt
142142 * count. If you do this, peterz and tglx will hunt you down.
143+ *
144+ * Not to mention it'll break the actual preemption model for missing a
145+ * preemption point when TIF_NEED_RESCHED gets set while preemption is
146+ * disabled.
143147 */
144−#define this_cpu_cmpxchg_double_8(ptr1, ptr2, o1, o2, n1, n2) \
145−({ \
146− int __ret; \
147− preempt_disable_notrace(); \
148− __ret = cmpxchg_double_local( raw_cpu_ptr(&(ptr1)), \
149− raw_cpu_ptr(&(ptr2)), \
150− o1, o2, n1, n2); \
151− preempt_enable_notrace(); \
152− __ret; \
153−})
154148
155149 #define _pcp_protect(op, pcp, ...) \
156150 ({ \
@@ -240,6 +234,22 @@ PERCPU_RET_OP(add, add, ldadd) · 83 unmodified lines
240234 #define this_cpu_cmpxchg_8(pcp, o, n) \
241235 _pcp_protect_return(cmpxchg_relaxed, pcp, o, n)
242236
237+#define this_cpu_cmpxchg64(pcp, o, n) this_cpu_cmpxchg_8(pcp, o, n)
238+
239+#define this_cpu_cmpxchg128(pcp, o, n) \
240+({ \
241+ typedef typeof(pcp) pcp_op_T__; \
242+ u128 old__, new__, ret__; \
243+ pcp_op_T__ *ptr__; \
244+ old__ = o; \
245+ new__ = n; \
246+ preempt_disable_notrace(); \
247+ ptr__ = raw_cpu_ptr(&(pcp)); \
248+ ret__ = cmpxchg128_local((void *)ptr__, old__, new__); \
249+ preempt_enable_notrace(); \
250+ ret__; \
251+})
252+
243253 #ifdef __KVM_NVHE_HYPERVISOR__
244254 extern unsigned long __hyp_per_cpu_offset(unsigned int cpu);
245255 #define __per_cpu_offset
arch/csky/include/asm/atomic.h+0−35
@@ -195,41 +195,6 @@ arch_atomic_dec_if_positive(atomic_t *v) · 194 unmodified lines
195195 }
196196 #define arch_atomic_dec_if_positive arch_atomic_dec_if_positive
197197
198−#define ATOMIC_OP() \
199−static __always_inline \
200−int arch_atomic_xchg_relaxed(atomic_t *v, int n) \
201−{ \
202− return __xchg_relaxed(n, &(v->counter), 4); \
203−} \
204−static __always_inline \
205−int arch_atomic_cmpxchg_relaxed(atomic_t *v, int o, int n) \
206−{ \
207− return __cmpxchg_relaxed(&(v->counter), o, n, 4); \
208−} \
209−static __always_inline \
210−int arch_atomic_cmpxchg_acquire(atomic_t *v, int o, int n) \
211−{ \
212− return __cmpxchg_acquire(&(v->counter), o, n, 4); \
213−} \
214−static __always_inline \
215−int arch_atomic_cmpxchg(atomic_t *v, int o, int n) \
216−{ \
217− return __cmpxchg(&(v->counter), o, n, 4); \
218−}
219−
220−#define ATOMIC_OPS() \
221− ATOMIC_OP()
222−
223−ATOMIC_OPS()
224−
225−#define arch_atomic_xchg_relaxed arch_atomic_xchg_relaxed
226−#define arch_atomic_cmpxchg_relaxed arch_atomic_cmpxchg_relaxed
227−#define arch_atomic_cmpxchg_acquire arch_atomic_cmpxchg_acquire
228−#define arch_atomic_cmpxchg arch_atomic_cmpxchg
229−
230−#undef ATOMIC_OPS
231−#undef ATOMIC_OP
232−
233198 #else
234199 #include <asm-generic/atomic.h>
235200 #endif
arch/hexagon/include/asm/atomic.h+9−60
@@ -28,58 +28,8 @@ static inline void arch_atomic_set(atomic_t *v, int new) · 27 unmodified lines
2828
2929 #define arch_atomic_set_release(v, i) arch_atomic_set((v), (i))
3030
31−/**
32− * arch_atomic_read - reads a word, atomically
33− * @v: pointer to atomic value
34− *
35− * Assumes all word reads on our architecture are atomic.
36− */
3731 #define arch_atomic_read(v) READ_ONCE((v)->counter)
3832
39−/**
40− * arch_atomic_xchg - atomic
41− * @v: pointer to memory to change
42− * @new: new value (technically passed in a register -- see xchg)
43− */
44−#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), (new)))
45−
46−
47−/**
48− * arch_atomic_cmpxchg - atomic compare-and-exchange values
49− * @v: pointer to value to change
50− * @old: desired old value to match
51− * @new: new value to put in
52− *
53− * Parameters are then pointer, value-in-register, value-in-register,
54− * and the output is the old value.
55− *
56− * Apparently this is complicated for archs that don't support
57− * the memw_locked like we do (or it's broken or whatever).
58− *
59− * Kind of the lynchpin of the rest of the generically defined routines.
60− * Remember V2 had that bug with dotnew predicate set by memw_locked.
61− *
62− * "old" is "expected" old val, __oldval is actual old value
63− */
64−static inline int arch_atomic_cmpxchg(atomic_t *v, int old, int new)
65−{
66− int __oldval;
67−
68− asm volatile(
69− "1: %0 = memw_locked(%1);\n"
70− " { P0 = cmp.eq(%0,%2);\n"
71− " if (!P0.new) jump:nt 2f; }\n"
72− " memw_locked(%1,P0) = %3;\n"
73− " if (!P0) jump 1b;\n"
74− "2:\n"
75− : "=&r" (__oldval)
76− : "r" (&v->counter), "r" (old), "r" (new)
77− : "memory", "p0"
78− );
79−
80− return __oldval;
81−}
82−
8333 #define ATOMIC_OP(op) \
8434 static inline void arch_atomic_##op(int i, atomic_t *v) \
8535 { \
@@ -135,6 +85,11 @@ static inline int arch_atomic_fetch_##op(int i, atomic_t *v) \ · 49 unmodified lines
13585 ATOMIC_OPS(add)
13686 ATOMIC_OPS(sub)
13787
88+#define arch_atomic_add_return arch_atomic_add_return
89+#define arch_atomic_sub_return arch_atomic_sub_return
90+#define arch_atomic_fetch_add arch_atomic_fetch_add
91+#define arch_atomic_fetch_sub arch_atomic_fetch_sub
92+
13893 #undef ATOMIC_OPS
13994 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_FETCH_OP(op)
14095
@@ -142,21 +97,15 @@ ATOMIC_OPS(and) · 1 unmodified line
14297 ATOMIC_OPS(or)
14398 ATOMIC_OPS(xor)
14499
100+#define arch_atomic_fetch_and arch_atomic_fetch_and
101+#define arch_atomic_fetch_or arch_atomic_fetch_or
102+#define arch_atomic_fetch_xor arch_atomic_fetch_xor
103+
145104 #undef ATOMIC_OPS
146105 #undef ATOMIC_FETCH_OP
147106 #undef ATOMIC_OP_RETURN
148107 #undef ATOMIC_OP
149108
150−/**
151− * arch_atomic_fetch_add_unless - add unless the number is a given value
152− * @v: pointer to value
153− * @a: amount to add
154− * @u: unless value is equal to u
155− *
156− * Returns old value.
157− *
158− */
159−
160109 static inline int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u)
161110 {
162111 int __oldval;
arch/ia64/include/asm/atomic.h+0−7
@@ -207,13 +207,6 @@ ATOMIC64_FETCH_OP(xor, ^) · 206 unmodified lines
207207 #undef ATOMIC64_FETCH_OP
208208 #undef ATOMIC64_OP
209209
210−#define arch_atomic_cmpxchg(v, old, new) (arch_cmpxchg(&((v)->counter), old, new))
211−#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), new))
212−
213−#define arch_atomic64_cmpxchg(v, old, new) \
214− (arch_cmpxchg(&((v)->counter), old, new))
215−#define arch_atomic64_xchg(v, new) (arch_xchg(&((v)->counter), new))
216−
217210 #define arch_atomic_add(i,v) (void)arch_atomic_add_return((i), (v))
218211 #define arch_atomic_sub(i,v) (void)arch_atomic_sub_return((i), (v))
219212
arch/loongarch/include/asm/atomic.h+0−56
@@ -29,21 +29,7 @@ · 28 unmodified lines
2929
3030 #define ATOMIC_INIT(i) { (i) }
3131
32−/*
33− * arch_atomic_read - read atomic variable
34− * @v: pointer of type atomic_t
35− *
36− * Atomically reads the value of @v.
37− */
3832 #define arch_atomic_read(v) READ_ONCE((v)->counter)
39−
40−/*
41− * arch_atomic_set - set atomic variable
42− * @v: pointer of type atomic_t
43− * @i: required value
44− *
45− * Atomically sets the value of @v to @i.
46− */
4733 #define arch_atomic_set(v, i) WRITE_ONCE((v)->counter, (i))
4834
4935 #define ATOMIC_OP(op, I, asm_op) \
@@ -139,14 +125,6 @@ static inline int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u) · 89 unmodified lines
139125 }
140126 #define arch_atomic_fetch_add_unless arch_atomic_fetch_add_unless
141127
142−/*
143− * arch_atomic_sub_if_positive - conditionally subtract integer from atomic variable
144− * @i: integer value to subtract
145− * @v: pointer of type atomic_t
146− *
147− * Atomically test @v and subtract @i if @v is greater or equal than @i.
148− * The function returns the old value of @v minus @i.
149− */
150128 static inline int arch_atomic_sub_if_positive(int i, atomic_t *v)
151129 {
152130 int result;
@@ -181,31 +159,13 @@ static inline int arch_atomic_sub_if_positive(int i, atomic_t *v) · 28 unmodified lines
181159 return result;
182160 }
183161
184−#define arch_atomic_cmpxchg(v, o, n) (arch_cmpxchg(&((v)->counter), (o), (n)))
185−#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), (new)))
186−
187−/*
188− * arch_atomic_dec_if_positive - decrement by 1 if old value positive
189− * @v: pointer of type atomic_t
190− */
191162 #define arch_atomic_dec_if_positive(v) arch_atomic_sub_if_positive(1, v)
192163
193164 #ifdef CONFIG_64BIT
194165
195166 #define ATOMIC64_INIT(i) { (i) }
196167
197−/*
198− * arch_atomic64_read - read atomic variable
199− * @v: pointer of type atomic64_t
200− *
201− */
202168 #define arch_atomic64_read(v) READ_ONCE((v)->counter)
203−
204−/*
205− * arch_atomic64_set - set atomic variable
206− * @v: pointer of type atomic64_t
207− * @i: required value
208− */
209169 #define arch_atomic64_set(v, i) WRITE_ONCE((v)->counter, (i))
210170
211171 #define ATOMIC64_OP(op, I, asm_op) \
@@ -300,14 +260,6 @@ static inline long arch_atomic64_fetch_add_unless(atomic64_t *v, long a, long u) · 88 unmodified lines
300260 }
301261 #define arch_atomic64_fetch_add_unless arch_atomic64_fetch_add_unless
302262
303−/*
304− * arch_atomic64_sub_if_positive - conditionally subtract integer from atomic variable
305− * @i: integer value to subtract
306− * @v: pointer of type atomic64_t
307− *
308− * Atomically test @v and subtract @i if @v is greater or equal than @i.
309− * The function returns the old value of @v minus @i.
310− */
311263 static inline long arch_atomic64_sub_if_positive(long i, atomic64_t *v)
312264 {
313265 long result;
@@ -342,14 +294,6 @@ static inline long arch_atomic64_sub_if_positive(long i, atomic64_t *v) · 28 unmodified lines
342294 return result;
343295 }
344296
345−#define arch_atomic64_cmpxchg(v, o, n) \
346− ((__typeof__((v)->counter))arch_cmpxchg(&((v)->counter), (o), (n)))
347−#define arch_atomic64_xchg(v, new) (arch_xchg(&((v)->counter), (new)))
348−
349−/*
350− * arch_atomic64_dec_if_positive - decrement by 1 if old value positive
351− * @v: pointer of type atomic64_t
352− */
353297 #define arch_atomic64_dec_if_positive(v) arch_atomic64_sub_if_positive(1, v)
354298
355299 #endif /* CONFIG_64BIT */
arch/m68k/include/asm/atomic.h+12−6
@@ -106,6 +106,11 @@ static inline int arch_atomic_fetch_##op(int i, atomic_t * v) \ · 105 unmodified lines
106106 ATOMIC_OPS(add, +=, add)
107107 ATOMIC_OPS(sub, -=, sub)
108108
109+#define arch_atomic_add_return arch_atomic_add_return
110+#define arch_atomic_sub_return arch_atomic_sub_return
111+#define arch_atomic_fetch_add arch_atomic_fetch_add
112+#define arch_atomic_fetch_sub arch_atomic_fetch_sub
113+
109114 #undef ATOMIC_OPS
110115 #define ATOMIC_OPS(op, c_op, asm_op) \
111116 ATOMIC_OP(op, c_op, asm_op) \
@@ -115,6 +120,10 @@ ATOMIC_OPS(and, &=, and) · 3 unmodified lines
115120 ATOMIC_OPS(or, |=, or)
116121 ATOMIC_OPS(xor, ^=, eor)
117122
123+#define arch_atomic_fetch_and arch_atomic_fetch_and
124+#define arch_atomic_fetch_or arch_atomic_fetch_or
125+#define arch_atomic_fetch_xor arch_atomic_fetch_xor
126+
118127 #undef ATOMIC_OPS
119128 #undef ATOMIC_FETCH_OP
120129 #undef ATOMIC_OP_RETURN
@@ -158,12 +167,7 @@ static inline int arch_atomic_inc_and_test(atomic_t *v) · 37 unmodified lines
158167 }
159168 #define arch_atomic_inc_and_test arch_atomic_inc_and_test
160169
161−#ifdef CONFIG_RMW_INSNS
162−
163−#define arch_atomic_cmpxchg(v, o, n) ((int)arch_cmpxchg(&((v)->counter), (o), (n)))
164−#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), new))
165−
166−#else /* !CONFIG_RMW_INSNS */
170+#ifndef CONFIG_RMW_INSNS
167171
168172 static inline int arch_atomic_cmpxchg(atomic_t *v, int old, int new)
169173 {
@@ -177,6 +181,7 @@ static inline int arch_atomic_cmpxchg(atomic_t *v, int old, int new) · 7 unmodified lines
177181 local_irq_restore(flags);
178182 return prev;
179183 }
184+#define arch_atomic_cmpxchg arch_atomic_cmpxchg
180185
181186 static inline int arch_atomic_xchg(atomic_t *v, int new)
182187 {
@@ -189,6 +194,7 @@ static inline int arch_atomic_xchg(atomic_t *v, int new) · 6 unmodified lines
189194 local_irq_restore(flags);
190195 return prev;
191196 }
197+#define arch_atomic_xchg arch_atomic_xchg
192198
193199 #endif /* !CONFIG_RMW_INSNS */
194200
arch/mips/include/asm/atomic.h+0−11
@@ -33,17 +33,6 @@ static __always_inline void arch_##pfx##_set(pfx##_t *v, type i) \ · 32 unmodified lines
3333 { \
3434 WRITE_ONCE(v->counter, i); \
3535 } \
36− \
37−static __always_inline type \
38−arch_##pfx##_cmpxchg(pfx##_t *v, type o, type n) \
39−{ \
40− return arch_cmpxchg(&v->counter, o, n); \
41−} \
42− \
43−static __always_inline type arch_##pfx##_xchg(pfx##_t *v, type n) \
44−{ \
45− return arch_xchg(&v->counter, n); \
46−}
4736
4837 ATOMIC_OPS(atomic, int)
4938
arch/openrisc/include/asm/atomic.h+0−3
@@ -130,7 +130,4 @@ static inline int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u) · 129 unmodified lines
130130
131131 #include <asm/cmpxchg.h>
132132
133−#define arch_atomic_xchg(ptr, v) (arch_xchg(&(ptr)->counter, (v)))
134−#define arch_atomic_cmpxchg(v, old, new) (arch_cmpxchg(&((v)->counter), (old), (new)))
135−
136133 #endif /* __ASM_OPENRISC_ATOMIC_H */
arch/parisc/include/asm/atomic.h+18−9
@@ -73,10 +73,6 @@ static __inline__ int arch_atomic_read(const atomic_t *v) · 72 unmodified lines
7373 return READ_ONCE((v)->counter);
7474 }
7575
76−/* exported interface */
77−#define arch_atomic_cmpxchg(v, o, n) (arch_cmpxchg(&((v)->counter), (o), (n)))
78−#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), new))
79−
8076 #define ATOMIC_OP(op, c_op) \
8177 static __inline__ void arch_atomic_##op(int i, atomic_t *v) \
8278 { \
@@ -122,6 +118,11 @@ static __inline__ int arch_atomic_fetch_##op(int i, atomic_t *v) \ · 39 unmodified lines
122118 ATOMIC_OPS(add, +=)
123119 ATOMIC_OPS(sub, -=)
124120
121+#define arch_atomic_add_return arch_atomic_add_return
122+#define arch_atomic_sub_return arch_atomic_sub_return
123+#define arch_atomic_fetch_add arch_atomic_fetch_add
124+#define arch_atomic_fetch_sub arch_atomic_fetch_sub
125+
125126 #undef ATOMIC_OPS
126127 #define ATOMIC_OPS(op, c_op) \
127128 ATOMIC_OP(op, c_op) \
@@ -131,6 +132,10 @@ ATOMIC_OPS(and, &=) · 3 unmodified lines
131132 ATOMIC_OPS(or, |=)
132133 ATOMIC_OPS(xor, ^=)
133134
135+#define arch_atomic_fetch_and arch_atomic_fetch_and
136+#define arch_atomic_fetch_or arch_atomic_fetch_or
137+#define arch_atomic_fetch_xor arch_atomic_fetch_xor
138+
134139 #undef ATOMIC_OPS
135140 #undef ATOMIC_FETCH_OP
136141 #undef ATOMIC_OP_RETURN
@@ -185,6 +190,11 @@ static __inline__ s64 arch_atomic64_fetch_##op(s64 i, atomic64_t *v) \ · 48 unmodified lines
185190 ATOMIC64_OPS(add, +=)
186191 ATOMIC64_OPS(sub, -=)
187192
193+#define arch_atomic64_add_return arch_atomic64_add_return
194+#define arch_atomic64_sub_return arch_atomic64_sub_return
195+#define arch_atomic64_fetch_add arch_atomic64_fetch_add
196+#define arch_atomic64_fetch_sub arch_atomic64_fetch_sub
197+
188198 #undef ATOMIC64_OPS
189199 #define ATOMIC64_OPS(op, c_op) \
190200 ATOMIC64_OP(op, c_op) \
@@ -194,6 +204,10 @@ ATOMIC64_OPS(and, &=) · 3 unmodified lines
194204 ATOMIC64_OPS(or, |=)
195205 ATOMIC64_OPS(xor, ^=)
196206
207+#define arch_atomic64_fetch_and arch_atomic64_fetch_and
208+#define arch_atomic64_fetch_or arch_atomic64_fetch_or
209+#define arch_atomic64_fetch_xor arch_atomic64_fetch_xor
210+
197211 #undef ATOMIC64_OPS
198212 #undef ATOMIC64_FETCH_OP
199213 #undef ATOMIC64_OP_RETURN
@@ -218,11 +232,6 @@ arch_atomic64_read(const atomic64_t *v) · 18 unmodified lines
218232 return READ_ONCE((v)->counter);
219233 }
220234
221−/* exported interface */
222−#define arch_atomic64_cmpxchg(v, o, n) \
223− ((__typeof__((v)->counter))arch_cmpxchg(&((v)->counter), (o), (n)))
224−#define arch_atomic64_xchg(v, new) (arch_xchg(&((v)->counter), new))
225−
226235 #endif /* !CONFIG_64BIT */
227236
228237
arch/powerpc/include/asm/atomic.h+0−24
@@ -126,18 +126,6 @@ ATOMIC_OPS(xor, xor, "", K) · 125 unmodified lines
126126 #undef ATOMIC_OP_RETURN_RELAXED
127127 #undef ATOMIC_OP
128128
129−#define arch_atomic_cmpxchg(v, o, n) \
130− (arch_cmpxchg(&((v)->counter), (o), (n)))
131−#define arch_atomic_cmpxchg_relaxed(v, o, n) \
132− arch_cmpxchg_relaxed(&((v)->counter), (o), (n))
133−#define arch_atomic_cmpxchg_acquire(v, o, n) \
134− arch_cmpxchg_acquire(&((v)->counter), (o), (n))
135−
136−#define arch_atomic_xchg(v, new) \
137− (arch_xchg(&((v)->counter), new))
138−#define arch_atomic_xchg_relaxed(v, new) \
139− arch_xchg_relaxed(&((v)->counter), (new))
140−
141129 /**
142130 * atomic_fetch_add_unless - add unless the number is a given value
143131 * @v: pointer of type atomic_t
@@ -396,18 +384,6 @@ static __inline__ s64 arch_atomic64_dec_if_positive(atomic64_t *v) · 252 unmodified lines
396384 }
397385 #define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive
398386
399−#define arch_atomic64_cmpxchg(v, o, n) \
400− (arch_cmpxchg(&((v)->counter), (o), (n)))
401−#define arch_atomic64_cmpxchg_relaxed(v, o, n) \
402− arch_cmpxchg_relaxed(&((v)->counter), (o), (n))
403−#define arch_atomic64_cmpxchg_acquire(v, o, n) \
404− arch_cmpxchg_acquire(&((v)->counter), (o), (n))
405−
406−#define arch_atomic64_xchg(v, new) \
407− (arch_xchg(&((v)->counter), new))
408−#define arch_atomic64_xchg_relaxed(v, new) \
409− arch_xchg_relaxed(&((v)->counter), (new))
410−
411387 /**
412388 * atomic64_fetch_add_unless - add unless the number is a given value
413389 * @v: pointer of type atomic64_t
arch/powerpc/kernel/smp.c+6−6
@@ -417,9 +417,9 @@ noinstr static void nmi_ipi_lock_start(unsigned long *flags) · 416 unmodified lines
417417 {
418418 raw_local_irq_save(*flags);
419419 hard_irq_disable();
420− while (arch_atomic_cmpxchg(&__nmi_ipi_lock, 0, 1) == 1) {
420+ while (raw_atomic_cmpxchg(&__nmi_ipi_lock, 0, 1) == 1) {
421421 raw_local_irq_restore(*flags);
422− spin_until_cond(arch_atomic_read(&__nmi_ipi_lock) == 0);
422+ spin_until_cond(raw_atomic_read(&__nmi_ipi_lock) == 0);
423423 raw_local_irq_save(*flags);
424424 hard_irq_disable();
425425 }
@@ -427,15 +427,15 @@ noinstr static void nmi_ipi_lock_start(unsigned long *flags) · 1 unmodified line
427427
428428 noinstr static void nmi_ipi_lock(void)
429429 {
430− while (arch_atomic_cmpxchg(&__nmi_ipi_lock, 0, 1) == 1)
431− spin_until_cond(arch_atomic_read(&__nmi_ipi_lock) == 0);
430+ while (raw_atomic_cmpxchg(&__nmi_ipi_lock, 0, 1) == 1)
431+ spin_until_cond(raw_atomic_read(&__nmi_ipi_lock) == 0);
432432 }
433433
434434 noinstr static void nmi_ipi_unlock(void)
435435 {
436436 smp_mb();
437− WARN_ON(arch_atomic_read(&__nmi_ipi_lock) != 1);
438− arch_atomic_set(&__nmi_ipi_lock, 0);
437+ WARN_ON(raw_atomic_read(&__nmi_ipi_lock) != 1);
438+ raw_atomic_set(&__nmi_ipi_lock, 0);
439439 }
440440
441441 noinstr static void nmi_ipi_unlock_end(unsigned long *flags)
arch/riscv/include/asm/atomic.h+0−72
@@ -238,78 +238,6 @@ static __always_inline s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, · 237 unmodified lines
238238 #define arch_atomic64_fetch_add_unless arch_atomic64_fetch_add_unless
239239 #endif
240240
241−/*
242− * atomic_{cmp,}xchg is required to have exactly the same ordering semantics as
243− * {cmp,}xchg and the operations that return, so they need a full barrier.
244− */
245−#define ATOMIC_OP(c_t, prefix, size) \
246−static __always_inline \
247−c_t arch_atomic##prefix##_xchg_relaxed(atomic##prefix##_t *v, c_t n) \
248−{ \
249− return __xchg_relaxed(&(v->counter), n, size); \
250−} \
251−static __always_inline \
252−c_t arch_atomic##prefix##_xchg_acquire(atomic##prefix##_t *v, c_t n) \
253−{ \
254− return __xchg_acquire(&(v->counter), n, size); \
255−} \
256−static __always_inline \
257−c_t arch_atomic##prefix##_xchg_release(atomic##prefix##_t *v, c_t n) \
258−{ \
259− return __xchg_release(&(v->counter), n, size); \
260−} \
261−static __always_inline \
262−c_t arch_atomic##prefix##_xchg(atomic##prefix##_t *v, c_t n) \
263−{ \
264− return __arch_xchg(&(v->counter), n, size); \
265−} \
266−static __always_inline \
267−c_t arch_atomic##prefix##_cmpxchg_relaxed(atomic##prefix##_t *v, \
268− c_t o, c_t n) \
269−{ \
270− return __cmpxchg_relaxed(&(v->counter), o, n, size); \
271−} \
272−static __always_inline \
273−c_t arch_atomic##prefix##_cmpxchg_acquire(atomic##prefix##_t *v, \
274− c_t o, c_t n) \
275−{ \
276− return __cmpxchg_acquire(&(v->counter), o, n, size); \
277−} \
278−static __always_inline \
279−c_t arch_atomic##prefix##_cmpxchg_release(atomic##prefix##_t *v, \
280− c_t o, c_t n) \
281−{ \
282− return __cmpxchg_release(&(v->counter), o, n, size); \
283−} \
284−static __always_inline \
285−c_t arch_atomic##prefix##_cmpxchg(atomic##prefix##_t *v, c_t o, c_t n) \
286−{ \
287− return __cmpxchg(&(v->counter), o, n, size); \
288−}
289−
290−#ifdef CONFIG_GENERIC_ATOMIC64
291−#define ATOMIC_OPS() \
292− ATOMIC_OP(int, , 4)
293−#else
294−#define ATOMIC_OPS() \
295− ATOMIC_OP(int, , 4) \
296− ATOMIC_OP(s64, 64, 8)
297−#endif
298−
299−ATOMIC_OPS()
300−
301−#define arch_atomic_xchg_relaxed arch_atomic_xchg_relaxed
302−#define arch_atomic_xchg_acquire arch_atomic_xchg_acquire
303−#define arch_atomic_xchg_release arch_atomic_xchg_release
304−#define arch_atomic_xchg arch_atomic_xchg
305−#define arch_atomic_cmpxchg_relaxed arch_atomic_cmpxchg_relaxed
306−#define arch_atomic_cmpxchg_acquire arch_atomic_cmpxchg_acquire
307−#define arch_atomic_cmpxchg_release arch_atomic_cmpxchg_release
308−#define arch_atomic_cmpxchg arch_atomic_cmpxchg
309−
310−#undef ATOMIC_OPS
311−#undef ATOMIC_OP
312−
313241 static __always_inline bool arch_atomic_inc_unless_negative(atomic_t *v)
314242 {
315243 int prev, rc;
arch/s390/include/asm/cmpxchg.h+6−26
@@ -190,38 +190,18 @@ static __always_inline unsigned long __cmpxchg(unsigned long address, · 189 unmodified lines
190190 #define arch_cmpxchg_local arch_cmpxchg
191191 #define arch_cmpxchg64_local arch_cmpxchg
192192
193−#define system_has_cmpxchg_double() 1
193+#define system_has_cmpxchg128() 1
194194
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)
195+static __always_inline u128 arch_cmpxchg128(volatile u128 *ptr, u128 old, u128 new)
198196 {
199− union register_pair old = { .even = o1, .odd = o2, };
200− union register_pair new = { .even = n1, .odd = n2, };
201− int cc;
202−
203197 asm volatile(
204198 " 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)
199+ : [old] "+d" (old), [ptr] "+QS" (*ptr)
200+ : [new] "d" (new)
210201 : "memory", "cc");
211− return !cc;
202+ return old;
212203 }
213204
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−})
205+#define arch_cmpxchg128 arch_cmpxchg128
226206
227207 #endif /* __ASM_CMPXCHG_H */
arch/s390/include/asm/cpu_mf.h+1−1
@@ -140,7 +140,7 @@ union hws_trailer_header { · 139 unmodified lines
140140 unsigned int dsdes:16; /* 48-63: size of diagnostic SDE */
141141 unsigned long long overflow; /* 64 - Overflow Count */
142142 };
143− __uint128_t val;
143+ u128 val;
144144 };
145145
146146 struct hws_trailer_entry {
arch/s390/include/asm/percpu.h+16−18
@@ -148,6 +148,22 @@ · 147 unmodified lines
148148 #define this_cpu_cmpxchg_4(pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval)
149149 #define this_cpu_cmpxchg_8(pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval)
150150
151+#define this_cpu_cmpxchg64(pcp, o, n) this_cpu_cmpxchg_8(pcp, o, n)
152+
153+#define this_cpu_cmpxchg128(pcp, oval, nval) \
154+({ \
155+ typedef typeof(pcp) pcp_op_T__; \
156+ u128 old__, new__, ret__; \
157+ pcp_op_T__ *ptr__; \
158+ old__ = oval; \
159+ new__ = nval; \
160+ preempt_disable_notrace(); \
161+ ptr__ = raw_cpu_ptr(&(pcp)); \
162+ ret__ = cmpxchg128((void *)ptr__, old__, new__); \
163+ preempt_enable_notrace(); \
164+ ret__; \
165+})
166+
151167 #define arch_this_cpu_xchg(pcp, nval) \
152168 ({ \
153169 typeof(pcp) *ptr__; \
@@ -164,24 +180,6 @@ · 10 unmodified lines
164180 #define this_cpu_xchg_4(pcp, nval) arch_this_cpu_xchg(pcp, nval)
165181 #define this_cpu_xchg_8(pcp, nval) arch_this_cpu_xchg(pcp, nval)
166182
167−#define arch_this_cpu_cmpxchg_double(pcp1, pcp2, o1, o2, n1, n2) \
168−({ \
169− typeof(pcp1) *p1__; \
170− typeof(pcp2) *p2__; \
171− int ret__; \
172− \
173− preempt_disable_notrace(); \
174− p1__ = raw_cpu_ptr(&(pcp1)); \
175− p2__ = raw_cpu_ptr(&(pcp2)); \
176− ret__ = __cmpxchg_double((unsigned long)p1__, (unsigned long)p2__, \
177− (unsigned long)(o1), (unsigned long)(o2), \
178− (unsigned long)(n1), (unsigned long)(n2)); \
179− preempt_enable_notrace(); \
180− ret__; \
181−})
182−
183−#define this_cpu_cmpxchg_double_8 arch_this_cpu_cmpxchg_double
184−
185183 #include <asm-generic/percpu.h>
186184
187185 #endif /* __ARCH_S390_PERCPU__ */
arch/s390/kernel/perf_cpum_sf.c+3−13
@@ -1271,16 +1271,6 @@ static void hw_collect_samples(struct perf_event *event, unsigned long *sdbt, · 1270 unmodified lines
12711271 }
12721272 }
12731273
1274−static inline __uint128_t __cdsg(__uint128_t *ptr, __uint128_t old, __uint128_t new)
1275−{
1276− asm volatile(
1277− " cdsg %[old],%[new],%[ptr]\n"
1278− : [old] "+d" (old), [ptr] "+QS" (*ptr)
1279− : [new] "d" (new)
1280− : "memory", "cc");
1281− return old;
1282−}
1283−
12841274 /* hw_perf_event_update() - Process sampling buffer
12851275 * @event: The perf event
12861276 * @flush_all: Flag to also flush partially filled sample-data-blocks
@@ -1352,7 +1342,7 @@ static void hw_perf_event_update(struct perf_event *event, int flush_all) · 65 unmodified lines
13521342 new.f = 0;
13531343 new.a = 1;
13541344 new.overflow = 0;
1355− prev.val = __cdsg(&te->header.val, old.val, new.val);
1345+ prev.val = cmpxchg128(&te->header.val, old.val, new.val);
13561346 } while (prev.val != old.val);
13571347
13581348 /* Advance to next sample-data-block */
@@ -1562,7 +1552,7 @@ static bool aux_set_alert(struct aux_buffer *aux, unsigned long alert_index, · 203 unmodified lines
15621552 }
15631553 new.a = 1;
15641554 new.overflow = 0;
1565− prev.val = __cdsg(&te->header.val, old.val, new.val);
1555+ prev.val = cmpxchg128(&te->header.val, old.val, new.val);
15661556 } while (prev.val != old.val);
15671557 return true;
15681558 }
@@ -1636,7 +1626,7 @@ static bool aux_reset_buffer(struct aux_buffer *aux, unsigned long range, · 67 unmodified lines
16361626 new.a = 1;
16371627 else
16381628 new.a = 0;
1639− prev.val = __cdsg(&te->header.val, old.val, new.val);
1629+ prev.val = cmpxchg128(&te->header.val, old.val, new.val);
16401630 } while (prev.val != old.val);
16411631 *overflow += orig_overflow;
16421632 }
arch/sh/include/asm/atomic-grb.h+9−0
@@ -71,6 +71,11 @@ static inline int arch_atomic_fetch_##op(int i, atomic_t *v) \ · 70 unmodified lines
7171 ATOMIC_OPS(add)
7272 ATOMIC_OPS(sub)
7373
74+#define arch_atomic_add_return arch_atomic_add_return
75+#define arch_atomic_sub_return arch_atomic_sub_return
76+#define arch_atomic_fetch_add arch_atomic_fetch_add
77+#define arch_atomic_fetch_sub arch_atomic_fetch_sub
78+
7479 #undef ATOMIC_OPS
7580 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_FETCH_OP(op)
7681
@@ -78,6 +83,10 @@ ATOMIC_OPS(and) · 1 unmodified line
7883 ATOMIC_OPS(or)
7984 ATOMIC_OPS(xor)
8085
86+#define arch_atomic_fetch_and arch_atomic_fetch_and
87+#define arch_atomic_fetch_or arch_atomic_fetch_or
88+#define arch_atomic_fetch_xor arch_atomic_fetch_xor
89+
8190 #undef ATOMIC_OPS
8291 #undef ATOMIC_FETCH_OP
8392 #undef ATOMIC_OP_RETURN
arch/sh/include/asm/atomic-irq.h+9−0
@@ -55,6 +55,11 @@ static inline int arch_atomic_fetch_##op(int i, atomic_t *v) \ · 54 unmodified lines
5555 ATOMIC_OPS(add, +=)
5656 ATOMIC_OPS(sub, -=)
5757
58+#define arch_atomic_add_return arch_atomic_add_return
59+#define arch_atomic_sub_return arch_atomic_sub_return
60+#define arch_atomic_fetch_add arch_atomic_fetch_add
61+#define arch_atomic_fetch_sub arch_atomic_fetch_sub
62+
5863 #undef ATOMIC_OPS
5964 #define ATOMIC_OPS(op, c_op) \
6065 ATOMIC_OP(op, c_op) \
@@ -64,6 +69,10 @@ ATOMIC_OPS(and, &=) · 3 unmodified lines
6469 ATOMIC_OPS(or, |=)
6570 ATOMIC_OPS(xor, ^=)
6671
72+#define arch_atomic_fetch_and arch_atomic_fetch_and
73+#define arch_atomic_fetch_or arch_atomic_fetch_or
74+#define arch_atomic_fetch_xor arch_atomic_fetch_xor
75+
6776 #undef ATOMIC_OPS
6877 #undef ATOMIC_FETCH_OP
6978 #undef ATOMIC_OP_RETURN
arch/sh/include/asm/atomic-llsc.h+9−0
@@ -73,6 +73,11 @@ static inline int arch_atomic_fetch_##op(int i, atomic_t *v) \ · 72 unmodified lines
7373 ATOMIC_OPS(add)
7474 ATOMIC_OPS(sub)
7575
76+#define arch_atomic_add_return arch_atomic_add_return
77+#define arch_atomic_sub_return arch_atomic_sub_return
78+#define arch_atomic_fetch_add arch_atomic_fetch_add
79+#define arch_atomic_fetch_sub arch_atomic_fetch_sub
80+
7681 #undef ATOMIC_OPS
7782 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_FETCH_OP(op)
7883
@@ -80,6 +85,10 @@ ATOMIC_OPS(and) · 1 unmodified line
8085 ATOMIC_OPS(or)
8186 ATOMIC_OPS(xor)
8287
88+#define arch_atomic_fetch_and arch_atomic_fetch_and
89+#define arch_atomic_fetch_or arch_atomic_fetch_or
90+#define arch_atomic_fetch_xor arch_atomic_fetch_xor
91+
8392 #undef ATOMIC_OPS
8493 #undef ATOMIC_FETCH_OP
8594 #undef ATOMIC_OP_RETURN
arch/sh/include/asm/atomic.h+0−3
@@ -30,9 +30,6 @@ · 29 unmodified lines
3030 #include <asm/atomic-irq.h>
3131 #endif
3232
33−#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), new))
34−#define arch_atomic_cmpxchg(v, o, n) (arch_cmpxchg(&((v)->counter), (o), (n)))
35−
3633 #endif /* CONFIG_CPU_J2 */
3734
3835 #endif /* __ASM_SH_ATOMIC_H */
arch/sparc/include/asm/atomic_32.h+16−2
@@ -19,17 +19,31 @@ · 18 unmodified lines
1919 #include <asm-generic/atomic64.h>
2020
2121 int arch_atomic_add_return(int, atomic_t *);
22+#define arch_atomic_add_return arch_atomic_add_return
23+
2224 int arch_atomic_fetch_add(int, atomic_t *);
25+#define arch_atomic_fetch_add arch_atomic_fetch_add
26+
2327 int arch_atomic_fetch_and(int, atomic_t *);
28+#define arch_atomic_fetch_and arch_atomic_fetch_and
29+
2430 int arch_atomic_fetch_or(int, atomic_t *);
31+#define arch_atomic_fetch_or arch_atomic_fetch_or
32+
2533 int arch_atomic_fetch_xor(int, atomic_t *);
34+#define arch_atomic_fetch_xor arch_atomic_fetch_xor
35+
2636 int arch_atomic_cmpxchg(atomic_t *, int, int);
37+#define arch_atomic_cmpxchg arch_atomic_cmpxchg
38+
2739 int arch_atomic_xchg(atomic_t *, int);
28−int arch_atomic_fetch_add_unless(atomic_t *, int, int);
29−void arch_atomic_set(atomic_t *, int);
40+#define arch_atomic_xchg arch_atomic_xchg
3041
42+int arch_atomic_fetch_add_unless(atomic_t *, int, int);
3143 #define arch_atomic_fetch_add_unless arch_atomic_fetch_add_unless
3244
45+void arch_atomic_set(atomic_t *, int);
46+
3347 #define arch_atomic_set_release(v, i) arch_atomic_set((v), (i))
3448
3549 #define arch_atomic_read(v) READ_ONCE((v)->counter)
arch/sparc/include/asm/atomic_64.h+18−11
@@ -37,6 +37,16 @@ s64 arch_atomic64_fetch_##op(s64, atomic64_t *); · 36 unmodified lines
3737 ATOMIC_OPS(add)
3838 ATOMIC_OPS(sub)
3939
40+#define arch_atomic_add_return arch_atomic_add_return
41+#define arch_atomic_sub_return arch_atomic_sub_return
42+#define arch_atomic_fetch_add arch_atomic_fetch_add
43+#define arch_atomic_fetch_sub arch_atomic_fetch_sub
44+
45+#define arch_atomic64_add_return arch_atomic64_add_return
46+#define arch_atomic64_sub_return arch_atomic64_sub_return
47+#define arch_atomic64_fetch_add arch_atomic64_fetch_add
48+#define arch_atomic64_fetch_sub arch_atomic64_fetch_sub
49+
4050 #undef ATOMIC_OPS
4151 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_FETCH_OP(op)
4252
@@ -44,22 +54,19 @@ ATOMIC_OPS(and) · 1 unmodified line
4454 ATOMIC_OPS(or)
4555 ATOMIC_OPS(xor)
4656
57+#define arch_atomic_fetch_and arch_atomic_fetch_and
58+#define arch_atomic_fetch_or arch_atomic_fetch_or
59+#define arch_atomic_fetch_xor arch_atomic_fetch_xor
60+
61+#define arch_atomic64_fetch_and arch_atomic64_fetch_and
62+#define arch_atomic64_fetch_or arch_atomic64_fetch_or
63+#define arch_atomic64_fetch_xor arch_atomic64_fetch_xor
64+
4765 #undef ATOMIC_OPS
4866 #undef ATOMIC_FETCH_OP
4967 #undef ATOMIC_OP_RETURN
5068 #undef ATOMIC_OP
5169
52−#define arch_atomic_cmpxchg(v, o, n) (arch_cmpxchg(&((v)->counter), (o), (n)))
53−
54−static inline int arch_atomic_xchg(atomic_t *v, int new)
55−{
56− return arch_xchg(&v->counter, new);
57−}
58−
59−#define arch_atomic64_cmpxchg(v, o, n) \
60− ((__typeof__((v)->counter))arch_cmpxchg(&((v)->counter), (o), (n)))
61−#define arch_atomic64_xchg(v, new) (arch_xchg(&((v)->counter), new))
62−
6370 s64 arch_atomic64_dec_if_positive(atomic64_t *v);
6471 #define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive
6572
arch/x86/include/asm/atomic.h+0−87
@@ -14,12 +14,6 @@ · 13 unmodified lines
1414 * resource counting etc..
1515 */
1616
17−/**
18− * arch_atomic_read - read atomic variable
19− * @v: pointer of type atomic_t
20− *
21− * Atomically reads the value of @v.
22− */
2317 static __always_inline int arch_atomic_read(const atomic_t *v)
2418 {
2519 /*
@@ -29,25 +23,11 @@ static __always_inline int arch_atomic_read(const atomic_t *v) · 3 unmodified lines
2923 return __READ_ONCE((v)->counter);
3024 }
3125
32−/**
33− * arch_atomic_set - set atomic variable
34− * @v: pointer of type atomic_t
35− * @i: required value
36− *
37− * Atomically sets the value of @v to @i.
38− */
3926 static __always_inline void arch_atomic_set(atomic_t *v, int i)
4027 {
4128 __WRITE_ONCE(v->counter, i);
4229 }
4330
44−/**
45− * arch_atomic_add - add integer to atomic variable
46− * @i: integer value to add
47− * @v: pointer of type atomic_t
48− *
49− * Atomically adds @i to @v.
50− */
5131 static __always_inline void arch_atomic_add(int i, atomic_t *v)
5232 {
5333 asm volatile(LOCK_PREFIX "addl %1,%0"
@@ -55,13 +35,6 @@ static __always_inline void arch_atomic_add(int i, atomic_t *v) · 1 unmodified line
5535 : "ir" (i) : "memory");
5636 }
5737
58−/**
59− * arch_atomic_sub - subtract integer from atomic variable
60− * @i: integer value to subtract
61− * @v: pointer of type atomic_t
62− *
63− * Atomically subtracts @i from @v.
64− */
6538 static __always_inline void arch_atomic_sub(int i, atomic_t *v)
6639 {
6740 asm volatile(LOCK_PREFIX "subl %1,%0"
@@ -69,27 +42,12 @@ static __always_inline void arch_atomic_sub(int i, atomic_t *v) · 1 unmodified line
6942 : "ir" (i) : "memory");
7043 }
7144
72−/**
73− * arch_atomic_sub_and_test - subtract value from variable and test result
74− * @i: integer value to subtract
75− * @v: pointer of type atomic_t
76− *
77− * Atomically subtracts @i from @v and returns
78− * true if the result is zero, or false for all
79− * other cases.
80− */
8145 static __always_inline bool arch_atomic_sub_and_test(int i, atomic_t *v)
8246 {
8347 return GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, e, "er", i);
8448 }
8549 #define arch_atomic_sub_and_test arch_atomic_sub_and_test
8650
87−/**
88− * arch_atomic_inc - increment atomic variable
89− * @v: pointer of type atomic_t
90− *
91− * Atomically increments @v by 1.
92− */
9351 static __always_inline void arch_atomic_inc(atomic_t *v)
9452 {
9553 asm volatile(LOCK_PREFIX "incl %0"
@@ -97,12 +55,6 @@ static __always_inline void arch_atomic_inc(atomic_t *v) · 1 unmodified line
9755 }
9856 #define arch_atomic_inc arch_atomic_inc
9957
100−/**
101− * arch_atomic_dec - decrement atomic variable
102− * @v: pointer of type atomic_t
103− *
104− * Atomically decrements @v by 1.
105− */
10658 static __always_inline void arch_atomic_dec(atomic_t *v)
10759 {
10860 asm volatile(LOCK_PREFIX "decl %0"
@@ -110,69 +62,30 @@ static __always_inline void arch_atomic_dec(atomic_t *v) · 1 unmodified line
11062 }
11163 #define arch_atomic_dec arch_atomic_dec
11264
113−/**
114− * arch_atomic_dec_and_test - decrement and test
115− * @v: pointer of type atomic_t
116− *
117− * Atomically decrements @v by 1 and
118− * returns true if the result is 0, or false for all other
119− * cases.
120− */
12165 static __always_inline bool arch_atomic_dec_and_test(atomic_t *v)
12266 {
12367 return GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, e);
12468 }
12569 #define arch_atomic_dec_and_test arch_atomic_dec_and_test
12670
127−/**
128− * arch_atomic_inc_and_test - increment and test
129− * @v: pointer of type atomic_t
130− *
131− * Atomically increments @v by 1
132− * and returns true if the result is zero, or false for all
133− * other cases.
134− */
13571 static __always_inline bool arch_atomic_inc_and_test(atomic_t *v)
13672 {
13773 return GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, e);
13874 }
13975 #define arch_atomic_inc_and_test arch_atomic_inc_and_test
14076
141−/**
142− * arch_atomic_add_negative - add and test if negative
143− * @i: integer value to add
144− * @v: pointer of type atomic_t
145− *
146− * Atomically adds @i to @v and returns true
147− * if the result is negative, or false when
148− * result is greater than or equal to zero.
149− */
15077 static __always_inline bool arch_atomic_add_negative(int i, atomic_t *v)
15178 {
15279 return GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, s, "er", i);
15380 }
15481 #define arch_atomic_add_negative arch_atomic_add_negative
15582
156−/**
157− * arch_atomic_add_return - add integer and return
158− * @i: integer value to add
159− * @v: pointer of type atomic_t
160− *
161− * Atomically adds @i to @v and returns @i + @v
162− */
16383 static __always_inline int arch_atomic_add_return(int i, atomic_t *v)
16484 {
16585 return i + xadd(&v->counter, i);
16686 }
16787 #define arch_atomic_add_return arch_atomic_add_return
16888
169−/**
170− * arch_atomic_sub_return - subtract integer and return
171− * @v: pointer of type atomic_t
172− * @i: integer value to subtract
173− *
174− * Atomically subtracts @i from @v and returns @v - @i
175− */
17689 static __always_inline int arch_atomic_sub_return(int i, atomic_t *v)
17790 {
17891 return arch_atomic_add_return(-i, v);
arch/x86/include/asm/atomic64_32.h+0−76
@@ -61,30 +61,12 @@ ATOMIC64_DECL(add_unless); · 60 unmodified lines
6161 #undef __ATOMIC64_DECL
6262 #undef ATOMIC64_EXPORT
6363
64−/**
65− * arch_atomic64_cmpxchg - cmpxchg atomic64 variable
66− * @v: pointer to type atomic64_t
67− * @o: expected value
68− * @n: new value
69− *
70− * Atomically sets @v to @n if it was equal to @o and returns
71− * the old value.
72− */
73−
7464 static __always_inline s64 arch_atomic64_cmpxchg(atomic64_t *v, s64 o, s64 n)
7565 {
7666 return arch_cmpxchg64(&v->counter, o, n);
7767 }
7868 #define arch_atomic64_cmpxchg arch_atomic64_cmpxchg
7969
80−/**
81− * arch_atomic64_xchg - xchg atomic64 variable
82− * @v: pointer to type atomic64_t
83− * @n: value to assign
84− *
85− * Atomically xchgs the value of @v to @n and returns
86− * the old value.
87− */
8870 static __always_inline s64 arch_atomic64_xchg(atomic64_t *v, s64 n)
8971 {
9072 s64 o;
@@ -97,13 +79,6 @@ static __always_inline s64 arch_atomic64_xchg(atomic64_t *v, s64 n) · 6 unmodified lines
9779 }
9880 #define arch_atomic64_xchg arch_atomic64_xchg
9981
100−/**
101− * arch_atomic64_set - set atomic64 variable
102− * @v: pointer to type atomic64_t
103− * @i: value to assign
104− *
105− * Atomically sets the value of @v to @n.
106− */
10782 static __always_inline void arch_atomic64_set(atomic64_t *v, s64 i)
10883 {
10984 unsigned high = (unsigned)(i >> 32);
@@ -113,12 +88,6 @@ static __always_inline void arch_atomic64_set(atomic64_t *v, s64 i) · 3 unmodified lines
11388 : "eax", "edx", "memory");
11489 }
11590
116−/**
117− * arch_atomic64_read - read atomic64 variable
118− * @v: pointer to type atomic64_t
119− *
120− * Atomically reads the value of @v and returns it.
121− */
12291 static __always_inline s64 arch_atomic64_read(const atomic64_t *v)
12392 {
12493 s64 r;
@@ -126,13 +95,6 @@ static __always_inline s64 arch_atomic64_read(const atomic64_t *v) · 1 unmodified line
12695 return r;
12796 }
12897
129−/**
130− * arch_atomic64_add_return - add and return
131− * @i: integer value to add
132− * @v: pointer to type atomic64_t
133− *
134− * Atomically adds @i to @v and returns @i + *@v
135− */
13698 static __always_inline s64 arch_atomic64_add_return(s64 i, atomic64_t *v)
13799 {
138100 alternative_atomic64(add_return,
@@ -142,9 +104,6 @@ static __always_inline s64 arch_atomic64_add_return(s64 i, atomic64_t *v) · 3 unmodified lines
142104 }
143105 #define arch_atomic64_add_return arch_atomic64_add_return
144106
145−/*
146− * Other variants with different arithmetic operators:
147− */
148107 static __always_inline s64 arch_atomic64_sub_return(s64 i, atomic64_t *v)
149108 {
150109 alternative_atomic64(sub_return,
@@ -172,13 +131,6 @@ static __always_inline s64 arch_atomic64_dec_return(atomic64_t *v) · 21 unmodified lines
172131 }
173132 #define arch_atomic64_dec_return arch_atomic64_dec_return
174133
175−/**
176− * arch_atomic64_add - add integer to atomic64 variable
177− * @i: integer value to add
178− * @v: pointer to type atomic64_t
179− *
180− * Atomically adds @i to @v.
181− */
182134 static __always_inline s64 arch_atomic64_add(s64 i, atomic64_t *v)
183135 {
184136 __alternative_atomic64(add, add_return,
@@ -187,13 +139,6 @@ static __always_inline s64 arch_atomic64_add(s64 i, atomic64_t *v) · 2 unmodified lines
187139 return i;
188140 }
189141
190−/**
191− * arch_atomic64_sub - subtract the atomic64 variable
192− * @i: integer value to subtract
193− * @v: pointer to type atomic64_t
194− *
195− * Atomically subtracts @i from @v.
196− */
197142 static __always_inline s64 arch_atomic64_sub(s64 i, atomic64_t *v)
198143 {
199144 __alternative_atomic64(sub, sub_return,
@@ -202,12 +147,6 @@ static __always_inline s64 arch_atomic64_sub(s64 i, atomic64_t *v) · 2 unmodified lines
202147 return i;
203148 }
204149
205−/**
206− * arch_atomic64_inc - increment atomic64 variable
207− * @v: pointer to type atomic64_t
208− *
209− * Atomically increments @v by 1.
210− */
211150 static __always_inline void arch_atomic64_inc(atomic64_t *v)
212151 {
213152 __alternative_atomic64(inc, inc_return, /* no output */,
@@ -215,12 +154,6 @@ static __always_inline void arch_atomic64_inc(atomic64_t *v) · 1 unmodified line
215154 }
216155 #define arch_atomic64_inc arch_atomic64_inc
217156
218−/**
219− * arch_atomic64_dec - decrement atomic64 variable
220− * @v: pointer to type atomic64_t
221− *
222− * Atomically decrements @v by 1.
223− */
224157 static __always_inline void arch_atomic64_dec(atomic64_t *v)
225158 {
226159 __alternative_atomic64(dec, dec_return, /* no output */,
@@ -228,15 +161,6 @@ static __always_inline void arch_atomic64_dec(atomic64_t *v) · 1 unmodified line
228161 }
229162 #define arch_atomic64_dec arch_atomic64_dec
230163
231−/**
232− * arch_atomic64_add_unless - add unless the number is a given value
233− * @v: pointer of type atomic64_t
234− * @a: the amount to add to v...
235− * @u: ...unless v is equal to u.
236− *
237− * Atomically adds @a to @v, so long as it was not @u.
238− * Returns non-zero if the add was done, zero otherwise.
239− */
240164 static __always_inline int arch_atomic64_add_unless(atomic64_t *v, s64 a, s64 u)
241165 {
242166 unsigned low = (unsigned)u;
arch/x86/include/asm/atomic64_64.h+0−81
@@ -10,37 +10,16 @@ · 9 unmodified lines
1010
1111 #define ATOMIC64_INIT(i) { (i) }
1212
13−/**
14− * arch_atomic64_read - read atomic64 variable
15− * @v: pointer of type atomic64_t
16− *
17− * Atomically reads the value of @v.
18− * Doesn't imply a read memory barrier.
19− */
2013 static __always_inline s64 arch_atomic64_read(const atomic64_t *v)
2114 {
2215 return __READ_ONCE((v)->counter);
2316 }
2417
25−/**
26− * arch_atomic64_set - set atomic64 variable
27− * @v: pointer to type atomic64_t
28− * @i: required value
29− *
30− * Atomically sets the value of @v to @i.
31− */
3218 static __always_inline void arch_atomic64_set(atomic64_t *v, s64 i)
3319 {
3420 __WRITE_ONCE(v->counter, i);
3521 }
3622
37−/**
38− * arch_atomic64_add - add integer to atomic64 variable
39− * @i: integer value to add
40− * @v: pointer to type atomic64_t
41− *
42− * Atomically adds @i to @v.
43− */
4423 static __always_inline void arch_atomic64_add(s64 i, atomic64_t *v)
4524 {
4625 asm volatile(LOCK_PREFIX "addq %1,%0"
@@ -48,13 +27,6 @@ static __always_inline void arch_atomic64_add(s64 i, atomic64_t *v) · 1 unmodified line
4827 : "er" (i), "m" (v->counter) : "memory");
4928 }
5029
51−/**
52− * arch_atomic64_sub - subtract the atomic64 variable
53− * @i: integer value to subtract
54− * @v: pointer to type atomic64_t
55− *
56− * Atomically subtracts @i from @v.
57− */
5830 static __always_inline void arch_atomic64_sub(s64 i, atomic64_t *v)
5931 {
6032 asm volatile(LOCK_PREFIX "subq %1,%0"
@@ -62,27 +34,12 @@ static __always_inline void arch_atomic64_sub(s64 i, atomic64_t *v) · 1 unmodified line
6234 : "er" (i), "m" (v->counter) : "memory");
6335 }
6436
65−/**
66− * arch_atomic64_sub_and_test - subtract value from variable and test result
67− * @i: integer value to subtract
68− * @v: pointer to type atomic64_t
69− *
70− * Atomically subtracts @i from @v and returns
71− * true if the result is zero, or false for all
72− * other cases.
73− */
7437 static __always_inline bool arch_atomic64_sub_and_test(s64 i, atomic64_t *v)
7538 {
7639 return GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, e, "er", i);
7740 }
7841 #define arch_atomic64_sub_and_test arch_atomic64_sub_and_test
7942
80−/**
81− * arch_atomic64_inc - increment atomic64 variable
82− * @v: pointer to type atomic64_t
83− *
84− * Atomically increments @v by 1.
85− */
8643 static __always_inline void arch_atomic64_inc(atomic64_t *v)
8744 {
8845 asm volatile(LOCK_PREFIX "incq %0"
@@ -91,12 +48,6 @@ static __always_inline void arch_atomic64_inc(atomic64_t *v) · 2 unmodified lines
9148 }
9249 #define arch_atomic64_inc arch_atomic64_inc
9350
94−/**
95− * arch_atomic64_dec - decrement atomic64 variable
96− * @v: pointer to type atomic64_t
97− *
98− * Atomically decrements @v by 1.
99− */
10051 static __always_inline void arch_atomic64_dec(atomic64_t *v)
10152 {
10253 asm volatile(LOCK_PREFIX "decq %0"
@@ -105,56 +56,24 @@ static __always_inline void arch_atomic64_dec(atomic64_t *v) · 2 unmodified lines
10556 }
10657 #define arch_atomic64_dec arch_atomic64_dec
10758
108−/**
109− * arch_atomic64_dec_and_test - decrement and test
110− * @v: pointer to type atomic64_t
111− *
112− * Atomically decrements @v by 1 and
113− * returns true if the result is 0, or false for all other
114− * cases.
115− */
11659 static __always_inline bool arch_atomic64_dec_and_test(atomic64_t *v)
11760 {
11861 return GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, e);
11962 }
12063 #define arch_atomic64_dec_and_test arch_atomic64_dec_and_test
12164
122−/**
123− * arch_atomic64_inc_and_test - increment and test
124− * @v: pointer to type atomic64_t
125− *
126− * Atomically increments @v by 1
127− * and returns true if the result is zero, or false for all
128− * other cases.
129− */
13065 static __always_inline bool arch_atomic64_inc_and_test(atomic64_t *v)
13166 {
13267 return GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, e);
13368 }
13469 #define arch_atomic64_inc_and_test arch_atomic64_inc_and_test
13570
136−/**
137− * arch_atomic64_add_negative - add and test if negative
138− * @i: integer value to add
139− * @v: pointer to type atomic64_t
140− *
141− * Atomically adds @i to @v and returns true
142− * if the result is negative, or false when
143− * result is greater than or equal to zero.
144− */
14571 static __always_inline bool arch_atomic64_add_negative(s64 i, atomic64_t *v)
14672 {
14773 return GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, s, "er", i);
14874 }
14975 #define arch_atomic64_add_negative arch_atomic64_add_negative
15076
151−/**
152− * arch_atomic64_add_return - add and return
153− * @i: integer value to add
154− * @v: pointer to type atomic64_t
155− *
156− * Atomically adds @i to @v and returns @i + @v
157− */
15877 static __always_inline s64 arch_atomic64_add_return(s64 i, atomic64_t *v)
15978 {
16079 return i + xadd(&v->counter, i);
arch/x86/include/asm/cmpxchg.h+0−25
@@ -239,29 +239,4 @@ extern void __add_wrong_size(void) · 238 unmodified lines
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+1−1
@@ -103,6 +103,6 @@ static inline bool __try_cmpxchg64(volatile u64 *ptr, u64 *pold, u64 new) · 102 unmodified lines
103103
104104 #endif
105105
106−#define system_has_cmpxchg_double() boot_cpu_has(X86_FEATURE_CX8)
106+#define system_has_cmpxchg64() boot_cpu_has(X86_FEATURE_CX8)
107107
108108 #endif /* _ASM_X86_CMPXCHG_32_H */
arch/x86/include/asm/cmpxchg_64.h+66−1
@@ -20,6 +20,71 @@ · 19 unmodified lines
2020 arch_try_cmpxchg((ptr), (po), (n)); \
2121 })
2222
23−#define system_has_cmpxchg_double() boot_cpu_has(X86_FEATURE_CX16)
23+union __u128_halves {
24+ u128 full;
25+ struct {
26+ u64 low, high;
27+ };
28+};
29+
30+#define __arch_cmpxchg128(_ptr, _old, _new, _lock) \
31+({ \
32+ union __u128_halves o = { .full = (_old), }, \
33+ n = { .full = (_new), }; \
34+ \
35+ asm volatile(_lock "cmpxchg16b %[ptr]" \
36+ : [ptr] "+m" (*(_ptr)), \
37+ "+a" (o.low), "+d" (o.high) \
38+ : "b" (n.low), "c" (n.high) \
39+ : "memory"); \
40+ \
41+ o.full; \
42+})
43+
44+static __always_inline u128 arch_cmpxchg128(volatile u128 *ptr, u128 old, u128 new)
45+{
46+ return __arch_cmpxchg128(ptr, old, new, LOCK_PREFIX);
47+}
48+#define arch_cmpxchg128 arch_cmpxchg128
49+
50+static __always_inline u128 arch_cmpxchg128_local(volatile u128 *ptr, u128 old, u128 new)
51+{
52+ return __arch_cmpxchg128(ptr, old, new,);
53+}
54+#define arch_cmpxchg128_local arch_cmpxchg128_local
55+
56+#define __arch_try_cmpxchg128(_ptr, _oldp, _new, _lock) \
57+({ \
58+ union __u128_halves o = { .full = *(_oldp), }, \
59+ n = { .full = (_new), }; \
60+ bool ret; \
61+ \
62+ asm volatile(_lock "cmpxchg16b %[ptr]" \
63+ CC_SET(e) \
64+ : CC_OUT(e) (ret), \
65+ [ptr] "+m" (*ptr), \
66+ "+a" (o.low), "+d" (o.high) \
67+ : "b" (n.low), "c" (n.high) \
68+ : "memory"); \
69+ \
70+ if (unlikely(!ret)) \
71+ *(_oldp) = o.full; \
72+ \
73+ likely(ret); \
74+})
75+
76+static __always_inline bool arch_try_cmpxchg128(volatile u128 *ptr, u128 *oldp, u128 new)
77+{
78+ return __arch_try_cmpxchg128(ptr, oldp, new, LOCK_PREFIX);
79+}
80+#define arch_try_cmpxchg128 arch_try_cmpxchg128
81+
82+static __always_inline bool arch_try_cmpxchg128_local(volatile u128 *ptr, u128 *oldp, u128 new)
83+{
84+ return __arch_try_cmpxchg128(ptr, oldp, new,);
85+}
86+#define arch_try_cmpxchg128_local arch_try_cmpxchg128_local
87+
88+#define system_has_cmpxchg128() boot_cpu_has(X86_FEATURE_CX16)
2489
2590 #endif /* _ASM_X86_CMPXCHG_64_H */
arch/x86/include/asm/percpu.h+61−41
@@ -210,6 +210,67 @@ do { \ · 209 unmodified lines
210210 (typeof(_var))(unsigned long) pco_old__; \
211211 })
212212
213+#if defined(CONFIG_X86_32) && !defined(CONFIG_UML)
214+#define percpu_cmpxchg64_op(size, qual, _var, _oval, _nval) \
215+({ \
216+ union { \
217+ u64 var; \
218+ struct { \
219+ u32 low, high; \
220+ }; \
221+ } old__, new__; \
222+ \
223+ old__.var = _oval; \
224+ new__.var = _nval; \
225+ \
226+ asm qual (ALTERNATIVE("leal %P[var], %%esi; call this_cpu_cmpxchg8b_emu", \
227+ "cmpxchg8b " __percpu_arg([var]), X86_FEATURE_CX8) \
228+ : [var] "+m" (_var), \
229+ "+a" (old__.low), \
230+ "+d" (old__.high) \
231+ : "b" (new__.low), \
232+ "c" (new__.high) \
233+ : "memory", "esi"); \
234+ \
235+ old__.var; \
236+})
237+
238+#define raw_cpu_cmpxchg64(pcp, oval, nval) percpu_cmpxchg64_op(8, , pcp, oval, nval)
239+#define this_cpu_cmpxchg64(pcp, oval, nval) percpu_cmpxchg64_op(8, volatile, pcp, oval, nval)
240+#endif
241+
242+#ifdef CONFIG_X86_64
243+#define raw_cpu_cmpxchg64(pcp, oval, nval) percpu_cmpxchg_op(8, , pcp, oval, nval);
244+#define this_cpu_cmpxchg64(pcp, oval, nval) percpu_cmpxchg_op(8, volatile, pcp, oval, nval);
245+
246+#define percpu_cmpxchg128_op(size, qual, _var, _oval, _nval) \
247+({ \
248+ union { \
249+ u128 var; \
250+ struct { \
251+ u64 low, high; \
252+ }; \
253+ } old__, new__; \
254+ \
255+ old__.var = _oval; \
256+ new__.var = _nval; \
257+ \
258+ asm qual (ALTERNATIVE("leaq %P[var], %%rsi; call this_cpu_cmpxchg16b_emu", \
259+ "cmpxchg16b " __percpu_arg([var]), X86_FEATURE_CX16) \
260+ : [var] "+m" (_var), \
261+ "+a" (old__.low), \
262+ "+d" (old__.high) \
263+ : "b" (new__.low), \
264+ "c" (new__.high) \
265+ : "memory", "rsi"); \
266+ \
267+ old__.var; \
268+})
269+
270+#define raw_cpu_cmpxchg128(pcp, oval, nval) percpu_cmpxchg128_op(16, , pcp, oval, nval)
271+#define this_cpu_cmpxchg128(pcp, oval, nval) percpu_cmpxchg128_op(16, volatile, pcp, oval, nval)
272+#endif
273+
213274 /*
214275 * this_cpu_read() makes gcc load the percpu variable every time it is
215276 * accessed while this_cpu_read_stable() allows the value to be cached.
@@ -290,23 +351,6 @@ do { \ · 74 unmodified lines
290351 #define this_cpu_cmpxchg_2(pcp, oval, nval) percpu_cmpxchg_op(2, volatile, pcp, oval, nval)
291352 #define this_cpu_cmpxchg_4(pcp, oval, nval) percpu_cmpxchg_op(4, volatile, pcp, oval, nval)
292353
293−#ifdef CONFIG_X86_CMPXCHG64
294−#define percpu_cmpxchg8b_double(pcp1, pcp2, o1, o2, n1, n2) \
295−({ \
296− bool __ret; \
297− typeof(pcp1) __o1 = (o1), __n1 = (n1); \
298− typeof(pcp2) __o2 = (o2), __n2 = (n2); \
299− asm volatile("cmpxchg8b "__percpu_arg(1) \
300− CC_SET(z) \
301− : CC_OUT(z) (__ret), "+m" (pcp1), "+m" (pcp2), "+a" (__o1), "+d" (__o2) \
302− : "b" (__n1), "c" (__n2)); \
303− __ret; \
304−})
305−
306−#define raw_cpu_cmpxchg_double_4 percpu_cmpxchg8b_double
307−#define this_cpu_cmpxchg_double_4 percpu_cmpxchg8b_double
308−#endif /* CONFIG_X86_CMPXCHG64 */
309−
310354 /*
311355 * Per cpu atomic 64 bit operations are only available under 64 bit.
312356 * 32 bit must fall back to generic operations.
@@ -329,30 +373,6 @@ do { \ · 16 unmodified lines
329373 #define this_cpu_add_return_8(pcp, val) percpu_add_return_op(8, volatile, pcp, val)
330374 #define this_cpu_xchg_8(pcp, nval) percpu_xchg_op(8, volatile, pcp, nval)
331375 #define this_cpu_cmpxchg_8(pcp, oval, nval) percpu_cmpxchg_op(8, volatile, pcp, oval, nval)
332−
333−/*
334− * Pretty complex macro to generate cmpxchg16 instruction. The instruction
335− * is not supported on early AMD64 processors so we must be able to emulate
336− * it in software. The address used in the cmpxchg16 instruction must be
337− * aligned to a 16 byte boundary.
338− */
339−#define percpu_cmpxchg16b_double(pcp1, pcp2, o1, o2, n1, n2) \
340−({ \
341− bool __ret; \
342− typeof(pcp1) __o1 = (o1), __n1 = (n1); \
343− typeof(pcp2) __o2 = (o2), __n2 = (n2); \
344− alternative_io("leaq %P1,%%rsi\n\tcall this_cpu_cmpxchg16b_emu\n\t", \
345− "cmpxchg16b " __percpu_arg(1) "\n\tsetz %0\n\t", \
346− X86_FEATURE_CX16, \
347− ASM_OUTPUT2("=a" (__ret), "+m" (pcp1), \
348− "+m" (pcp2), "+d" (__o2)), \
349− "b" (__n1), "c" (__n2), "a" (__o1) : "rsi"); \
350− __ret; \
351−})
352−
353−#define raw_cpu_cmpxchg_double_8 percpu_cmpxchg16b_double
354−#define this_cpu_cmpxchg_double_8 percpu_cmpxchg16b_double
355−
356376 #endif
357377
358378 static __always_inline bool x86_this_cpu_constant_test_bit(unsigned int nr,
arch/x86/kernel/alternative.c+2−2
@@ -1967,7 +1967,7 @@ struct bp_patching_desc *try_get_desc(void) · 1966 unmodified lines
19671967 {
19681968 struct bp_patching_desc *desc = &bp_desc;
19691969
1970− if (!arch_atomic_inc_not_zero(&desc->refs))
1970+ if (!raw_atomic_inc_not_zero(&desc->refs))
19711971 return NULL;
19721972
19731973 return desc;
@@ -1978,7 +1978,7 @@ static __always_inline void put_desc(void) · 4 unmodified lines
19781978 struct bp_patching_desc *desc = &bp_desc;
19791979
19801980 smp_mb__before_atomic();
1981− arch_atomic_dec(&desc->refs);
1981+ raw_atomic_dec(&desc->refs);
19821982 }
19831983
19841984 static __always_inline void *text_poke_addr(struct text_poke_loc *tp)
arch/x86/kernel/cpu/mce/core.c+8−8
@@ -1022,12 +1022,12 @@ static noinstr int mce_start(int *no_way_out) · 1021 unmodified lines
10221022 if (!timeout)
10231023 return ret;
10241024
1025− arch_atomic_add(*no_way_out, &global_nwo);
1025+ raw_atomic_add(*no_way_out, &global_nwo);
10261026 /*
10271027 * Rely on the implied barrier below, such that global_nwo
10281028 * is updated before mce_callin.
10291029 */
1030− order = arch_atomic_inc_return(&mce_callin);
1030+ order = raw_atomic_inc_return(&mce_callin);
10311031 arch_cpumask_clear_cpu(smp_processor_id(), &mce_missing_cpus);
10321032
10331033 /* Enable instrumentation around calls to external facilities */
@@ -1036,10 +1036,10 @@ static noinstr int mce_start(int *no_way_out) · 2 unmodified lines
10361036 /*
10371037 * Wait for everyone.
10381038 */
1039− while (arch_atomic_read(&mce_callin) != num_online_cpus()) {
1039+ while (raw_atomic_read(&mce_callin) != num_online_cpus()) {
10401040 if (mce_timed_out(&timeout,
10411041 "Timeout: Not all CPUs entered broadcast exception handler")) {
1042− arch_atomic_set(&global_nwo, 0);
1042+ raw_atomic_set(&global_nwo, 0);
10431043 goto out;
10441044 }
10451045 ndelay(SPINUNIT);
@@ -1054,7 +1054,7 @@ static noinstr int mce_start(int *no_way_out) · 8 unmodified lines
10541054 /*
10551055 * Monarch: Starts executing now, the others wait.
10561056 */
1057− arch_atomic_set(&mce_executing, 1);
1057+ raw_atomic_set(&mce_executing, 1);
10581058 } else {
10591059 /*
10601060 * Subject: Now start the scanning loop one by one in
@@ -1062,10 +1062,10 @@ static noinstr int mce_start(int *no_way_out) · 1 unmodified line
10621062 * This way when there are any shared banks it will be
10631063 * only seen by one CPU before cleared, avoiding duplicates.
10641064 */
1065− while (arch_atomic_read(&mce_executing) < order) {
1065+ while (raw_atomic_read(&mce_executing) < order) {
10661066 if (mce_timed_out(&timeout,
10671067 "Timeout: Subject CPUs unable to finish machine check processing")) {
1068− arch_atomic_set(&global_nwo, 0);
1068+ raw_atomic_set(&global_nwo, 0);
10691069 goto out;
10701070 }
10711071 ndelay(SPINUNIT);
@@ -1075,7 +1075,7 @@ static noinstr int mce_start(int *no_way_out) · 3 unmodified lines
10751075 /*
10761076 * Cache the global no_way_out state.
10771077 */
1078− *no_way_out = arch_atomic_read(&global_nwo);
1078+ *no_way_out = raw_atomic_read(&global_nwo);
10791079
10801080 ret = order;
10811081
arch/x86/kernel/nmi.c+1−1
@@ -496,7 +496,7 @@ DEFINE_IDTENTRY_RAW(exc_nmi) · 495 unmodified lines
496496 */
497497 sev_es_nmi_complete();
498498 if (IS_ENABLED(CONFIG_NMI_CHECK_CPU))
499− arch_atomic_long_inc(&nsp->idt_calls);
499+ raw_atomic_long_inc(&nsp->idt_calls);
500500
501501 if (IS_ENABLED(CONFIG_SMP) && arch_cpu_is_offline(smp_processor_id()))
502502 return;
arch/x86/kernel/pvclock.c+2−2
@@ -101,11 +101,11 @@ u64 __pvclock_clocksource_read(struct pvclock_vcpu_time_info *src, bool dowd) · 100 unmodified lines
101101 * updating at the same time, and one of them could be slightly behind,
102102 * making the assumption that last_value always go forward fail to hold.
103103 */
104− last = arch_atomic64_read(&last_value);
104+ last = raw_atomic64_read(&last_value);
105105 do {
106106 if (ret <= last)
107107 return last;
108− } while (!arch_atomic64_try_cmpxchg(&last_value, &last, ret));
108+ } while (!raw_atomic64_try_cmpxchg(&last_value, &last, ret));
109109
110110 return ret;
111111 }
arch/x86/kvm/x86.c+1−1
@@ -13161,7 +13161,7 @@ EXPORT_SYMBOL_GPL(kvm_arch_end_assignment); · 13160 unmodified lines
1316113161
1316213162 bool noinstr kvm_arch_has_assigned_device(struct kvm *kvm)
1316313163 {
13164− return arch_atomic_read(&kvm->arch.assigned_device_count);
13164+ return raw_atomic_read(&kvm->arch.assigned_device_count);
1316513165 }
1316613166 EXPORT_SYMBOL_GPL(kvm_arch_has_assigned_device);
1316713167
arch/x86/lib/Makefile+2−1
@@ -61,8 +61,9 @@ ifeq ($(CONFIG_X86_32),y) · 60 unmodified lines
6161 lib-y += strstr_32.o
6262 lib-y += string_32.o
6363 lib-y += memmove_32.o
64+ lib-y += cmpxchg8b_emu.o
6465 ifneq ($(CONFIG_X86_CMPXCHG64),y)
65− lib-y += cmpxchg8b_emu.o atomic64_386_32.o
66+ lib-y += atomic64_386_32.o
6667 endif
6768 else
6869 obj-y += iomap_copy_64.o
arch/x86/lib/cmpxchg16b_emu.S+25−18
@@ -1,47 +1,54 @@
11 /* SPDX-License-Identifier: GPL-2.0-only */
22 #include <linux/linkage.h>
33 #include <asm/percpu.h>
4+#include <asm/processor-flags.h>
45
56 .text
67
78 /*
9+ * Emulate 'cmpxchg16b %gs:(%rsi)'
10+ *
811 * Inputs:
912 * %rsi : memory location to compare
1013 * %rax : low 64 bits of old value
1114 * %rdx : high 64 bits of old value
1215 * %rbx : low 64 bits of new value
1316 * %rcx : high 64 bits of new value
14− * %al : Operation successful
17+ *
18+ * Notably this is not LOCK prefixed and is not safe against NMIs
1519 */
1620 SYM_FUNC_START(this_cpu_cmpxchg16b_emu)
1721
18−#
19−# Emulate 'cmpxchg16b %gs:(%rsi)' except we return the result in %al not
20−# via the ZF. Caller will access %al to get result.
21−#
22−# Note that this is only useful for a cpuops operation. Meaning that we
23−# do *not* have a fully atomic operation but just an operation that is
24−# *atomic* on a single cpu (as provided by the this_cpu_xx class of
25−# macros).
26−#
2722 pushfq
2823 cli
2924
30− cmpq PER_CPU_VAR((%rsi)), %rax
31− jne .Lnot_same
32− cmpq PER_CPU_VAR(8(%rsi)), %rdx
33− jne .Lnot_same
25+ /* if (*ptr == old) */
26+ cmpq PER_CPU_VAR(0(%rsi)), %rax
27+ jne .Lnot_same
28+ cmpq PER_CPU_VAR(8(%rsi)), %rdx
29+ jne .Lnot_same
3430
35− movq %rbx, PER_CPU_VAR((%rsi))
36− movq %rcx, PER_CPU_VAR(8(%rsi))
31+ /* *ptr = new */
32+ movq %rbx, PER_CPU_VAR(0(%rsi))
33+ movq %rcx, PER_CPU_VAR(8(%rsi))
34+
35+ /* set ZF in EFLAGS to indicate success */
36+ orl $X86_EFLAGS_ZF, (%rsp)
3737
3838 popfq
39− mov $1, %al
4039 RET
4140
4241 .Lnot_same:
42+ /* *ptr != old */
43+
44+ /* old = *ptr */
45+ movq PER_CPU_VAR(0(%rsi)), %rax
46+ movq PER_CPU_VAR(8(%rsi)), %rdx
47+
48+ /* clear ZF in EFLAGS to indicate failure */
49+ andl $(~X86_EFLAGS_ZF), (%rsp)
50+
4351 popfq
44− xor %al,%al
4552 RET
4653
4754 SYM_FUNC_END(this_cpu_cmpxchg16b_emu)
arch/x86/lib/cmpxchg8b_emu.S+53−14
@@ -2,10 +2,16 @@ · 1 unmodified line
22
33 #include <linux/linkage.h>
44 #include <asm/export.h>
5+#include <asm/percpu.h>
6+#include <asm/processor-flags.h>
57
68 .text
79
10+#ifndef CONFIG_X86_CMPXCHG64
11+
812 /*
13+ * Emulate 'cmpxchg8b (%esi)' on UP
14+ *
915 * Inputs:
1016 * %esi : memory location to compare
1117 * %eax : low 32 bits of old value
@@ -15,32 +21,65 @@ · 3 unmodified lines
1521 */
1622 SYM_FUNC_START(cmpxchg8b_emu)
1723
18−#
19−# Emulate 'cmpxchg8b (%esi)' on UP except we don't
20−# set the whole ZF thing (caller will just compare
21−# eax:edx with the expected value)
22−#
2324 pushfl
2425 cli
2526
26− cmpl (%esi), %eax
27− jne .Lnot_same
28− cmpl 4(%esi), %edx
29− jne .Lhalf_same
27+ cmpl 0(%esi), %eax
28+ jne .Lnot_same
29+ cmpl 4(%esi), %edx
30+ jne .Lnot_same
31+
32+ movl %ebx, 0(%esi)
33+ movl %ecx, 4(%esi)
3034
31− movl %ebx, (%esi)
32− movl %ecx, 4(%esi)
35+ orl $X86_EFLAGS_ZF, (%esp)
3336
3437 popfl
3538 RET
3639
3740 .Lnot_same:
38− movl (%esi), %eax
39−.Lhalf_same:
40− movl 4(%esi), %edx
41+ movl 0(%esi), %eax
42+ movl 4(%esi), %edx
43+
44+ andl $(~X86_EFLAGS_ZF), (%esp)
4145
4246 popfl
4347 RET
4448
4549 SYM_FUNC_END(cmpxchg8b_emu)
4650 EXPORT_SYMBOL(cmpxchg8b_emu)
51+
52+#endif
53+
54+#ifndef CONFIG_UML
55+
56+SYM_FUNC_START(this_cpu_cmpxchg8b_emu)
57+
58+ pushfl
59+ cli
60+
61+ cmpl PER_CPU_VAR(0(%esi)), %eax
62+ jne .Lnot_same2
63+ cmpl PER_CPU_VAR(4(%esi)), %edx
64+ jne .Lnot_same2
65+
66+ movl %ebx, PER_CPU_VAR(0(%esi))
67+ movl %ecx, PER_CPU_VAR(4(%esi))
68+
69+ orl $X86_EFLAGS_ZF, (%esp)
70+
71+ popfl
72+ RET
73+
74+.Lnot_same2:
75+ movl PER_CPU_VAR(0(%esi)), %eax
76+ movl PER_CPU_VAR(4(%esi)), %edx
77+
78+ andl $(~X86_EFLAGS_ZF), (%esp)
79+
80+ popfl
81+ RET
82+
83+SYM_FUNC_END(this_cpu_cmpxchg8b_emu)
84+
85+#endif
arch/xtensa/include/asm/atomic.h+9−3
@@ -245,6 +245,11 @@ static inline int arch_atomic_fetch_##op(int i, atomic_t * v) \ · 244 unmodified lines
245245 ATOMIC_OPS(add)
246246 ATOMIC_OPS(sub)
247247
248+#define arch_atomic_add_return arch_atomic_add_return
249+#define arch_atomic_sub_return arch_atomic_sub_return
250+#define arch_atomic_fetch_add arch_atomic_fetch_add
251+#define arch_atomic_fetch_sub arch_atomic_fetch_sub
252+
248253 #undef ATOMIC_OPS
249254 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_FETCH_OP(op)
250255
@@ -252,12 +257,13 @@ ATOMIC_OPS(and) · 1 unmodified line
252257 ATOMIC_OPS(or)
253258 ATOMIC_OPS(xor)
254259
260+#define arch_atomic_fetch_and arch_atomic_fetch_and
261+#define arch_atomic_fetch_or arch_atomic_fetch_or
262+#define arch_atomic_fetch_xor arch_atomic_fetch_xor
263+
255264 #undef ATOMIC_OPS
256265 #undef ATOMIC_FETCH_OP
257266 #undef ATOMIC_OP_RETURN
258267 #undef ATOMIC_OP
259268
260−#define arch_atomic_cmpxchg(v, o, n) ((int)arch_cmpxchg(&((v)->counter), (o), (n)))
261−#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), new))
262−
263269 #endif /* _XTENSA_ATOMIC_H */
drivers/iommu/amd/amd_iommu_types.h+7−2
@@ -986,8 +986,13 @@ union irte_ga_hi { · 985 unmodified lines
986986 };
987987
988988 struct irte_ga {
989− union irte_ga_lo lo;
990− union irte_ga_hi hi;
989+ union {
990+ struct {
991+ union irte_ga_lo lo;
992+ union irte_ga_hi hi;
993+ };
994+ u128 irte;
995+ };
991996 };
992997
993998 struct irq_2_irte {
drivers/iommu/amd/iommu.c+4−6
@@ -3023,10 +3023,10 @@ out: · 3022 unmodified lines
30233023 static int modify_irte_ga(struct amd_iommu *iommu, u16 devid, int index,
30243024 struct irte_ga *irte, struct amd_ir_data *data)
30253025 {
3026− bool ret;
30273026 struct irq_remap_table *table;
3028− unsigned long flags;
30293027 struct irte_ga *entry;
3028+ unsigned long flags;
3029+ u128 old;
30303030
30313031 table = get_irq_table(iommu, devid);
30323032 if (!table)
@@ -3037,16 +3037,14 @@ static int modify_irte_ga(struct amd_iommu *iommu, u16 devid, int index, · 4 unmodified lines
30373037 entry = (struct irte_ga *)table->table;
30383038 entry = &entry[index];
30393039
3040− ret = cmpxchg_double(&entry->lo.val, &entry->hi.val,
3041− entry->lo.val, entry->hi.val,
3042− irte->lo.val, irte->hi.val);
30433040 /*
30443041 * We use cmpxchg16 to atomically update the 128-bit IRTE,
30453042 * and it cannot be updated by the hardware or other processors
30463043 * behind us, so the return value of cmpxchg16 should be the
30473044 * same as the old value.
30483045 */
3049− WARN_ON(!ret);
3046+ old = entry->irte;
3047+ WARN_ON(!try_cmpxchg128(&entry->irte, &old, irte->irte));
30503048
30513049 if (data)
30523050 data->ref = entry;
drivers/iommu/intel/irq_remapping.c+2−6
@@ -175,18 +175,14 @@ static int modify_irte(struct irq_2_iommu *irq_iommu, · 174 unmodified lines
175175 irte = &iommu->ir_table->base[index];
176176
177177 if ((irte->pst == 1) || (irte_modified->pst == 1)) {
178− bool ret;
179−
180− ret = cmpxchg_double(&irte->low, &irte->high,
181− irte->low, irte->high,
182− irte_modified->low, irte_modified->high);
183178 /*
184179 * We use cmpxchg16 to atomically update the 128-bit IRTE,
185180 * and it cannot be updated by the hardware or other processors
186181 * behind us, so the return value of cmpxchg16 should be the
187182 * same as the old value.
188183 */
189− WARN_ON(!ret);
184+ u128 old = irte->irte;
185+ WARN_ON(!try_cmpxchg128(&irte->irte, &old, irte_modified->irte));
190186 } else {
191187 WRITE_ONCE(irte->low, irte_modified->low);
192188 WRITE_ONCE(irte->high, irte_modified->high);
drivers/md/bcache/btree.c+22−1
@@ -559,6 +559,27 @@ static void mca_data_alloc(struct btree *b, struct bkey *k, gfp_t gfp) · 558 unmodified lines
559559 }
560560 }
561561
562+#define cmp_int(l, r) ((l > r) - (l < r))
563+
564+#ifdef CONFIG_PROVE_LOCKING
565+static int btree_lock_cmp_fn(const struct lockdep_map *_a,
566+ const struct lockdep_map *_b)
567+{
568+ const struct btree *a = container_of(_a, struct btree, lock.dep_map);
569+ const struct btree *b = container_of(_b, struct btree, lock.dep_map);
570+
571+ return -cmp_int(a->level, b->level) ?: bkey_cmp(&a->key, &b->key);
572+}
573+
574+static void btree_lock_print_fn(const struct lockdep_map *map)
575+{
576+ const struct btree *b = container_of(map, struct btree, lock.dep_map);
577+
578+ printk(KERN_CONT " l=%u %llu:%llu", b->level,
579+ KEY_INODE(&b->key), KEY_OFFSET(&b->key));
580+}
581+#endif
582+
562583 static struct btree *mca_bucket_alloc(struct cache_set *c,
563584 struct bkey *k, gfp_t gfp)
564585 {
@@ -572,7 +593,7 @@ static struct btree *mca_bucket_alloc(struct cache_set *c, · 7 unmodified lines
572593 return NULL;
573594
574595 init_rwsem(&b->lock);
575− lockdep_set_novalidate_class(&b->lock);
596+ lock_set_cmp_fn(&b->lock, btree_lock_cmp_fn, btree_lock_print_fn);
576597 mutex_init(&b->write_lock);
577598 lockdep_set_novalidate_class(&b->write_lock);
578599 INIT_LIST_HEAD(&b->list);
drivers/md/bcache/btree.h+2−2
@@ -247,8 +247,8 @@ static inline void bch_btree_op_init(struct btree_op *op, int write_lock_level) · 246 unmodified lines
247247
248248 static inline void rw_lock(bool w, struct btree *b, int level)
249249 {
250− w ? down_write_nested(&b->lock, level + 1)
251− : down_read_nested(&b->lock, level + 1);
250+ w ? down_write(&b->lock)
251+ : down_read(&b->lock);
252252 if (w)
253253 b->seq++;
254254 }
include/asm-generic/atomic.h+0−3
@@ -130,7 +130,4 @@ ATOMIC_OP(xor, ^) · 129 unmodified lines
130130 #define arch_atomic_read(v) READ_ONCE((v)->counter)
131131 #define arch_atomic_set(v, i) WRITE_ONCE(((v)->counter), (i))
132132
133−#define arch_atomic_xchg(ptr, v) (arch_xchg(&(ptr)->counter, (u32)(v)))
134−#define arch_atomic_cmpxchg(v, old, new) (arch_cmpxchg(&((v)->counter), (u32)(old), (u32)(new)))
135−
136133 #endif /* __ASM_GENERIC_ATOMIC_H */
include/asm-generic/bitops/atomic.h+6−6
@@ -15,21 +15,21 @@ static __always_inline void · 14 unmodified lines
1515 arch_set_bit(unsigned int nr, volatile unsigned long *p)
1616 {
1717 p += BIT_WORD(nr);
18− arch_atomic_long_or(BIT_MASK(nr), (atomic_long_t *)p);
18+ raw_atomic_long_or(BIT_MASK(nr), (atomic_long_t *)p);
1919 }
2020
2121 static __always_inline void
2222 arch_clear_bit(unsigned int nr, volatile unsigned long *p)
2323 {
2424 p += BIT_WORD(nr);
25− arch_atomic_long_andnot(BIT_MASK(nr), (atomic_long_t *)p);
25+ raw_atomic_long_andnot(BIT_MASK(nr), (atomic_long_t *)p);
2626 }
2727
2828 static __always_inline void
2929 arch_change_bit(unsigned int nr, volatile unsigned long *p)
3030 {
3131 p += BIT_WORD(nr);
32− arch_atomic_long_xor(BIT_MASK(nr), (atomic_long_t *)p);
32+ raw_atomic_long_xor(BIT_MASK(nr), (atomic_long_t *)p);
3333 }
3434
3535 static __always_inline int
@@ -39,7 +39,7 @@ arch_test_and_set_bit(unsigned int nr, volatile unsigned long *p) · 3 unmodified lines
3939 unsigned long mask = BIT_MASK(nr);
4040
4141 p += BIT_WORD(nr);
42− old = arch_atomic_long_fetch_or(mask, (atomic_long_t *)p);
42+ old = raw_atomic_long_fetch_or(mask, (atomic_long_t *)p);
4343 return !!(old & mask);
4444 }
4545
@@ -50,7 +50,7 @@ arch_test_and_clear_bit(unsigned int nr, volatile unsigned long *p) · 4 unmodified lines
5050 unsigned long mask = BIT_MASK(nr);
5151
5252 p += BIT_WORD(nr);
53− old = arch_atomic_long_fetch_andnot(mask, (atomic_long_t *)p);
53+ old = raw_atomic_long_fetch_andnot(mask, (atomic_long_t *)p);
5454 return !!(old & mask);
5555 }
5656
@@ -61,7 +61,7 @@ arch_test_and_change_bit(unsigned int nr, volatile unsigned long *p) · 4 unmodified lines
6161 unsigned long mask = BIT_MASK(nr);
6262
6363 p += BIT_WORD(nr);
64− old = arch_atomic_long_fetch_xor(mask, (atomic_long_t *)p);
64+ old = raw_atomic_long_fetch_xor(mask, (atomic_long_t *)p);
6565 return !!(old & mask);
6666 }
6767
include/asm-generic/bitops/lock.h+4−4
@@ -25,7 +25,7 @@ arch_test_and_set_bit_lock(unsigned int nr, volatile unsigned long *p) · 24 unmodified lines
2525 if (READ_ONCE(*p) & mask)
2626 return 1;
2727
28− old = arch_atomic_long_fetch_or_acquire(mask, (atomic_long_t *)p);
28+ old = raw_atomic_long_fetch_or_acquire(mask, (atomic_long_t *)p);
2929 return !!(old & mask);
3030 }
3131
@@ -41,7 +41,7 @@ static __always_inline void · 9 unmodified lines
4141 arch_clear_bit_unlock(unsigned int nr, volatile unsigned long *p)
4242 {
4343 p += BIT_WORD(nr);
44− arch_atomic_long_fetch_andnot_release(BIT_MASK(nr), (atomic_long_t *)p);
44+ raw_atomic_long_fetch_andnot_release(BIT_MASK(nr), (atomic_long_t *)p);
4545 }
4646
4747 /**
@@ -63,7 +63,7 @@ arch___clear_bit_unlock(unsigned int nr, volatile unsigned long *p) · 15 unmodified lines
6363 p += BIT_WORD(nr);
6464 old = READ_ONCE(*p);
6565 old &= ~BIT_MASK(nr);
66− arch_atomic_long_set_release((atomic_long_t *)p, old);
66+ raw_atomic_long_set_release((atomic_long_t *)p, old);
6767 }
6868
6969 /**
@@ -83,7 +83,7 @@ static inline bool arch_clear_bit_unlock_is_negative_byte(unsigned int nr, · 13 unmodified lines
8383 unsigned long mask = BIT_MASK(nr);
8484
8585 p += BIT_WORD(nr);
86− old = arch_atomic_long_fetch_andnot_release(mask, (atomic_long_t *)p);
86+ old = raw_atomic_long_fetch_andnot_release(mask, (atomic_long_t *)p);
8787 return !!(old & BIT(7));
8888 }
8989 #define arch_clear_bit_unlock_is_negative_byte arch_clear_bit_unlock_is_negative_byte
include/asm-generic/percpu.h+152−49
@@ -89,27 +89,35 @@ do { \ · 88 unmodified lines
8989 __ret; \
9090 })
9191
92−#define raw_cpu_generic_cmpxchg(pcp, oval, nval) \
92+#define __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, _cmpxchg) \
93+({ \
94+ typeof(pcp) __val, __old = *(ovalp); \
95+ __val = _cmpxchg(pcp, __old, nval); \
96+ if (__val != __old) \
97+ *(ovalp) = __val; \
98+ __val == __old; \
99+})
100+
101+#define raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) \
93102 ({ \
94103 typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \
95− typeof(pcp) __ret; \
96− __ret = *__p; \
97− if (__ret == (oval)) \
104+ typeof(pcp) __val = *__p, ___old = *(ovalp); \
105+ bool __ret; \
106+ if (__val == ___old) { \
98107 *__p = nval; \
108+ __ret = true; \
109+ } else { \
110+ *(ovalp) = __val; \
111+ __ret = false; \
112+ } \
99113 __ret; \
100114 })
101115
102−#define raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
116+#define raw_cpu_generic_cmpxchg(pcp, oval, nval) \
103117 ({ \
104− typeof(pcp1) *__p1 = raw_cpu_ptr(&(pcp1)); \
105− typeof(pcp2) *__p2 = raw_cpu_ptr(&(pcp2)); \
106− int __ret = 0; \
107− if (*__p1 == (oval1) && *__p2 == (oval2)) { \
108− *__p1 = nval1; \
109− *__p2 = nval2; \
110− __ret = 1; \
111− } \
112− (__ret); \
118+ typeof(pcp) __old = (oval); \
119+ raw_cpu_generic_try_cmpxchg(pcp, &__old, nval); \
120+ __old; \
113121 })
114122
115123 #define __this_cpu_generic_read_nopreempt(pcp) \
@@ -170,23 +178,22 @@ do { \ · 54 unmodified lines
170178 __ret; \
171179 })
172180
173−#define this_cpu_generic_cmpxchg(pcp, oval, nval) \
181+#define this_cpu_generic_try_cmpxchg(pcp, ovalp, nval) \
174182 ({ \
175− typeof(pcp) __ret; \
183+ bool __ret; \
176184 unsigned long __flags; \
177185 raw_local_irq_save(__flags); \
178− __ret = raw_cpu_generic_cmpxchg(pcp, oval, nval); \
186+ __ret = raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval); \
179187 raw_local_irq_restore(__flags); \
180188 __ret; \
181189 })
182190
183−#define this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
191+#define this_cpu_generic_cmpxchg(pcp, oval, nval) \
184192 ({ \
185− int __ret; \
193+ typeof(pcp) __ret; \
186194 unsigned long __flags; \
187195 raw_local_irq_save(__flags); \
188− __ret = raw_cpu_generic_cmpxchg_double(pcp1, pcp2, \
189− oval1, oval2, nval1, nval2); \
196+ __ret = raw_cpu_generic_cmpxchg(pcp, oval, nval); \
190197 raw_local_irq_restore(__flags); \
191198 __ret; \
192199 })
@@ -282,6 +289,62 @@ do { \ · 89 unmodified lines
282289 #define raw_cpu_xchg_8(pcp, nval) raw_cpu_generic_xchg(pcp, nval)
283290 #endif
284291
292+#ifndef raw_cpu_try_cmpxchg_1
293+#ifdef raw_cpu_cmpxchg_1
294+#define raw_cpu_try_cmpxchg_1(pcp, ovalp, nval) \
295+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_1)
296+#else
297+#define raw_cpu_try_cmpxchg_1(pcp, ovalp, nval) \
298+ raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
299+#endif
300+#endif
301+#ifndef raw_cpu_try_cmpxchg_2
302+#ifdef raw_cpu_cmpxchg_2
303+#define raw_cpu_try_cmpxchg_2(pcp, ovalp, nval) \
304+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_2)
305+#else
306+#define raw_cpu_try_cmpxchg_2(pcp, ovalp, nval) \
307+ raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
308+#endif
309+#endif
310+#ifndef raw_cpu_try_cmpxchg_4
311+#ifdef raw_cpu_cmpxchg_4
312+#define raw_cpu_try_cmpxchg_4(pcp, ovalp, nval) \
313+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_4)
314+#else
315+#define raw_cpu_try_cmpxchg_4(pcp, ovalp, nval) \
316+ raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
317+#endif
318+#endif
319+#ifndef raw_cpu_try_cmpxchg_8
320+#ifdef raw_cpu_cmpxchg_8
321+#define raw_cpu_try_cmpxchg_8(pcp, ovalp, nval) \
322+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_8)
323+#else
324+#define raw_cpu_try_cmpxchg_8(pcp, ovalp, nval) \
325+ raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
326+#endif
327+#endif
328+
329+#ifndef raw_cpu_try_cmpxchg64
330+#ifdef raw_cpu_cmpxchg64
331+#define raw_cpu_try_cmpxchg64(pcp, ovalp, nval) \
332+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg64)
333+#else
334+#define raw_cpu_try_cmpxchg64(pcp, ovalp, nval) \
335+ raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
336+#endif
337+#endif
338+#ifndef raw_cpu_try_cmpxchg128
339+#ifdef raw_cpu_cmpxchg128
340+#define raw_cpu_try_cmpxchg128(pcp, ovalp, nval) \
341+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg128)
342+#else
343+#define raw_cpu_try_cmpxchg128(pcp, ovalp, nval) \
344+ raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
345+#endif
346+#endif
347+
285348 #ifndef raw_cpu_cmpxchg_1
286349 #define raw_cpu_cmpxchg_1(pcp, oval, nval) \
287350 raw_cpu_generic_cmpxchg(pcp, oval, nval)
@@ -299,21 +362,13 @@ do { \ · 11 unmodified lines
299362 raw_cpu_generic_cmpxchg(pcp, oval, nval)
300363 #endif
301364
302−#ifndef raw_cpu_cmpxchg_double_1
303−#define raw_cpu_cmpxchg_double_1(pcp1, pcp2, oval1, oval2, nval1, nval2) \
304− raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
305−#endif
306−#ifndef raw_cpu_cmpxchg_double_2
307−#define raw_cpu_cmpxchg_double_2(pcp1, pcp2, oval1, oval2, nval1, nval2) \
308− raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
309−#endif
310−#ifndef raw_cpu_cmpxchg_double_4
311−#define raw_cpu_cmpxchg_double_4(pcp1, pcp2, oval1, oval2, nval1, nval2) \
312− raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
365+#ifndef raw_cpu_cmpxchg64
366+#define raw_cpu_cmpxchg64(pcp, oval, nval) \
367+ raw_cpu_generic_cmpxchg(pcp, oval, nval)
313368 #endif
314−#ifndef raw_cpu_cmpxchg_double_8
315−#define raw_cpu_cmpxchg_double_8(pcp1, pcp2, oval1, oval2, nval1, nval2) \
316− raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
369+#ifndef raw_cpu_cmpxchg128
370+#define raw_cpu_cmpxchg128(pcp, oval, nval) \
371+ raw_cpu_generic_cmpxchg(pcp, oval, nval)
317372 #endif
318373
319374 #ifndef this_cpu_read_1
@@ -407,6 +462,62 @@ do { \ · 87 unmodified lines
407462 #define this_cpu_xchg_8(pcp, nval) this_cpu_generic_xchg(pcp, nval)
408463 #endif
409464
465+#ifndef this_cpu_try_cmpxchg_1
466+#ifdef this_cpu_cmpxchg_1
467+#define this_cpu_try_cmpxchg_1(pcp, ovalp, nval) \
468+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_1)
469+#else
470+#define this_cpu_try_cmpxchg_1(pcp, ovalp, nval) \
471+ this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
472+#endif
473+#endif
474+#ifndef this_cpu_try_cmpxchg_2
475+#ifdef this_cpu_cmpxchg_2
476+#define this_cpu_try_cmpxchg_2(pcp, ovalp, nval) \
477+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_2)
478+#else
479+#define this_cpu_try_cmpxchg_2(pcp, ovalp, nval) \
480+ this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
481+#endif
482+#endif
483+#ifndef this_cpu_try_cmpxchg_4
484+#ifdef this_cpu_cmpxchg_4
485+#define this_cpu_try_cmpxchg_4(pcp, ovalp, nval) \
486+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_4)
487+#else
488+#define this_cpu_try_cmpxchg_4(pcp, ovalp, nval) \
489+ this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
490+#endif
491+#endif
492+#ifndef this_cpu_try_cmpxchg_8
493+#ifdef this_cpu_cmpxchg_8
494+#define this_cpu_try_cmpxchg_8(pcp, ovalp, nval) \
495+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_8)
496+#else
497+#define this_cpu_try_cmpxchg_8(pcp, ovalp, nval) \
498+ this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
499+#endif
500+#endif
501+
502+#ifndef this_cpu_try_cmpxchg64
503+#ifdef this_cpu_cmpxchg64
504+#define this_cpu_try_cmpxchg64(pcp, ovalp, nval) \
505+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg64)
506+#else
507+#define this_cpu_try_cmpxchg64(pcp, ovalp, nval) \
508+ this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
509+#endif
510+#endif
511+#ifndef this_cpu_try_cmpxchg128
512+#ifdef this_cpu_cmpxchg128
513+#define this_cpu_try_cmpxchg128(pcp, ovalp, nval) \
514+ __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg128)
515+#else
516+#define this_cpu_try_cmpxchg128(pcp, ovalp, nval) \
517+ this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
518+#endif
519+#endif
520+
410521 #ifndef this_cpu_cmpxchg_1
411522 #define this_cpu_cmpxchg_1(pcp, oval, nval) \
412523 this_cpu_generic_cmpxchg(pcp, oval, nval)
@@ -424,21 +535,13 @@ do { \ · 11 unmodified lines
424535 this_cpu_generic_cmpxchg(pcp, oval, nval)
425536 #endif
426537
427−#ifndef this_cpu_cmpxchg_double_1
428−#define this_cpu_cmpxchg_double_1(pcp1, pcp2, oval1, oval2, nval1, nval2) \
429− this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
430−#endif
431−#ifndef this_cpu_cmpxchg_double_2
432−#define this_cpu_cmpxchg_double_2(pcp1, pcp2, oval1, oval2, nval1, nval2) \
433− this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
434−#endif
435−#ifndef this_cpu_cmpxchg_double_4
436−#define this_cpu_cmpxchg_double_4(pcp1, pcp2, oval1, oval2, nval1, nval2) \
437− this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
538+#ifndef this_cpu_cmpxchg64
539+#define this_cpu_cmpxchg64(pcp, oval, nval) \
540+ this_cpu_generic_cmpxchg(pcp, oval, nval)
438541 #endif
439−#ifndef this_cpu_cmpxchg_double_8
440−#define this_cpu_cmpxchg_double_8(pcp1, pcp2, oval1, oval2, nval1, nval2) \
441− this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
542+#ifndef this_cpu_cmpxchg128
543+#define this_cpu_cmpxchg128(pcp, oval, nval) \
544+ this_cpu_generic_cmpxchg(pcp, oval, nval)
442545 #endif
443546
444547 #endif /* _ASM_GENERIC_PERCPU_H_ */
include/crypto/b128ops.h+3−11
@@ -49,10 +49,6 @@ · 48 unmodified lines
4949
5050 #include <linux/types.h>
5151
52−typedef struct {
53− u64 a, b;
54−} u128;
55−
5652 typedef struct {
5753 __be64 a, b;
5854 } be128;
@@ -61,20 +57,16 @@ typedef struct { · 2 unmodified lines
6157 __le64 b, a;
6258 } le128;
6359
64−static inline void u128_xor(u128 *r, const u128 *p, const u128 *q)
60+static inline void be128_xor(be128 *r, const be128 *p, const be128 *q)
6561 {
6662 r->a = p->a ^ q->a;
6763 r->b = p->b ^ q->b;
6864 }
6965
70−static inline void be128_xor(be128 *r, const be128 *p, const be128 *q)
71−{
72− u128_xor((u128 *)r, (u128 *)p, (u128 *)q);
73−}
74−
7566 static inline void le128_xor(le128 *r, const le128 *p, const le128 *q)
7667 {
77− u128_xor((u128 *)r, (u128 *)p, (u128 *)q);
68+ r->a = p->a ^ q->a;
69+ r->b = p->b ^ q->b;
7870 }
7971
8072 #endif /* _CRYPTO_B128OPS_H */
include/linux/atomic/atomic-arch-fallback.h+3576−1587
@@ -8,2664 +8,4653 @@ · 7 unmodified lines
88
99 #include <linux/compiler.h>
1010
11−#ifndef arch_xchg_relaxed
12−#define arch_xchg_acquire arch_xchg
13−#define arch_xchg_release arch_xchg
14−#define arch_xchg_relaxed arch_xchg
15−#else /* arch_xchg_relaxed */
16−
17−#ifndef arch_xchg_acquire
18−#define arch_xchg_acquire(...) \
19− __atomic_op_acquire(arch_xchg, __VA_ARGS__)
11+#if defined(arch_xchg)
12+#define raw_xchg arch_xchg
13+#elif defined(arch_xchg_relaxed)
14+#define raw_xchg(...) \
15+ __atomic_op_fence(arch_xchg, __VA_ARGS__)
16+#else
17+extern void raw_xchg_not_implemented(void);
18+#define raw_xchg(...) raw_xchg_not_implemented()
2019 #endif
2120
22−#ifndef arch_xchg_release
23−#define arch_xchg_release(...) \
24− __atomic_op_release(arch_xchg, __VA_ARGS__)
21+#if defined(arch_xchg_acquire)
22+#define raw_xchg_acquire arch_xchg_acquire
23+#elif defined(arch_xchg_relaxed)
24+#define raw_xchg_acquire(...) \
25+ __atomic_op_acquire(arch_xchg, __VA_ARGS__)
26+#elif defined(arch_xchg)
27+#define raw_xchg_acquire arch_xchg
28+#else
29+extern void raw_xchg_acquire_not_implemented(void);
30+#define raw_xchg_acquire(...) raw_xchg_acquire_not_implemented()
2531 #endif
2632
27−#ifndef arch_xchg
28−#define arch_xchg(...) \
29− __atomic_op_fence(arch_xchg, __VA_ARGS__)
33+#if defined(arch_xchg_release)
34+#define raw_xchg_release arch_xchg_release
35+#elif defined(arch_xchg_relaxed)
36+#define raw_xchg_release(...) \
37+ __atomic_op_release(arch_xchg, __VA_ARGS__)
38+#elif defined(arch_xchg)
39+#define raw_xchg_release arch_xchg
40+#else
41+extern void raw_xchg_release_not_implemented(void);
42+#define raw_xchg_release(...) raw_xchg_release_not_implemented()
43+#endif
44+
45+#if defined(arch_xchg_relaxed)
46+#define raw_xchg_relaxed arch_xchg_relaxed
47+#elif defined(arch_xchg)
48+#define raw_xchg_relaxed arch_xchg
49+#else
50+extern void raw_xchg_relaxed_not_implemented(void);
51+#define raw_xchg_relaxed(...) raw_xchg_relaxed_not_implemented()
52+#endif
53+
54+#if defined(arch_cmpxchg)
55+#define raw_cmpxchg arch_cmpxchg
56+#elif defined(arch_cmpxchg_relaxed)
57+#define raw_cmpxchg(...) \
58+ __atomic_op_fence(arch_cmpxchg, __VA_ARGS__)
59+#else
60+extern void raw_cmpxchg_not_implemented(void);
61+#define raw_cmpxchg(...) raw_cmpxchg_not_implemented()
3062 #endif
3163
32−#endif /* arch_xchg_relaxed */
33−
34−#ifndef arch_cmpxchg_relaxed
35−#define arch_cmpxchg_acquire arch_cmpxchg
36−#define arch_cmpxchg_release arch_cmpxchg
37−#define arch_cmpxchg_relaxed arch_cmpxchg
38−#else /* arch_cmpxchg_relaxed */
39−
40−#ifndef arch_cmpxchg_acquire
41−#define arch_cmpxchg_acquire(...) \
64+#if defined(arch_cmpxchg_acquire)
65+#define raw_cmpxchg_acquire arch_cmpxchg_acquire
66+#elif defined(arch_cmpxchg_relaxed)
67+#define raw_cmpxchg_acquire(...) \
4268 __atomic_op_acquire(arch_cmpxchg, __VA_ARGS__)
69+#elif defined(arch_cmpxchg)
70+#define raw_cmpxchg_acquire arch_cmpxchg
71+#else
72+extern void raw_cmpxchg_acquire_not_implemented(void);
73+#define raw_cmpxchg_acquire(...) raw_cmpxchg_acquire_not_implemented()
4374 #endif
4475
45−#ifndef arch_cmpxchg_release
46−#define arch_cmpxchg_release(...) \
76+#if defined(arch_cmpxchg_release)
77+#define raw_cmpxchg_release arch_cmpxchg_release
78+#elif defined(arch_cmpxchg_relaxed)
79+#define raw_cmpxchg_release(...) \
4780 __atomic_op_release(arch_cmpxchg, __VA_ARGS__)
81+#elif defined(arch_cmpxchg)
82+#define raw_cmpxchg_release arch_cmpxchg
83+#else
84+extern void raw_cmpxchg_release_not_implemented(void);
85+#define raw_cmpxchg_release(...) raw_cmpxchg_release_not_implemented()
86+#endif
87+
88+#if defined(arch_cmpxchg_relaxed)
89+#define raw_cmpxchg_relaxed arch_cmpxchg_relaxed
90+#elif defined(arch_cmpxchg)
91+#define raw_cmpxchg_relaxed arch_cmpxchg
92+#else
93+extern void raw_cmpxchg_relaxed_not_implemented(void);
94+#define raw_cmpxchg_relaxed(...) raw_cmpxchg_relaxed_not_implemented()
95+#endif
96+
97+#if defined(arch_cmpxchg64)
98+#define raw_cmpxchg64 arch_cmpxchg64
99+#elif defined(arch_cmpxchg64_relaxed)
100+#define raw_cmpxchg64(...) \
101+ __atomic_op_fence(arch_cmpxchg64, __VA_ARGS__)
102+#else
103+extern void raw_cmpxchg64_not_implemented(void);
104+#define raw_cmpxchg64(...) raw_cmpxchg64_not_implemented()
48105 #endif
49106
50−#ifndef arch_cmpxchg
51−#define arch_cmpxchg(...) \
52− __atomic_op_fence(arch_cmpxchg, __VA_ARGS__)
53−#endif
54−
55−#endif /* arch_cmpxchg_relaxed */
56−
57−#ifndef arch_cmpxchg64_relaxed
58−#define arch_cmpxchg64_acquire arch_cmpxchg64
59−#define arch_cmpxchg64_release arch_cmpxchg64
60−#define arch_cmpxchg64_relaxed arch_cmpxchg64
61−#else /* arch_cmpxchg64_relaxed */
62−
63−#ifndef arch_cmpxchg64_acquire
64−#define arch_cmpxchg64_acquire(...) \
107+#if defined(arch_cmpxchg64_acquire)
108+#define raw_cmpxchg64_acquire arch_cmpxchg64_acquire
109+#elif defined(arch_cmpxchg64_relaxed)
110+#define raw_cmpxchg64_acquire(...) \
65111 __atomic_op_acquire(arch_cmpxchg64, __VA_ARGS__)
112+#elif defined(arch_cmpxchg64)
113+#define raw_cmpxchg64_acquire arch_cmpxchg64
114+#else
115+extern void raw_cmpxchg64_acquire_not_implemented(void);
116+#define raw_cmpxchg64_acquire(...) raw_cmpxchg64_acquire_not_implemented()
66117 #endif
67118
68−#ifndef arch_cmpxchg64_release
69−#define arch_cmpxchg64_release(...) \
119+#if defined(arch_cmpxchg64_release)
120+#define raw_cmpxchg64_release arch_cmpxchg64_release
121+#elif defined(arch_cmpxchg64_relaxed)
122+#define raw_cmpxchg64_release(...) \
70123 __atomic_op_release(arch_cmpxchg64, __VA_ARGS__)
124+#elif defined(arch_cmpxchg64)
125+#define raw_cmpxchg64_release arch_cmpxchg64
126+#else
127+extern void raw_cmpxchg64_release_not_implemented(void);
128+#define raw_cmpxchg64_release(...) raw_cmpxchg64_release_not_implemented()
129+#endif
130+
131+#if defined(arch_cmpxchg64_relaxed)
132+#define raw_cmpxchg64_relaxed arch_cmpxchg64_relaxed
133+#elif defined(arch_cmpxchg64)
134+#define raw_cmpxchg64_relaxed arch_cmpxchg64
135+#else
136+extern void raw_cmpxchg64_relaxed_not_implemented(void);
137+#define raw_cmpxchg64_relaxed(...) raw_cmpxchg64_relaxed_not_implemented()
138+#endif
139+
140+#if defined(arch_cmpxchg128)
141+#define raw_cmpxchg128 arch_cmpxchg128
142+#elif defined(arch_cmpxchg128_relaxed)
143+#define raw_cmpxchg128(...) \
144+ __atomic_op_fence(arch_cmpxchg128, __VA_ARGS__)
145+#else
146+extern void raw_cmpxchg128_not_implemented(void);
147+#define raw_cmpxchg128(...) raw_cmpxchg128_not_implemented()
148+#endif
149+
150+#if defined(arch_cmpxchg128_acquire)
151+#define raw_cmpxchg128_acquire arch_cmpxchg128_acquire
152+#elif defined(arch_cmpxchg128_relaxed)
153+#define raw_cmpxchg128_acquire(...) \
154+ __atomic_op_acquire(arch_cmpxchg128, __VA_ARGS__)
155+#elif defined(arch_cmpxchg128)
156+#define raw_cmpxchg128_acquire arch_cmpxchg128
157+#else
158+extern void raw_cmpxchg128_acquire_not_implemented(void);
159+#define raw_cmpxchg128_acquire(...) raw_cmpxchg128_acquire_not_implemented()
160+#endif
161+
162+#if defined(arch_cmpxchg128_release)
163+#define raw_cmpxchg128_release arch_cmpxchg128_release
164+#elif defined(arch_cmpxchg128_relaxed)
165+#define raw_cmpxchg128_release(...) \
166+ __atomic_op_release(arch_cmpxchg128, __VA_ARGS__)
167+#elif defined(arch_cmpxchg128)
168+#define raw_cmpxchg128_release arch_cmpxchg128
169+#else
170+extern void raw_cmpxchg128_release_not_implemented(void);
171+#define raw_cmpxchg128_release(...) raw_cmpxchg128_release_not_implemented()
172+#endif
173+
174+#if defined(arch_cmpxchg128_relaxed)
175+#define raw_cmpxchg128_relaxed arch_cmpxchg128_relaxed
176+#elif defined(arch_cmpxchg128)
177+#define raw_cmpxchg128_relaxed arch_cmpxchg128
178+#else
179+extern void raw_cmpxchg128_relaxed_not_implemented(void);
180+#define raw_cmpxchg128_relaxed(...) raw_cmpxchg128_relaxed_not_implemented()
181+#endif
182+
183+#if defined(arch_try_cmpxchg)
184+#define raw_try_cmpxchg arch_try_cmpxchg
185+#elif defined(arch_try_cmpxchg_relaxed)
186+#define raw_try_cmpxchg(...) \
187+ __atomic_op_fence(arch_try_cmpxchg, __VA_ARGS__)
188+#else
189+#define raw_try_cmpxchg(_ptr, _oldp, _new) \
190+({ \
191+ typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
192+ ___r = raw_cmpxchg((_ptr), ___o, (_new)); \
193+ if (unlikely(___r != ___o)) \
194+ *___op = ___r; \
195+ likely(___r == ___o); \
196+})
71197 #endif
72198
73−#ifndef arch_cmpxchg64
74−#define arch_cmpxchg64(...) \
75− __atomic_op_fence(arch_cmpxchg64, __VA_ARGS__)
199+#if defined(arch_try_cmpxchg_acquire)
200+#define raw_try_cmpxchg_acquire arch_try_cmpxchg_acquire
201+#elif defined(arch_try_cmpxchg_relaxed)
202+#define raw_try_cmpxchg_acquire(...) \
203+ __atomic_op_acquire(arch_try_cmpxchg, __VA_ARGS__)
204+#elif defined(arch_try_cmpxchg)
205+#define raw_try_cmpxchg_acquire arch_try_cmpxchg
206+#else
207+#define raw_try_cmpxchg_acquire(_ptr, _oldp, _new) \
208+({ \
209+ typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
210+ ___r = raw_cmpxchg_acquire((_ptr), ___o, (_new)); \
211+ if (unlikely(___r != ___o)) \
212+ *___op = ___r; \
213+ likely(___r == ___o); \
214+})
76215 #endif
77216
78−#endif /* arch_cmpxchg64_relaxed */
79−
80−#ifndef arch_try_cmpxchg_relaxed
81−#ifdef arch_try_cmpxchg
82−#define arch_try_cmpxchg_acquire arch_try_cmpxchg
83−#define arch_try_cmpxchg_release arch_try_cmpxchg
84−#define arch_try_cmpxchg_relaxed arch_try_cmpxchg
85−#endif /* arch_try_cmpxchg */
86−
87−#ifndef arch_try_cmpxchg
88−#define arch_try_cmpxchg(_ptr, _oldp, _new) \
217+#if defined(arch_try_cmpxchg_release)
218+#define raw_try_cmpxchg_release arch_try_cmpxchg_release
219+#elif defined(arch_try_cmpxchg_relaxed)
220+#define raw_try_cmpxchg_release(...) \
221+ __atomic_op_release(arch_try_cmpxchg, __VA_ARGS__)
222+#elif defined(arch_try_cmpxchg)
223+#define raw_try_cmpxchg_release arch_try_cmpxchg
224+#else
225+#define raw_try_cmpxchg_release(_ptr, _oldp, _new) \
89226 ({ \
90227 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
91− ___r = arch_cmpxchg((_ptr), ___o, (_new)); \
228+ ___r = raw_cmpxchg_release((_ptr), ___o, (_new)); \
92229 if (unlikely(___r != ___o)) \
93230 *___op = ___r; \
94231 likely(___r == ___o); \
95232 })
96−#endif /* arch_try_cmpxchg */
233+#endif
97234
98−#ifndef arch_try_cmpxchg_acquire
99−#define arch_try_cmpxchg_acquire(_ptr, _oldp, _new) \
235+#if defined(arch_try_cmpxchg_relaxed)
236+#define raw_try_cmpxchg_relaxed arch_try_cmpxchg_relaxed
237+#elif defined(arch_try_cmpxchg)
238+#define raw_try_cmpxchg_relaxed arch_try_cmpxchg
239+#else
240+#define raw_try_cmpxchg_relaxed(_ptr, _oldp, _new) \
100241 ({ \
101242 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
102− ___r = arch_cmpxchg_acquire((_ptr), ___o, (_new)); \
243+ ___r = raw_cmpxchg_relaxed((_ptr), ___o, (_new)); \
103244 if (unlikely(___r != ___o)) \
104245 *___op = ___r; \
105246 likely(___r == ___o); \
106247 })
107−#endif /* arch_try_cmpxchg_acquire */
248+#endif
108249
109−#ifndef arch_try_cmpxchg_release
110−#define arch_try_cmpxchg_release(_ptr, _oldp, _new) \
250+#if defined(arch_try_cmpxchg64)
251+#define raw_try_cmpxchg64 arch_try_cmpxchg64
252+#elif defined(arch_try_cmpxchg64_relaxed)
253+#define raw_try_cmpxchg64(...) \
254+ __atomic_op_fence(arch_try_cmpxchg64, __VA_ARGS__)
255+#else
256+#define raw_try_cmpxchg64(_ptr, _oldp, _new) \
111257 ({ \
112258 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
113− ___r = arch_cmpxchg_release((_ptr), ___o, (_new)); \
259+ ___r = raw_cmpxchg64((_ptr), ___o, (_new)); \
114260 if (unlikely(___r != ___o)) \
115261 *___op = ___r; \
116262 likely(___r == ___o); \
117263 })
118−#endif /* arch_try_cmpxchg_release */
264+#endif
119265
120−#ifndef arch_try_cmpxchg_relaxed
121−#define arch_try_cmpxchg_relaxed(_ptr, _oldp, _new) \
266+#if defined(arch_try_cmpxchg64_acquire)
267+#define raw_try_cmpxchg64_acquire arch_try_cmpxchg64_acquire
268+#elif defined(arch_try_cmpxchg64_relaxed)
269+#define raw_try_cmpxchg64_acquire(...) \
270+ __atomic_op_acquire(arch_try_cmpxchg64, __VA_ARGS__)
271+#elif defined(arch_try_cmpxchg64)
272+#define raw_try_cmpxchg64_acquire arch_try_cmpxchg64
273+#else
274+#define raw_try_cmpxchg64_acquire(_ptr, _oldp, _new) \
122275 ({ \
123276 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
124− ___r = arch_cmpxchg_relaxed((_ptr), ___o, (_new)); \
277+ ___r = raw_cmpxchg64_acquire((_ptr), ___o, (_new)); \
125278 if (unlikely(___r != ___o)) \
126279 *___op = ___r; \
127280 likely(___r == ___o); \
128281 })
129−#endif /* arch_try_cmpxchg_relaxed */
130−
131−#else /* arch_try_cmpxchg_relaxed */
132−
133−#ifndef arch_try_cmpxchg_acquire
134−#define arch_try_cmpxchg_acquire(...) \
135− __atomic_op_acquire(arch_try_cmpxchg, __VA_ARGS__)
136282 #endif
137283
138−#ifndef arch_try_cmpxchg_release
139−#define arch_try_cmpxchg_release(...) \
140− __atomic_op_release(arch_try_cmpxchg, __VA_ARGS__)
284+#if defined(arch_try_cmpxchg64_release)
285+#define raw_try_cmpxchg64_release arch_try_cmpxchg64_release
286+#elif defined(arch_try_cmpxchg64_relaxed)
287+#define raw_try_cmpxchg64_release(...) \
288+ __atomic_op_release(arch_try_cmpxchg64, __VA_ARGS__)
289+#elif defined(arch_try_cmpxchg64)
290+#define raw_try_cmpxchg64_release arch_try_cmpxchg64
291+#else
292+#define raw_try_cmpxchg64_release(_ptr, _oldp, _new) \
293+({ \
294+ typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
295+ ___r = raw_cmpxchg64_release((_ptr), ___o, (_new)); \
296+ if (unlikely(___r != ___o)) \
297+ *___op = ___r; \
298+ likely(___r == ___o); \
299+})
141300 #endif
142301
143−#ifndef arch_try_cmpxchg
144−#define arch_try_cmpxchg(...) \
145− __atomic_op_fence(arch_try_cmpxchg, __VA_ARGS__)
302+#if defined(arch_try_cmpxchg64_relaxed)
303+#define raw_try_cmpxchg64_relaxed arch_try_cmpxchg64_relaxed
304+#elif defined(arch_try_cmpxchg64)
305+#define raw_try_cmpxchg64_relaxed arch_try_cmpxchg64
306+#else
307+#define raw_try_cmpxchg64_relaxed(_ptr, _oldp, _new) \
308+({ \
309+ typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
310+ ___r = raw_cmpxchg64_relaxed((_ptr), ___o, (_new)); \
311+ if (unlikely(___r != ___o)) \
312+ *___op = ___r; \
313+ likely(___r == ___o); \
314+})
146315 #endif
147316
148−#endif /* arch_try_cmpxchg_relaxed */
149−
150−#ifndef arch_try_cmpxchg64_relaxed
151−#ifdef arch_try_cmpxchg64
152−#define arch_try_cmpxchg64_acquire arch_try_cmpxchg64
153−#define arch_try_cmpxchg64_release arch_try_cmpxchg64
154−#define arch_try_cmpxchg64_relaxed arch_try_cmpxchg64
155−#endif /* arch_try_cmpxchg64 */
156−
157−#ifndef arch_try_cmpxchg64
158−#define arch_try_cmpxchg64(_ptr, _oldp, _new) \
317+#if defined(arch_try_cmpxchg128)
318+#define raw_try_cmpxchg128 arch_try_cmpxchg128
319+#elif defined(arch_try_cmpxchg128_relaxed)
320+#define raw_try_cmpxchg128(...) \
321+ __atomic_op_fence(arch_try_cmpxchg128, __VA_ARGS__)
322+#else
323+#define raw_try_cmpxchg128(_ptr, _oldp, _new) \
159324 ({ \
160325 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
161− ___r = arch_cmpxchg64((_ptr), ___o, (_new)); \
326+ ___r = raw_cmpxchg128((_ptr), ___o, (_new)); \
162327 if (unlikely(___r != ___o)) \
163328 *___op = ___r; \
164329 likely(___r == ___o); \
165330 })
166−#endif /* arch_try_cmpxchg64 */
331+#endif
167332
168−#ifndef arch_try_cmpxchg64_acquire
169−#define arch_try_cmpxchg64_acquire(_ptr, _oldp, _new) \
333+#if defined(arch_try_cmpxchg128_acquire)
334+#define raw_try_cmpxchg128_acquire arch_try_cmpxchg128_acquire
335+#elif defined(arch_try_cmpxchg128_relaxed)
336+#define raw_try_cmpxchg128_acquire(...) \
337+ __atomic_op_acquire(arch_try_cmpxchg128, __VA_ARGS__)
338+#elif defined(arch_try_cmpxchg128)
339+#define raw_try_cmpxchg128_acquire arch_try_cmpxchg128
340+#else
341+#define raw_try_cmpxchg128_acquire(_ptr, _oldp, _new) \
170342 ({ \
171343 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
172− ___r = arch_cmpxchg64_acquire((_ptr), ___o, (_new)); \
344+ ___r = raw_cmpxchg128_acquire((_ptr), ___o, (_new)); \
173345 if (unlikely(___r != ___o)) \
174346 *___op = ___r; \
175347 likely(___r == ___o); \
176348 })
177−#endif /* arch_try_cmpxchg64_acquire */
349+#endif
178350
179−#ifndef arch_try_cmpxchg64_release
180−#define arch_try_cmpxchg64_release(_ptr, _oldp, _new) \
351+#if defined(arch_try_cmpxchg128_release)
352+#define raw_try_cmpxchg128_release arch_try_cmpxchg128_release
353+#elif defined(arch_try_cmpxchg128_relaxed)
354+#define raw_try_cmpxchg128_release(...) \
355+ __atomic_op_release(arch_try_cmpxchg128, __VA_ARGS__)
356+#elif defined(arch_try_cmpxchg128)
357+#define raw_try_cmpxchg128_release arch_try_cmpxchg128
358+#else
359+#define raw_try_cmpxchg128_release(_ptr, _oldp, _new) \
181360 ({ \
182361 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
183− ___r = arch_cmpxchg64_release((_ptr), ___o, (_new)); \
362+ ___r = raw_cmpxchg128_release((_ptr), ___o, (_new)); \
184363 if (unlikely(___r != ___o)) \
185364 *___op = ___r; \
186365 likely(___r == ___o); \
187366 })
188−#endif /* arch_try_cmpxchg64_release */
367+#endif
189368
190−#ifndef arch_try_cmpxchg64_relaxed
191−#define arch_try_cmpxchg64_relaxed(_ptr, _oldp, _new) \
369+#if defined(arch_try_cmpxchg128_relaxed)
370+#define raw_try_cmpxchg128_relaxed arch_try_cmpxchg128_relaxed
371+#elif defined(arch_try_cmpxchg128)
372+#define raw_try_cmpxchg128_relaxed arch_try_cmpxchg128
373+#else
374+#define raw_try_cmpxchg128_relaxed(_ptr, _oldp, _new) \
192375 ({ \
193376 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
194− ___r = arch_cmpxchg64_relaxed((_ptr), ___o, (_new)); \
377+ ___r = raw_cmpxchg128_relaxed((_ptr), ___o, (_new)); \
195378 if (unlikely(___r != ___o)) \
196379 *___op = ___r; \
197380 likely(___r == ___o); \
198381 })
199−#endif /* arch_try_cmpxchg64_relaxed */
200−
201−#else /* arch_try_cmpxchg64_relaxed */
202−
203−#ifndef arch_try_cmpxchg64_acquire
204−#define arch_try_cmpxchg64_acquire(...) \
205− __atomic_op_acquire(arch_try_cmpxchg64, __VA_ARGS__)
206382 #endif
207383
208−#ifndef arch_try_cmpxchg64_release
209−#define arch_try_cmpxchg64_release(...) \
210− __atomic_op_release(arch_try_cmpxchg64, __VA_ARGS__)
211−#endif
384+#define raw_cmpxchg_local arch_cmpxchg_local
212385
213−#ifndef arch_try_cmpxchg64
214−#define arch_try_cmpxchg64(...) \
215− __atomic_op_fence(arch_try_cmpxchg64, __VA_ARGS__)
386+#ifdef arch_try_cmpxchg_local
387+#define raw_try_cmpxchg_local arch_try_cmpxchg_local
388+#else
389+#define raw_try_cmpxchg_local(_ptr, _oldp, _new) \
390+({ \
391+ typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
392+ ___r = raw_cmpxchg_local((_ptr), ___o, (_new)); \
393+ if (unlikely(___r != ___o)) \
394+ *___op = ___r; \
395+ likely(___r == ___o); \
396+})
216397 #endif
217398
218−#endif /* arch_try_cmpxchg64_relaxed */
399+#define raw_cmpxchg64_local arch_cmpxchg64_local
219400
220−#ifndef arch_try_cmpxchg_local
221−#define arch_try_cmpxchg_local(_ptr, _oldp, _new) \
401+#ifdef arch_try_cmpxchg64_local
402+#define raw_try_cmpxchg64_local arch_try_cmpxchg64_local
403+#else
404+#define raw_try_cmpxchg64_local(_ptr, _oldp, _new) \
222405 ({ \
223406 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
224− ___r = arch_cmpxchg_local((_ptr), ___o, (_new)); \
407+ ___r = raw_cmpxchg64_local((_ptr), ___o, (_new)); \
225408 if (unlikely(___r != ___o)) \
226409 *___op = ___r; \
227410 likely(___r == ___o); \
228411 })
229−#endif /* arch_try_cmpxchg_local */
412+#endif
230413
231−#ifndef arch_try_cmpxchg64_local
232−#define arch_try_cmpxchg64_local(_ptr, _oldp, _new) \
414+#define raw_cmpxchg128_local arch_cmpxchg128_local
415+
416+#ifdef arch_try_cmpxchg128_local
417+#define raw_try_cmpxchg128_local arch_try_cmpxchg128_local
418+#else
419+#define raw_try_cmpxchg128_local(_ptr, _oldp, _new) \
233420 ({ \
234421 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
235− ___r = arch_cmpxchg64_local((_ptr), ___o, (_new)); \
422+ ___r = raw_cmpxchg128_local((_ptr), ___o, (_new)); \
236423 if (unlikely(___r != ___o)) \
237424 *___op = ___r; \
238425 likely(___r == ___o); \
239426 })
240−#endif /* arch_try_cmpxchg64_local */
427+#endif
428+
429+#define raw_sync_cmpxchg arch_sync_cmpxchg
430+
431+/**
432+ * raw_atomic_read() - atomic load with relaxed ordering
433+ * @v: pointer to atomic_t
434+ *
435+ * Atomically loads the value of @v with relaxed ordering.
436+ *
437+ * Safe to use in noinstr code; prefer atomic_read() elsewhere.
438+ *
439+ * Return: The value loaded from @v.
440+ */
441+static __always_inline int
442+raw_atomic_read(const atomic_t *v)
443+{
444+ return arch_atomic_read(v);
445+}
241446
242−#ifndef arch_atomic_read_acquire
447+/**
448+ * raw_atomic_read_acquire() - atomic load with acquire ordering
449+ * @v: pointer to atomic_t
450+ *
451+ * Atomically loads the value of @v with acquire ordering.
452+ *
453+ * Safe to use in noinstr code; prefer atomic_read_acquire() elsewhere.
454+ *
455+ * Return: The value loaded from @v.
456+ */
243457 static __always_inline int
244−arch_atomic_read_acquire(const atomic_t *v)
458+raw_atomic_read_acquire(const atomic_t *v)
245459 {
460+#if defined(arch_atomic_read_acquire)
461+ return arch_atomic_read_acquire(v);
462+#elif defined(arch_atomic_read)
463+ return arch_atomic_read(v);
464+#else
246465 int ret;
247466
248467 if (__native_word(atomic_t)) {
249468 ret = smp_load_acquire(&(v)->counter);
250469 } else {
251− ret = arch_atomic_read(v);
470+ ret = raw_atomic_read(v);
252471 __atomic_acquire_fence();
253472 }
254473
255474 return ret;
256−}
257−#define arch_atomic_read_acquire arch_atomic_read_acquire
258475 #endif
476+}
477+
478+/**
479+ * raw_atomic_set() - atomic set with relaxed ordering
480+ * @v: pointer to atomic_t
481+ * @i: int value to assign
482+ *
483+ * Atomically sets @v to @i with relaxed ordering.
484+ *
485+ * Safe to use in noinstr code; prefer atomic_set() elsewhere.
486+ *
487+ * Return: Nothing.
488+ */
489+static __always_inline void
490+raw_atomic_set(atomic_t *v, int i)
491+{
492+ arch_atomic_set(v, i);
493+}
259494
260−#ifndef arch_atomic_set_release
495+/**
496+ * raw_atomic_set_release() - atomic set with release ordering
497+ * @v: pointer to atomic_t
498+ * @i: int value to assign
499+ *
500+ * Atomically sets @v to @i with release ordering.
501+ *
502+ * Safe to use in noinstr code; prefer atomic_set_release() elsewhere.
503+ *
504+ * Return: Nothing.
505+ */
261506 static __always_inline void
262−arch_atomic_set_release(atomic_t *v, int i)
507+raw_atomic_set_release(atomic_t *v, int i)
263508 {
509+#if defined(arch_atomic_set_release)
510+ arch_atomic_set_release(v, i);
511+#elif defined(arch_atomic_set)
512+ arch_atomic_set(v, i);
513+#else
264514 if (__native_word(atomic_t)) {
265515 smp_store_release(&(v)->counter, i);
266516 } else {
267517 __atomic_release_fence();
268− arch_atomic_set(v, i);
518+ raw_atomic_set(v, i);
269519 }
270−}
271−#define arch_atomic_set_release arch_atomic_set_release
272520 #endif
521+}
522+
523+/**
524+ * raw_atomic_add() - atomic add with relaxed ordering
525+ * @i: int value to add
526+ * @v: pointer to atomic_t
527+ *
528+ * Atomically updates @v to (@v + @i) with relaxed ordering.
529+ *
530+ * Safe to use in noinstr code; prefer atomic_add() elsewhere.
531+ *
532+ * Return: Nothing.
533+ */
534+static __always_inline void
535+raw_atomic_add(int i, atomic_t *v)
536+{
537+ arch_atomic_add(i, v);
538+}
273539
274−#ifndef arch_atomic_add_return_relaxed
275−#define arch_atomic_add_return_acquire arch_atomic_add_return
276−#define arch_atomic_add_return_release arch_atomic_add_return
277−#define arch_atomic_add_return_relaxed arch_atomic_add_return
278−#else /* arch_atomic_add_return_relaxed */
540+/**
541+ * raw_atomic_add_return() - atomic add with full ordering
542+ * @i: int value to add
543+ * @v: pointer to atomic_t
544+ *
545+ * Atomically updates @v to (@v + @i) with full ordering.
546+ *
547+ * Safe to use in noinstr code; prefer atomic_add_return() elsewhere.
548+ *
549+ * Return: The updated value of @v.
550+ */
551+static __always_inline int
552+raw_atomic_add_return(int i, atomic_t *v)
553+{
554+#if defined(arch_atomic_add_return)
555+ return arch_atomic_add_return(i, v);
556+#elif defined(arch_atomic_add_return_relaxed)
557+ int ret;
558+ __atomic_pre_full_fence();
559+ ret = arch_atomic_add_return_relaxed(i, v);
560+ __atomic_post_full_fence();
561+ return ret;
562+#else
563+#error "Unable to define raw_atomic_add_return"
564+#endif
565+}
279566
280−#ifndef arch_atomic_add_return_acquire
567+/**
568+ * raw_atomic_add_return_acquire() - atomic add with acquire ordering
569+ * @i: int value to add
570+ * @v: pointer to atomic_t
571+ *
572+ * Atomically updates @v to (@v + @i) with acquire ordering.
573+ *
574+ * Safe to use in noinstr code; prefer atomic_add_return_acquire() elsewhere.
575+ *
576+ * Return: The updated value of @v.
577+ */
281578 static __always_inline int
282−arch_atomic_add_return_acquire(int i, atomic_t *v)
579+raw_atomic_add_return_acquire(int i, atomic_t *v)
283580 {
581+#if defined(arch_atomic_add_return_acquire)
582+ return arch_atomic_add_return_acquire(i, v);
583+#elif defined(arch_atomic_add_return_relaxed)
284584 int ret = arch_atomic_add_return_relaxed(i, v);
285585 __atomic_acquire_fence();
286586 return ret;
287−}
288−#define arch_atomic_add_return_acquire arch_atomic_add_return_acquire
587+#elif defined(arch_atomic_add_return)
588+ return arch_atomic_add_return(i, v);
589+#else
590+#error "Unable to define raw_atomic_add_return_acquire"
289591 #endif
592+}
290593
291−#ifndef arch_atomic_add_return_release
594+/**
595+ * raw_atomic_add_return_release() - atomic add with release ordering
596+ * @i: int value to add
597+ * @v: pointer to atomic_t
598+ *
599+ * Atomically updates @v to (@v + @i) with release ordering.
600+ *
601+ * Safe to use in noinstr code; prefer atomic_add_return_release() elsewhere.
602+ *
603+ * Return: The updated value of @v.
604+ */
292605 static __always_inline int
293−arch_atomic_add_return_release(int i, atomic_t *v)
606+raw_atomic_add_return_release(int i, atomic_t *v)
294607 {
608+#if defined(arch_atomic_add_return_release)
609+ return arch_atomic_add_return_release(i, v);
610+#elif defined(arch_atomic_add_return_relaxed)
295611 __atomic_release_fence();
296612 return arch_atomic_add_return_relaxed(i, v);
613+#elif defined(arch_atomic_add_return)
614+ return arch_atomic_add_return(i, v);
615+#else
616+#error "Unable to define raw_atomic_add_return_release"
617+#endif
297618 }
298−#define arch_atomic_add_return_release arch_atomic_add_return_release
619+
620+/**
621+ * raw_atomic_add_return_relaxed() - atomic add with relaxed ordering
622+ * @i: int value to add
623+ * @v: pointer to atomic_t
624+ *
625+ * Atomically updates @v to (@v + @i) with relaxed ordering.
626+ *
627+ * Safe to use in noinstr code; prefer atomic_add_return_relaxed() elsewhere.
628+ *
629+ * Return: The updated value of @v.
630+ */
631+static __always_inline int
632+raw_atomic_add_return_relaxed(int i, atomic_t *v)
633+{
634+#if defined(arch_atomic_add_return_relaxed)
635+ return arch_atomic_add_return_relaxed(i, v);
636+#elif defined(arch_atomic_add_return)
637+ return arch_atomic_add_return(i, v);
638+#else
639+#error "Unable to define raw_atomic_add_return_relaxed"
299640 #endif
641+}
300642
301−#ifndef arch_atomic_add_return
643+/**
644+ * raw_atomic_fetch_add() - atomic add with full ordering
645+ * @i: int value to add
646+ * @v: pointer to atomic_t
647+ *
648+ * Atomically updates @v to (@v + @i) with full ordering.
649+ *
650+ * Safe to use in noinstr code; prefer atomic_fetch_add() elsewhere.
651+ *
652+ * Return: The original value of @v.
653+ */
302654 static __always_inline int
303−arch_atomic_add_return(int i, atomic_t *v)
655+raw_atomic_fetch_add(int i, atomic_t *v)
304656 {
657+#if defined(arch_atomic_fetch_add)
658+ return arch_atomic_fetch_add(i, v);
659+#elif defined(arch_atomic_fetch_add_relaxed)
305660 int ret;
306661 __atomic_pre_full_fence();
307− ret = arch_atomic_add_return_relaxed(i, v);
662+ ret = arch_atomic_fetch_add_relaxed(i, v);
308663 __atomic_post_full_fence();
309664 return ret;
310−}
311−#define arch_atomic_add_return arch_atomic_add_return
665+#else
666+#error "Unable to define raw_atomic_fetch_add"
312667 #endif
668+}
313669
314−#endif /* arch_atomic_add_return_relaxed */
315−
316−#ifndef arch_atomic_fetch_add_relaxed
317−#define arch_atomic_fetch_add_acquire arch_atomic_fetch_add
318−#define arch_atomic_fetch_add_release arch_atomic_fetch_add
319−#define arch_atomic_fetch_add_relaxed arch_atomic_fetch_add
320−#else /* arch_atomic_fetch_add_relaxed */
321−
322−#ifndef arch_atomic_fetch_add_acquire
670+/**
671+ * raw_atomic_fetch_add_acquire() - atomic add with acquire ordering
672+ * @i: int value to add
673+ * @v: pointer to atomic_t
674+ *
675+ * Atomically updates @v to (@v + @i) with acquire ordering.
676+ *
677+ * Safe to use in noinstr code; prefer atomic_fetch_add_acquire() elsewhere.
678+ *
679+ * Return: The original value of @v.
680+ */
323681 static __always_inline int
324−arch_atomic_fetch_add_acquire(int i, atomic_t *v)
682+raw_atomic_fetch_add_acquire(int i, atomic_t *v)
325683 {
684+#if defined(arch_atomic_fetch_add_acquire)
685+ return arch_atomic_fetch_add_acquire(i, v);
686+#elif defined(arch_atomic_fetch_add_relaxed)
326687 int ret = arch_atomic_fetch_add_relaxed(i, v);
327688 __atomic_acquire_fence();
328689 return ret;
329−}
330−#define arch_atomic_fetch_add_acquire arch_atomic_fetch_add_acquire
690+#elif defined(arch_atomic_fetch_add)
691+ return arch_atomic_fetch_add(i, v);
692+#else
693+#error "Unable to define raw_atomic_fetch_add_acquire"
331694 #endif
695+}
332696
333−#ifndef arch_atomic_fetch_add_release
697+/**
698+ * raw_atomic_fetch_add_release() - atomic add with release ordering
699+ * @i: int value to add
700+ * @v: pointer to atomic_t
701+ *
702+ * Atomically updates @v to (@v + @i) with release ordering.
703+ *
704+ * Safe to use in noinstr code; prefer atomic_fetch_add_release() elsewhere.
705+ *
706+ * Return: The original value of @v.
707+ */
334708 static __always_inline int
335−arch_atomic_fetch_add_release(int i, atomic_t *v)
709+raw_atomic_fetch_add_release(int i, atomic_t *v)
336710 {
711+#if defined(arch_atomic_fetch_add_release)
712+ return arch_atomic_fetch_add_release(i, v);
713+#elif defined(arch_atomic_fetch_add_relaxed)
337714 __atomic_release_fence();
338715 return arch_atomic_fetch_add_relaxed(i, v);
716+#elif defined(arch_atomic_fetch_add)
717+ return arch_atomic_fetch_add(i, v);
718+#else
719+#error "Unable to define raw_atomic_fetch_add_release"
720+#endif
339721 }
340−#define arch_atomic_fetch_add_release arch_atomic_fetch_add_release
722+
723+/**
724+ * raw_atomic_fetch_add_relaxed() - atomic add with relaxed ordering
725+ * @i: int value to add
726+ * @v: pointer to atomic_t
727+ *
728+ * Atomically updates @v to (@v + @i) with relaxed ordering.
729+ *
730+ * Safe to use in noinstr code; prefer atomic_fetch_add_relaxed() elsewhere.
731+ *
732+ * Return: The original value of @v.
733+ */
734+static __always_inline int
735+raw_atomic_fetch_add_relaxed(int i, atomic_t *v)
736+{
737+#if defined(arch_atomic_fetch_add_relaxed)
738+ return arch_atomic_fetch_add_relaxed(i, v);
739+#elif defined(arch_atomic_fetch_add)
740+ return arch_atomic_fetch_add(i, v);
741+#else
742+#error "Unable to define raw_atomic_fetch_add_relaxed"
341743 #endif
744+}
745+
746+/**
747+ * raw_atomic_sub() - atomic subtract with relaxed ordering
748+ * @i: int value to subtract
749+ * @v: pointer to atomic_t
750+ *
751+ * Atomically updates @v to (@v - @i) with relaxed ordering.
752+ *
753+ * Safe to use in noinstr code; prefer atomic_sub() elsewhere.
754+ *
755+ * Return: Nothing.
756+ */
757+static __always_inline void
758+raw_atomic_sub(int i, atomic_t *v)
759+{
760+ arch_atomic_sub(i, v);
761+}
342762
343−#ifndef arch_atomic_fetch_add
763+/**
764+ * raw_atomic_sub_return() - atomic subtract with full ordering
765+ * @i: int value to subtract
766+ * @v: pointer to atomic_t
767+ *
768+ * Atomically updates @v to (@v - @i) with full ordering.
769+ *
770+ * Safe to use in noinstr code; prefer atomic_sub_return() elsewhere.
771+ *
772+ * Return: The updated value of @v.
773+ */
344774 static __always_inline int
345−arch_atomic_fetch_add(int i, atomic_t *v)
775+raw_atomic_sub_return(int i, atomic_t *v)
346776 {
777+#if defined(arch_atomic_sub_return)
778+ return arch_atomic_sub_return(i, v);
779+#elif defined(arch_atomic_sub_return_relaxed)
347780 int ret;
348781 __atomic_pre_full_fence();
349− ret = arch_atomic_fetch_add_relaxed(i, v);
782+ ret = arch_atomic_sub_return_relaxed(i, v);
350783 __atomic_post_full_fence();
351784 return ret;
352−}
353−#define arch_atomic_fetch_add arch_atomic_fetch_add
785+#else
786+#error "Unable to define raw_atomic_sub_return"
354787 #endif
788+}
355789
356−#endif /* arch_atomic_fetch_add_relaxed */
357−
358−#ifndef arch_atomic_sub_return_relaxed
359−#define arch_atomic_sub_return_acquire arch_atomic_sub_return
360−#define arch_atomic_sub_return_release arch_atomic_sub_return
361−#define arch_atomic_sub_return_relaxed arch_atomic_sub_return
362−#else /* arch_atomic_sub_return_relaxed */
363−
364−#ifndef arch_atomic_sub_return_acquire
790+/**
791+ * raw_atomic_sub_return_acquire() - atomic subtract with acquire ordering
792+ * @i: int value to subtract
793+ * @v: pointer to atomic_t
794+ *
795+ * Atomically updates @v to (@v - @i) with acquire ordering.
796+ *
797+ * Safe to use in noinstr code; prefer atomic_sub_return_acquire() elsewhere.
798+ *
799+ * Return: The updated value of @v.
800+ */
365801 static __always_inline int
366−arch_atomic_sub_return_acquire(int i, atomic_t *v)
802+raw_atomic_sub_return_acquire(int i, atomic_t *v)
367803 {
804+#if defined(arch_atomic_sub_return_acquire)
805+ return arch_atomic_sub_return_acquire(i, v);
806+#elif defined(arch_atomic_sub_return_relaxed)
368807 int ret = arch_atomic_sub_return_relaxed(i, v);
369808 __atomic_acquire_fence();
370809 return ret;
371−}
372−#define arch_atomic_sub_return_acquire arch_atomic_sub_return_acquire
810+#elif defined(arch_atomic_sub_return)
811+ return arch_atomic_sub_return(i, v);
812+#else
813+#error "Unable to define raw_atomic_sub_return_acquire"
373814 #endif
815+}
374816
375−#ifndef arch_atomic_sub_return_release
817+/**
818+ * raw_atomic_sub_return_release() - atomic subtract with release ordering
819+ * @i: int value to subtract
820+ * @v: pointer to atomic_t
821+ *
822+ * Atomically updates @v to (@v - @i) with release ordering.
823+ *
824+ * Safe to use in noinstr code; prefer atomic_sub_return_release() elsewhere.
825+ *
826+ * Return: The updated value of @v.
827+ */
376828 static __always_inline int
377−arch_atomic_sub_return_release(int i, atomic_t *v)
829+raw_atomic_sub_return_release(int i, atomic_t *v)
378830 {
831+#if defined(arch_atomic_sub_return_release)
832+ return arch_atomic_sub_return_release(i, v);
833+#elif defined(arch_atomic_sub_return_relaxed)
379834 __atomic_release_fence();
380835 return arch_atomic_sub_return_relaxed(i, v);
836+#elif defined(arch_atomic_sub_return)
837+ return arch_atomic_sub_return(i, v);
838+#else
839+#error "Unable to define raw_atomic_sub_return_release"
840+#endif
381841 }
382−#define arch_atomic_sub_return_release arch_atomic_sub_return_release
842+
843+/**
844+ * raw_atomic_sub_return_relaxed() - atomic subtract with relaxed ordering
845+ * @i: int value to subtract
846+ * @v: pointer to atomic_t
847+ *
848+ * Atomically updates @v to (@v - @i) with relaxed ordering.
849+ *
850+ * Safe to use in noinstr code; prefer atomic_sub_return_relaxed() elsewhere.
851+ *
852+ * Return: The updated value of @v.
853+ */
854+static __always_inline int
855+raw_atomic_sub_return_relaxed(int i, atomic_t *v)
856+{
857+#if defined(arch_atomic_sub_return_relaxed)
858+ return arch_atomic_sub_return_relaxed(i, v);
859+#elif defined(arch_atomic_sub_return)
860+ return arch_atomic_sub_return(i, v);
861+#else
862+#error "Unable to define raw_atomic_sub_return_relaxed"
383863 #endif
864+}
384865
385−#ifndef arch_atomic_sub_return
866+/**
867+ * raw_atomic_fetch_sub() - atomic subtract with full ordering
868+ * @i: int value to subtract
869+ * @v: pointer to atomic_t
870+ *
871+ * Atomically updates @v to (@v - @i) with full ordering.
872+ *
873+ * Safe to use in noinstr code; prefer atomic_fetch_sub() elsewhere.
874+ *
875+ * Return: The original value of @v.
876+ */
386877 static __always_inline int
387−arch_atomic_sub_return(int i, atomic_t *v)
878+raw_atomic_fetch_sub(int i, atomic_t *v)
388879 {
880+#if defined(arch_atomic_fetch_sub)
881+ return arch_atomic_fetch_sub(i, v);
882+#elif defined(arch_atomic_fetch_sub_relaxed)
389883 int ret;
390884 __atomic_pre_full_fence();
391− ret = arch_atomic_sub_return_relaxed(i, v);
885+ ret = arch_atomic_fetch_sub_relaxed(i, v);
392886 __atomic_post_full_fence();
393887 return ret;
394−}
395−#define arch_atomic_sub_return arch_atomic_sub_return
888+#else
889+#error "Unable to define raw_atomic_fetch_sub"
396890 #endif
891+}
397892
398−#endif /* arch_atomic_sub_return_relaxed */
399−
400−#ifndef arch_atomic_fetch_sub_relaxed
401−#define arch_atomic_fetch_sub_acquire arch_atomic_fetch_sub
402−#define arch_atomic_fetch_sub_release arch_atomic_fetch_sub
403−#define arch_atomic_fetch_sub_relaxed arch_atomic_fetch_sub
404−#else /* arch_atomic_fetch_sub_relaxed */
405−
406−#ifndef arch_atomic_fetch_sub_acquire
893+/**
894+ * raw_atomic_fetch_sub_acquire() - atomic subtract with acquire ordering
895+ * @i: int value to subtract
896+ * @v: pointer to atomic_t
897+ *
898+ * Atomically updates @v to (@v - @i) with acquire ordering.
899+ *
900+ * Safe to use in noinstr code; prefer atomic_fetch_sub_acquire() elsewhere.
901+ *
902+ * Return: The original value of @v.
903+ */
407904 static __always_inline int
408−arch_atomic_fetch_sub_acquire(int i, atomic_t *v)
905+raw_atomic_fetch_sub_acquire(int i, atomic_t *v)
409906 {
907+#if defined(arch_atomic_fetch_sub_acquire)
908+ return arch_atomic_fetch_sub_acquire(i, v);
909+#elif defined(arch_atomic_fetch_sub_relaxed)
410910 int ret = arch_atomic_fetch_sub_relaxed(i, v);
411911 __atomic_acquire_fence();
412912 return ret;
413−}
414−#define arch_atomic_fetch_sub_acquire arch_atomic_fetch_sub_acquire
913+#elif defined(arch_atomic_fetch_sub)
914+ return arch_atomic_fetch_sub(i, v);
915+#else
916+#error "Unable to define raw_atomic_fetch_sub_acquire"
415917 #endif
918+}
416919
417−#ifndef arch_atomic_fetch_sub_release
920+/**
921+ * raw_atomic_fetch_sub_release() - atomic subtract with release ordering
922+ * @i: int value to subtract
923+ * @v: pointer to atomic_t
924+ *
925+ * Atomically updates @v to (@v - @i) with release ordering.
926+ *
927+ * Safe to use in noinstr code; prefer atomic_fetch_sub_release() elsewhere.
928+ *
929+ * Return: The original value of @v.
930+ */
418931 static __always_inline int
419−arch_atomic_fetch_sub_release(int i, atomic_t *v)
932+raw_atomic_fetch_sub_release(int i, atomic_t *v)
420933 {
934+#if defined(arch_atomic_fetch_sub_release)
935+ return arch_atomic_fetch_sub_release(i, v);
936+#elif defined(arch_atomic_fetch_sub_relaxed)
421937 __atomic_release_fence();
422938 return arch_atomic_fetch_sub_relaxed(i, v);
423−}
424−#define arch_atomic_fetch_sub_release arch_atomic_fetch_sub_release
939+#elif defined(arch_atomic_fetch_sub)
940+ return arch_atomic_fetch_sub(i, v);
941+#else
942+#error "Unable to define raw_atomic_fetch_sub_release"
425943 #endif
944+}
426945
427−#ifndef arch_atomic_fetch_sub
946+/**
947+ * raw_atomic_fetch_sub_relaxed() - atomic subtract with relaxed ordering
948+ * @i: int value to subtract
949+ * @v: pointer to atomic_t
950+ *
951+ * Atomically updates @v to (@v - @i) with relaxed ordering.
952+ *
953+ * Safe to use in noinstr code; prefer atomic_fetch_sub_relaxed() elsewhere.
954+ *
955+ * Return: The original value of @v.
956+ */
428957 static __always_inline int
429−arch_atomic_fetch_sub(int i, atomic_t *v)
958+raw_atomic_fetch_sub_relaxed(int i, atomic_t *v)
430959 {
431− int ret;
432− __atomic_pre_full_fence();
433− ret = arch_atomic_fetch_sub_relaxed(i, v);
434− __atomic_post_full_fence();
435− return ret;
436−}
437−#define arch_atomic_fetch_sub arch_atomic_fetch_sub
960+#if defined(arch_atomic_fetch_sub_relaxed)
961+ return arch_atomic_fetch_sub_relaxed(i, v);
962+#elif defined(arch_atomic_fetch_sub)
963+ return arch_atomic_fetch_sub(i, v);
964+#else
965+#error "Unable to define raw_atomic_fetch_sub_relaxed"
438966 #endif
439−
440−#endif /* arch_atomic_fetch_sub_relaxed */
441−
442−#ifndef arch_atomic_inc
443−static __always_inline void
444−arch_atomic_inc(atomic_t *v)
445−{
446− arch_atomic_add(1, v);
447967 }
448−#define arch_atomic_inc arch_atomic_inc
449−#endif
450−
451−#ifndef arch_atomic_inc_return_relaxed
452−#ifdef arch_atomic_inc_return
453−#define arch_atomic_inc_return_acquire arch_atomic_inc_return
454−#define arch_atomic_inc_return_release arch_atomic_inc_return
455−#define arch_atomic_inc_return_relaxed arch_atomic_inc_return
456−#endif /* arch_atomic_inc_return */
457968
458−#ifndef arch_atomic_inc_return
459−static __always_inline int
460−arch_atomic_inc_return(atomic_t *v)
969+/**
970+ * raw_atomic_inc() - atomic increment with relaxed ordering
971+ * @v: pointer to atomic_t
972+ *
973+ * Atomically updates @v to (@v + 1) with relaxed ordering.
974+ *
975+ * Safe to use in noinstr code; prefer atomic_inc() elsewhere.
976+ *
977+ * Return: Nothing.
978+ */
979+static __always_inline void
980+raw_atomic_inc(atomic_t *v)
461981 {
462− return arch_atomic_add_return(1, v);
463−}
464−#define arch_atomic_inc_return arch_atomic_inc_return
982+#if defined(arch_atomic_inc)
983+ arch_atomic_inc(v);
984+#else
985+ raw_atomic_add(1, v);
465986 #endif
466−
467−#ifndef arch_atomic_inc_return_acquire
468−static __always_inline int
469−arch_atomic_inc_return_acquire(atomic_t *v)
470−{
471− return arch_atomic_add_return_acquire(1, v);
472987 }
473−#define arch_atomic_inc_return_acquire arch_atomic_inc_return_acquire
474−#endif
475988
476−#ifndef arch_atomic_inc_return_release
989+/**
990+ * raw_atomic_inc_return() - atomic increment with full ordering
991+ * @v: pointer to atomic_t
992+ *
993+ * Atomically updates @v to (@v + 1) with full ordering.
994+ *
995+ * Safe to use in noinstr code; prefer atomic_inc_return() elsewhere.
996+ *
997+ * Return: The updated value of @v.
998+ */
477999 static __always_inline int
478−arch_atomic_inc_return_release(atomic_t *v)
1000+raw_atomic_inc_return(atomic_t *v)
4791001 {
480− return arch_atomic_add_return_release(1, v);
481−}
482−#define arch_atomic_inc_return_release arch_atomic_inc_return_release
1002+#if defined(arch_atomic_inc_return)
1003+ return arch_atomic_inc_return(v);
1004+#elif defined(arch_atomic_inc_return_relaxed)
1005+ int ret;
1006+ __atomic_pre_full_fence();
1007+ ret = arch_atomic_inc_return_relaxed(v);
1008+ __atomic_post_full_fence();
1009+ return ret;
1010+#else
1011+ return raw_atomic_add_return(1, v);
4831012 #endif
484−
485−#ifndef arch_atomic_inc_return_relaxed
486−static __always_inline int
487−arch_atomic_inc_return_relaxed(atomic_t *v)
488−{
489− return arch_atomic_add_return_relaxed(1, v);
4901013 }
491−#define arch_atomic_inc_return_relaxed arch_atomic_inc_return_relaxed
492−#endif
4931014
494−#else /* arch_atomic_inc_return_relaxed */
495−
496−#ifndef arch_atomic_inc_return_acquire
1015+/**
1016+ * raw_atomic_inc_return_acquire() - atomic increment with acquire ordering
1017+ * @v: pointer to atomic_t
1018+ *
1019+ * Atomically updates @v to (@v + 1) with acquire ordering.
1020+ *
1021+ * Safe to use in noinstr code; prefer atomic_inc_return_acquire() elsewhere.
1022+ *
1023+ * Return: The updated value of @v.
1024+ */
4971025 static __always_inline int
498−arch_atomic_inc_return_acquire(atomic_t *v)
1026+raw_atomic_inc_return_acquire(atomic_t *v)
4991027 {
1028+#if defined(arch_atomic_inc_return_acquire)
1029+ return arch_atomic_inc_return_acquire(v);
1030+#elif defined(arch_atomic_inc_return_relaxed)
5001031 int ret = arch_atomic_inc_return_relaxed(v);
5011032 __atomic_acquire_fence();
5021033 return ret;
503−}
504−#define arch_atomic_inc_return_acquire arch_atomic_inc_return_acquire
1034+#elif defined(arch_atomic_inc_return)
1035+ return arch_atomic_inc_return(v);
1036+#else
1037+ return raw_atomic_add_return_acquire(1, v);
5051038 #endif
1039+}
5061040
507−#ifndef arch_atomic_inc_return_release
1041+/**
1042+ * raw_atomic_inc_return_release() - atomic increment with release ordering
1043+ * @v: pointer to atomic_t
1044+ *
1045+ * Atomically updates @v to (@v + 1) with release ordering.
1046+ *
1047+ * Safe to use in noinstr code; prefer atomic_inc_return_release() elsewhere.
1048+ *
1049+ * Return: The updated value of @v.
1050+ */
5081051 static __always_inline int
509−arch_atomic_inc_return_release(atomic_t *v)
1052+raw_atomic_inc_return_release(atomic_t *v)
5101053 {
1054+#if defined(arch_atomic_inc_return_release)
1055+ return arch_atomic_inc_return_release(v);
1056+#elif defined(arch_atomic_inc_return_relaxed)
5111057 __atomic_release_fence();
5121058 return arch_atomic_inc_return_relaxed(v);
513−}
514−#define arch_atomic_inc_return_release arch_atomic_inc_return_release
1059+#elif defined(arch_atomic_inc_return)
1060+ return arch_atomic_inc_return(v);
1061+#else
1062+ return raw_atomic_add_return_release(1, v);
5151063 #endif
516−
517−#ifndef arch_atomic_inc_return
518−static __always_inline int
519−arch_atomic_inc_return(atomic_t *v)
520−{
521− int ret;
522− __atomic_pre_full_fence();
523− ret = arch_atomic_inc_return_relaxed(v);
524− __atomic_post_full_fence();
525− return ret;
5261064 }
527−#define arch_atomic_inc_return arch_atomic_inc_return
528−#endif
529−
530−#endif /* arch_atomic_inc_return_relaxed */
5311065
532−#ifndef arch_atomic_fetch_inc_relaxed
533−#ifdef arch_atomic_fetch_inc
534−#define arch_atomic_fetch_inc_acquire arch_atomic_fetch_inc
535−#define arch_atomic_fetch_inc_release arch_atomic_fetch_inc
536−#define arch_atomic_fetch_inc_relaxed arch_atomic_fetch_inc
537−#endif /* arch_atomic_fetch_inc */
538−
539−#ifndef arch_atomic_fetch_inc
1066+/**
1067+ * raw_atomic_inc_return_relaxed() - atomic increment with relaxed ordering
1068+ * @v: pointer to atomic_t
1069+ *
1070+ * Atomically updates @v to (@v + 1) with relaxed ordering.
1071+ *
1072+ * Safe to use in noinstr code; prefer atomic_inc_return_relaxed() elsewhere.
1073+ *
1074+ * Return: The updated value of @v.
1075+ */
5401076 static __always_inline int
541−arch_atomic_fetch_inc(atomic_t *v)
1077+raw_atomic_inc_return_relaxed(atomic_t *v)
5421078 {
543− return arch_atomic_fetch_add(1, v);
544−}
545−#define arch_atomic_fetch_inc arch_atomic_fetch_inc
1079+#if defined(arch_atomic_inc_return_relaxed)
1080+ return arch_atomic_inc_return_relaxed(v);
1081+#elif defined(arch_atomic_inc_return)
1082+ return arch_atomic_inc_return(v);
1083+#else
1084+ return raw_atomic_add_return_relaxed(1, v);
5461085 #endif
547−
548−#ifndef arch_atomic_fetch_inc_acquire
549−static __always_inline int
550−arch_atomic_fetch_inc_acquire(atomic_t *v)
551−{
552− return arch_atomic_fetch_add_acquire(1, v);
5531086 }
554−#define arch_atomic_fetch_inc_acquire arch_atomic_fetch_inc_acquire
555−#endif
5561087
557−#ifndef arch_atomic_fetch_inc_release
1088+/**
1089+ * raw_atomic_fetch_inc() - atomic increment with full ordering
1090+ * @v: pointer to atomic_t
1091+ *
1092+ * Atomically updates @v to (@v + 1) with full ordering.
1093+ *
1094+ * Safe to use in noinstr code; prefer atomic_fetch_inc() elsewhere.
1095+ *
1096+ * Return: The original value of @v.
1097+ */
5581098 static __always_inline int
559−arch_atomic_fetch_inc_release(atomic_t *v)
1099+raw_atomic_fetch_inc(atomic_t *v)
5601100 {
561− return arch_atomic_fetch_add_release(1, v);
562−}
563−#define arch_atomic_fetch_inc_release arch_atomic_fetch_inc_release
1101+#if defined(arch_atomic_fetch_inc)
1102+ return arch_atomic_fetch_inc(v);
1103+#elif defined(arch_atomic_fetch_inc_relaxed)
1104+ int ret;
1105+ __atomic_pre_full_fence();
1106+ ret = arch_atomic_fetch_inc_relaxed(v);
1107+ __atomic_post_full_fence();
1108+ return ret;
1109+#else
1110+ return raw_atomic_fetch_add(1, v);
5641111 #endif
565−
566−#ifndef arch_atomic_fetch_inc_relaxed
567−static __always_inline int
568−arch_atomic_fetch_inc_relaxed(atomic_t *v)
569−{
570− return arch_atomic_fetch_add_relaxed(1, v);
5711112 }
572−#define arch_atomic_fetch_inc_relaxed arch_atomic_fetch_inc_relaxed
573−#endif
5741113
575−#else /* arch_atomic_fetch_inc_relaxed */
576−
577−#ifndef arch_atomic_fetch_inc_acquire
1114+/**
1115+ * raw_atomic_fetch_inc_acquire() - atomic increment with acquire ordering
1116+ * @v: pointer to atomic_t
1117+ *
1118+ * Atomically updates @v to (@v + 1) with acquire ordering.
1119+ *
1120+ * Safe to use in noinstr code; prefer atomic_fetch_inc_acquire() elsewhere.
1121+ *
1122+ * Return: The original value of @v.
1123+ */
5781124 static __always_inline int
579−arch_atomic_fetch_inc_acquire(atomic_t *v)
1125+raw_atomic_fetch_inc_acquire(atomic_t *v)
5801126 {
1127+#if defined(arch_atomic_fetch_inc_acquire)
1128+ return arch_atomic_fetch_inc_acquire(v);
1129+#elif defined(arch_atomic_fetch_inc_relaxed)
5811130 int ret = arch_atomic_fetch_inc_relaxed(v);
5821131 __atomic_acquire_fence();
5831132 return ret;
584−}
585−#define arch_atomic_fetch_inc_acquire arch_atomic_fetch_inc_acquire
1133+#elif defined(arch_atomic_fetch_inc)
1134+ return arch_atomic_fetch_inc(v);
1135+#else
1136+ return raw_atomic_fetch_add_acquire(1, v);
5861137 #endif
1138+}
5871139
588−#ifndef arch_atomic_fetch_inc_release
1140+/**
1141+ * raw_atomic_fetch_inc_release() - atomic increment with release ordering
1142+ * @v: pointer to atomic_t
1143+ *
1144+ * Atomically updates @v to (@v + 1) with release ordering.
1145+ *
1146+ * Safe to use in noinstr code; prefer atomic_fetch_inc_release() elsewhere.
1147+ *
1148+ * Return: The original value of @v.
1149+ */
5891150 static __always_inline int
590−arch_atomic_fetch_inc_release(atomic_t *v)
1151+raw_atomic_fetch_inc_release(atomic_t *v)
5911152 {
1153+#if defined(arch_atomic_fetch_inc_release)
1154+ return arch_atomic_fetch_inc_release(v);
1155+#elif defined(arch_atomic_fetch_inc_relaxed)
5921156 __atomic_release_fence();
5931157 return arch_atomic_fetch_inc_relaxed(v);
594−}
595−#define arch_atomic_fetch_inc_release arch_atomic_fetch_inc_release
1158+#elif defined(arch_atomic_fetch_inc)
1159+ return arch_atomic_fetch_inc(v);
1160+#else
1161+ return raw_atomic_fetch_add_release(1, v);
5961162 #endif
1163+}
5971164
598−#ifndef arch_atomic_fetch_inc
1165+/**
1166+ * raw_atomic_fetch_inc_relaxed() - atomic increment with relaxed ordering
1167+ * @v: pointer to atomic_t
1168+ *
1169+ * Atomically updates @v to (@v + 1) with relaxed ordering.
1170+ *
1171+ * Safe to use in noinstr code; prefer atomic_fetch_inc_relaxed() elsewhere.
1172+ *
1173+ * Return: The original value of @v.
1174+ */
5991175 static __always_inline int
600−arch_atomic_fetch_inc(atomic_t *v)
1176+raw_atomic_fetch_inc_relaxed(atomic_t *v)
6011177 {
602− int ret;
603− __atomic_pre_full_fence();
604− ret = arch_atomic_fetch_inc_relaxed(v);
605− __atomic_post_full_fence();
606− return ret;
607−}
608−#define arch_atomic_fetch_inc arch_atomic_fetch_inc
1178+#if defined(arch_atomic_fetch_inc_relaxed)
1179+ return arch_atomic_fetch_inc_relaxed(v);
1180+#elif defined(arch_atomic_fetch_inc)
1181+ return arch_atomic_fetch_inc(v);
1182+#else
1183+ return raw_atomic_fetch_add_relaxed(1, v);
6091184 #endif
610−
611−#endif /* arch_atomic_fetch_inc_relaxed */
612−
613−#ifndef arch_atomic_dec
614−static __always_inline void
615−arch_atomic_dec(atomic_t *v)
616−{
617− arch_atomic_sub(1, v);
6181185 }
619−#define arch_atomic_dec arch_atomic_dec
620−#endif
621−
622−#ifndef arch_atomic_dec_return_relaxed
623−#ifdef arch_atomic_dec_return
624−#define arch_atomic_dec_return_acquire arch_atomic_dec_return
625−#define arch_atomic_dec_return_release arch_atomic_dec_return
626−#define arch_atomic_dec_return_relaxed arch_atomic_dec_return
627−#endif /* arch_atomic_dec_return */
6281186
629−#ifndef arch_atomic_dec_return
630−static __always_inline int
631−arch_atomic_dec_return(atomic_t *v)
1187+/**
1188+ * raw_atomic_dec() - atomic decrement with relaxed ordering
1189+ * @v: pointer to atomic_t
1190+ *
1191+ * Atomically updates @v to (@v - 1) with relaxed ordering.
1192+ *
1193+ * Safe to use in noinstr code; prefer atomic_dec() elsewhere.
1194+ *
1195+ * Return: Nothing.
1196+ */
1197+static __always_inline void
1198+raw_atomic_dec(atomic_t *v)
6321199 {
633− return arch_atomic_sub_return(1, v);
634−}
635−#define arch_atomic_dec_return arch_atomic_dec_return
1200+#if defined(arch_atomic_dec)
1201+ arch_atomic_dec(v);
1202+#else
1203+ raw_atomic_sub(1, v);
6361204 #endif
637−
638−#ifndef arch_atomic_dec_return_acquire
639−static __always_inline int
640−arch_atomic_dec_return_acquire(atomic_t *v)
641−{
642− return arch_atomic_sub_return_acquire(1, v);
6431205 }
644−#define arch_atomic_dec_return_acquire arch_atomic_dec_return_acquire
645−#endif
6461206
647−#ifndef arch_atomic_dec_return_release
1207+/**
1208+ * raw_atomic_dec_return() - atomic decrement with full ordering
1209+ * @v: pointer to atomic_t
1210+ *
1211+ * Atomically updates @v to (@v - 1) with full ordering.
1212+ *
1213+ * Safe to use in noinstr code; prefer atomic_dec_return() elsewhere.
1214+ *
1215+ * Return: The updated value of @v.
1216+ */
6481217 static __always_inline int
649−arch_atomic_dec_return_release(atomic_t *v)
1218+raw_atomic_dec_return(atomic_t *v)
6501219 {
651− return arch_atomic_sub_return_release(1, v);
652−}
653−#define arch_atomic_dec_return_release arch_atomic_dec_return_release
1220+#if defined(arch_atomic_dec_return)
1221+ return arch_atomic_dec_return(v);
1222+#elif defined(arch_atomic_dec_return_relaxed)
1223+ int ret;
1224+ __atomic_pre_full_fence();
1225+ ret = arch_atomic_dec_return_relaxed(v);
1226+ __atomic_post_full_fence();
1227+ return ret;
1228+#else
1229+ return raw_atomic_sub_return(1, v);
6541230 #endif
655−
656−#ifndef arch_atomic_dec_return_relaxed
657−static __always_inline int
658−arch_atomic_dec_return_relaxed(atomic_t *v)
659−{
660− return arch_atomic_sub_return_relaxed(1, v);
6611231 }
662−#define arch_atomic_dec_return_relaxed arch_atomic_dec_return_relaxed
663−#endif
6641232
665−#else /* arch_atomic_dec_return_relaxed */
666−
667−#ifndef arch_atomic_dec_return_acquire
1233+/**
1234+ * raw_atomic_dec_return_acquire() - atomic decrement with acquire ordering
1235+ * @v: pointer to atomic_t
1236+ *
1237+ * Atomically updates @v to (@v - 1) with acquire ordering.
1238+ *
1239+ * Safe to use in noinstr code; prefer atomic_dec_return_acquire() elsewhere.
1240+ *
1241+ * Return: The updated value of @v.
1242+ */
6681243 static __always_inline int
669−arch_atomic_dec_return_acquire(atomic_t *v)
1244+raw_atomic_dec_return_acquire(atomic_t *v)
6701245 {
1246+#if defined(arch_atomic_dec_return_acquire)
1247+ return arch_atomic_dec_return_acquire(v);
1248+#elif defined(arch_atomic_dec_return_relaxed)
6711249 int ret = arch_atomic_dec_return_relaxed(v);
6721250 __atomic_acquire_fence();
6731251 return ret;
674−}
675−#define arch_atomic_dec_return_acquire arch_atomic_dec_return_acquire
1252+#elif defined(arch_atomic_dec_return)
1253+ return arch_atomic_dec_return(v);
1254+#else
1255+ return raw_atomic_sub_return_acquire(1, v);
6761256 #endif
1257+}
6771258
678−#ifndef arch_atomic_dec_return_release
1259+/**
1260+ * raw_atomic_dec_return_release() - atomic decrement with release ordering
1261+ * @v: pointer to atomic_t
1262+ *
1263+ * Atomically updates @v to (@v - 1) with release ordering.
1264+ *
1265+ * Safe to use in noinstr code; prefer atomic_dec_return_release() elsewhere.
1266+ *
1267+ * Return: The updated value of @v.
1268+ */
6791269 static __always_inline int
680−arch_atomic_dec_return_release(atomic_t *v)
1270+raw_atomic_dec_return_release(atomic_t *v)
6811271 {
1272+#if defined(arch_atomic_dec_return_release)
1273+ return arch_atomic_dec_return_release(v);
1274+#elif defined(arch_atomic_dec_return_relaxed)
6821275 __atomic_release_fence();
6831276 return arch_atomic_dec_return_relaxed(v);
1277+#elif defined(arch_atomic_dec_return)
1278+ return arch_atomic_dec_return(v);
1279+#else
1280+ return raw_atomic_sub_return_release(1, v);
1281+#endif
6841282 }
685−#define arch_atomic_dec_return_release arch_atomic_dec_return_release
1283+
1284+/**
1285+ * raw_atomic_dec_return_relaxed() - atomic decrement with relaxed ordering
1286+ * @v: pointer to atomic_t
1287+ *
1288+ * Atomically updates @v to (@v - 1) with relaxed ordering.
1289+ *
1290+ * Safe to use in noinstr code; prefer atomic_dec_return_relaxed() elsewhere.
1291+ *
1292+ * Return: The updated value of @v.
1293+ */
1294+static __always_inline int
1295+raw_atomic_dec_return_relaxed(atomic_t *v)
1296+{
1297+#if defined(arch_atomic_dec_return_relaxed)
1298+ return arch_atomic_dec_return_relaxed(v);
1299+#elif defined(arch_atomic_dec_return)
1300+ return arch_atomic_dec_return(v);
1301+#else
1302+ return raw_atomic_sub_return_relaxed(1, v);
6861303 #endif
1304+}
6871305
688−#ifndef arch_atomic_dec_return
1306+/**
1307+ * raw_atomic_fetch_dec() - atomic decrement with full ordering
1308+ * @v: pointer to atomic_t
1309+ *
1310+ * Atomically updates @v to (@v - 1) with full ordering.
1311+ *
1312+ * Safe to use in noinstr code; prefer atomic_fetch_dec() elsewhere.
1313+ *
1314+ * Return: The original value of @v.
1315+ */
6891316 static __always_inline int
690−arch_atomic_dec_return(atomic_t *v)
1317+raw_atomic_fetch_dec(atomic_t *v)
6911318 {
1319+#if defined(arch_atomic_fetch_dec)
1320+ return arch_atomic_fetch_dec(v);
1321+#elif defined(arch_atomic_fetch_dec_relaxed)
6921322 int ret;
6931323 __atomic_pre_full_fence();
694− ret = arch_atomic_dec_return_relaxed(v);
1324+ ret = arch_atomic_fetch_dec_relaxed(v);
6951325 __atomic_post_full_fence();
6961326 return ret;
697−}
698−#define arch_atomic_dec_return arch_atomic_dec_return
1327+#else
1328+ return raw_atomic_fetch_sub(1, v);
6991329 #endif
700−
701−#endif /* arch_atomic_dec_return_relaxed */
702−
703−#ifndef arch_atomic_fetch_dec_relaxed
704−#ifdef arch_atomic_fetch_dec
705−#define arch_atomic_fetch_dec_acquire arch_atomic_fetch_dec
706−#define arch_atomic_fetch_dec_release arch_atomic_fetch_dec
707−#define arch_atomic_fetch_dec_relaxed arch_atomic_fetch_dec
708−#endif /* arch_atomic_fetch_dec */
709−
710−#ifndef arch_atomic_fetch_dec
711−static __always_inline int
712−arch_atomic_fetch_dec(atomic_t *v)
713−{
714− return arch_atomic_fetch_sub(1, v);
7151330 }
716−#define arch_atomic_fetch_dec arch_atomic_fetch_dec
717−#endif
7181331
719−#ifndef arch_atomic_fetch_dec_acquire
1332+/**
1333+ * raw_atomic_fetch_dec_acquire() - atomic decrement with acquire ordering
1334+ * @v: pointer to atomic_t
1335+ *
1336+ * Atomically updates @v to (@v - 1) with acquire ordering.
1337+ *
1338+ * Safe to use in noinstr code; prefer atomic_fetch_dec_acquire() elsewhere.
1339+ *
1340+ * Return: The original value of @v.
1341+ */
7201342 static __always_inline int
721−arch_atomic_fetch_dec_acquire(atomic_t *v)
1343+raw_atomic_fetch_dec_acquire(atomic_t *v)
7221344 {
723− return arch_atomic_fetch_sub_acquire(1, v);
724−}
725−#define arch_atomic_fetch_dec_acquire arch_atomic_fetch_dec_acquire
1345+#if defined(arch_atomic_fetch_dec_acquire)
1346+ return arch_atomic_fetch_dec_acquire(v);
1347+#elif defined(arch_atomic_fetch_dec_relaxed)
1348+ int ret = arch_atomic_fetch_dec_relaxed(v);
1349+ __atomic_acquire_fence();
1350+ return ret;
1351+#elif defined(arch_atomic_fetch_dec)
1352+ return arch_atomic_fetch_dec(v);
1353+#else
1354+ return raw_atomic_fetch_sub_acquire(1, v);
7261355 #endif
727−
728−#ifndef arch_atomic_fetch_dec_release
729−static __always_inline int
730−arch_atomic_fetch_dec_release(atomic_t *v)
731−{
732− return arch_atomic_fetch_sub_release(1, v);
7331356 }
734−#define arch_atomic_fetch_dec_release arch_atomic_fetch_dec_release
735−#endif
7361357
737−#ifndef arch_atomic_fetch_dec_relaxed
1358+/**
1359+ * raw_atomic_fetch_dec_release() - atomic decrement with release ordering
1360+ * @v: pointer to atomic_t
1361+ *
1362+ * Atomically updates @v to (@v - 1) with release ordering.
1363+ *
1364+ * Safe to use in noinstr code; prefer atomic_fetch_dec_release() elsewhere.
1365+ *
1366+ * Return: The original value of @v.
1367+ */
7381368 static __always_inline int
739−arch_atomic_fetch_dec_relaxed(atomic_t *v)
1369+raw_atomic_fetch_dec_release(atomic_t *v)
7401370 {
741− return arch_atomic_fetch_sub_relaxed(1, v);
742−}
743−#define arch_atomic_fetch_dec_relaxed arch_atomic_fetch_dec_relaxed
1371+#if defined(arch_atomic_fetch_dec_release)
1372+ return arch_atomic_fetch_dec_release(v);
1373+#elif defined(arch_atomic_fetch_dec_relaxed)
1374+ __atomic_release_fence();
1375+ return arch_atomic_fetch_dec_relaxed(v);
1376+#elif defined(arch_atomic_fetch_dec)
1377+ return arch_atomic_fetch_dec(v);
1378+#else
1379+ return raw_atomic_fetch_sub_release(1, v);
7441380 #endif
1381+}
7451382
746−#else /* arch_atomic_fetch_dec_relaxed */
747−
748−#ifndef arch_atomic_fetch_dec_acquire
1383+/**
1384+ * raw_atomic_fetch_dec_relaxed() - atomic decrement with relaxed ordering
1385+ * @v: pointer to atomic_t
1386+ *
1387+ * Atomically updates @v to (@v - 1) with relaxed ordering.
1388+ *
1389+ * Safe to use in noinstr code; prefer atomic_fetch_dec_relaxed() elsewhere.
1390+ *
1391+ * Return: The original value of @v.
1392+ */
7491393 static __always_inline int
750−arch_atomic_fetch_dec_acquire(atomic_t *v)
1394+raw_atomic_fetch_dec_relaxed(atomic_t *v)
7511395 {
752− int ret = arch_atomic_fetch_dec_relaxed(v);
753− __atomic_acquire_fence();
754− return ret;
755−}
756−#define arch_atomic_fetch_dec_acquire arch_atomic_fetch_dec_acquire
1396+#if defined(arch_atomic_fetch_dec_relaxed)
1397+ return arch_atomic_fetch_dec_relaxed(v);
1398+#elif defined(arch_atomic_fetch_dec)
1399+ return arch_atomic_fetch_dec(v);
1400+#else
1401+ return raw_atomic_fetch_sub_relaxed(1, v);
7571402 #endif
1403+}
7581404
759−#ifndef arch_atomic_fetch_dec_release
760−static __always_inline int
761−arch_atomic_fetch_dec_release(atomic_t *v)
1405+/**
1406+ * raw_atomic_and() - atomic bitwise AND with relaxed ordering
1407+ * @i: int value
1408+ * @v: pointer to atomic_t
1409+ *
1410+ * Atomically updates @v to (@v & @i) with relaxed ordering.
1411+ *
1412+ * Safe to use in noinstr code; prefer atomic_and() elsewhere.
1413+ *
1414+ * Return: Nothing.
1415+ */
1416+static __always_inline void
1417+raw_atomic_and(int i, atomic_t *v)
7621418 {
763− __atomic_release_fence();
764− return arch_atomic_fetch_dec_relaxed(v);
1419+ arch_atomic_and(i, v);
7651420 }
766−#define arch_atomic_fetch_dec_release arch_atomic_fetch_dec_release
767−#endif
7681421
769−#ifndef arch_atomic_fetch_dec
1422+/**
1423+ * raw_atomic_fetch_and() - atomic bitwise AND with full ordering
1424+ * @i: int value
1425+ * @v: pointer to atomic_t
1426+ *
1427+ * Atomically updates @v to (@v & @i) with full ordering.
1428+ *
1429+ * Safe to use in noinstr code; prefer atomic_fetch_and() elsewhere.
1430+ *
1431+ * Return: The original value of @v.
1432+ */
7701433 static __always_inline int
771−arch_atomic_fetch_dec(atomic_t *v)
1434+raw_atomic_fetch_and(int i, atomic_t *v)
7721435 {
1436+#if defined(arch_atomic_fetch_and)
1437+ return arch_atomic_fetch_and(i, v);
1438+#elif defined(arch_atomic_fetch_and_relaxed)
7731439 int ret;
7741440 __atomic_pre_full_fence();
775− ret = arch_atomic_fetch_dec_relaxed(v);
1441+ ret = arch_atomic_fetch_and_relaxed(i, v);
7761442 __atomic_post_full_fence();
7771443 return ret;
778−}
779−#define arch_atomic_fetch_dec arch_atomic_fetch_dec
1444+#else
1445+#error "Unable to define raw_atomic_fetch_and"
7801446 #endif
1447+}
7811448
782−#endif /* arch_atomic_fetch_dec_relaxed */
783−
784−#ifndef arch_atomic_fetch_and_relaxed
785−#define arch_atomic_fetch_and_acquire arch_atomic_fetch_and
786−#define arch_atomic_fetch_and_release arch_atomic_fetch_and
787−#define arch_atomic_fetch_and_relaxed arch_atomic_fetch_and
788−#else /* arch_atomic_fetch_and_relaxed */
789−
790−#ifndef arch_atomic_fetch_and_acquire
1449+/**
1450+ * raw_atomic_fetch_and_acquire() - atomic bitwise AND with acquire ordering
1451+ * @i: int value
1452+ * @v: pointer to atomic_t
1453+ *
1454+ * Atomically updates @v to (@v & @i) with acquire ordering.
1455+ *
1456+ * Safe to use in noinstr code; prefer atomic_fetch_and_acquire() elsewhere.
1457+ *
1458+ * Return: The original value of @v.
1459+ */
7911460 static __always_inline int
792−arch_atomic_fetch_and_acquire(int i, atomic_t *v)
1461+raw_atomic_fetch_and_acquire(int i, atomic_t *v)
7931462 {
1463+#if defined(arch_atomic_fetch_and_acquire)
1464+ return arch_atomic_fetch_and_acquire(i, v);
1465+#elif defined(arch_atomic_fetch_and_relaxed)
7941466 int ret = arch_atomic_fetch_and_relaxed(i, v);
7951467 __atomic_acquire_fence();
7961468 return ret;
797−}
798−#define arch_atomic_fetch_and_acquire arch_atomic_fetch_and_acquire
1469+#elif defined(arch_atomic_fetch_and)
1470+ return arch_atomic_fetch_and(i, v);
1471+#else
1472+#error "Unable to define raw_atomic_fetch_and_acquire"
7991473 #endif
1474+}
8001475
801−#ifndef arch_atomic_fetch_and_release
1476+/**
1477+ * raw_atomic_fetch_and_release() - atomic bitwise AND with release ordering
1478+ * @i: int value
1479+ * @v: pointer to atomic_t
1480+ *
1481+ * Atomically updates @v to (@v & @i) with release ordering.
1482+ *
1483+ * Safe to use in noinstr code; prefer atomic_fetch_and_release() elsewhere.
1484+ *
1485+ * Return: The original value of @v.
1486+ */
8021487 static __always_inline int
803−arch_atomic_fetch_and_release(int i, atomic_t *v)
1488+raw_atomic_fetch_and_release(int i, atomic_t *v)
8041489 {
1490+#if defined(arch_atomic_fetch_and_release)
1491+ return arch_atomic_fetch_and_release(i, v);
1492+#elif defined(arch_atomic_fetch_and_relaxed)
8051493 __atomic_release_fence();
8061494 return arch_atomic_fetch_and_relaxed(i, v);
807−}
808−#define arch_atomic_fetch_and_release arch_atomic_fetch_and_release
1495+#elif defined(arch_atomic_fetch_and)
1496+ return arch_atomic_fetch_and(i, v);
1497+#else
1498+#error "Unable to define raw_atomic_fetch_and_release"
8091499 #endif
1500+}
8101501
811−#ifndef arch_atomic_fetch_and
1502+/**
1503+ * raw_atomic_fetch_and_relaxed() - atomic bitwise AND with relaxed ordering
1504+ * @i: int value
1505+ * @v: pointer to atomic_t
1506+ *
1507+ * Atomically updates @v to (@v & @i) with relaxed ordering.
1508+ *
1509+ * Safe to use in noinstr code; prefer atomic_fetch_and_relaxed() elsewhere.
1510+ *
1511+ * Return: The original value of @v.
1512+ */
8121513 static __always_inline int
813−arch_atomic_fetch_and(int i, atomic_t *v)
1514+raw_atomic_fetch_and_relaxed(int i, atomic_t *v)
8141515 {
815− int ret;
816− __atomic_pre_full_fence();
817− ret = arch_atomic_fetch_and_relaxed(i, v);
818− __atomic_post_full_fence();
819− return ret;
820−}
821−#define arch_atomic_fetch_and arch_atomic_fetch_and
1516+#if defined(arch_atomic_fetch_and_relaxed)
1517+ return arch_atomic_fetch_and_relaxed(i, v);
1518+#elif defined(arch_atomic_fetch_and)
1519+ return arch_atomic_fetch_and(i, v);
1520+#else
1521+#error "Unable to define raw_atomic_fetch_and_relaxed"
8221522 #endif
1523+}
8231524
824−#endif /* arch_atomic_fetch_and_relaxed */
825−
826−#ifndef arch_atomic_andnot
1525+/**
1526+ * raw_atomic_andnot() - atomic bitwise AND NOT with relaxed ordering
1527+ * @i: int value
1528+ * @v: pointer to atomic_t
1529+ *
1530+ * Atomically updates @v to (@v & ~@i) with relaxed ordering.
1531+ *
1532+ * Safe to use in noinstr code; prefer atomic_andnot() elsewhere.
1533+ *
1534+ * Return: Nothing.
1535+ */
8271536 static __always_inline void
828−arch_atomic_andnot(int i, atomic_t *v)
1537+raw_atomic_andnot(int i, atomic_t *v)
8291538 {
830− arch_atomic_and(~i, v);
831−}
832−#define arch_atomic_andnot arch_atomic_andnot
1539+#if defined(arch_atomic_andnot)
1540+ arch_atomic_andnot(i, v);
1541+#else
1542+ raw_atomic_and(~i, v);
8331543 #endif
834−
835−#ifndef arch_atomic_fetch_andnot_relaxed
836−#ifdef arch_atomic_fetch_andnot
837−#define arch_atomic_fetch_andnot_acquire arch_atomic_fetch_andnot
838−#define arch_atomic_fetch_andnot_release arch_atomic_fetch_andnot
839−#define arch_atomic_fetch_andnot_relaxed arch_atomic_fetch_andnot
840−#endif /* arch_atomic_fetch_andnot */
841−
842−#ifndef arch_atomic_fetch_andnot
843−static __always_inline int
844−arch_atomic_fetch_andnot(int i, atomic_t *v)
845−{
846− return arch_atomic_fetch_and(~i, v);
8471544 }
848−#define arch_atomic_fetch_andnot arch_atomic_fetch_andnot
849−#endif
8501545
851−#ifndef arch_atomic_fetch_andnot_acquire
852−static __always_inline int
853−arch_atomic_fetch_andnot_acquire(int i, atomic_t *v)
854−{
855− return arch_atomic_fetch_and_acquire(~i, v);
856−}
857−#define arch_atomic_fetch_andnot_acquire arch_atomic_fetch_andnot_acquire
858−#endif
859−
860−#ifndef arch_atomic_fetch_andnot_release
1546+/**
1547+ * raw_atomic_fetch_andnot() - atomic bitwise AND NOT with full ordering
1548+ * @i: int value
1549+ * @v: pointer to atomic_t
1550+ *
1551+ * Atomically updates @v to (@v & ~@i) with full ordering.
1552+ *
1553+ * Safe to use in noinstr code; prefer atomic_fetch_andnot() elsewhere.
1554+ *
1555+ * Return: The original value of @v.
1556+ */
8611557 static __always_inline int
862−arch_atomic_fetch_andnot_release(int i, atomic_t *v)
1558+raw_atomic_fetch_andnot(int i, atomic_t *v)
8631559 {
864− return arch_atomic_fetch_and_release(~i, v);
865−}
866−#define arch_atomic_fetch_andnot_release arch_atomic_fetch_andnot_release
1560+#if defined(arch_atomic_fetch_andnot)
1561+ return arch_atomic_fetch_andnot(i, v);
1562+#elif defined(arch_atomic_fetch_andnot_relaxed)
1563+ int ret;
1564+ __atomic_pre_full_fence();
1565+ ret = arch_atomic_fetch_andnot_relaxed(i, v);
1566+ __atomic_post_full_fence();
1567+ return ret;
1568+#else
1569+ return raw_atomic_fetch_and(~i, v);
8671570 #endif
868−
869−#ifndef arch_atomic_fetch_andnot_relaxed
870−static __always_inline int
871−arch_atomic_fetch_andnot_relaxed(int i, atomic_t *v)
872−{
873− return arch_atomic_fetch_and_relaxed(~i, v);
8741571 }
875−#define arch_atomic_fetch_andnot_relaxed arch_atomic_fetch_andnot_relaxed
876−#endif
877−
878−#else /* arch_atomic_fetch_andnot_relaxed */
8791572
880−#ifndef arch_atomic_fetch_andnot_acquire
1573+/**
1574+ * raw_atomic_fetch_andnot_acquire() - atomic bitwise AND NOT with acquire ordering
1575+ * @i: int value
1576+ * @v: pointer to atomic_t
1577+ *
1578+ * Atomically updates @v to (@v & ~@i) with acquire ordering.
1579+ *
1580+ * Safe to use in noinstr code; prefer atomic_fetch_andnot_acquire() elsewhere.
1581+ *
1582+ * Return: The original value of @v.
1583+ */
8811584 static __always_inline int
882−arch_atomic_fetch_andnot_acquire(int i, atomic_t *v)
1585+raw_atomic_fetch_andnot_acquire(int i, atomic_t *v)
8831586 {
1587+#if defined(arch_atomic_fetch_andnot_acquire)
1588+ return arch_atomic_fetch_andnot_acquire(i, v);
1589+#elif defined(arch_atomic_fetch_andnot_relaxed)
8841590 int ret = arch_atomic_fetch_andnot_relaxed(i, v);
8851591 __atomic_acquire_fence();
8861592 return ret;
887−}
888−#define arch_atomic_fetch_andnot_acquire arch_atomic_fetch_andnot_acquire
1593+#elif defined(arch_atomic_fetch_andnot)
1594+ return arch_atomic_fetch_andnot(i, v);
1595+#else
1596+ return raw_atomic_fetch_and_acquire(~i, v);
8891597 #endif
1598+}
8901599
891−#ifndef arch_atomic_fetch_andnot_release
1600+/**
1601+ * raw_atomic_fetch_andnot_release() - atomic bitwise AND NOT with release ordering
1602+ * @i: int value
1603+ * @v: pointer to atomic_t
1604+ *
1605+ * Atomically updates @v to (@v & ~@i) with release ordering.
1606+ *
1607+ * Safe to use in noinstr code; prefer atomic_fetch_andnot_release() elsewhere.
1608+ *
1609+ * Return: The original value of @v.
1610+ */
8921611 static __always_inline int
893−arch_atomic_fetch_andnot_release(int i, atomic_t *v)
1612+raw_atomic_fetch_andnot_release(int i, atomic_t *v)
8941613 {
1614+#if defined(arch_atomic_fetch_andnot_release)
1615+ return arch_atomic_fetch_andnot_release(i, v);
1616+#elif defined(arch_atomic_fetch_andnot_relaxed)
8951617 __atomic_release_fence();
8961618 return arch_atomic_fetch_andnot_relaxed(i, v);
1619+#elif defined(arch_atomic_fetch_andnot)
1620+ return arch_atomic_fetch_andnot(i, v);
1621+#else
1622+ return raw_atomic_fetch_and_release(~i, v);
1623+#endif
8971624 }
898−#define arch_atomic_fetch_andnot_release arch_atomic_fetch_andnot_release
1625+
1626+/**
1627+ * raw_atomic_fetch_andnot_relaxed() - atomic bitwise AND NOT with relaxed ordering
1628+ * @i: int value
1629+ * @v: pointer to atomic_t
1630+ *
1631+ * Atomically updates @v to (@v & ~@i) with relaxed ordering.
1632+ *
1633+ * Safe to use in noinstr code; prefer atomic_fetch_andnot_relaxed() elsewhere.
1634+ *
1635+ * Return: The original value of @v.
1636+ */
1637+static __always_inline int
1638+raw_atomic_fetch_andnot_relaxed(int i, atomic_t *v)
1639+{
1640+#if defined(arch_atomic_fetch_andnot_relaxed)
1641+ return arch_atomic_fetch_andnot_relaxed(i, v);
1642+#elif defined(arch_atomic_fetch_andnot)
1643+ return arch_atomic_fetch_andnot(i, v);
1644+#else
1645+ return raw_atomic_fetch_and_relaxed(~i, v);
8991646 #endif
1647+}
1648+
1649+/**
1650+ * raw_atomic_or() - atomic bitwise OR with relaxed ordering
1651+ * @i: int value
1652+ * @v: pointer to atomic_t
1653+ *
1654+ * Atomically updates @v to (@v | @i) with relaxed ordering.
1655+ *
1656+ * Safe to use in noinstr code; prefer atomic_or() elsewhere.
1657+ *
1658+ * Return: Nothing.
1659+ */
1660+static __always_inline void
1661+raw_atomic_or(int i, atomic_t *v)
1662+{
1663+ arch_atomic_or(i, v);
1664+}
9001665
901−#ifndef arch_atomic_fetch_andnot
1666+/**
1667+ * raw_atomic_fetch_or() - atomic bitwise OR with full ordering
1668+ * @i: int value
1669+ * @v: pointer to atomic_t
1670+ *
1671+ * Atomically updates @v to (@v | @i) with full ordering.
1672+ *
1673+ * Safe to use in noinstr code; prefer atomic_fetch_or() elsewhere.
1674+ *
1675+ * Return: The original value of @v.
1676+ */
9021677 static __always_inline int
903−arch_atomic_fetch_andnot(int i, atomic_t *v)
1678+raw_atomic_fetch_or(int i, atomic_t *v)
9041679 {
1680+#if defined(arch_atomic_fetch_or)
1681+ return arch_atomic_fetch_or(i, v);
1682+#elif defined(arch_atomic_fetch_or_relaxed)
9051683 int ret;
9061684 __atomic_pre_full_fence();
907− ret = arch_atomic_fetch_andnot_relaxed(i, v);
1685+ ret = arch_atomic_fetch_or_relaxed(i, v);
9081686 __atomic_post_full_fence();
9091687 return ret;
910−}
911−#define arch_atomic_fetch_andnot arch_atomic_fetch_andnot
1688+#else
1689+#error "Unable to define raw_atomic_fetch_or"
9121690 #endif
1691+}
9131692
914−#endif /* arch_atomic_fetch_andnot_relaxed */
915−
916−#ifndef arch_atomic_fetch_or_relaxed
917−#define arch_atomic_fetch_or_acquire arch_atomic_fetch_or
918−#define arch_atomic_fetch_or_release arch_atomic_fetch_or
919−#define arch_atomic_fetch_or_relaxed arch_atomic_fetch_or
920−#else /* arch_atomic_fetch_or_relaxed */
921−
922−#ifndef arch_atomic_fetch_or_acquire
1693+/**
1694+ * raw_atomic_fetch_or_acquire() - atomic bitwise OR with acquire ordering
1695+ * @i: int value
1696+ * @v: pointer to atomic_t
1697+ *
1698+ * Atomically updates @v to (@v | @i) with acquire ordering.
1699+ *
1700+ * Safe to use in noinstr code; prefer atomic_fetch_or_acquire() elsewhere.
1701+ *
1702+ * Return: The original value of @v.
1703+ */
9231704 static __always_inline int
924−arch_atomic_fetch_or_acquire(int i, atomic_t *v)
1705+raw_atomic_fetch_or_acquire(int i, atomic_t *v)
9251706 {
1707+#if defined(arch_atomic_fetch_or_acquire)
1708+ return arch_atomic_fetch_or_acquire(i, v);
1709+#elif defined(arch_atomic_fetch_or_relaxed)
9261710 int ret = arch_atomic_fetch_or_relaxed(i, v);
9271711 __atomic_acquire_fence();
9281712 return ret;
929−}
930−#define arch_atomic_fetch_or_acquire arch_atomic_fetch_or_acquire
1713+#elif defined(arch_atomic_fetch_or)
1714+ return arch_atomic_fetch_or(i, v);
1715+#else
1716+#error "Unable to define raw_atomic_fetch_or_acquire"
9311717 #endif
1718+}
9321719
933−#ifndef arch_atomic_fetch_or_release
1720+/**
1721+ * raw_atomic_fetch_or_release() - atomic bitwise OR with release ordering
1722+ * @i: int value
1723+ * @v: pointer to atomic_t
1724+ *
1725+ * Atomically updates @v to (@v | @i) with release ordering.
1726+ *
1727+ * Safe to use in noinstr code; prefer atomic_fetch_or_release() elsewhere.
1728+ *
1729+ * Return: The original value of @v.
1730+ */
9341731 static __always_inline int
935−arch_atomic_fetch_or_release(int i, atomic_t *v)
1732+raw_atomic_fetch_or_release(int i, atomic_t *v)
9361733 {
1734+#if defined(arch_atomic_fetch_or_release)
1735+ return arch_atomic_fetch_or_release(i, v);
1736+#elif defined(arch_atomic_fetch_or_relaxed)
9371737 __atomic_release_fence();
9381738 return arch_atomic_fetch_or_relaxed(i, v);
1739+#elif defined(arch_atomic_fetch_or)
1740+ return arch_atomic_fetch_or(i, v);
1741+#else
1742+#error "Unable to define raw_atomic_fetch_or_release"
1743+#endif
9391744 }
940−#define arch_atomic_fetch_or_release arch_atomic_fetch_or_release
1745+
1746+/**
1747+ * raw_atomic_fetch_or_relaxed() - atomic bitwise OR with relaxed ordering
1748+ * @i: int value
1749+ * @v: pointer to atomic_t
1750+ *
1751+ * Atomically updates @v to (@v | @i) with relaxed ordering.
1752+ *
1753+ * Safe to use in noinstr code; prefer atomic_fetch_or_relaxed() elsewhere.
1754+ *
1755+ * Return: The original value of @v.
1756+ */
1757+static __always_inline int
1758+raw_atomic_fetch_or_relaxed(int i, atomic_t *v)
1759+{
1760+#if defined(arch_atomic_fetch_or_relaxed)
1761+ return arch_atomic_fetch_or_relaxed(i, v);
1762+#elif defined(arch_atomic_fetch_or)
1763+ return arch_atomic_fetch_or(i, v);
1764+#else
1765+#error "Unable to define raw_atomic_fetch_or_relaxed"
9411766 #endif
1767+}
9421768
943−#ifndef arch_atomic_fetch_or
1769+/**
1770+ * raw_atomic_xor() - atomic bitwise XOR with relaxed ordering
1771+ * @i: int value
1772+ * @v: pointer to atomic_t
1773+ *
1774+ * Atomically updates @v to (@v ^ @i) with relaxed ordering.
1775+ *
1776+ * Safe to use in noinstr code; prefer atomic_xor() elsewhere.
1777+ *
1778+ * Return: Nothing.
1779+ */
1780+static __always_inline void
1781+raw_atomic_xor(int i, atomic_t *v)
1782+{
1783+ arch_atomic_xor(i, v);
1784+}
1785+
1786+/**
1787+ * raw_atomic_fetch_xor() - atomic bitwise XOR with full ordering
1788+ * @i: int value
1789+ * @v: pointer to atomic_t
1790+ *
1791+ * Atomically updates @v to (@v ^ @i) with full ordering.
1792+ *
1793+ * Safe to use in noinstr code; prefer atomic_fetch_xor() elsewhere.
1794+ *
1795+ * Return: The original value of @v.
1796+ */
9441797 static __always_inline int
945−arch_atomic_fetch_or(int i, atomic_t *v)
1798+raw_atomic_fetch_xor(int i, atomic_t *v)
9461799 {
1800+#if defined(arch_atomic_fetch_xor)
1801+ return arch_atomic_fetch_xor(i, v);
1802+#elif defined(arch_atomic_fetch_xor_relaxed)
9471803 int ret;
9481804 __atomic_pre_full_fence();
949− ret = arch_atomic_fetch_or_relaxed(i, v);
1805+ ret = arch_atomic_fetch_xor_relaxed(i, v);
9501806 __atomic_post_full_fence();
9511807 return ret;
952−}
953−#define arch_atomic_fetch_or arch_atomic_fetch_or
1808+#else
1809+#error "Unable to define raw_atomic_fetch_xor"
9541810 #endif
1811+}
9551812
956−#endif /* arch_atomic_fetch_or_relaxed */
957−
958−#ifndef arch_atomic_fetch_xor_relaxed
959−#define arch_atomic_fetch_xor_acquire arch_atomic_fetch_xor
960−#define arch_atomic_fetch_xor_release arch_atomic_fetch_xor
961−#define arch_atomic_fetch_xor_relaxed arch_atomic_fetch_xor
962−#else /* arch_atomic_fetch_xor_relaxed */
963−
964−#ifndef arch_atomic_fetch_xor_acquire
1813+/**
1814+ * raw_atomic_fetch_xor_acquire() - atomic bitwise XOR with acquire ordering
1815+ * @i: int value
1816+ * @v: pointer to atomic_t
1817+ *
1818+ * Atomically updates @v to (@v ^ @i) with acquire ordering.
1819+ *
1820+ * Safe to use in noinstr code; prefer atomic_fetch_xor_acquire() elsewhere.
1821+ *
1822+ * Return: The original value of @v.
1823+ */
9651824 static __always_inline int
966−arch_atomic_fetch_xor_acquire(int i, atomic_t *v)
1825+raw_atomic_fetch_xor_acquire(int i, atomic_t *v)
9671826 {
1827+#if defined(arch_atomic_fetch_xor_acquire)
1828+ return arch_atomic_fetch_xor_acquire(i, v);
1829+#elif defined(arch_atomic_fetch_xor_relaxed)
9681830 int ret = arch_atomic_fetch_xor_relaxed(i, v);
9691831 __atomic_acquire_fence();
9701832 return ret;
971−}
972−#define arch_atomic_fetch_xor_acquire arch_atomic_fetch_xor_acquire
1833+#elif defined(arch_atomic_fetch_xor)
1834+ return arch_atomic_fetch_xor(i, v);
1835+#else
1836+#error "Unable to define raw_atomic_fetch_xor_acquire"
9731837 #endif
1838+}
9741839
975−#ifndef arch_atomic_fetch_xor_release
1840+/**
1841+ * raw_atomic_fetch_xor_release() - atomic bitwise XOR with release ordering
1842+ * @i: int value
1843+ * @v: pointer to atomic_t
1844+ *
1845+ * Atomically updates @v to (@v ^ @i) with release ordering.
1846+ *
1847+ * Safe to use in noinstr code; prefer atomic_fetch_xor_release() elsewhere.
1848+ *
1849+ * Return: The original value of @v.
1850+ */
9761851 static __always_inline int
977−arch_atomic_fetch_xor_release(int i, atomic_t *v)
1852+raw_atomic_fetch_xor_release(int i, atomic_t *v)
9781853 {
1854+#if defined(arch_atomic_fetch_xor_release)
1855+ return arch_atomic_fetch_xor_release(i, v);
1856+#elif defined(arch_atomic_fetch_xor_relaxed)
9791857 __atomic_release_fence();
9801858 return arch_atomic_fetch_xor_relaxed(i, v);
1859+#elif defined(arch_atomic_fetch_xor)
1860+ return arch_atomic_fetch_xor(i, v);
1861+#else
1862+#error "Unable to define raw_atomic_fetch_xor_release"
1863+#endif
9811864 }
982−#define arch_atomic_fetch_xor_release arch_atomic_fetch_xor_release
1865+
1866+/**
1867+ * raw_atomic_fetch_xor_relaxed() - atomic bitwise XOR with relaxed ordering
1868+ * @i: int value
1869+ * @v: pointer to atomic_t
1870+ *
1871+ * Atomically updates @v to (@v ^ @i) with relaxed ordering.
1872+ *
1873+ * Safe to use in noinstr code; prefer atomic_fetch_xor_relaxed() elsewhere.
1874+ *
1875+ * Return: The original value of @v.
1876+ */
1877+static __always_inline int
1878+raw_atomic_fetch_xor_relaxed(int i, atomic_t *v)
1879+{
1880+#if defined(arch_atomic_fetch_xor_relaxed)
1881+ return arch_atomic_fetch_xor_relaxed(i, v);
1882+#elif defined(arch_atomic_fetch_xor)
1883+ return arch_atomic_fetch_xor(i, v);
1884+#else
1885+#error "Unable to define raw_atomic_fetch_xor_relaxed"
9831886 #endif
1887+}
9841888
985−#ifndef arch_atomic_fetch_xor
1889+/**
1890+ * raw_atomic_xchg() - atomic exchange with full ordering
1891+ * @v: pointer to atomic_t
1892+ * @new: int value to assign
1893+ *
1894+ * Atomically updates @v to @new with full ordering.
1895+ *
1896+ * Safe to use in noinstr code; prefer atomic_xchg() elsewhere.
1897+ *
1898+ * Return: The original value of @v.
1899+ */
9861900 static __always_inline int
987−arch_atomic_fetch_xor(int i, atomic_t *v)
1901+raw_atomic_xchg(atomic_t *v, int new)
9881902 {
1903+#if defined(arch_atomic_xchg)
1904+ return arch_atomic_xchg(v, new);
1905+#elif defined(arch_atomic_xchg_relaxed)
9891906 int ret;
9901907 __atomic_pre_full_fence();
991− ret = arch_atomic_fetch_xor_relaxed(i, v);
1908+ ret = arch_atomic_xchg_relaxed(v, new);
9921909 __atomic_post_full_fence();
9931910 return ret;
994−}
995−#define arch_atomic_fetch_xor arch_atomic_fetch_xor
1911+#else
1912+ return raw_xchg(&v->counter, new);
9961913 #endif
1914+}
9971915
998−#endif /* arch_atomic_fetch_xor_relaxed */
999−
1000−#ifndef arch_atomic_xchg_relaxed
1001−#define arch_atomic_xchg_acquire arch_atomic_xchg
1002−#define arch_atomic_xchg_release arch_atomic_xchg
1003−#define arch_atomic_xchg_relaxed arch_atomic_xchg
1004−#else /* arch_atomic_xchg_relaxed */
1005−
1006−#ifndef arch_atomic_xchg_acquire
1916+/**
1917+ * raw_atomic_xchg_acquire() - atomic exchange with acquire ordering
1918+ * @v: pointer to atomic_t
1919+ * @new: int value to assign
1920+ *
1921+ * Atomically updates @v to @new with acquire ordering.
1922+ *
1923+ * Safe to use in noinstr code; prefer atomic_xchg_acquire() elsewhere.
1924+ *
1925+ * Return: The original value of @v.
1926+ */
10071927 static __always_inline int
1008−arch_atomic_xchg_acquire(atomic_t *v, int i)
1928+raw_atomic_xchg_acquire(atomic_t *v, int new)
10091929 {
1010− int ret = arch_atomic_xchg_relaxed(v, i);
1930+#if defined(arch_atomic_xchg_acquire)
1931+ return arch_atomic_xchg_acquire(v, new);
1932+#elif defined(arch_atomic_xchg_relaxed)
1933+ int ret = arch_atomic_xchg_relaxed(v, new);
10111934 __atomic_acquire_fence();
10121935 return ret;
1013−}
1014−#define arch_atomic_xchg_acquire arch_atomic_xchg_acquire
1936+#elif defined(arch_atomic_xchg)
1937+ return arch_atomic_xchg(v, new);
1938+#else
1939+ return raw_xchg_acquire(&v->counter, new);
10151940 #endif
1941+}
10161942
1017−#ifndef arch_atomic_xchg_release
1943+/**
1944+ * raw_atomic_xchg_release() - atomic exchange with release ordering
1945+ * @v: pointer to atomic_t
1946+ * @new: int value to assign
1947+ *
1948+ * Atomically updates @v to @new with release ordering.
1949+ *
1950+ * Safe to use in noinstr code; prefer atomic_xchg_release() elsewhere.
1951+ *
1952+ * Return: The original value of @v.
1953+ */
10181954 static __always_inline int
1019−arch_atomic_xchg_release(atomic_t *v, int i)
1955+raw_atomic_xchg_release(atomic_t *v, int new)
10201956 {
1957+#if defined(arch_atomic_xchg_release)
1958+ return arch_atomic_xchg_release(v, new);
1959+#elif defined(arch_atomic_xchg_relaxed)
10211960 __atomic_release_fence();
1022− return arch_atomic_xchg_relaxed(v, i);
1961+ return arch_atomic_xchg_relaxed(v, new);
1962+#elif defined(arch_atomic_xchg)
1963+ return arch_atomic_xchg(v, new);
1964+#else
1965+ return raw_xchg_release(&v->counter, new);
1966+#endif
10231967 }
1024−#define arch_atomic_xchg_release arch_atomic_xchg_release
1968+
1969+/**
1970+ * raw_atomic_xchg_relaxed() - atomic exchange with relaxed ordering
1971+ * @v: pointer to atomic_t
1972+ * @new: int value to assign
1973+ *
1974+ * Atomically updates @v to @new with relaxed ordering.
1975+ *
1976+ * Safe to use in noinstr code; prefer atomic_xchg_relaxed() elsewhere.
1977+ *
1978+ * Return: The original value of @v.
1979+ */
1980+static __always_inline int
1981+raw_atomic_xchg_relaxed(atomic_t *v, int new)
1982+{
1983+#if defined(arch_atomic_xchg_relaxed)
1984+ return arch_atomic_xchg_relaxed(v, new);
1985+#elif defined(arch_atomic_xchg)
1986+ return arch_atomic_xchg(v, new);
1987+#else
1988+ return raw_xchg_relaxed(&v->counter, new);
10251989 #endif
1990+}
10261991
1027−#ifndef arch_atomic_xchg
1992+/**
1993+ * raw_atomic_cmpxchg() - atomic compare and exchange with full ordering
1994+ * @v: pointer to atomic_t
1995+ * @old: int value to compare with
1996+ * @new: int value to assign
1997+ *
1998+ * If (@v == @old), atomically updates @v to @new with full ordering.
1999+ *
2000+ * Safe to use in noinstr code; prefer atomic_cmpxchg() elsewhere.
2001+ *
2002+ * Return: The original value of @v.
2003+ */
10282004 static __always_inline int
1029−arch_atomic_xchg(atomic_t *v, int i)
2005+raw_atomic_cmpxchg(atomic_t *v, int old, int new)
10302006 {
2007+#if defined(arch_atomic_cmpxchg)
2008+ return arch_atomic_cmpxchg(v, old, new);
2009+#elif defined(arch_atomic_cmpxchg_relaxed)
10312010 int ret;
10322011 __atomic_pre_full_fence();
1033− ret = arch_atomic_xchg_relaxed(v, i);
2012+ ret = arch_atomic_cmpxchg_relaxed(v, old, new);
10342013 __atomic_post_full_fence();
10352014 return ret;
1036−}
1037−#define arch_atomic_xchg arch_atomic_xchg
1038−#endif
1039−
1040−#endif /* arch_atomic_xchg_relaxed */
1041−
1042−#ifndef arch_atomic_cmpxchg_relaxed
1043−#define arch_atomic_cmpxchg_acquire arch_atomic_cmpxchg
1044−#define arch_atomic_cmpxchg_release arch_atomic_cmpxchg
1045−#define arch_atomic_cmpxchg_relaxed arch_atomic_cmpxchg
1046−#else /* arch_atomic_cmpxchg_relaxed */
2015+#else
2016+ return raw_cmpxchg(&v->counter, old, new);
2017+#endif
2018+}
10472019
1048−#ifndef arch_atomic_cmpxchg_acquire
2020+/**
2021+ * raw_atomic_cmpxchg_acquire() - atomic compare and exchange with acquire ordering
2022+ * @v: pointer to atomic_t
2023+ * @old: int value to compare with
2024+ * @new: int value to assign
2025+ *
2026+ * If (@v == @old), atomically updates @v to @new with acquire ordering.
2027+ *
2028+ * Safe to use in noinstr code; prefer atomic_cmpxchg_acquire() elsewhere.
2029+ *
2030+ * Return: The original value of @v.
2031+ */
10492032 static __always_inline int
1050−arch_atomic_cmpxchg_acquire(atomic_t *v, int old, int new)
2033+raw_atomic_cmpxchg_acquire(atomic_t *v, int old, int new)
10512034 {
2035+#if defined(arch_atomic_cmpxchg_acquire)
2036+ return arch_atomic_cmpxchg_acquire(v, old, new);
2037+#elif defined(arch_atomic_cmpxchg_relaxed)
10522038 int ret = arch_atomic_cmpxchg_relaxed(v, old, new);
10532039 __atomic_acquire_fence();
10542040 return ret;
1055−}
1056−#define arch_atomic_cmpxchg_acquire arch_atomic_cmpxchg_acquire
2041+#elif defined(arch_atomic_cmpxchg)
2042+ return arch_atomic_cmpxchg(v, old, new);
2043+#else
2044+ return raw_cmpxchg_acquire(&v->counter, old, new);
10572045 #endif
2046+}
10582047
1059−#ifndef arch_atomic_cmpxchg_release
2048+/**
2049+ * raw_atomic_cmpxchg_release() - atomic compare and exchange with release ordering
2050+ * @v: pointer to atomic_t
2051+ * @old: int value to compare with
2052+ * @new: int value to assign
2053+ *
2054+ * If (@v == @old), atomically updates @v to @new with release ordering.
2055+ *
2056+ * Safe to use in noinstr code; prefer atomic_cmpxchg_release() elsewhere.
2057+ *
2058+ * Return: The original value of @v.
2059+ */
10602060 static __always_inline int
1061−arch_atomic_cmpxchg_release(atomic_t *v, int old, int new)
2061+raw_atomic_cmpxchg_release(atomic_t *v, int old, int new)
10622062 {
2063+#if defined(arch_atomic_cmpxchg_release)
2064+ return arch_atomic_cmpxchg_release(v, old, new);
2065+#elif defined(arch_atomic_cmpxchg_relaxed)
10632066 __atomic_release_fence();
10642067 return arch_atomic_cmpxchg_relaxed(v, old, new);
1065−}
1066−#define arch_atomic_cmpxchg_release arch_atomic_cmpxchg_release
2068+#elif defined(arch_atomic_cmpxchg)
2069+ return arch_atomic_cmpxchg(v, old, new);
2070+#else
2071+ return raw_cmpxchg_release(&v->counter, old, new);
10672072 #endif
2073+}
10682074
1069−#ifndef arch_atomic_cmpxchg
2075+/**
2076+ * raw_atomic_cmpxchg_relaxed() - atomic compare and exchange with relaxed ordering
2077+ * @v: pointer to atomic_t
2078+ * @old: int value to compare with
2079+ * @new: int value to assign
2080+ *
2081+ * If (@v == @old), atomically updates @v to @new with relaxed ordering.
2082+ *
2083+ * Safe to use in noinstr code; prefer atomic_cmpxchg_relaxed() elsewhere.
2084+ *
2085+ * Return: The original value of @v.
2086+ */
10702087 static __always_inline int
1071−arch_atomic_cmpxchg(atomic_t *v, int old, int new)
2088+raw_atomic_cmpxchg_relaxed(atomic_t *v, int old, int new)
10722089 {
1073− int ret;
1074− __atomic_pre_full_fence();
1075− ret = arch_atomic_cmpxchg_relaxed(v, old, new);
1076− __atomic_post_full_fence();
1077− return ret;
1078−}
1079−#define arch_atomic_cmpxchg arch_atomic_cmpxchg
2090+#if defined(arch_atomic_cmpxchg_relaxed)
2091+ return arch_atomic_cmpxchg_relaxed(v, old, new);
2092+#elif defined(arch_atomic_cmpxchg)
2093+ return arch_atomic_cmpxchg(v, old, new);
2094+#else
2095+ return raw_cmpxchg_relaxed(&v->counter, old, new);
10802096 #endif
2097+}
10812098
1082−#endif /* arch_atomic_cmpxchg_relaxed */
1083−
1084−#ifndef arch_atomic_try_cmpxchg_relaxed
1085−#ifdef arch_atomic_try_cmpxchg
1086−#define arch_atomic_try_cmpxchg_acquire arch_atomic_try_cmpxchg
1087−#define arch_atomic_try_cmpxchg_release arch_atomic_try_cmpxchg
1088−#define arch_atomic_try_cmpxchg_relaxed arch_atomic_try_cmpxchg
1089−#endif /* arch_atomic_try_cmpxchg */
1090−
1091−#ifndef arch_atomic_try_cmpxchg
2099+/**
2100+ * raw_atomic_try_cmpxchg() - atomic compare and exchange with full ordering
2101+ * @v: pointer to atomic_t
2102+ * @old: pointer to int value to compare with
2103+ * @new: int value to assign
2104+ *
2105+ * If (@v == @old), atomically updates @v to @new with full ordering.
2106+ * Otherwise, updates @old to the current value of @v.
2107+ *
2108+ * Safe to use in noinstr code; prefer atomic_try_cmpxchg() elsewhere.
2109+ *
2110+ * Return: @true if the exchange occured, @false otherwise.
2111+ */
10922112 static __always_inline bool
1093−arch_atomic_try_cmpxchg(atomic_t *v, int *old, int new)
2113+raw_atomic_try_cmpxchg(atomic_t *v, int *old, int new)
10942114 {
2115+#if defined(arch_atomic_try_cmpxchg)
2116+ return arch_atomic_try_cmpxchg(v, old, new);
2117+#elif defined(arch_atomic_try_cmpxchg_relaxed)
2118+ bool ret;
2119+ __atomic_pre_full_fence();
2120+ ret = arch_atomic_try_cmpxchg_relaxed(v, old, new);
2121+ __atomic_post_full_fence();
2122+ return ret;
2123+#else
10952124 int r, o = *old;
1096− r = arch_atomic_cmpxchg(v, o, new);
2125+ r = raw_atomic_cmpxchg(v, o, new);
10972126 if (unlikely(r != o))
10982127 *old = r;
10992128 return likely(r == o);
1100−}
1101−#define arch_atomic_try_cmpxchg arch_atomic_try_cmpxchg
11022129 #endif
2130+}
11032131
1104−#ifndef arch_atomic_try_cmpxchg_acquire
2132+/**
2133+ * raw_atomic_try_cmpxchg_acquire() - atomic compare and exchange with acquire ordering
2134+ * @v: pointer to atomic_t
2135+ * @old: pointer to int value to compare with
2136+ * @new: int value to assign
2137+ *
2138+ * If (@v == @old), atomically updates @v to @new with acquire ordering.
2139+ * Otherwise, updates @old to the current value of @v.
2140+ *
2141+ * Safe to use in noinstr code; prefer atomic_try_cmpxchg_acquire() elsewhere.
2142+ *
2143+ * Return: @true if the exchange occured, @false otherwise.
2144+ */
11052145 static __always_inline bool
1106−arch_atomic_try_cmpxchg_acquire(atomic_t *v, int *old, int new)
2146+raw_atomic_try_cmpxchg_acquire(atomic_t *v, int *old, int new)
11072147 {
2148+#if defined(arch_atomic_try_cmpxchg_acquire)
2149+ return arch_atomic_try_cmpxchg_acquire(v, old, new);
2150+#elif defined(arch_atomic_try_cmpxchg_relaxed)
2151+ bool ret = arch_atomic_try_cmpxchg_relaxed(v, old, new);
2152+ __atomic_acquire_fence();
2153+ return ret;
2154+#elif defined(arch_atomic_try_cmpxchg)
2155+ return arch_atomic_try_cmpxchg(v, old, new);
2156+#else
11082157 int r, o = *old;
1109− r = arch_atomic_cmpxchg_acquire(v, o, new);
2158+ r = raw_atomic_cmpxchg_acquire(v, o, new);
11102159 if (unlikely(r != o))
11112160 *old = r;
11122161 return likely(r == o);
1113−}
1114−#define arch_atomic_try_cmpxchg_acquire arch_atomic_try_cmpxchg_acquire
11152162 #endif
2163+}
11162164
1117−#ifndef arch_atomic_try_cmpxchg_release
2165+/**
2166+ * raw_atomic_try_cmpxchg_release() - atomic compare and exchange with release ordering
2167+ * @v: pointer to atomic_t
2168+ * @old: pointer to int value to compare with
2169+ * @new: int value to assign
2170+ *
2171+ * If (@v == @old), atomically updates @v to @new with release ordering.
2172+ * Otherwise, updates @old to the current value of @v.
2173+ *
2174+ * Safe to use in noinstr code; prefer atomic_try_cmpxchg_release() elsewhere.
2175+ *
2176+ * Return: @true if the exchange occured, @false otherwise.
2177+ */
11182178 static __always_inline bool
1119−arch_atomic_try_cmpxchg_release(atomic_t *v, int *old, int new)
2179+raw_atomic_try_cmpxchg_release(atomic_t *v, int *old, int new)
11202180 {
2181+#if defined(arch_atomic_try_cmpxchg_release)
2182+ return arch_atomic_try_cmpxchg_release(v, old, new);
2183+#elif defined(arch_atomic_try_cmpxchg_relaxed)
2184+ __atomic_release_fence();
2185+ return arch_atomic_try_cmpxchg_relaxed(v, old, new);
2186+#elif defined(arch_atomic_try_cmpxchg)
2187+ return arch_atomic_try_cmpxchg(v, old, new);
2188+#else
11212189 int r, o = *old;
1122− r = arch_atomic_cmpxchg_release(v, o, new);
2190+ r = raw_atomic_cmpxchg_release(v, o, new);
11232191 if (unlikely(r != o))
11242192 *old = r;
11252193 return likely(r == o);
1126−}
1127−#define arch_atomic_try_cmpxchg_release arch_atomic_try_cmpxchg_release
11282194 #endif
2195+}
11292196
1130−#ifndef arch_atomic_try_cmpxchg_relaxed
2197+/**
2198+ * raw_atomic_try_cmpxchg_relaxed() - atomic compare and exchange with relaxed ordering
2199+ * @v: pointer to atomic_t
2200+ * @old: pointer to int value to compare with
2201+ * @new: int value to assign
2202+ *
2203+ * If (@v == @old), atomically updates @v to @new with relaxed ordering.
2204+ * Otherwise, updates @old to the current value of @v.
2205+ *
2206+ * Safe to use in noinstr code; prefer atomic_try_cmpxchg_relaxed() elsewhere.
2207+ *
2208+ * Return: @true if the exchange occured, @false otherwise.
2209+ */
11312210 static __always_inline bool
1132−arch_atomic_try_cmpxchg_relaxed(atomic_t *v, int *old, int new)
2211+raw_atomic_try_cmpxchg_relaxed(atomic_t *v, int *old, int new)
11332212 {
2213+#if defined(arch_atomic_try_cmpxchg_relaxed)
2214+ return arch_atomic_try_cmpxchg_relaxed(v, old, new);
2215+#elif defined(arch_atomic_try_cmpxchg)
2216+ return arch_atomic_try_cmpxchg(v, old, new);
2217+#else
11342218 int r, o = *old;
1135− r = arch_atomic_cmpxchg_relaxed(v, o, new);
2219+ r = raw_atomic_cmpxchg_relaxed(v, o, new);
11362220 if (unlikely(r != o))
11372221 *old = r;
11382222 return likely(r == o);
1139−}
1140−#define arch_atomic_try_cmpxchg_relaxed arch_atomic_try_cmpxchg_relaxed
1141−#endif
1142−
1143−#else /* arch_atomic_try_cmpxchg_relaxed */
1144−
1145−#ifndef arch_atomic_try_cmpxchg_acquire
1146−static __always_inline bool
1147−arch_atomic_try_cmpxchg_acquire(atomic_t *v, int *old, int new)
1148−{
1149− bool ret = arch_atomic_try_cmpxchg_relaxed(v, old, new);
1150− __atomic_acquire_fence();
1151− return ret;
1152−}
1153−#define arch_atomic_try_cmpxchg_acquire arch_atomic_try_cmpxchg_acquire
1154−#endif
1155−
1156−#ifndef arch_atomic_try_cmpxchg_release
1157−static __always_inline bool
1158−arch_atomic_try_cmpxchg_release(atomic_t *v, int *old, int new)
1159−{
1160− __atomic_release_fence();
1161− return arch_atomic_try_cmpxchg_relaxed(v, old, new);
1162−}
1163−#define arch_atomic_try_cmpxchg_release arch_atomic_try_cmpxchg_release
11642223 #endif
1165−
1166−#ifndef arch_atomic_try_cmpxchg
1167−static __always_inline bool
1168−arch_atomic_try_cmpxchg(atomic_t *v, int *old, int new)
1169−{
1170− bool ret;
1171− __atomic_pre_full_fence();
1172− ret = arch_atomic_try_cmpxchg_relaxed(v, old, new);
1173− __atomic_post_full_fence();
1174− return ret;
11752224 }
1176−#define arch_atomic_try_cmpxchg arch_atomic_try_cmpxchg
1177−#endif
11782225
1179−#endif /* arch_atomic_try_cmpxchg_relaxed */
1180−
1181−#ifndef arch_atomic_sub_and_test
11822226 /**
1183− * arch_atomic_sub_and_test - subtract value from variable and test result
1184− * @i: integer value to subtract
1185− * @v: pointer of type atomic_t
2227+ * raw_atomic_sub_and_test() - atomic subtract and test if zero with full ordering
2228+ * @i: int value to add
2229+ * @v: pointer to atomic_t
2230+ *
2231+ * Atomically updates @v to (@v - @i) with full ordering.
11862232 *
1187− * Atomically subtracts @i from @v and returns
1188− * true if the result is zero, or false for all
1189− * other cases.
2233+ * Safe to use in noinstr code; prefer atomic_sub_and_test() elsewhere.
2234+ *
2235+ * Return: @true if the resulting value of @v is zero, @false otherwise.
11902236 */
11912237 static __always_inline bool
1192−arch_atomic_sub_and_test(int i, atomic_t *v)
2238+raw_atomic_sub_and_test(int i, atomic_t *v)
11932239 {
1194− return arch_atomic_sub_return(i, v) == 0;
1195−}
1196−#define arch_atomic_sub_and_test arch_atomic_sub_and_test
2240+#if defined(arch_atomic_sub_and_test)
2241+ return arch_atomic_sub_and_test(i, v);
2242+#else
2243+ return raw_atomic_sub_return(i, v) == 0;
11972244 #endif
2245+}
11982246
1199−#ifndef arch_atomic_dec_and_test
12002247 /**
1201− * arch_atomic_dec_and_test - decrement and test
1202− * @v: pointer of type atomic_t
2248+ * raw_atomic_dec_and_test() - atomic decrement and test if zero with full ordering
2249+ * @v: pointer to atomic_t
2250+ *
2251+ * Atomically updates @v to (@v - 1) with full ordering.
12032252 *
1204− * Atomically decrements @v by 1 and
1205− * returns true if the result is 0, or false for all other
1206− * cases.
2253+ * Safe to use in noinstr code; prefer atomic_dec_and_test() elsewhere.
2254+ *
2255+ * Return: @true if the resulting value of @v is zero, @false otherwise.
12072256 */
12082257 static __always_inline bool
1209−arch_atomic_dec_and_test(atomic_t *v)
2258+raw_atomic_dec_and_test(atomic_t *v)
12102259 {
1211− return arch_atomic_dec_return(v) == 0;
1212−}
1213−#define arch_atomic_dec_and_test arch_atomic_dec_and_test
2260+#if defined(arch_atomic_dec_and_test)
2261+ return arch_atomic_dec_and_test(v);
2262+#else
2263+ return raw_atomic_dec_return(v) == 0;
12142264 #endif
2265+}
12152266
1216−#ifndef arch_atomic_inc_and_test
12172267 /**
1218− * arch_atomic_inc_and_test - increment and test
1219− * @v: pointer of type atomic_t
2268+ * raw_atomic_inc_and_test() - atomic increment and test if zero with full ordering
2269+ * @v: pointer to atomic_t
2270+ *
2271+ * Atomically updates @v to (@v + 1) with full ordering.
12202272 *
1221− * Atomically increments @v by 1
1222− * and returns true if the result is zero, or false for all
1223− * other cases.
2273+ * Safe to use in noinstr code; prefer atomic_inc_and_test() elsewhere.
2274+ *
2275+ * Return: @true if the resulting value of @v is zero, @false otherwise.
12242276 */
12252277 static __always_inline bool
1226−arch_atomic_inc_and_test(atomic_t *v)
2278+raw_atomic_inc_and_test(atomic_t *v)
12272279 {
1228− return arch_atomic_inc_return(v) == 0;
1229−}
1230−#define arch_atomic_inc_and_test arch_atomic_inc_and_test
2280+#if defined(arch_atomic_inc_and_test)
2281+ return arch_atomic_inc_and_test(v);
2282+#else
2283+ return raw_atomic_inc_return(v) == 0;
12312284 #endif
2285+}
12322286
1233−#ifndef arch_atomic_add_negative_relaxed
1234−#ifdef arch_atomic_add_negative
1235−#define arch_atomic_add_negative_acquire arch_atomic_add_negative
1236−#define arch_atomic_add_negative_release arch_atomic_add_negative
1237−#define arch_atomic_add_negative_relaxed arch_atomic_add_negative
1238−#endif /* arch_atomic_add_negative */
1239−
1240−#ifndef arch_atomic_add_negative
12412287 /**
1242− * arch_atomic_add_negative - Add and test if negative
1243− * @i: integer value to add
1244− * @v: pointer of type atomic_t
2288+ * raw_atomic_add_negative() - atomic add and test if negative with full ordering
2289+ * @i: int value to add
2290+ * @v: pointer to atomic_t
12452291 *
1246− * Atomically adds @i to @v and returns true if the result is negative,
1247− * or false when the result is greater than or equal to zero.
2292+ * Atomically updates @v to (@v + @i) with full ordering.
2293+ *
2294+ * Safe to use in noinstr code; prefer atomic_add_negative() elsewhere.
2295+ *
2296+ * Return: @true if the resulting value of @v is negative, @false otherwise.
12482297 */
12492298 static __always_inline bool
1250−arch_atomic_add_negative(int i, atomic_t *v)
2299+raw_atomic_add_negative(int i, atomic_t *v)
12512300 {
1252− return arch_atomic_add_return(i, v) < 0;
1253−}
1254−#define arch_atomic_add_negative arch_atomic_add_negative
2301+#if defined(arch_atomic_add_negative)
2302+ return arch_atomic_add_negative(i, v);
2303+#elif defined(arch_atomic_add_negative_relaxed)
2304+ bool ret;
2305+ __atomic_pre_full_fence();
2306+ ret = arch_atomic_add_negative_relaxed(i, v);
2307+ __atomic_post_full_fence();
2308+ return ret;
2309+#else
2310+ return raw_atomic_add_return(i, v) < 0;
12552311 #endif
2312+}
12562313
1257−#ifndef arch_atomic_add_negative_acquire
12582314 /**
1259− * arch_atomic_add_negative_acquire - Add and test if negative
1260− * @i: integer value to add
1261− * @v: pointer of type atomic_t
2315+ * raw_atomic_add_negative_acquire() - atomic add and test if negative with acquire ordering
2316+ * @i: int value to add
2317+ * @v: pointer to atomic_t
2318+ *
2319+ * Atomically updates @v to (@v + @i) with acquire ordering.
12622320 *
1263− * Atomically adds @i to @v and returns true if the result is negative,
1264− * or false when the result is greater than or equal to zero.
2321+ * Safe to use in noinstr code; prefer atomic_add_negative_acquire() elsewhere.
2322+ *
2323+ * Return: @true if the resulting value of @v is negative, @false otherwise.
12652324 */
12662325 static __always_inline bool
1267−arch_atomic_add_negative_acquire(int i, atomic_t *v)
2326+raw_atomic_add_negative_acquire(int i, atomic_t *v)
12682327 {
1269− return arch_atomic_add_return_acquire(i, v) < 0;
1270−}
1271−#define arch_atomic_add_negative_acquire arch_atomic_add_negative_acquire
2328+#if defined(arch_atomic_add_negative_acquire)
2329+ return arch_atomic_add_negative_acquire(i, v);
2330+#elif defined(arch_atomic_add_negative_relaxed)
2331+ bool ret = arch_atomic_add_negative_relaxed(i, v);
2332+ __atomic_acquire_fence();
2333+ return ret;
2334+#elif defined(arch_atomic_add_negative)
2335+ return arch_atomic_add_negative(i, v);
2336+#else
2337+ return raw_atomic_add_return_acquire(i, v) < 0;
12722338 #endif
2339+}
12732340
1274−#ifndef arch_atomic_add_negative_release
12752341 /**
1276− * arch_atomic_add_negative_release - Add and test if negative
1277− * @i: integer value to add
1278− * @v: pointer of type atomic_t
2342+ * raw_atomic_add_negative_release() - atomic add and test if negative with release ordering
2343+ * @i: int value to add
2344+ * @v: pointer to atomic_t
12792345 *
1280− * Atomically adds @i to @v and returns true if the result is negative,
1281− * or false when the result is greater than or equal to zero.
2346+ * Atomically updates @v to (@v + @i) with release ordering.
2347+ *
2348+ * Safe to use in noinstr code; prefer atomic_add_negative_release() elsewhere.
2349+ *
2350+ * Return: @true if the resulting value of @v is negative, @false otherwise.
12822351 */
12832352 static __always_inline bool
1284−arch_atomic_add_negative_release(int i, atomic_t *v)
2353+raw_atomic_add_negative_release(int i, atomic_t *v)
12852354 {
1286− return arch_atomic_add_return_release(i, v) < 0;
1287−}
1288−#define arch_atomic_add_negative_release arch_atomic_add_negative_release
2355+#if defined(arch_atomic_add_negative_release)
2356+ return arch_atomic_add_negative_release(i, v);
2357+#elif defined(arch_atomic_add_negative_relaxed)
2358+ __atomic_release_fence();
2359+ return arch_atomic_add_negative_relaxed(i, v);
2360+#elif defined(arch_atomic_add_negative)
2361+ return arch_atomic_add_negative(i, v);
2362+#else
2363+ return raw_atomic_add_return_release(i, v) < 0;
12892364 #endif
2365+}
12902366
1291−#ifndef arch_atomic_add_negative_relaxed
12922367 /**
1293− * arch_atomic_add_negative_relaxed - Add and test if negative
1294− * @i: integer value to add
1295− * @v: pointer of type atomic_t
2368+ * raw_atomic_add_negative_relaxed() - atomic add and test if negative with relaxed ordering
2369+ * @i: int value to add
2370+ * @v: pointer to atomic_t
2371+ *
2372+ * Atomically updates @v to (@v + @i) with relaxed ordering.
2373+ *
2374+ * Safe to use in noinstr code; prefer atomic_add_negative_relaxed() elsewhere.
12962375 *
1297− * Atomically adds @i to @v and returns true if the result is negative,
1298− * or false when the result is greater than or equal to zero.
2376+ * Return: @true if the resulting value of @v is negative, @false otherwise.
12992377 */
13002378 static __always_inline bool
1301−arch_atomic_add_negative_relaxed(int i, atomic_t *v)
1302−{
1303− return arch_atomic_add_return_relaxed(i, v) < 0;
1304−}
1305−#define arch_atomic_add_negative_relaxed arch_atomic_add_negative_relaxed
1306−#endif
1307−
1308−#else /* arch_atomic_add_negative_relaxed */
1309−
1310−#ifndef arch_atomic_add_negative_acquire
1311−static __always_inline bool
1312−arch_atomic_add_negative_acquire(int i, atomic_t *v)
1313−{
1314− bool ret = arch_atomic_add_negative_relaxed(i, v);
1315− __atomic_acquire_fence();
1316− return ret;
1317−}
1318−#define arch_atomic_add_negative_acquire arch_atomic_add_negative_acquire
1319−#endif
1320−
1321−#ifndef arch_atomic_add_negative_release
1322−static __always_inline bool
1323−arch_atomic_add_negative_release(int i, atomic_t *v)
2379+raw_atomic_add_negative_relaxed(int i, atomic_t *v)
13242380 {
1325− __atomic_release_fence();
2381+#if defined(arch_atomic_add_negative_relaxed)
13262382 return arch_atomic_add_negative_relaxed(i, v);
1327−}
1328−#define arch_atomic_add_negative_release arch_atomic_add_negative_release
2383+#elif defined(arch_atomic_add_negative)
2384+ return arch_atomic_add_negative(i, v);
2385+#else
2386+ return raw_atomic_add_return_relaxed(i, v) < 0;
13292387 #endif
1330−
1331−#ifndef arch_atomic_add_negative
1332−static __always_inline bool
1333−arch_atomic_add_negative(int i, atomic_t *v)
1334−{
1335− bool ret;
1336− __atomic_pre_full_fence();
1337− ret = arch_atomic_add_negative_relaxed(i, v);
1338− __atomic_post_full_fence();
1339− return ret;
13402388 }
1341−#define arch_atomic_add_negative arch_atomic_add_negative
1342−#endif
1343−
1344−#endif /* arch_atomic_add_negative_relaxed */
13452389
1346−#ifndef arch_atomic_fetch_add_unless
13472390 /**
1348− * arch_atomic_fetch_add_unless - add unless the number is already a given value
1349− * @v: pointer of type atomic_t
1350− * @a: the amount to add to v...
1351− * @u: ...unless v is equal to u.
2391+ * raw_atomic_fetch_add_unless() - atomic add unless value with full ordering
2392+ * @v: pointer to atomic_t
2393+ * @a: int value to add
2394+ * @u: int value to compare with
2395+ *
2396+ * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
2397+ *
2398+ * Safe to use in noinstr code; prefer atomic_fetch_add_unless() elsewhere.
13522399 *
1353− * Atomically adds @a to @v, so long as @v was not already @u.
1354− * Returns original value of @v
2400+ * Return: The original value of @v.
13552401 */
13562402 static __always_inline int
1357−arch_atomic_fetch_add_unless(atomic_t *v, int a, int u)
2403+raw_atomic_fetch_add_unless(atomic_t *v, int a, int u)
13582404 {
1359− int c = arch_atomic_read(v);
2405+#if defined(arch_atomic_fetch_add_unless)
2406+ return arch_atomic_fetch_add_unless(v, a, u);
2407+#else
2408+ int c = raw_atomic_read(v);
13602409
13612410 do {
13622411 if (unlikely(c == u))
13632412 break;
1364− } while (!arch_atomic_try_cmpxchg(v, &c, c + a));
2413+ } while (!raw_atomic_try_cmpxchg(v, &c, c + a));
13652414
13662415 return c;
1367−}
1368−#define arch_atomic_fetch_add_unless arch_atomic_fetch_add_unless
13692416 #endif
2417+}
13702418
1371−#ifndef arch_atomic_add_unless
13722419 /**
1373− * arch_atomic_add_unless - add unless the number is already a given value
1374− * @v: pointer of type atomic_t
1375− * @a: the amount to add to v...
1376− * @u: ...unless v is equal to u.
2420+ * raw_atomic_add_unless() - atomic add unless value with full ordering
2421+ * @v: pointer to atomic_t
2422+ * @a: int value to add
2423+ * @u: int value to compare with
2424+ *
2425+ * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
2426+ *
2427+ * Safe to use in noinstr code; prefer atomic_add_unless() elsewhere.
13772428 *
1378− * Atomically adds @a to @v, if @v was not already @u.
1379− * Returns true if the addition was done.
2429+ * Return: @true if @v was updated, @false otherwise.
13802430 */
13812431 static __always_inline bool
1382−arch_atomic_add_unless(atomic_t *v, int a, int u)
2432+raw_atomic_add_unless(atomic_t *v, int a, int u)
13832433 {
1384− return arch_atomic_fetch_add_unless(v, a, u) != u;
1385−}
1386−#define arch_atomic_add_unless arch_atomic_add_unless
2434+#if defined(arch_atomic_add_unless)
2435+ return arch_atomic_add_unless(v, a, u);
2436+#else
2437+ return raw_atomic_fetch_add_unless(v, a, u) != u;
13872438 #endif
2439+}
13882440
1389−#ifndef arch_atomic_inc_not_zero
13902441 /**
1391− * arch_atomic_inc_not_zero - increment unless the number is zero
1392− * @v: pointer of type atomic_t
2442+ * raw_atomic_inc_not_zero() - atomic increment unless zero with full ordering
2443+ * @v: pointer to atomic_t
2444+ *
2445+ * If (@v != 0), atomically updates @v to (@v + 1) with full ordering.
2446+ *
2447+ * Safe to use in noinstr code; prefer atomic_inc_not_zero() elsewhere.
13932448 *
1394− * Atomically increments @v by 1, if @v is non-zero.
1395− * Returns true if the increment was done.
2449+ * Return: @true if @v was updated, @false otherwise.
13962450 */
13972451 static __always_inline bool
1398−arch_atomic_inc_not_zero(atomic_t *v)
2452+raw_atomic_inc_not_zero(atomic_t *v)
13992453 {
1400− return arch_atomic_add_unless(v, 1, 0);
1401−}
1402−#define arch_atomic_inc_not_zero arch_atomic_inc_not_zero
2454+#if defined(arch_atomic_inc_not_zero)
2455+ return arch_atomic_inc_not_zero(v);
2456+#else
2457+ return raw_atomic_add_unless(v, 1, 0);
14032458 #endif
2459+}
14042460
1405−#ifndef arch_atomic_inc_unless_negative
2461+/**
2462+ * raw_atomic_inc_unless_negative() - atomic increment unless negative with full ordering
2463+ * @v: pointer to atomic_t
2464+ *
2465+ * If (@v >= 0), atomically updates @v to (@v + 1) with full ordering.
2466+ *
2467+ * Safe to use in noinstr code; prefer atomic_inc_unless_negative() elsewhere.
2468+ *
2469+ * Return: @true if @v was updated, @false otherwise.
2470+ */
14062471 static __always_inline bool
1407−arch_atomic_inc_unless_negative(atomic_t *v)
2472+raw_atomic_inc_unless_negative(atomic_t *v)
14082473 {
1409− int c = arch_atomic_read(v);
2474+#if defined(arch_atomic_inc_unless_negative)
2475+ return arch_atomic_inc_unless_negative(v);
2476+#else
2477+ int c = raw_atomic_read(v);
14102478
14112479 do {
14122480 if (unlikely(c < 0))
14132481 return false;
1414− } while (!arch_atomic_try_cmpxchg(v, &c, c + 1));
2482+ } while (!raw_atomic_try_cmpxchg(v, &c, c + 1));
14152483
14162484 return true;
1417−}
1418−#define arch_atomic_inc_unless_negative arch_atomic_inc_unless_negative
14192485 #endif
2486+}
14202487
1421−#ifndef arch_atomic_dec_unless_positive
2488+/**
2489+ * raw_atomic_dec_unless_positive() - atomic decrement unless positive with full ordering
2490+ * @v: pointer to atomic_t
2491+ *
2492+ * If (@v <= 0), atomically updates @v to (@v - 1) with full ordering.
2493+ *
2494+ * Safe to use in noinstr code; prefer atomic_dec_unless_positive() elsewhere.
2495+ *
2496+ * Return: @true if @v was updated, @false otherwise.
2497+ */
14222498 static __always_inline bool
1423−arch_atomic_dec_unless_positive(atomic_t *v)
2499+raw_atomic_dec_unless_positive(atomic_t *v)
14242500 {
1425− int c = arch_atomic_read(v);
2501+#if defined(arch_atomic_dec_unless_positive)
2502+ return arch_atomic_dec_unless_positive(v);
2503+#else
2504+ int c = raw_atomic_read(v);
14262505
14272506 do {
14282507 if (unlikely(c > 0))
14292508 return false;
1430− } while (!arch_atomic_try_cmpxchg(v, &c, c - 1));
2509+ } while (!raw_atomic_try_cmpxchg(v, &c, c - 1));
14312510
14322511 return true;
1433−}
1434−#define arch_atomic_dec_unless_positive arch_atomic_dec_unless_positive
14352512 #endif
2513+}
14362514
1437−#ifndef arch_atomic_dec_if_positive
2515+/**
2516+ * raw_atomic_dec_if_positive() - atomic decrement if positive with full ordering
2517+ * @v: pointer to atomic_t
2518+ *
2519+ * If (@v > 0), atomically updates @v to (@v - 1) with full ordering.
2520+ *
2521+ * Safe to use in noinstr code; prefer atomic_dec_if_positive() elsewhere.
2522+ *
2523+ * Return: The old value of (@v - 1), regardless of whether @v was updated.
2524+ */
14382525 static __always_inline int
1439−arch_atomic_dec_if_positive(atomic_t *v)
2526+raw_atomic_dec_if_positive(atomic_t *v)
14402527 {
1441− int dec, c = arch_atomic_read(v);
2528+#if defined(arch_atomic_dec_if_positive)
2529+ return arch_atomic_dec_if_positive(v);
2530+#else
2531+ int dec, c = raw_atomic_read(v);
14422532
14432533 do {
14442534 dec = c - 1;
14452535 if (unlikely(dec < 0))
14462536 break;
1447− } while (!arch_atomic_try_cmpxchg(v, &c, dec));
2537+ } while (!raw_atomic_try_cmpxchg(v, &c, dec));
14482538
14492539 return dec;
1450−}
1451−#define arch_atomic_dec_if_positive arch_atomic_dec_if_positive
14522540 #endif
2541+}
14532542
14542543 #ifdef CONFIG_GENERIC_ATOMIC64
14552544 #include <asm-generic/atomic64.h>
14562545 #endif
14572546
1458−#ifndef arch_atomic64_read_acquire
2547+/**
2548+ * raw_atomic64_read() - atomic load with relaxed ordering
2549+ * @v: pointer to atomic64_t
2550+ *
2551+ * Atomically loads the value of @v with relaxed ordering.
2552+ *
2553+ * Safe to use in noinstr code; prefer atomic64_read() elsewhere.
2554+ *
2555+ * Return: The value loaded from @v.
2556+ */
2557+static __always_inline s64
2558+raw_atomic64_read(const atomic64_t *v)
2559+{
2560+ return arch_atomic64_read(v);
2561+}
2562+
2563+/**
2564+ * raw_atomic64_read_acquire() - atomic load with acquire ordering
2565+ * @v: pointer to atomic64_t
2566+ *
2567+ * Atomically loads the value of @v with acquire ordering.
2568+ *
2569+ * Safe to use in noinstr code; prefer atomic64_read_acquire() elsewhere.
2570+ *
2571+ * Return: The value loaded from @v.
2572+ */
14592573 static __always_inline s64
1460−arch_atomic64_read_acquire(const atomic64_t *v)
2574+raw_atomic64_read_acquire(const atomic64_t *v)
14612575 {
2576+#if defined(arch_atomic64_read_acquire)
2577+ return arch_atomic64_read_acquire(v);
2578+#elif defined(arch_atomic64_read)
2579+ return arch_atomic64_read(v);
2580+#else
14622581 s64 ret;
14632582
14642583 if (__native_word(atomic64_t)) {
14652584 ret = smp_load_acquire(&(v)->counter);
14662585 } else {
1467− ret = arch_atomic64_read(v);
2586+ ret = raw_atomic64_read(v);
14682587 __atomic_acquire_fence();
14692588 }
14702589
14712590 return ret;
1472−}
1473−#define arch_atomic64_read_acquire arch_atomic64_read_acquire
14742591 #endif
2592+}
2593+
2594+/**
2595+ * raw_atomic64_set() - atomic set with relaxed ordering
2596+ * @v: pointer to atomic64_t
2597+ * @i: s64 value to assign
2598+ *
2599+ * Atomically sets @v to @i with relaxed ordering.
2600+ *
2601+ * Safe to use in noinstr code; prefer atomic64_set() elsewhere.
2602+ *
2603+ * Return: Nothing.
2604+ */
2605+static __always_inline void
2606+raw_atomic64_set(atomic64_t *v, s64 i)
2607+{
2608+ arch_atomic64_set(v, i);
2609+}
14752610
1476−#ifndef arch_atomic64_set_release
2611+/**
2612+ * raw_atomic64_set_release() - atomic set with release ordering
2613+ * @v: pointer to atomic64_t
2614+ * @i: s64 value to assign
2615+ *
2616+ * Atomically sets @v to @i with release ordering.
2617+ *
2618+ * Safe to use in noinstr code; prefer atomic64_set_release() elsewhere.
2619+ *
2620+ * Return: Nothing.
2621+ */
14772622 static __always_inline void
1478−arch_atomic64_set_release(atomic64_t *v, s64 i)
2623+raw_atomic64_set_release(atomic64_t *v, s64 i)
14792624 {
2625+#if defined(arch_atomic64_set_release)
2626+ arch_atomic64_set_release(v, i);
2627+#elif defined(arch_atomic64_set)
2628+ arch_atomic64_set(v, i);
2629+#else
14802630 if (__native_word(atomic64_t)) {
14812631 smp_store_release(&(v)->counter, i);
14822632 } else {
14832633 __atomic_release_fence();
1484− arch_atomic64_set(v, i);
2634+ raw_atomic64_set(v, i);
14852635 }
1486−}
1487−#define arch_atomic64_set_release arch_atomic64_set_release
14882636 #endif
2637+}
2638+
2639+/**
2640+ * raw_atomic64_add() - atomic add with relaxed ordering
2641+ * @i: s64 value to add
2642+ * @v: pointer to atomic64_t
2643+ *
2644+ * Atomically updates @v to (@v + @i) with relaxed ordering.
2645+ *
2646+ * Safe to use in noinstr code; prefer atomic64_add() elsewhere.
2647+ *
2648+ * Return: Nothing.
2649+ */
2650+static __always_inline void
2651+raw_atomic64_add(s64 i, atomic64_t *v)
2652+{
2653+ arch_atomic64_add(i, v);
2654+}
14892655
1490−#ifndef arch_atomic64_add_return_relaxed
1491−#define arch_atomic64_add_return_acquire arch_atomic64_add_return
1492−#define arch_atomic64_add_return_release arch_atomic64_add_return
1493−#define arch_atomic64_add_return_relaxed arch_atomic64_add_return
1494−#else /* arch_atomic64_add_return_relaxed */
2656+/**
2657+ * raw_atomic64_add_return() - atomic add with full ordering
2658+ * @i: s64 value to add
2659+ * @v: pointer to atomic64_t
2660+ *
2661+ * Atomically updates @v to (@v + @i) with full ordering.
2662+ *
2663+ * Safe to use in noinstr code; prefer atomic64_add_return() elsewhere.
2664+ *
2665+ * Return: The updated value of @v.
2666+ */
2667+static __always_inline s64
2668+raw_atomic64_add_return(s64 i, atomic64_t *v)
2669+{
2670+#if defined(arch_atomic64_add_return)
2671+ return arch_atomic64_add_return(i, v);
2672+#elif defined(arch_atomic64_add_return_relaxed)
2673+ s64 ret;
2674+ __atomic_pre_full_fence();
2675+ ret = arch_atomic64_add_return_relaxed(i, v);
2676+ __atomic_post_full_fence();
2677+ return ret;
2678+#else
2679+#error "Unable to define raw_atomic64_add_return"
2680+#endif
2681+}
14952682
1496−#ifndef arch_atomic64_add_return_acquire
2683+/**
2684+ * raw_atomic64_add_return_acquire() - atomic add with acquire ordering
2685+ * @i: s64 value to add
2686+ * @v: pointer to atomic64_t
2687+ *
2688+ * Atomically updates @v to (@v + @i) with acquire ordering.
2689+ *
2690+ * Safe to use in noinstr code; prefer atomic64_add_return_acquire() elsewhere.
2691+ *
2692+ * Return: The updated value of @v.
2693+ */
14972694 static __always_inline s64
1498−arch_atomic64_add_return_acquire(s64 i, atomic64_t *v)
2695+raw_atomic64_add_return_acquire(s64 i, atomic64_t *v)
14992696 {
2697+#if defined(arch_atomic64_add_return_acquire)
2698+ return arch_atomic64_add_return_acquire(i, v);
2699+#elif defined(arch_atomic64_add_return_relaxed)
15002700 s64 ret = arch_atomic64_add_return_relaxed(i, v);
15012701 __atomic_acquire_fence();
15022702 return ret;
1503−}
1504−#define arch_atomic64_add_return_acquire arch_atomic64_add_return_acquire
2703+#elif defined(arch_atomic64_add_return)
2704+ return arch_atomic64_add_return(i, v);
2705+#else
2706+#error "Unable to define raw_atomic64_add_return_acquire"
15052707 #endif
2708+}
15062709
1507−#ifndef arch_atomic64_add_return_release
2710+/**
2711+ * raw_atomic64_add_return_release() - atomic add with release ordering
2712+ * @i: s64 value to add
2713+ * @v: pointer to atomic64_t
2714+ *
2715+ * Atomically updates @v to (@v + @i) with release ordering.
2716+ *
2717+ * Safe to use in noinstr code; prefer atomic64_add_return_release() elsewhere.
2718+ *
2719+ * Return: The updated value of @v.
2720+ */
15082721 static __always_inline s64
1509−arch_atomic64_add_return_release(s64 i, atomic64_t *v)
2722+raw_atomic64_add_return_release(s64 i, atomic64_t *v)
15102723 {
2724+#if defined(arch_atomic64_add_return_release)
2725+ return arch_atomic64_add_return_release(i, v);
2726+#elif defined(arch_atomic64_add_return_relaxed)
15112727 __atomic_release_fence();
15122728 return arch_atomic64_add_return_relaxed(i, v);
2729+#elif defined(arch_atomic64_add_return)
2730+ return arch_atomic64_add_return(i, v);
2731+#else
2732+#error "Unable to define raw_atomic64_add_return_release"
2733+#endif
15132734 }
1514−#define arch_atomic64_add_return_release arch_atomic64_add_return_release
2735+
2736+/**
2737+ * raw_atomic64_add_return_relaxed() - atomic add with relaxed ordering
2738+ * @i: s64 value to add
2739+ * @v: pointer to atomic64_t
2740+ *
2741+ * Atomically updates @v to (@v + @i) with relaxed ordering.
2742+ *
2743+ * Safe to use in noinstr code; prefer atomic64_add_return_relaxed() elsewhere.
2744+ *
2745+ * Return: The updated value of @v.
2746+ */
2747+static __always_inline s64
2748+raw_atomic64_add_return_relaxed(s64 i, atomic64_t *v)
2749+{
2750+#if defined(arch_atomic64_add_return_relaxed)
2751+ return arch_atomic64_add_return_relaxed(i, v);
2752+#elif defined(arch_atomic64_add_return)
2753+ return arch_atomic64_add_return(i, v);
2754+#else
2755+#error "Unable to define raw_atomic64_add_return_relaxed"
15152756 #endif
2757+}
15162758
1517−#ifndef arch_atomic64_add_return
2759+/**
2760+ * raw_atomic64_fetch_add() - atomic add with full ordering
2761+ * @i: s64 value to add
2762+ * @v: pointer to atomic64_t
2763+ *
2764+ * Atomically updates @v to (@v + @i) with full ordering.
2765+ *
2766+ * Safe to use in noinstr code; prefer atomic64_fetch_add() elsewhere.
2767+ *
2768+ * Return: The original value of @v.
2769+ */
15182770 static __always_inline s64
1519−arch_atomic64_add_return(s64 i, atomic64_t *v)
2771+raw_atomic64_fetch_add(s64 i, atomic64_t *v)
15202772 {
2773+#if defined(arch_atomic64_fetch_add)
2774+ return arch_atomic64_fetch_add(i, v);
2775+#elif defined(arch_atomic64_fetch_add_relaxed)
15212776 s64 ret;
15222777 __atomic_pre_full_fence();
1523− ret = arch_atomic64_add_return_relaxed(i, v);
2778+ ret = arch_atomic64_fetch_add_relaxed(i, v);
15242779 __atomic_post_full_fence();
15252780 return ret;
1526−}
1527−#define arch_atomic64_add_return arch_atomic64_add_return
2781+#else
2782+#error "Unable to define raw_atomic64_fetch_add"
15282783 #endif
2784+}
15292785
1530−#endif /* arch_atomic64_add_return_relaxed */
1531−
1532−#ifndef arch_atomic64_fetch_add_relaxed
1533−#define arch_atomic64_fetch_add_acquire arch_atomic64_fetch_add
1534−#define arch_atomic64_fetch_add_release arch_atomic64_fetch_add
1535−#define arch_atomic64_fetch_add_relaxed arch_atomic64_fetch_add
1536−#else /* arch_atomic64_fetch_add_relaxed */
1537−
1538−#ifndef arch_atomic64_fetch_add_acquire
2786+/**
2787+ * raw_atomic64_fetch_add_acquire() - atomic add with acquire ordering
2788+ * @i: s64 value to add
2789+ * @v: pointer to atomic64_t
2790+ *
2791+ * Atomically updates @v to (@v + @i) with acquire ordering.
2792+ *
2793+ * Safe to use in noinstr code; prefer atomic64_fetch_add_acquire() elsewhere.
2794+ *
2795+ * Return: The original value of @v.
2796+ */
15392797 static __always_inline s64
1540−arch_atomic64_fetch_add_acquire(s64 i, atomic64_t *v)
2798+raw_atomic64_fetch_add_acquire(s64 i, atomic64_t *v)
15412799 {
2800+#if defined(arch_atomic64_fetch_add_acquire)
2801+ return arch_atomic64_fetch_add_acquire(i, v);
2802+#elif defined(arch_atomic64_fetch_add_relaxed)
15422803 s64 ret = arch_atomic64_fetch_add_relaxed(i, v);
15432804 __atomic_acquire_fence();
15442805 return ret;
1545−}
1546−#define arch_atomic64_fetch_add_acquire arch_atomic64_fetch_add_acquire
2806+#elif defined(arch_atomic64_fetch_add)
2807+ return arch_atomic64_fetch_add(i, v);
2808+#else
2809+#error "Unable to define raw_atomic64_fetch_add_acquire"
15472810 #endif
2811+}
15482812
1549−#ifndef arch_atomic64_fetch_add_release
2813+/**
2814+ * raw_atomic64_fetch_add_release() - atomic add with release ordering
2815+ * @i: s64 value to add
2816+ * @v: pointer to atomic64_t
2817+ *
2818+ * Atomically updates @v to (@v + @i) with release ordering.
2819+ *
2820+ * Safe to use in noinstr code; prefer atomic64_fetch_add_release() elsewhere.
2821+ *
2822+ * Return: The original value of @v.
2823+ */
15502824 static __always_inline s64
1551−arch_atomic64_fetch_add_release(s64 i, atomic64_t *v)
2825+raw_atomic64_fetch_add_release(s64 i, atomic64_t *v)
15522826 {
2827+#if defined(arch_atomic64_fetch_add_release)
2828+ return arch_atomic64_fetch_add_release(i, v);
2829+#elif defined(arch_atomic64_fetch_add_relaxed)
15532830 __atomic_release_fence();
15542831 return arch_atomic64_fetch_add_relaxed(i, v);
2832+#elif defined(arch_atomic64_fetch_add)
2833+ return arch_atomic64_fetch_add(i, v);
2834+#else
2835+#error "Unable to define raw_atomic64_fetch_add_release"
2836+#endif
15552837 }
1556−#define arch_atomic64_fetch_add_release arch_atomic64_fetch_add_release
2838+
2839+/**
2840+ * raw_atomic64_fetch_add_relaxed() - atomic add with relaxed ordering
2841+ * @i: s64 value to add
2842+ * @v: pointer to atomic64_t
2843+ *
2844+ * Atomically updates @v to (@v + @i) with relaxed ordering.
2845+ *
2846+ * Safe to use in noinstr code; prefer atomic64_fetch_add_relaxed() elsewhere.
2847+ *
2848+ * Return: The original value of @v.
2849+ */
2850+static __always_inline s64
2851+raw_atomic64_fetch_add_relaxed(s64 i, atomic64_t *v)
2852+{
2853+#if defined(arch_atomic64_fetch_add_relaxed)
2854+ return arch_atomic64_fetch_add_relaxed(i, v);
2855+#elif defined(arch_atomic64_fetch_add)
2856+ return arch_atomic64_fetch_add(i, v);
2857+#else
2858+#error "Unable to define raw_atomic64_fetch_add_relaxed"
15572859 #endif
2860+}
2861+
2862+/**
2863+ * raw_atomic64_sub() - atomic subtract with relaxed ordering
2864+ * @i: s64 value to subtract
2865+ * @v: pointer to atomic64_t
2866+ *
2867+ * Atomically updates @v to (@v - @i) with relaxed ordering.
2868+ *
2869+ * Safe to use in noinstr code; prefer atomic64_sub() elsewhere.
2870+ *
2871+ * Return: Nothing.
2872+ */
2873+static __always_inline void
2874+raw_atomic64_sub(s64 i, atomic64_t *v)
2875+{
2876+ arch_atomic64_sub(i, v);
2877+}
15582878
1559−#ifndef arch_atomic64_fetch_add
2879+/**
2880+ * raw_atomic64_sub_return() - atomic subtract with full ordering
2881+ * @i: s64 value to subtract
2882+ * @v: pointer to atomic64_t
2883+ *
2884+ * Atomically updates @v to (@v - @i) with full ordering.
2885+ *
2886+ * Safe to use in noinstr code; prefer atomic64_sub_return() elsewhere.
2887+ *
2888+ * Return: The updated value of @v.
2889+ */
15602890 static __always_inline s64
1561−arch_atomic64_fetch_add(s64 i, atomic64_t *v)
2891+raw_atomic64_sub_return(s64 i, atomic64_t *v)
15622892 {
2893+#if defined(arch_atomic64_sub_return)
2894+ return arch_atomic64_sub_return(i, v);
2895+#elif defined(arch_atomic64_sub_return_relaxed)
15632896 s64 ret;
15642897 __atomic_pre_full_fence();
1565− ret = arch_atomic64_fetch_add_relaxed(i, v);
2898+ ret = arch_atomic64_sub_return_relaxed(i, v);
15662899 __atomic_post_full_fence();
15672900 return ret;
1568−}
1569−#define arch_atomic64_fetch_add arch_atomic64_fetch_add
2901+#else
2902+#error "Unable to define raw_atomic64_sub_return"
15702903 #endif
2904+}
15712905
1572−#endif /* arch_atomic64_fetch_add_relaxed */
1573−
1574−#ifndef arch_atomic64_sub_return_relaxed
1575−#define arch_atomic64_sub_return_acquire arch_atomic64_sub_return
1576−#define arch_atomic64_sub_return_release arch_atomic64_sub_return
1577−#define arch_atomic64_sub_return_relaxed arch_atomic64_sub_return
1578−#else /* arch_atomic64_sub_return_relaxed */
1579−
1580−#ifndef arch_atomic64_sub_return_acquire
2906+/**
2907+ * raw_atomic64_sub_return_acquire() - atomic subtract with acquire ordering
2908+ * @i: s64 value to subtract
2909+ * @v: pointer to atomic64_t
2910+ *
2911+ * Atomically updates @v to (@v - @i) with acquire ordering.
2912+ *
2913+ * Safe to use in noinstr code; prefer atomic64_sub_return_acquire() elsewhere.
2914+ *
2915+ * Return: The updated value of @v.
2916+ */
15812917 static __always_inline s64
1582−arch_atomic64_sub_return_acquire(s64 i, atomic64_t *v)
2918+raw_atomic64_sub_return_acquire(s64 i, atomic64_t *v)
15832919 {
2920+#if defined(arch_atomic64_sub_return_acquire)
2921+ return arch_atomic64_sub_return_acquire(i, v);
2922+#elif defined(arch_atomic64_sub_return_relaxed)
15842923 s64 ret = arch_atomic64_sub_return_relaxed(i, v);
15852924 __atomic_acquire_fence();
15862925 return ret;
1587−}
1588−#define arch_atomic64_sub_return_acquire arch_atomic64_sub_return_acquire
2926+#elif defined(arch_atomic64_sub_return)
2927+ return arch_atomic64_sub_return(i, v);
2928+#else
2929+#error "Unable to define raw_atomic64_sub_return_acquire"
15892930 #endif
2931+}
15902932
1591−#ifndef arch_atomic64_sub_return_release
2933+/**
2934+ * raw_atomic64_sub_return_release() - atomic subtract with release ordering
2935+ * @i: s64 value to subtract
2936+ * @v: pointer to atomic64_t
2937+ *
2938+ * Atomically updates @v to (@v - @i) with release ordering.
2939+ *
2940+ * Safe to use in noinstr code; prefer atomic64_sub_return_release() elsewhere.
2941+ *
2942+ * Return: The updated value of @v.
2943+ */
15922944 static __always_inline s64
1593−arch_atomic64_sub_return_release(s64 i, atomic64_t *v)
2945+raw_atomic64_sub_return_release(s64 i, atomic64_t *v)
15942946 {
2947+#if defined(arch_atomic64_sub_return_release)
2948+ return arch_atomic64_sub_return_release(i, v);
2949+#elif defined(arch_atomic64_sub_return_relaxed)
15952950 __atomic_release_fence();
15962951 return arch_atomic64_sub_return_relaxed(i, v);
2952+#elif defined(arch_atomic64_sub_return)
2953+ return arch_atomic64_sub_return(i, v);
2954+#else
2955+#error "Unable to define raw_atomic64_sub_return_release"
2956+#endif
15972957 }
1598−#define arch_atomic64_sub_return_release arch_atomic64_sub_return_release
2958+
2959+/**
2960+ * raw_atomic64_sub_return_relaxed() - atomic subtract with relaxed ordering
2961+ * @i: s64 value to subtract
2962+ * @v: pointer to atomic64_t
2963+ *
2964+ * Atomically updates @v to (@v - @i) with relaxed ordering.
2965+ *
2966+ * Safe to use in noinstr code; prefer atomic64_sub_return_relaxed() elsewhere.
2967+ *
2968+ * Return: The updated value of @v.
2969+ */
2970+static __always_inline s64
2971+raw_atomic64_sub_return_relaxed(s64 i, atomic64_t *v)
2972+{
2973+#if defined(arch_atomic64_sub_return_relaxed)
2974+ return arch_atomic64_sub_return_relaxed(i, v);
2975+#elif defined(arch_atomic64_sub_return)
2976+ return arch_atomic64_sub_return(i, v);
2977+#else
2978+#error "Unable to define raw_atomic64_sub_return_relaxed"
15992979 #endif
2980+}
16002981
1601−#ifndef arch_atomic64_sub_return
2982+/**
2983+ * raw_atomic64_fetch_sub() - atomic subtract with full ordering
2984+ * @i: s64 value to subtract
2985+ * @v: pointer to atomic64_t
2986+ *
2987+ * Atomically updates @v to (@v - @i) with full ordering.
2988+ *
2989+ * Safe to use in noinstr code; prefer atomic64_fetch_sub() elsewhere.
2990+ *
2991+ * Return: The original value of @v.
2992+ */
16022993 static __always_inline s64
1603−arch_atomic64_sub_return(s64 i, atomic64_t *v)
2994+raw_atomic64_fetch_sub(s64 i, atomic64_t *v)
16042995 {
2996+#if defined(arch_atomic64_fetch_sub)
2997+ return arch_atomic64_fetch_sub(i, v);
2998+#elif defined(arch_atomic64_fetch_sub_relaxed)
16052999 s64 ret;
16063000 __atomic_pre_full_fence();
1607− ret = arch_atomic64_sub_return_relaxed(i, v);
3001+ ret = arch_atomic64_fetch_sub_relaxed(i, v);
16083002 __atomic_post_full_fence();
16093003 return ret;
1610−}
1611−#define arch_atomic64_sub_return arch_atomic64_sub_return
3004+#else
3005+#error "Unable to define raw_atomic64_fetch_sub"
16123006 #endif
3007+}
16133008
1614−#endif /* arch_atomic64_sub_return_relaxed */
1615−
1616−#ifndef arch_atomic64_fetch_sub_relaxed
1617−#define arch_atomic64_fetch_sub_acquire arch_atomic64_fetch_sub
1618−#define arch_atomic64_fetch_sub_release arch_atomic64_fetch_sub
1619−#define arch_atomic64_fetch_sub_relaxed arch_atomic64_fetch_sub
1620−#else /* arch_atomic64_fetch_sub_relaxed */
1621−
1622−#ifndef arch_atomic64_fetch_sub_acquire
3009+/**
3010+ * raw_atomic64_fetch_sub_acquire() - atomic subtract with acquire ordering
3011+ * @i: s64 value to subtract
3012+ * @v: pointer to atomic64_t
3013+ *
3014+ * Atomically updates @v to (@v - @i) with acquire ordering.
3015+ *
3016+ * Safe to use in noinstr code; prefer atomic64_fetch_sub_acquire() elsewhere.
3017+ *
3018+ * Return: The original value of @v.
3019+ */
16233020 static __always_inline s64
1624−arch_atomic64_fetch_sub_acquire(s64 i, atomic64_t *v)
3021+raw_atomic64_fetch_sub_acquire(s64 i, atomic64_t *v)
16253022 {
3023+#if defined(arch_atomic64_fetch_sub_acquire)
3024+ return arch_atomic64_fetch_sub_acquire(i, v);
3025+#elif defined(arch_atomic64_fetch_sub_relaxed)
16263026 s64 ret = arch_atomic64_fetch_sub_relaxed(i, v);
16273027 __atomic_acquire_fence();
16283028 return ret;
1629−}
1630−#define arch_atomic64_fetch_sub_acquire arch_atomic64_fetch_sub_acquire
3029+#elif defined(arch_atomic64_fetch_sub)
3030+ return arch_atomic64_fetch_sub(i, v);
3031+#else
3032+#error "Unable to define raw_atomic64_fetch_sub_acquire"
16313033 #endif
3034+}
16323035
1633−#ifndef arch_atomic64_fetch_sub_release
3036+/**
3037+ * raw_atomic64_fetch_sub_release() - atomic subtract with release ordering
3038+ * @i: s64 value to subtract
3039+ * @v: pointer to atomic64_t
3040+ *
3041+ * Atomically updates @v to (@v - @i) with release ordering.
3042+ *
3043+ * Safe to use in noinstr code; prefer atomic64_fetch_sub_release() elsewhere.
3044+ *
3045+ * Return: The original value of @v.
3046+ */
16343047 static __always_inline s64
1635−arch_atomic64_fetch_sub_release(s64 i, atomic64_t *v)
3048+raw_atomic64_fetch_sub_release(s64 i, atomic64_t *v)
16363049 {
3050+#if defined(arch_atomic64_fetch_sub_release)
3051+ return arch_atomic64_fetch_sub_release(i, v);
3052+#elif defined(arch_atomic64_fetch_sub_relaxed)
16373053 __atomic_release_fence();
16383054 return arch_atomic64_fetch_sub_relaxed(i, v);
1639−}
1640−#define arch_atomic64_fetch_sub_release arch_atomic64_fetch_sub_release
3055+#elif defined(arch_atomic64_fetch_sub)
3056+ return arch_atomic64_fetch_sub(i, v);
3057+#else
3058+#error "Unable to define raw_atomic64_fetch_sub_release"
16413059 #endif
3060+}
16423061
1643−#ifndef arch_atomic64_fetch_sub
3062+/**
3063+ * raw_atomic64_fetch_sub_relaxed() - atomic subtract with relaxed ordering
3064+ * @i: s64 value to subtract
3065+ * @v: pointer to atomic64_t
3066+ *
3067+ * Atomically updates @v to (@v - @i) with relaxed ordering.
3068+ *
3069+ * Safe to use in noinstr code; prefer atomic64_fetch_sub_relaxed() elsewhere.
3070+ *
3071+ * Return: The original value of @v.
3072+ */
16443073 static __always_inline s64
1645−arch_atomic64_fetch_sub(s64 i, atomic64_t *v)
3074+raw_atomic64_fetch_sub_relaxed(s64 i, atomic64_t *v)
16463075 {
1647− s64 ret;
1648− __atomic_pre_full_fence();
1649− ret = arch_atomic64_fetch_sub_relaxed(i, v);
1650− __atomic_post_full_fence();
1651− return ret;
1652−}
1653−#define arch_atomic64_fetch_sub arch_atomic64_fetch_sub
3076+#if defined(arch_atomic64_fetch_sub_relaxed)
3077+ return arch_atomic64_fetch_sub_relaxed(i, v);
3078+#elif defined(arch_atomic64_fetch_sub)
3079+ return arch_atomic64_fetch_sub(i, v);
3080+#else
3081+#error "Unable to define raw_atomic64_fetch_sub_relaxed"
16543082 #endif
1655−
1656−#endif /* arch_atomic64_fetch_sub_relaxed */
1657−
1658−#ifndef arch_atomic64_inc
1659−static __always_inline void
1660−arch_atomic64_inc(atomic64_t *v)
1661−{
1662− arch_atomic64_add(1, v);
16633083 }
1664−#define arch_atomic64_inc arch_atomic64_inc
1665−#endif
16663084
1667−#ifndef arch_atomic64_inc_return_relaxed
1668−#ifdef arch_atomic64_inc_return
1669−#define arch_atomic64_inc_return_acquire arch_atomic64_inc_return
1670−#define arch_atomic64_inc_return_release arch_atomic64_inc_return
1671−#define arch_atomic64_inc_return_relaxed arch_atomic64_inc_return
1672−#endif /* arch_atomic64_inc_return */
1673−
1674−#ifndef arch_atomic64_inc_return
1675−static __always_inline s64
1676−arch_atomic64_inc_return(atomic64_t *v)
3085+/**
3086+ * raw_atomic64_inc() - atomic increment with relaxed ordering
3087+ * @v: pointer to atomic64_t
3088+ *
3089+ * Atomically updates @v to (@v + 1) with relaxed ordering.
3090+ *
3091+ * Safe to use in noinstr code; prefer atomic64_inc() elsewhere.
3092+ *
3093+ * Return: Nothing.
3094+ */
3095+static __always_inline void
3096+raw_atomic64_inc(atomic64_t *v)
16773097 {
1678− return arch_atomic64_add_return(1, v);
1679−}
1680−#define arch_atomic64_inc_return arch_atomic64_inc_return
3098+#if defined(arch_atomic64_inc)
3099+ arch_atomic64_inc(v);
3100+#else
3101+ raw_atomic64_add(1, v);
16813102 #endif
1682−
1683−#ifndef arch_atomic64_inc_return_acquire
1684−static __always_inline s64
1685−arch_atomic64_inc_return_acquire(atomic64_t *v)
1686−{
1687− return arch_atomic64_add_return_acquire(1, v);
16883103 }
1689−#define arch_atomic64_inc_return_acquire arch_atomic64_inc_return_acquire
1690−#endif
16913104
1692−#ifndef arch_atomic64_inc_return_release
3105+/**
3106+ * raw_atomic64_inc_return() - atomic increment with full ordering
3107+ * @v: pointer to atomic64_t
3108+ *
3109+ * Atomically updates @v to (@v + 1) with full ordering.
3110+ *
3111+ * Safe to use in noinstr code; prefer atomic64_inc_return() elsewhere.
3112+ *
3113+ * Return: The updated value of @v.
3114+ */
16933115 static __always_inline s64
1694−arch_atomic64_inc_return_release(atomic64_t *v)
3116+raw_atomic64_inc_return(atomic64_t *v)
16953117 {
1696− return arch_atomic64_add_return_release(1, v);
1697−}
1698−#define arch_atomic64_inc_return_release arch_atomic64_inc_return_release
3118+#if defined(arch_atomic64_inc_return)
3119+ return arch_atomic64_inc_return(v);
3120+#elif defined(arch_atomic64_inc_return_relaxed)
3121+ s64 ret;
3122+ __atomic_pre_full_fence();
3123+ ret = arch_atomic64_inc_return_relaxed(v);
3124+ __atomic_post_full_fence();
3125+ return ret;
3126+#else
3127+ return raw_atomic64_add_return(1, v);
16993128 #endif
1700−
1701−#ifndef arch_atomic64_inc_return_relaxed
1702−static __always_inline s64
1703−arch_atomic64_inc_return_relaxed(atomic64_t *v)
1704−{
1705− return arch_atomic64_add_return_relaxed(1, v);
17063129 }
1707−#define arch_atomic64_inc_return_relaxed arch_atomic64_inc_return_relaxed
1708−#endif
17093130
1710−#else /* arch_atomic64_inc_return_relaxed */
1711−
1712−#ifndef arch_atomic64_inc_return_acquire
3131+/**
3132+ * raw_atomic64_inc_return_acquire() - atomic increment with acquire ordering
3133+ * @v: pointer to atomic64_t
3134+ *
3135+ * Atomically updates @v to (@v + 1) with acquire ordering.
3136+ *
3137+ * Safe to use in noinstr code; prefer atomic64_inc_return_acquire() elsewhere.
3138+ *
3139+ * Return: The updated value of @v.
3140+ */
17133141 static __always_inline s64
1714−arch_atomic64_inc_return_acquire(atomic64_t *v)
3142+raw_atomic64_inc_return_acquire(atomic64_t *v)
17153143 {
3144+#if defined(arch_atomic64_inc_return_acquire)
3145+ return arch_atomic64_inc_return_acquire(v);
3146+#elif defined(arch_atomic64_inc_return_relaxed)
17163147 s64 ret = arch_atomic64_inc_return_relaxed(v);
17173148 __atomic_acquire_fence();
17183149 return ret;
1719−}
1720−#define arch_atomic64_inc_return_acquire arch_atomic64_inc_return_acquire
3150+#elif defined(arch_atomic64_inc_return)
3151+ return arch_atomic64_inc_return(v);
3152+#else
3153+ return raw_atomic64_add_return_acquire(1, v);
17213154 #endif
3155+}
17223156
1723−#ifndef arch_atomic64_inc_return_release
3157+/**
3158+ * raw_atomic64_inc_return_release() - atomic increment with release ordering
3159+ * @v: pointer to atomic64_t
3160+ *
3161+ * Atomically updates @v to (@v + 1) with release ordering.
3162+ *
3163+ * Safe to use in noinstr code; prefer atomic64_inc_return_release() elsewhere.
3164+ *
3165+ * Return: The updated value of @v.
3166+ */
17243167 static __always_inline s64
1725−arch_atomic64_inc_return_release(atomic64_t *v)
3168+raw_atomic64_inc_return_release(atomic64_t *v)
17263169 {
3170+#if defined(arch_atomic64_inc_return_release)
3171+ return arch_atomic64_inc_return_release(v);
3172+#elif defined(arch_atomic64_inc_return_relaxed)
17273173 __atomic_release_fence();
17283174 return arch_atomic64_inc_return_relaxed(v);
1729−}
1730−#define arch_atomic64_inc_return_release arch_atomic64_inc_return_release
3175+#elif defined(arch_atomic64_inc_return)
3176+ return arch_atomic64_inc_return(v);
3177+#else
3178+ return raw_atomic64_add_return_release(1, v);
17313179 #endif
1732−
1733−#ifndef arch_atomic64_inc_return
1734−static __always_inline s64
1735−arch_atomic64_inc_return(atomic64_t *v)
1736−{
1737− s64 ret;
1738− __atomic_pre_full_fence();
1739− ret = arch_atomic64_inc_return_relaxed(v);
1740− __atomic_post_full_fence();
1741− return ret;
17423180 }
1743−#define arch_atomic64_inc_return arch_atomic64_inc_return
1744−#endif
1745−
1746−#endif /* arch_atomic64_inc_return_relaxed */
17473181
1748−#ifndef arch_atomic64_fetch_inc_relaxed
1749−#ifdef arch_atomic64_fetch_inc
1750−#define arch_atomic64_fetch_inc_acquire arch_atomic64_fetch_inc
1751−#define arch_atomic64_fetch_inc_release arch_atomic64_fetch_inc
1752−#define arch_atomic64_fetch_inc_relaxed arch_atomic64_fetch_inc
1753−#endif /* arch_atomic64_fetch_inc */
1754−
1755−#ifndef arch_atomic64_fetch_inc
3182+/**
3183+ * raw_atomic64_inc_return_relaxed() - atomic increment with relaxed ordering
3184+ * @v: pointer to atomic64_t
3185+ *
3186+ * Atomically updates @v to (@v + 1) with relaxed ordering.
3187+ *
3188+ * Safe to use in noinstr code; prefer atomic64_inc_return_relaxed() elsewhere.
3189+ *
3190+ * Return: The updated value of @v.
3191+ */
17563192 static __always_inline s64
1757−arch_atomic64_fetch_inc(atomic64_t *v)
3193+raw_atomic64_inc_return_relaxed(atomic64_t *v)
17583194 {
1759− return arch_atomic64_fetch_add(1, v);
1760−}
1761−#define arch_atomic64_fetch_inc arch_atomic64_fetch_inc
3195+#if defined(arch_atomic64_inc_return_relaxed)
3196+ return arch_atomic64_inc_return_relaxed(v);
3197+#elif defined(arch_atomic64_inc_return)
3198+ return arch_atomic64_inc_return(v);
3199+#else
3200+ return raw_atomic64_add_return_relaxed(1, v);
17623201 #endif
1763−
1764−#ifndef arch_atomic64_fetch_inc_acquire
1765−static __always_inline s64
1766−arch_atomic64_fetch_inc_acquire(atomic64_t *v)
1767−{
1768− return arch_atomic64_fetch_add_acquire(1, v);
17693202 }
1770−#define arch_atomic64_fetch_inc_acquire arch_atomic64_fetch_inc_acquire
1771−#endif
17723203
1773−#ifndef arch_atomic64_fetch_inc_release
3204+/**
3205+ * raw_atomic64_fetch_inc() - atomic increment with full ordering
3206+ * @v: pointer to atomic64_t
3207+ *
3208+ * Atomically updates @v to (@v + 1) with full ordering.
3209+ *
3210+ * Safe to use in noinstr code; prefer atomic64_fetch_inc() elsewhere.
3211+ *
3212+ * Return: The original value of @v.
3213+ */
17743214 static __always_inline s64
1775−arch_atomic64_fetch_inc_release(atomic64_t *v)
3215+raw_atomic64_fetch_inc(atomic64_t *v)
17763216 {
1777− return arch_atomic64_fetch_add_release(1, v);
1778−}
1779−#define arch_atomic64_fetch_inc_release arch_atomic64_fetch_inc_release
3217+#if defined(arch_atomic64_fetch_inc)
3218+ return arch_atomic64_fetch_inc(v);
3219+#elif defined(arch_atomic64_fetch_inc_relaxed)
3220+ s64 ret;
3221+ __atomic_pre_full_fence();
3222+ ret = arch_atomic64_fetch_inc_relaxed(v);
3223+ __atomic_post_full_fence();
3224+ return ret;
3225+#else
3226+ return raw_atomic64_fetch_add(1, v);
17803227 #endif
1781−
1782−#ifndef arch_atomic64_fetch_inc_relaxed
1783−static __always_inline s64
1784−arch_atomic64_fetch_inc_relaxed(atomic64_t *v)
1785−{
1786− return arch_atomic64_fetch_add_relaxed(1, v);
17873228 }
1788−#define arch_atomic64_fetch_inc_relaxed arch_atomic64_fetch_inc_relaxed
1789−#endif
1790−
1791−#else /* arch_atomic64_fetch_inc_relaxed */
17923229
1793−#ifndef arch_atomic64_fetch_inc_acquire
3230+/**
3231+ * raw_atomic64_fetch_inc_acquire() - atomic increment with acquire ordering
3232+ * @v: pointer to atomic64_t
3233+ *
3234+ * Atomically updates @v to (@v + 1) with acquire ordering.
3235+ *
3236+ * Safe to use in noinstr code; prefer atomic64_fetch_inc_acquire() elsewhere.
3237+ *
3238+ * Return: The original value of @v.
3239+ */
17943240 static __always_inline s64
1795−arch_atomic64_fetch_inc_acquire(atomic64_t *v)
3241+raw_atomic64_fetch_inc_acquire(atomic64_t *v)
17963242 {
3243+#if defined(arch_atomic64_fetch_inc_acquire)
3244+ return arch_atomic64_fetch_inc_acquire(v);
3245+#elif defined(arch_atomic64_fetch_inc_relaxed)
17973246 s64 ret = arch_atomic64_fetch_inc_relaxed(v);
17983247 __atomic_acquire_fence();
17993248 return ret;
1800−}
1801−#define arch_atomic64_fetch_inc_acquire arch_atomic64_fetch_inc_acquire
3249+#elif defined(arch_atomic64_fetch_inc)
3250+ return arch_atomic64_fetch_inc(v);
3251+#else
3252+ return raw_atomic64_fetch_add_acquire(1, v);
18023253 #endif
3254+}
18033255
1804−#ifndef arch_atomic64_fetch_inc_release
3256+/**
3257+ * raw_atomic64_fetch_inc_release() - atomic increment with release ordering
3258+ * @v: pointer to atomic64_t
3259+ *
3260+ * Atomically updates @v to (@v + 1) with release ordering.
3261+ *
3262+ * Safe to use in noinstr code; prefer atomic64_fetch_inc_release() elsewhere.
3263+ *
3264+ * Return: The original value of @v.
3265+ */
18053266 static __always_inline s64
1806−arch_atomic64_fetch_inc_release(atomic64_t *v)
3267+raw_atomic64_fetch_inc_release(atomic64_t *v)
18073268 {
3269+#if defined(arch_atomic64_fetch_inc_release)
3270+ return arch_atomic64_fetch_inc_release(v);
3271+#elif defined(arch_atomic64_fetch_inc_relaxed)
18083272 __atomic_release_fence();
18093273 return arch_atomic64_fetch_inc_relaxed(v);
1810−}
1811−#define arch_atomic64_fetch_inc_release arch_atomic64_fetch_inc_release
1812−#endif
1813−
1814−#ifndef arch_atomic64_fetch_inc
1815−static __always_inline s64
1816−arch_atomic64_fetch_inc(atomic64_t *v)
1817−{
1818− s64 ret;
1819− __atomic_pre_full_fence();
1820− ret = arch_atomic64_fetch_inc_relaxed(v);
1821− __atomic_post_full_fence();
1822− return ret;
1823−}
1824−#define arch_atomic64_fetch_inc arch_atomic64_fetch_inc
3274+#elif defined(arch_atomic64_fetch_inc)
3275+ return arch_atomic64_fetch_inc(v);
3276+#else
3277+ return raw_atomic64_fetch_add_release(1, v);
18253278 #endif
1826−
1827−#endif /* arch_atomic64_fetch_inc_relaxed */
1828−
1829−#ifndef arch_atomic64_dec
1830−static __always_inline void
1831−arch_atomic64_dec(atomic64_t *v)
1832−{
1833− arch_atomic64_sub(1, v);
18343279 }
1835−#define arch_atomic64_dec arch_atomic64_dec
1836−#endif
18373280
1838−#ifndef arch_atomic64_dec_return_relaxed
1839−#ifdef arch_atomic64_dec_return
1840−#define arch_atomic64_dec_return_acquire arch_atomic64_dec_return
1841−#define arch_atomic64_dec_return_release arch_atomic64_dec_return
1842−#define arch_atomic64_dec_return_relaxed arch_atomic64_dec_return
1843−#endif /* arch_atomic64_dec_return */
1844−
1845−#ifndef arch_atomic64_dec_return
3281+/**
3282+ * raw_atomic64_fetch_inc_relaxed() - atomic increment with relaxed ordering
3283+ * @v: pointer to atomic64_t
3284+ *
3285+ * Atomically updates @v to (@v + 1) with relaxed ordering.
3286+ *
3287+ * Safe to use in noinstr code; prefer atomic64_fetch_inc_relaxed() elsewhere.
3288+ *
3289+ * Return: The original value of @v.
3290+ */
18463291 static __always_inline s64
1847−arch_atomic64_dec_return(atomic64_t *v)
3292+raw_atomic64_fetch_inc_relaxed(atomic64_t *v)
18483293 {
1849− return arch_atomic64_sub_return(1, v);
1850−}
1851−#define arch_atomic64_dec_return arch_atomic64_dec_return
3294+#if defined(arch_atomic64_fetch_inc_relaxed)
3295+ return arch_atomic64_fetch_inc_relaxed(v);
3296+#elif defined(arch_atomic64_fetch_inc)
3297+ return arch_atomic64_fetch_inc(v);
3298+#else
3299+ return raw_atomic64_fetch_add_relaxed(1, v);
18523300 #endif
3301+}
18533302
1854−#ifndef arch_atomic64_dec_return_acquire
1855−static __always_inline s64
1856−arch_atomic64_dec_return_acquire(atomic64_t *v)
3303+/**
3304+ * raw_atomic64_dec() - atomic decrement with relaxed ordering
3305+ * @v: pointer to atomic64_t
3306+ *
3307+ * Atomically updates @v to (@v - 1) with relaxed ordering.
3308+ *
3309+ * Safe to use in noinstr code; prefer atomic64_dec() elsewhere.
3310+ *
3311+ * Return: Nothing.
3312+ */
3313+static __always_inline void
3314+raw_atomic64_dec(atomic64_t *v)
18573315 {
1858− return arch_atomic64_sub_return_acquire(1, v);
1859−}
1860−#define arch_atomic64_dec_return_acquire arch_atomic64_dec_return_acquire
3316+#if defined(arch_atomic64_dec)
3317+ arch_atomic64_dec(v);
3318+#else
3319+ raw_atomic64_sub(1, v);
18613320 #endif
1862−
1863−#ifndef arch_atomic64_dec_return_release
1864−static __always_inline s64
1865−arch_atomic64_dec_return_release(atomic64_t *v)
1866−{
1867− return arch_atomic64_sub_return_release(1, v);
18683321 }
1869−#define arch_atomic64_dec_return_release arch_atomic64_dec_return_release
1870−#endif
18713322
1872−#ifndef arch_atomic64_dec_return_relaxed
3323+/**
3324+ * raw_atomic64_dec_return() - atomic decrement with full ordering
3325+ * @v: pointer to atomic64_t
3326+ *
3327+ * Atomically updates @v to (@v - 1) with full ordering.
3328+ *
3329+ * Safe to use in noinstr code; prefer atomic64_dec_return() elsewhere.
3330+ *
3331+ * Return: The updated value of @v.
3332+ */
18733333 static __always_inline s64
1874−arch_atomic64_dec_return_relaxed(atomic64_t *v)
3334+raw_atomic64_dec_return(atomic64_t *v)
18753335 {
1876− return arch_atomic64_sub_return_relaxed(1, v);
1877−}
1878−#define arch_atomic64_dec_return_relaxed arch_atomic64_dec_return_relaxed
3336+#if defined(arch_atomic64_dec_return)
3337+ return arch_atomic64_dec_return(v);
3338+#elif defined(arch_atomic64_dec_return_relaxed)
3339+ s64 ret;
3340+ __atomic_pre_full_fence();
3341+ ret = arch_atomic64_dec_return_relaxed(v);
3342+ __atomic_post_full_fence();
3343+ return ret;
3344+#else
3345+ return raw_atomic64_sub_return(1, v);
18793346 #endif
3347+}
18803348
1881−#else /* arch_atomic64_dec_return_relaxed */
1882−
1883−#ifndef arch_atomic64_dec_return_acquire
3349+/**
3350+ * raw_atomic64_dec_return_acquire() - atomic decrement with acquire ordering
3351+ * @v: pointer to atomic64_t
3352+ *
3353+ * Atomically updates @v to (@v - 1) with acquire ordering.
3354+ *
3355+ * Safe to use in noinstr code; prefer atomic64_dec_return_acquire() elsewhere.
3356+ *
3357+ * Return: The updated value of @v.
3358+ */
18843359 static __always_inline s64
1885−arch_atomic64_dec_return_acquire(atomic64_t *v)
3360+raw_atomic64_dec_return_acquire(atomic64_t *v)
18863361 {
3362+#if defined(arch_atomic64_dec_return_acquire)
3363+ return arch_atomic64_dec_return_acquire(v);
3364+#elif defined(arch_atomic64_dec_return_relaxed)
18873365 s64 ret = arch_atomic64_dec_return_relaxed(v);
18883366 __atomic_acquire_fence();
18893367 return ret;
1890−}
1891−#define arch_atomic64_dec_return_acquire arch_atomic64_dec_return_acquire
3368+#elif defined(arch_atomic64_dec_return)
3369+ return arch_atomic64_dec_return(v);
3370+#else
3371+ return raw_atomic64_sub_return_acquire(1, v);
18923372 #endif
3373+}
18933374
1894−#ifndef arch_atomic64_dec_return_release
3375+/**
3376+ * raw_atomic64_dec_return_release() - atomic decrement with release ordering
3377+ * @v: pointer to atomic64_t
3378+ *
3379+ * Atomically updates @v to (@v - 1) with release ordering.
3380+ *
3381+ * Safe to use in noinstr code; prefer atomic64_dec_return_release() elsewhere.
3382+ *
3383+ * Return: The updated value of @v.
3384+ */
18953385 static __always_inline s64
1896−arch_atomic64_dec_return_release(atomic64_t *v)
3386+raw_atomic64_dec_return_release(atomic64_t *v)
18973387 {
3388+#if defined(arch_atomic64_dec_return_release)
3389+ return arch_atomic64_dec_return_release(v);
3390+#elif defined(arch_atomic64_dec_return_relaxed)
18983391 __atomic_release_fence();
18993392 return arch_atomic64_dec_return_relaxed(v);
3393+#elif defined(arch_atomic64_dec_return)
3394+ return arch_atomic64_dec_return(v);
3395+#else
3396+ return raw_atomic64_sub_return_release(1, v);
3397+#endif
19003398 }
1901−#define arch_atomic64_dec_return_release arch_atomic64_dec_return_release
3399+
3400+/**
3401+ * raw_atomic64_dec_return_relaxed() - atomic decrement with relaxed ordering
3402+ * @v: pointer to atomic64_t
3403+ *
3404+ * Atomically updates @v to (@v - 1) with relaxed ordering.
3405+ *
3406+ * Safe to use in noinstr code; prefer atomic64_dec_return_relaxed() elsewhere.
3407+ *
3408+ * Return: The updated value of @v.
3409+ */
3410+static __always_inline s64
3411+raw_atomic64_dec_return_relaxed(atomic64_t *v)
3412+{
3413+#if defined(arch_atomic64_dec_return_relaxed)
3414+ return arch_atomic64_dec_return_relaxed(v);
3415+#elif defined(arch_atomic64_dec_return)
3416+ return arch_atomic64_dec_return(v);
3417+#else
3418+ return raw_atomic64_sub_return_relaxed(1, v);
19023419 #endif
3420+}
19033421
1904−#ifndef arch_atomic64_dec_return
3422+/**
3423+ * raw_atomic64_fetch_dec() - atomic decrement with full ordering
3424+ * @v: pointer to atomic64_t
3425+ *
3426+ * Atomically updates @v to (@v - 1) with full ordering.
3427+ *
3428+ * Safe to use in noinstr code; prefer atomic64_fetch_dec() elsewhere.
3429+ *
3430+ * Return: The original value of @v.
3431+ */
19053432 static __always_inline s64
1906−arch_atomic64_dec_return(atomic64_t *v)
3433+raw_atomic64_fetch_dec(atomic64_t *v)
19073434 {
3435+#if defined(arch_atomic64_fetch_dec)
3436+ return arch_atomic64_fetch_dec(v);
3437+#elif defined(arch_atomic64_fetch_dec_relaxed)
19083438 s64 ret;
19093439 __atomic_pre_full_fence();
1910− ret = arch_atomic64_dec_return_relaxed(v);
3440+ ret = arch_atomic64_fetch_dec_relaxed(v);
19113441 __atomic_post_full_fence();
19123442 return ret;
1913−}
1914−#define arch_atomic64_dec_return arch_atomic64_dec_return
3443+#else
3444+ return raw_atomic64_fetch_sub(1, v);
19153445 #endif
1916−
1917−#endif /* arch_atomic64_dec_return_relaxed */
1918−
1919−#ifndef arch_atomic64_fetch_dec_relaxed
1920−#ifdef arch_atomic64_fetch_dec
1921−#define arch_atomic64_fetch_dec_acquire arch_atomic64_fetch_dec
1922−#define arch_atomic64_fetch_dec_release arch_atomic64_fetch_dec
1923−#define arch_atomic64_fetch_dec_relaxed arch_atomic64_fetch_dec
1924−#endif /* arch_atomic64_fetch_dec */
1925−
1926−#ifndef arch_atomic64_fetch_dec
1927−static __always_inline s64
1928−arch_atomic64_fetch_dec(atomic64_t *v)
1929−{
1930− return arch_atomic64_fetch_sub(1, v);
19313446 }
1932−#define arch_atomic64_fetch_dec arch_atomic64_fetch_dec
1933−#endif
19343447
1935−#ifndef arch_atomic64_fetch_dec_acquire
3448+/**
3449+ * raw_atomic64_fetch_dec_acquire() - atomic decrement with acquire ordering
3450+ * @v: pointer to atomic64_t
3451+ *
3452+ * Atomically updates @v to (@v - 1) with acquire ordering.
3453+ *
3454+ * Safe to use in noinstr code; prefer atomic64_fetch_dec_acquire() elsewhere.
3455+ *
3456+ * Return: The original value of @v.
3457+ */
19363458 static __always_inline s64
1937−arch_atomic64_fetch_dec_acquire(atomic64_t *v)
3459+raw_atomic64_fetch_dec_acquire(atomic64_t *v)
19383460 {
1939− return arch_atomic64_fetch_sub_acquire(1, v);
1940−}
1941−#define arch_atomic64_fetch_dec_acquire arch_atomic64_fetch_dec_acquire
3461+#if defined(arch_atomic64_fetch_dec_acquire)
3462+ return arch_atomic64_fetch_dec_acquire(v);
3463+#elif defined(arch_atomic64_fetch_dec_relaxed)
3464+ s64 ret = arch_atomic64_fetch_dec_relaxed(v);
3465+ __atomic_acquire_fence();
3466+ return ret;
3467+#elif defined(arch_atomic64_fetch_dec)
3468+ return arch_atomic64_fetch_dec(v);
3469+#else
3470+ return raw_atomic64_fetch_sub_acquire(1, v);
19423471 #endif
1943−
1944−#ifndef arch_atomic64_fetch_dec_release
1945−static __always_inline s64
1946−arch_atomic64_fetch_dec_release(atomic64_t *v)
1947−{
1948− return arch_atomic64_fetch_sub_release(1, v);
19493472 }
1950−#define arch_atomic64_fetch_dec_release arch_atomic64_fetch_dec_release
1951−#endif
19523473
1953−#ifndef arch_atomic64_fetch_dec_relaxed
3474+/**
3475+ * raw_atomic64_fetch_dec_release() - atomic decrement with release ordering
3476+ * @v: pointer to atomic64_t
3477+ *
3478+ * Atomically updates @v to (@v - 1) with release ordering.
3479+ *
3480+ * Safe to use in noinstr code; prefer atomic64_fetch_dec_release() elsewhere.
3481+ *
3482+ * Return: The original value of @v.
3483+ */
19543484 static __always_inline s64
1955−arch_atomic64_fetch_dec_relaxed(atomic64_t *v)
3485+raw_atomic64_fetch_dec_release(atomic64_t *v)
19563486 {
1957− return arch_atomic64_fetch_sub_relaxed(1, v);
1958−}
1959−#define arch_atomic64_fetch_dec_relaxed arch_atomic64_fetch_dec_relaxed
3487+#if defined(arch_atomic64_fetch_dec_release)
3488+ return arch_atomic64_fetch_dec_release(v);
3489+#elif defined(arch_atomic64_fetch_dec_relaxed)
3490+ __atomic_release_fence();
3491+ return arch_atomic64_fetch_dec_relaxed(v);
3492+#elif defined(arch_atomic64_fetch_dec)
3493+ return arch_atomic64_fetch_dec(v);
3494+#else
3495+ return raw_atomic64_fetch_sub_release(1, v);
19603496 #endif
3497+}
19613498
1962−#else /* arch_atomic64_fetch_dec_relaxed */
1963−
1964−#ifndef arch_atomic64_fetch_dec_acquire
3499+/**
3500+ * raw_atomic64_fetch_dec_relaxed() - atomic decrement with relaxed ordering
3501+ * @v: pointer to atomic64_t
3502+ *
3503+ * Atomically updates @v to (@v - 1) with relaxed ordering.
3504+ *
3505+ * Safe to use in noinstr code; prefer atomic64_fetch_dec_relaxed() elsewhere.
3506+ *
3507+ * Return: The original value of @v.
3508+ */
19653509 static __always_inline s64
1966−arch_atomic64_fetch_dec_acquire(atomic64_t *v)
3510+raw_atomic64_fetch_dec_relaxed(atomic64_t *v)
19673511 {
1968− s64 ret = arch_atomic64_fetch_dec_relaxed(v);
1969− __atomic_acquire_fence();
1970− return ret;
1971−}
1972−#define arch_atomic64_fetch_dec_acquire arch_atomic64_fetch_dec_acquire
3512+#if defined(arch_atomic64_fetch_dec_relaxed)
3513+ return arch_atomic64_fetch_dec_relaxed(v);
3514+#elif defined(arch_atomic64_fetch_dec)
3515+ return arch_atomic64_fetch_dec(v);
3516+#else
3517+ return raw_atomic64_fetch_sub_relaxed(1, v);
19733518 #endif
3519+}
19743520
1975−#ifndef arch_atomic64_fetch_dec_release
1976−static __always_inline s64
1977−arch_atomic64_fetch_dec_release(atomic64_t *v)
3521+/**
3522+ * raw_atomic64_and() - atomic bitwise AND with relaxed ordering
3523+ * @i: s64 value
3524+ * @v: pointer to atomic64_t
3525+ *
3526+ * Atomically updates @v to (@v & @i) with relaxed ordering.
3527+ *
3528+ * Safe to use in noinstr code; prefer atomic64_and() elsewhere.
3529+ *
3530+ * Return: Nothing.
3531+ */
3532+static __always_inline void
3533+raw_atomic64_and(s64 i, atomic64_t *v)
19783534 {
1979− __atomic_release_fence();
1980− return arch_atomic64_fetch_dec_relaxed(v);
3535+ arch_atomic64_and(i, v);
19813536 }
1982−#define arch_atomic64_fetch_dec_release arch_atomic64_fetch_dec_release
1983−#endif
19843537
1985−#ifndef arch_atomic64_fetch_dec
3538+/**
3539+ * raw_atomic64_fetch_and() - atomic bitwise AND with full ordering
3540+ * @i: s64 value
3541+ * @v: pointer to atomic64_t
3542+ *
3543+ * Atomically updates @v to (@v & @i) with full ordering.
3544+ *
3545+ * Safe to use in noinstr code; prefer atomic64_fetch_and() elsewhere.
3546+ *
3547+ * Return: The original value of @v.
3548+ */
19863549 static __always_inline s64
1987−arch_atomic64_fetch_dec(atomic64_t *v)
3550+raw_atomic64_fetch_and(s64 i, atomic64_t *v)
19883551 {
3552+#if defined(arch_atomic64_fetch_and)
3553+ return arch_atomic64_fetch_and(i, v);
3554+#elif defined(arch_atomic64_fetch_and_relaxed)
19893555 s64 ret;
19903556 __atomic_pre_full_fence();
1991− ret = arch_atomic64_fetch_dec_relaxed(v);
3557+ ret = arch_atomic64_fetch_and_relaxed(i, v);
19923558 __atomic_post_full_fence();
19933559 return ret;
1994−}
1995−#define arch_atomic64_fetch_dec arch_atomic64_fetch_dec
3560+#else
3561+#error "Unable to define raw_atomic64_fetch_and"
19963562 #endif
3563+}
19973564
1998−#endif /* arch_atomic64_fetch_dec_relaxed */
1999−
2000−#ifndef arch_atomic64_fetch_and_relaxed
2001−#define arch_atomic64_fetch_and_acquire arch_atomic64_fetch_and
2002−#define arch_atomic64_fetch_and_release arch_atomic64_fetch_and
2003−#define arch_atomic64_fetch_and_relaxed arch_atomic64_fetch_and
2004−#else /* arch_atomic64_fetch_and_relaxed */
2005−
2006−#ifndef arch_atomic64_fetch_and_acquire
3565+/**
3566+ * raw_atomic64_fetch_and_acquire() - atomic bitwise AND with acquire ordering
3567+ * @i: s64 value
3568+ * @v: pointer to atomic64_t
3569+ *
3570+ * Atomically updates @v to (@v & @i) with acquire ordering.
3571+ *
3572+ * Safe to use in noinstr code; prefer atomic64_fetch_and_acquire() elsewhere.
3573+ *
3574+ * Return: The original value of @v.
3575+ */
20073576 static __always_inline s64
2008−arch_atomic64_fetch_and_acquire(s64 i, atomic64_t *v)
3577+raw_atomic64_fetch_and_acquire(s64 i, atomic64_t *v)
20093578 {
3579+#if defined(arch_atomic64_fetch_and_acquire)
3580+ return arch_atomic64_fetch_and_acquire(i, v);
3581+#elif defined(arch_atomic64_fetch_and_relaxed)
20103582 s64 ret = arch_atomic64_fetch_and_relaxed(i, v);
20113583 __atomic_acquire_fence();
20123584 return ret;
2013−}
2014−#define arch_atomic64_fetch_and_acquire arch_atomic64_fetch_and_acquire
3585+#elif defined(arch_atomic64_fetch_and)
3586+ return arch_atomic64_fetch_and(i, v);
3587+#else
3588+#error "Unable to define raw_atomic64_fetch_and_acquire"
20153589 #endif
3590+}
20163591
2017−#ifndef arch_atomic64_fetch_and_release
3592+/**
3593+ * raw_atomic64_fetch_and_release() - atomic bitwise AND with release ordering
3594+ * @i: s64 value
3595+ * @v: pointer to atomic64_t
3596+ *
3597+ * Atomically updates @v to (@v & @i) with release ordering.
3598+ *
3599+ * Safe to use in noinstr code; prefer atomic64_fetch_and_release() elsewhere.
3600+ *
3601+ * Return: The original value of @v.
3602+ */
20183603 static __always_inline s64
2019−arch_atomic64_fetch_and_release(s64 i, atomic64_t *v)
3604+raw_atomic64_fetch_and_release(s64 i, atomic64_t *v)
20203605 {
3606+#if defined(arch_atomic64_fetch_and_release)
3607+ return arch_atomic64_fetch_and_release(i, v);
3608+#elif defined(arch_atomic64_fetch_and_relaxed)
20213609 __atomic_release_fence();
20223610 return arch_atomic64_fetch_and_relaxed(i, v);
2023−}
2024−#define arch_atomic64_fetch_and_release arch_atomic64_fetch_and_release
3611+#elif defined(arch_atomic64_fetch_and)
3612+ return arch_atomic64_fetch_and(i, v);
3613+#else
3614+#error "Unable to define raw_atomic64_fetch_and_release"
20253615 #endif
3616+}
20263617
2027−#ifndef arch_atomic64_fetch_and
3618+/**
3619+ * raw_atomic64_fetch_and_relaxed() - atomic bitwise AND with relaxed ordering
3620+ * @i: s64 value
3621+ * @v: pointer to atomic64_t
3622+ *
3623+ * Atomically updates @v to (@v & @i) with relaxed ordering.
3624+ *
3625+ * Safe to use in noinstr code; prefer atomic64_fetch_and_relaxed() elsewhere.
3626+ *
3627+ * Return: The original value of @v.
3628+ */
20283629 static __always_inline s64
2029−arch_atomic64_fetch_and(s64 i, atomic64_t *v)
3630+raw_atomic64_fetch_and_relaxed(s64 i, atomic64_t *v)
20303631 {
2031− s64 ret;
2032− __atomic_pre_full_fence();
2033− ret = arch_atomic64_fetch_and_relaxed(i, v);
2034− __atomic_post_full_fence();
2035− return ret;
2036−}
2037−#define arch_atomic64_fetch_and arch_atomic64_fetch_and
3632+#if defined(arch_atomic64_fetch_and_relaxed)
3633+ return arch_atomic64_fetch_and_relaxed(i, v);
3634+#elif defined(arch_atomic64_fetch_and)
3635+ return arch_atomic64_fetch_and(i, v);
3636+#else
3637+#error "Unable to define raw_atomic64_fetch_and_relaxed"
20383638 #endif
2039−
2040−#endif /* arch_atomic64_fetch_and_relaxed */
2041−
2042−#ifndef arch_atomic64_andnot
2043−static __always_inline void
2044−arch_atomic64_andnot(s64 i, atomic64_t *v)
2045−{
2046− arch_atomic64_and(~i, v);
20473639 }
2048−#define arch_atomic64_andnot arch_atomic64_andnot
2049−#endif
2050−
2051−#ifndef arch_atomic64_fetch_andnot_relaxed
2052−#ifdef arch_atomic64_fetch_andnot
2053−#define arch_atomic64_fetch_andnot_acquire arch_atomic64_fetch_andnot
2054−#define arch_atomic64_fetch_andnot_release arch_atomic64_fetch_andnot
2055−#define arch_atomic64_fetch_andnot_relaxed arch_atomic64_fetch_andnot
2056−#endif /* arch_atomic64_fetch_andnot */
20573640
2058−#ifndef arch_atomic64_fetch_andnot
2059−static __always_inline s64
2060−arch_atomic64_fetch_andnot(s64 i, atomic64_t *v)
3641+/**
3642+ * raw_atomic64_andnot() - atomic bitwise AND NOT with relaxed ordering
3643+ * @i: s64 value
3644+ * @v: pointer to atomic64_t
3645+ *
3646+ * Atomically updates @v to (@v & ~@i) with relaxed ordering.
3647+ *
3648+ * Safe to use in noinstr code; prefer atomic64_andnot() elsewhere.
3649+ *
3650+ * Return: Nothing.
3651+ */
3652+static __always_inline void
3653+raw_atomic64_andnot(s64 i, atomic64_t *v)
20613654 {
2062− return arch_atomic64_fetch_and(~i, v);
2063−}
2064−#define arch_atomic64_fetch_andnot arch_atomic64_fetch_andnot
3655+#if defined(arch_atomic64_andnot)
3656+ arch_atomic64_andnot(i, v);
3657+#else
3658+ raw_atomic64_and(~i, v);
20653659 #endif
2066−
2067−#ifndef arch_atomic64_fetch_andnot_acquire
2068−static __always_inline s64
2069−arch_atomic64_fetch_andnot_acquire(s64 i, atomic64_t *v)
2070−{
2071− return arch_atomic64_fetch_and_acquire(~i, v);
20723660 }
2073−#define arch_atomic64_fetch_andnot_acquire arch_atomic64_fetch_andnot_acquire
2074−#endif
20753661
2076−#ifndef arch_atomic64_fetch_andnot_release
3662+/**
3663+ * raw_atomic64_fetch_andnot() - atomic bitwise AND NOT with full ordering
3664+ * @i: s64 value
3665+ * @v: pointer to atomic64_t
3666+ *
3667+ * Atomically updates @v to (@v & ~@i) with full ordering.
3668+ *
3669+ * Safe to use in noinstr code; prefer atomic64_fetch_andnot() elsewhere.
3670+ *
3671+ * Return: The original value of @v.
3672+ */
20773673 static __always_inline s64
2078−arch_atomic64_fetch_andnot_release(s64 i, atomic64_t *v)
3674+raw_atomic64_fetch_andnot(s64 i, atomic64_t *v)
20793675 {
2080− return arch_atomic64_fetch_and_release(~i, v);
2081−}
2082−#define arch_atomic64_fetch_andnot_release arch_atomic64_fetch_andnot_release
3676+#if defined(arch_atomic64_fetch_andnot)
3677+ return arch_atomic64_fetch_andnot(i, v);
3678+#elif defined(arch_atomic64_fetch_andnot_relaxed)
3679+ s64 ret;
3680+ __atomic_pre_full_fence();
3681+ ret = arch_atomic64_fetch_andnot_relaxed(i, v);
3682+ __atomic_post_full_fence();
3683+ return ret;
3684+#else
3685+ return raw_atomic64_fetch_and(~i, v);
20833686 #endif
2084−
2085−#ifndef arch_atomic64_fetch_andnot_relaxed
2086−static __always_inline s64
2087−arch_atomic64_fetch_andnot_relaxed(s64 i, atomic64_t *v)
2088−{
2089− return arch_atomic64_fetch_and_relaxed(~i, v);
20903687 }
2091−#define arch_atomic64_fetch_andnot_relaxed arch_atomic64_fetch_andnot_relaxed
2092−#endif
2093−
2094−#else /* arch_atomic64_fetch_andnot_relaxed */
20953688
2096−#ifndef arch_atomic64_fetch_andnot_acquire
3689+/**
3690+ * raw_atomic64_fetch_andnot_acquire() - atomic bitwise AND NOT with acquire ordering
3691+ * @i: s64 value
3692+ * @v: pointer to atomic64_t
3693+ *
3694+ * Atomically updates @v to (@v & ~@i) with acquire ordering.
3695+ *
3696+ * Safe to use in noinstr code; prefer atomic64_fetch_andnot_acquire() elsewhere.
3697+ *
3698+ * Return: The original value of @v.
3699+ */
20973700 static __always_inline s64
2098−arch_atomic64_fetch_andnot_acquire(s64 i, atomic64_t *v)
3701+raw_atomic64_fetch_andnot_acquire(s64 i, atomic64_t *v)
20993702 {
3703+#if defined(arch_atomic64_fetch_andnot_acquire)
3704+ return arch_atomic64_fetch_andnot_acquire(i, v);
3705+#elif defined(arch_atomic64_fetch_andnot_relaxed)
21003706 s64 ret = arch_atomic64_fetch_andnot_relaxed(i, v);
21013707 __atomic_acquire_fence();
21023708 return ret;
2103−}
2104−#define arch_atomic64_fetch_andnot_acquire arch_atomic64_fetch_andnot_acquire
3709+#elif defined(arch_atomic64_fetch_andnot)
3710+ return arch_atomic64_fetch_andnot(i, v);
3711+#else
3712+ return raw_atomic64_fetch_and_acquire(~i, v);
21053713 #endif
3714+}
21063715
2107−#ifndef arch_atomic64_fetch_andnot_release
3716+/**
3717+ * raw_atomic64_fetch_andnot_release() - atomic bitwise AND NOT with release ordering
3718+ * @i: s64 value
3719+ * @v: pointer to atomic64_t
3720+ *
3721+ * Atomically updates @v to (@v & ~@i) with release ordering.
3722+ *
3723+ * Safe to use in noinstr code; prefer atomic64_fetch_andnot_release() elsewhere.
3724+ *
3725+ * Return: The original value of @v.
3726+ */
21083727 static __always_inline s64
2109−arch_atomic64_fetch_andnot_release(s64 i, atomic64_t *v)
3728+raw_atomic64_fetch_andnot_release(s64 i, atomic64_t *v)
21103729 {
3730+#if defined(arch_atomic64_fetch_andnot_release)
3731+ return arch_atomic64_fetch_andnot_release(i, v);
3732+#elif defined(arch_atomic64_fetch_andnot_relaxed)
21113733 __atomic_release_fence();
21123734 return arch_atomic64_fetch_andnot_relaxed(i, v);
3735+#elif defined(arch_atomic64_fetch_andnot)
3736+ return arch_atomic64_fetch_andnot(i, v);
3737+#else
3738+ return raw_atomic64_fetch_and_release(~i, v);
3739+#endif
21133740 }
2114−#define arch_atomic64_fetch_andnot_release arch_atomic64_fetch_andnot_release
3741+
3742+/**
3743+ * raw_atomic64_fetch_andnot_relaxed() - atomic bitwise AND NOT with relaxed ordering

1241 more lines aren’t shown here.

include/linux/atomic/atomic-instrumented.h+3194−361
@@ -4,15 +4,10 @@ · 3 unmodified lines
44 // DO NOT MODIFY THIS FILE DIRECTLY
55
66 /*
7− * This file provides wrappers with KASAN instrumentation for atomic operations.
8− * To use this functionality an arch's atomic.h file needs to define all
9− * atomic operations with arch_ prefix (e.g. arch_atomic_read()) and include
10− * this file at the end. This file provides atomic_read() that forwards to
11− * arch_atomic_read() for actual atomic operation.
12− * Note: if an arch atomic operation is implemented by means of other atomic
13− * operations (e.g. atomic_read()/atomic_cmpxchg() loop), then it needs to use
14− * arch_ variants (i.e. arch_atomic_read()/arch_atomic_cmpxchg()) to avoid
15− * double instrumentation.
7+ * This file provoides atomic operations with explicit instrumentation (e.g.
8+ * KASAN, KCSAN), which should be used unless it is necessary to avoid
9+ * instrumentation. Where it is necessary to aovid instrumenation, the
10+ * raw_atomic*() operations should be used.
1611 */
1712 #ifndef _LINUX_ATOMIC_INSTRUMENTED_H
1813 #define _LINUX_ATOMIC_INSTRUMENTED_H
@@ -21,1927 +16,4696 @@ · 2 unmodified lines
2116 #include <linux/compiler.h>
2217 #include <linux/instrumented.h>
2318
19+/**
20+ * atomic_read() - atomic load with relaxed ordering
21+ * @v: pointer to atomic_t
22+ *
23+ * Atomically loads the value of @v with relaxed ordering.
24+ *
25+ * Unsafe to use in noinstr code; use raw_atomic_read() there.
26+ *
27+ * Return: The value loaded from @v.
28+ */
2429 static __always_inline int
2530 atomic_read(const atomic_t *v)
2631 {
2732 instrument_atomic_read(v, sizeof(*v));
28− return arch_atomic_read(v);
29−}
30−
33+ return raw_atomic_read(v);
34+}
35+
36+/**
37+ * atomic_read_acquire() - atomic load with acquire ordering
38+ * @v: pointer to atomic_t
39+ *
40+ * Atomically loads the value of @v with acquire ordering.
41+ *
42+ * Unsafe to use in noinstr code; use raw_atomic_read_acquire() there.
43+ *
44+ * Return: The value loaded from @v.
45+ */
3146 static __always_inline int
3247 atomic_read_acquire(const atomic_t *v)
3348 {
3449 instrument_atomic_read(v, sizeof(*v));
35− return arch_atomic_read_acquire(v);
36−}
37−
50+ return raw_atomic_read_acquire(v);
51+}
52+
53+/**
54+ * atomic_set() - atomic set with relaxed ordering
55+ * @v: pointer to atomic_t
56+ * @i: int value to assign
57+ *
58+ * Atomically sets @v to @i with relaxed ordering.
59+ *
60+ * Unsafe to use in noinstr code; use raw_atomic_set() there.
61+ *
62+ * Return: Nothing.
63+ */
3864 static __always_inline void
3965 atomic_set(atomic_t *v, int i)
4066 {
4167 instrument_atomic_write(v, sizeof(*v));
42− arch_atomic_set(v, i);
43−}
44−
68+ raw_atomic_set(v, i);
69+}
70+
71+/**
72+ * atomic_set_release() - atomic set with release ordering
73+ * @v: pointer to atomic_t
74+ * @i: int value to assign
75+ *
76+ * Atomically sets @v to @i with release ordering.
77+ *
78+ * Unsafe to use in noinstr code; use raw_atomic_set_release() there.
79+ *
80+ * Return: Nothing.
81+ */
4582 static __always_inline void
4683 atomic_set_release(atomic_t *v, int i)
4784 {
4885 kcsan_release();
4986 instrument_atomic_write(v, sizeof(*v));
50− arch_atomic_set_release(v, i);
51−}
52−
87+ raw_atomic_set_release(v, i);
88+}
89+
90+/**
91+ * atomic_add() - atomic add with relaxed ordering
92+ * @i: int value to add
93+ * @v: pointer to atomic_t
94+ *
95+ * Atomically updates @v to (@v + @i) with relaxed ordering.
96+ *
97+ * Unsafe to use in noinstr code; use raw_atomic_add() there.
98+ *
99+ * Return: Nothing.
100+ */
53101 static __always_inline void
54102 atomic_add(int i, atomic_t *v)
55103 {
56104 instrument_atomic_read_write(v, sizeof(*v));
57− arch_atomic_add(i, v);
105+ raw_atomic_add(i, v);
58106 }
59107
108+/**
109+ * atomic_add_return() - atomic add with full ordering
110+ * @i: int value to add
111+ * @v: pointer to atomic_t
112+ *
113+ * Atomically updates @v to (@v + @i) with full ordering.
114+ *
115+ * Unsafe to use in noinstr code; use raw_atomic_add_return() there.
116+ *
117+ * Return: The updated value of @v.
118+ */
60119 static __always_inline int
61120 atomic_add_return(int i, atomic_t *v)
62121 {
63122 kcsan_mb();
64123 instrument_atomic_read_write(v, sizeof(*v));
65− return arch_atomic_add_return(i, v);
124+ return raw_atomic_add_return(i, v);
66125 }
67126
127+/**
128+ * atomic_add_return_acquire() - atomic add with acquire ordering
129+ * @i: int value to add
130+ * @v: pointer to atomic_t
131+ *
132+ * Atomically updates @v to (@v + @i) with acquire ordering.
133+ *
134+ * Unsafe to use in noinstr code; use raw_atomic_add_return_acquire() there.
135+ *
136+ * Return: The updated value of @v.
137+ */
68138 static __always_inline int
69139 atomic_add_return_acquire(int i, atomic_t *v)
70140 {
71141 instrument_atomic_read_write(v, sizeof(*v));
72− return arch_atomic_add_return_acquire(i, v);
142+ return raw_atomic_add_return_acquire(i, v);
73143 }
74144
145+/**
146+ * atomic_add_return_release() - atomic add with release ordering
147+ * @i: int value to add
148+ * @v: pointer to atomic_t
149+ *
150+ * Atomically updates @v to (@v + @i) with release ordering.
151+ *
152+ * Unsafe to use in noinstr code; use raw_atomic_add_return_release() there.
153+ *
154+ * Return: The updated value of @v.
155+ */
75156 static __always_inline int
76157 atomic_add_return_release(int i, atomic_t *v)
77158 {
78159 kcsan_release();
79160 instrument_atomic_read_write(v, sizeof(*v));
80− return arch_atomic_add_return_release(i, v);
161+ return raw_atomic_add_return_release(i, v);
81162 }
82163
164+/**
165+ * atomic_add_return_relaxed() - atomic add with relaxed ordering
166+ * @i: int value to add
167+ * @v: pointer to atomic_t
168+ *
169+ * Atomically updates @v to (@v + @i) with relaxed ordering.
170+ *
171+ * Unsafe to use in noinstr code; use raw_atomic_add_return_relaxed() there.
172+ *
173+ * Return: The updated value of @v.
174+ */
83175 static __always_inline int
84176 atomic_add_return_relaxed(int i, atomic_t *v)
85177 {
86178 instrument_atomic_read_write(v, sizeof(*v));
87− return arch_atomic_add_return_relaxed(i, v);
179+ return raw_atomic_add_return_relaxed(i, v);
88180 }
89181
182+/**
183+ * atomic_fetch_add() - atomic add with full ordering
184+ * @i: int value to add
185+ * @v: pointer to atomic_t
186+ *
187+ * Atomically updates @v to (@v + @i) with full ordering.
188+ *
189+ * Unsafe to use in noinstr code; use raw_atomic_fetch_add() there.
190+ *
191+ * Return: The original value of @v.
192+ */
90193 static __always_inline int
91194 atomic_fetch_add(int i, atomic_t *v)
92195 {
93196 kcsan_mb();
94197 instrument_atomic_read_write(v, sizeof(*v));
95− return arch_atomic_fetch_add(i, v);
198+ return raw_atomic_fetch_add(i, v);
96199 }
97200
201+/**
202+ * atomic_fetch_add_acquire() - atomic add with acquire ordering
203+ * @i: int value to add
204+ * @v: pointer to atomic_t
205+ *
206+ * Atomically updates @v to (@v + @i) with acquire ordering.
207+ *
208+ * Unsafe to use in noinstr code; use raw_atomic_fetch_add_acquire() there.
209+ *
210+ * Return: The original value of @v.
211+ */
98212 static __always_inline int
99213 atomic_fetch_add_acquire(int i, atomic_t *v)
100214 {
101215 instrument_atomic_read_write(v, sizeof(*v));
102− return arch_atomic_fetch_add_acquire(i, v);
216+ return raw_atomic_fetch_add_acquire(i, v);
103217 }
104218
219+/**
220+ * atomic_fetch_add_release() - atomic add with release ordering
221+ * @i: int value to add
222+ * @v: pointer to atomic_t
223+ *
224+ * Atomically updates @v to (@v + @i) with release ordering.
225+ *
226+ * Unsafe to use in noinstr code; use raw_atomic_fetch_add_release() there.
227+ *
228+ * Return: The original value of @v.
229+ */
105230 static __always_inline int
106231 atomic_fetch_add_release(int i, atomic_t *v)
107232 {
108233 kcsan_release();
109234 instrument_atomic_read_write(v, sizeof(*v));
110− return arch_atomic_fetch_add_release(i, v);
235+ return raw_atomic_fetch_add_release(i, v);
111236 }
112237
238+/**
239+ * atomic_fetch_add_relaxed() - atomic add with relaxed ordering
240+ * @i: int value to add
241+ * @v: pointer to atomic_t
242+ *
243+ * Atomically updates @v to (@v + @i) with relaxed ordering.
244+ *
245+ * Unsafe to use in noinstr code; use raw_atomic_fetch_add_relaxed() there.
246+ *
247+ * Return: The original value of @v.
248+ */
113249 static __always_inline int
114250 atomic_fetch_add_relaxed(int i, atomic_t *v)
115251 {
116252 instrument_atomic_read_write(v, sizeof(*v));
117− return arch_atomic_fetch_add_relaxed(i, v);
253+ return raw_atomic_fetch_add_relaxed(i, v);
118254 }
119255
256+/**
257+ * atomic_sub() - atomic subtract with relaxed ordering
258+ * @i: int value to subtract
259+ * @v: pointer to atomic_t
260+ *
261+ * Atomically updates @v to (@v - @i) with relaxed ordering.
262+ *
263+ * Unsafe to use in noinstr code; use raw_atomic_sub() there.
264+ *
265+ * Return: Nothing.
266+ */
120267 static __always_inline void
121268 atomic_sub(int i, atomic_t *v)
122269 {
123270 instrument_atomic_read_write(v, sizeof(*v));
124− arch_atomic_sub(i, v);
271+ raw_atomic_sub(i, v);
125272 }
126273
274+/**
275+ * atomic_sub_return() - atomic subtract with full ordering
276+ * @i: int value to subtract
277+ * @v: pointer to atomic_t
278+ *
279+ * Atomically updates @v to (@v - @i) with full ordering.
280+ *
281+ * Unsafe to use in noinstr code; use raw_atomic_sub_return() there.
282+ *
283+ * Return: The updated value of @v.
284+ */
127285 static __always_inline int
128286 atomic_sub_return(int i, atomic_t *v)
129287 {
130288 kcsan_mb();
131289 instrument_atomic_read_write(v, sizeof(*v));
132− return arch_atomic_sub_return(i, v);
290+ return raw_atomic_sub_return(i, v);
133291 }
134292
293+/**
294+ * atomic_sub_return_acquire() - atomic subtract with acquire ordering
295+ * @i: int value to subtract
296+ * @v: pointer to atomic_t
297+ *
298+ * Atomically updates @v to (@v - @i) with acquire ordering.
299+ *
300+ * Unsafe to use in noinstr code; use raw_atomic_sub_return_acquire() there.
301+ *
302+ * Return: The updated value of @v.
303+ */
135304 static __always_inline int
136305 atomic_sub_return_acquire(int i, atomic_t *v)
137306 {
138307 instrument_atomic_read_write(v, sizeof(*v));
139− return arch_atomic_sub_return_acquire(i, v);
308+ return raw_atomic_sub_return_acquire(i, v);
140309 }
141310
311+/**
312+ * atomic_sub_return_release() - atomic subtract with release ordering
313+ * @i: int value to subtract
314+ * @v: pointer to atomic_t
315+ *
316+ * Atomically updates @v to (@v - @i) with release ordering.
317+ *
318+ * Unsafe to use in noinstr code; use raw_atomic_sub_return_release() there.
319+ *
320+ * Return: The updated value of @v.
321+ */
142322 static __always_inline int
143323 atomic_sub_return_release(int i, atomic_t *v)
144324 {
145325 kcsan_release();
146326 instrument_atomic_read_write(v, sizeof(*v));
147− return arch_atomic_sub_return_release(i, v);
327+ return raw_atomic_sub_return_release(i, v);
148328 }
149329
330+/**
331+ * atomic_sub_return_relaxed() - atomic subtract with relaxed ordering
332+ * @i: int value to subtract
333+ * @v: pointer to atomic_t
334+ *
335+ * Atomically updates @v to (@v - @i) with relaxed ordering.
336+ *
337+ * Unsafe to use in noinstr code; use raw_atomic_sub_return_relaxed() there.
338+ *
339+ * Return: The updated value of @v.
340+ */
150341 static __always_inline int
151342 atomic_sub_return_relaxed(int i, atomic_t *v)
152343 {
153344 instrument_atomic_read_write(v, sizeof(*v));
154− return arch_atomic_sub_return_relaxed(i, v);
345+ return raw_atomic_sub_return_relaxed(i, v);
155346 }
156347
348+/**
349+ * atomic_fetch_sub() - atomic subtract with full ordering
350+ * @i: int value to subtract
351+ * @v: pointer to atomic_t
352+ *
353+ * Atomically updates @v to (@v - @i) with full ordering.
354+ *
355+ * Unsafe to use in noinstr code; use raw_atomic_fetch_sub() there.
356+ *
357+ * Return: The original value of @v.
358+ */
157359 static __always_inline int
158360 atomic_fetch_sub(int i, atomic_t *v)
159361 {
160362 kcsan_mb();
161363 instrument_atomic_read_write(v, sizeof(*v));
162− return arch_atomic_fetch_sub(i, v);
364+ return raw_atomic_fetch_sub(i, v);
163365 }
164366
367+/**
368+ * atomic_fetch_sub_acquire() - atomic subtract with acquire ordering
369+ * @i: int value to subtract
370+ * @v: pointer to atomic_t
371+ *
372+ * Atomically updates @v to (@v - @i) with acquire ordering.
373+ *
374+ * Unsafe to use in noinstr code; use raw_atomic_fetch_sub_acquire() there.
375+ *
376+ * Return: The original value of @v.
377+ */
165378 static __always_inline int
166379 atomic_fetch_sub_acquire(int i, atomic_t *v)
167380 {
168381 instrument_atomic_read_write(v, sizeof(*v));
169− return arch_atomic_fetch_sub_acquire(i, v);
382+ return raw_atomic_fetch_sub_acquire(i, v);
170383 }
171384
385+/**
386+ * atomic_fetch_sub_release() - atomic subtract with release ordering
387+ * @i: int value to subtract
388+ * @v: pointer to atomic_t
389+ *
390+ * Atomically updates @v to (@v - @i) with release ordering.
391+ *
392+ * Unsafe to use in noinstr code; use raw_atomic_fetch_sub_release() there.
393+ *
394+ * Return: The original value of @v.
395+ */
172396 static __always_inline int
173397 atomic_fetch_sub_release(int i, atomic_t *v)
174398 {
175399 kcsan_release();
176400 instrument_atomic_read_write(v, sizeof(*v));
177− return arch_atomic_fetch_sub_release(i, v);
401+ return raw_atomic_fetch_sub_release(i, v);
178402 }
179403
404+/**
405+ * atomic_fetch_sub_relaxed() - atomic subtract with relaxed ordering
406+ * @i: int value to subtract
407+ * @v: pointer to atomic_t
408+ *
409+ * Atomically updates @v to (@v - @i) with relaxed ordering.
410+ *
411+ * Unsafe to use in noinstr code; use raw_atomic_fetch_sub_relaxed() there.
412+ *
413+ * Return: The original value of @v.
414+ */
180415 static __always_inline int
181416 atomic_fetch_sub_relaxed(int i, atomic_t *v)
182417 {
183418 instrument_atomic_read_write(v, sizeof(*v));
184− return arch_atomic_fetch_sub_relaxed(i, v);
419+ return raw_atomic_fetch_sub_relaxed(i, v);
185420 }
186421
422+/**
423+ * atomic_inc() - atomic increment with relaxed ordering
424+ * @v: pointer to atomic_t
425+ *
426+ * Atomically updates @v to (@v + 1) with relaxed ordering.
427+ *
428+ * Unsafe to use in noinstr code; use raw_atomic_inc() there.
429+ *
430+ * Return: Nothing.
431+ */
187432 static __always_inline void
188433 atomic_inc(atomic_t *v)
189434 {
190435 instrument_atomic_read_write(v, sizeof(*v));
191− arch_atomic_inc(v);
436+ raw_atomic_inc(v);
192437 }
193438
439+/**
440+ * atomic_inc_return() - atomic increment with full ordering
441+ * @v: pointer to atomic_t
442+ *
443+ * Atomically updates @v to (@v + 1) with full ordering.
444+ *
445+ * Unsafe to use in noinstr code; use raw_atomic_inc_return() there.
446+ *
447+ * Return: The updated value of @v.
448+ */
194449 static __always_inline int
195450 atomic_inc_return(atomic_t *v)
196451 {
197452 kcsan_mb();
198453 instrument_atomic_read_write(v, sizeof(*v));
199− return arch_atomic_inc_return(v);
454+ return raw_atomic_inc_return(v);
200455 }
201456
457+/**
458+ * atomic_inc_return_acquire() - atomic increment with acquire ordering
459+ * @v: pointer to atomic_t
460+ *
461+ * Atomically updates @v to (@v + 1) with acquire ordering.
462+ *
463+ * Unsafe to use in noinstr code; use raw_atomic_inc_return_acquire() there.
464+ *
465+ * Return: The updated value of @v.
466+ */
202467 static __always_inline int
203468 atomic_inc_return_acquire(atomic_t *v)
204469 {
205470 instrument_atomic_read_write(v, sizeof(*v));
206− return arch_atomic_inc_return_acquire(v);
471+ return raw_atomic_inc_return_acquire(v);
207472 }
208473
474+/**
475+ * atomic_inc_return_release() - atomic increment with release ordering
476+ * @v: pointer to atomic_t
477+ *
478+ * Atomically updates @v to (@v + 1) with release ordering.
479+ *
480+ * Unsafe to use in noinstr code; use raw_atomic_inc_return_release() there.
481+ *
482+ * Return: The updated value of @v.
483+ */
209484 static __always_inline int
210485 atomic_inc_return_release(atomic_t *v)
211486 {
212487 kcsan_release();
213488 instrument_atomic_read_write(v, sizeof(*v));
214− return arch_atomic_inc_return_release(v);
489+ return raw_atomic_inc_return_release(v);
215490 }
216491
492+/**
493+ * atomic_inc_return_relaxed() - atomic increment with relaxed ordering
494+ * @v: pointer to atomic_t
495+ *
496+ * Atomically updates @v to (@v + 1) with relaxed ordering.
497+ *
498+ * Unsafe to use in noinstr code; use raw_atomic_inc_return_relaxed() there.
499+ *
500+ * Return: The updated value of @v.
501+ */
217502 static __always_inline int
218503 atomic_inc_return_relaxed(atomic_t *v)
219504 {
220505 instrument_atomic_read_write(v, sizeof(*v));
221− return arch_atomic_inc_return_relaxed(v);
506+ return raw_atomic_inc_return_relaxed(v);
222507 }
223508
509+/**
510+ * atomic_fetch_inc() - atomic increment with full ordering
511+ * @v: pointer to atomic_t
512+ *
513+ * Atomically updates @v to (@v + 1) with full ordering.
514+ *
515+ * Unsafe to use in noinstr code; use raw_atomic_fetch_inc() there.
516+ *
517+ * Return: The original value of @v.
518+ */
224519 static __always_inline int
225520 atomic_fetch_inc(atomic_t *v)
226521 {
227522 kcsan_mb();
228523 instrument_atomic_read_write(v, sizeof(*v));
229− return arch_atomic_fetch_inc(v);
524+ return raw_atomic_fetch_inc(v);
230525 }
231526
527+/**
528+ * atomic_fetch_inc_acquire() - atomic increment with acquire ordering
529+ * @v: pointer to atomic_t
530+ *
531+ * Atomically updates @v to (@v + 1) with acquire ordering.
532+ *
533+ * Unsafe to use in noinstr code; use raw_atomic_fetch_inc_acquire() there.
534+ *
535+ * Return: The original value of @v.
536+ */
232537 static __always_inline int
233538 atomic_fetch_inc_acquire(atomic_t *v)
234539 {
235540 instrument_atomic_read_write(v, sizeof(*v));
236− return arch_atomic_fetch_inc_acquire(v);
541+ return raw_atomic_fetch_inc_acquire(v);
237542 }
238543
544+/**
545+ * atomic_fetch_inc_release() - atomic increment with release ordering
546+ * @v: pointer to atomic_t
547+ *
548+ * Atomically updates @v to (@v + 1) with release ordering.
549+ *
550+ * Unsafe to use in noinstr code; use raw_atomic_fetch_inc_release() there.
551+ *
552+ * Return: The original value of @v.
553+ */
239554 static __always_inline int
240555 atomic_fetch_inc_release(atomic_t *v)
241556 {
242557 kcsan_release();
243558 instrument_atomic_read_write(v, sizeof(*v));
244− return arch_atomic_fetch_inc_release(v);
559+ return raw_atomic_fetch_inc_release(v);
245560 }
246561
562+/**
563+ * atomic_fetch_inc_relaxed() - atomic increment with relaxed ordering
564+ * @v: pointer to atomic_t
565+ *
566+ * Atomically updates @v to (@v + 1) with relaxed ordering.
567+ *
568+ * Unsafe to use in noinstr code; use raw_atomic_fetch_inc_relaxed() there.
569+ *
570+ * Return: The original value of @v.
571+ */
247572 static __always_inline int
248573 atomic_fetch_inc_relaxed(atomic_t *v)
249574 {
250575 instrument_atomic_read_write(v, sizeof(*v));
251− return arch_atomic_fetch_inc_relaxed(v);
576+ return raw_atomic_fetch_inc_relaxed(v);
252577 }
253578
579+/**
580+ * atomic_dec() - atomic decrement with relaxed ordering
581+ * @v: pointer to atomic_t
582+ *
583+ * Atomically updates @v to (@v - 1) with relaxed ordering.
584+ *
585+ * Unsafe to use in noinstr code; use raw_atomic_dec() there.
586+ *
587+ * Return: Nothing.
588+ */
254589 static __always_inline void
255590 atomic_dec(atomic_t *v)
256591 {
257592 instrument_atomic_read_write(v, sizeof(*v));
258− arch_atomic_dec(v);
593+ raw_atomic_dec(v);
259594 }
260595
596+/**
597+ * atomic_dec_return() - atomic decrement with full ordering
598+ * @v: pointer to atomic_t
599+ *
600+ * Atomically updates @v to (@v - 1) with full ordering.
601+ *
602+ * Unsafe to use in noinstr code; use raw_atomic_dec_return() there.
603+ *
604+ * Return: The updated value of @v.
605+ */
261606 static __always_inline int
262607 atomic_dec_return(atomic_t *v)
263608 {
264609 kcsan_mb();
265610 instrument_atomic_read_write(v, sizeof(*v));
266− return arch_atomic_dec_return(v);
611+ return raw_atomic_dec_return(v);
267612 }
268613
614+/**
615+ * atomic_dec_return_acquire() - atomic decrement with acquire ordering
616+ * @v: pointer to atomic_t
617+ *
618+ * Atomically updates @v to (@v - 1) with acquire ordering.
619+ *
620+ * Unsafe to use in noinstr code; use raw_atomic_dec_return_acquire() there.
621+ *
622+ * Return: The updated value of @v.
623+ */
269624 static __always_inline int
270625 atomic_dec_return_acquire(atomic_t *v)
271626 {
272627 instrument_atomic_read_write(v, sizeof(*v));
273− return arch_atomic_dec_return_acquire(v);
628+ return raw_atomic_dec_return_acquire(v);
274629 }
275630
631+/**
632+ * atomic_dec_return_release() - atomic decrement with release ordering
633+ * @v: pointer to atomic_t
634+ *
635+ * Atomically updates @v to (@v - 1) with release ordering.
636+ *
637+ * Unsafe to use in noinstr code; use raw_atomic_dec_return_release() there.
638+ *
639+ * Return: The updated value of @v.
640+ */
276641 static __always_inline int
277642 atomic_dec_return_release(atomic_t *v)
278643 {
279644 kcsan_release();
280645 instrument_atomic_read_write(v, sizeof(*v));
281− return arch_atomic_dec_return_release(v);
646+ return raw_atomic_dec_return_release(v);
282647 }
283648
649+/**
650+ * atomic_dec_return_relaxed() - atomic decrement with relaxed ordering
651+ * @v: pointer to atomic_t
652+ *
653+ * Atomically updates @v to (@v - 1) with relaxed ordering.
654+ *
655+ * Unsafe to use in noinstr code; use raw_atomic_dec_return_relaxed() there.
656+ *
657+ * Return: The updated value of @v.
658+ */
284659 static __always_inline int
285660 atomic_dec_return_relaxed(atomic_t *v)
286661 {
287662 instrument_atomic_read_write(v, sizeof(*v));
288− return arch_atomic_dec_return_relaxed(v);
663+ return raw_atomic_dec_return_relaxed(v);
289664 }
290665
666+/**
667+ * atomic_fetch_dec() - atomic decrement with full ordering
668+ * @v: pointer to atomic_t
669+ *
670+ * Atomically updates @v to (@v - 1) with full ordering.
671+ *
672+ * Unsafe to use in noinstr code; use raw_atomic_fetch_dec() there.
673+ *
674+ * Return: The original value of @v.
675+ */
291676 static __always_inline int
292677 atomic_fetch_dec(atomic_t *v)
293678 {
294679 kcsan_mb();
295680 instrument_atomic_read_write(v, sizeof(*v));
296− return arch_atomic_fetch_dec(v);
681+ return raw_atomic_fetch_dec(v);
297682 }
298683
684+/**
685+ * atomic_fetch_dec_acquire() - atomic decrement with acquire ordering
686+ * @v: pointer to atomic_t
687+ *
688+ * Atomically updates @v to (@v - 1) with acquire ordering.
689+ *
690+ * Unsafe to use in noinstr code; use raw_atomic_fetch_dec_acquire() there.
691+ *
692+ * Return: The original value of @v.
693+ */
299694 static __always_inline int
300695 atomic_fetch_dec_acquire(atomic_t *v)
301696 {
302697 instrument_atomic_read_write(v, sizeof(*v));
303− return arch_atomic_fetch_dec_acquire(v);
698+ return raw_atomic_fetch_dec_acquire(v);
304699 }
305700
701+/**
702+ * atomic_fetch_dec_release() - atomic decrement with release ordering
703+ * @v: pointer to atomic_t
704+ *
705+ * Atomically updates @v to (@v - 1) with release ordering.
706+ *
707+ * Unsafe to use in noinstr code; use raw_atomic_fetch_dec_release() there.
708+ *
709+ * Return: The original value of @v.
710+ */
306711 static __always_inline int
307712 atomic_fetch_dec_release(atomic_t *v)
308713 {
309714 kcsan_release();
310715 instrument_atomic_read_write(v, sizeof(*v));
311− return arch_atomic_fetch_dec_release(v);
716+ return raw_atomic_fetch_dec_release(v);
312717 }
313718
719+/**
720+ * atomic_fetch_dec_relaxed() - atomic decrement with relaxed ordering
721+ * @v: pointer to atomic_t
722+ *
723+ * Atomically updates @v to (@v - 1) with relaxed ordering.
724+ *
725+ * Unsafe to use in noinstr code; use raw_atomic_fetch_dec_relaxed() there.
726+ *
727+ * Return: The original value of @v.
728+ */
314729 static __always_inline int
315730 atomic_fetch_dec_relaxed(atomic_t *v)
316731 {
317732 instrument_atomic_read_write(v, sizeof(*v));
318− return arch_atomic_fetch_dec_relaxed(v);
733+ return raw_atomic_fetch_dec_relaxed(v);
319734 }
320735
736+/**
737+ * atomic_and() - atomic bitwise AND with relaxed ordering
738+ * @i: int value
739+ * @v: pointer to atomic_t
740+ *
741+ * Atomically updates @v to (@v & @i) with relaxed ordering.
742+ *
743+ * Unsafe to use in noinstr code; use raw_atomic_and() there.
744+ *
745+ * Return: Nothing.
746+ */
321747 static __always_inline void
322748 atomic_and(int i, atomic_t *v)
323749 {
324750 instrument_atomic_read_write(v, sizeof(*v));
325− arch_atomic_and(i, v);
751+ raw_atomic_and(i, v);
326752 }
327753
754+/**
755+ * atomic_fetch_and() - atomic bitwise AND with full ordering
756+ * @i: int value
757+ * @v: pointer to atomic_t
758+ *
759+ * Atomically updates @v to (@v & @i) with full ordering.
760+ *
761+ * Unsafe to use in noinstr code; use raw_atomic_fetch_and() there.
762+ *
763+ * Return: The original value of @v.
764+ */
328765 static __always_inline int
329766 atomic_fetch_and(int i, atomic_t *v)
330767 {
331768 kcsan_mb();
332769 instrument_atomic_read_write(v, sizeof(*v));
333− return arch_atomic_fetch_and(i, v);
770+ return raw_atomic_fetch_and(i, v);
334771 }
335772
773+/**
774+ * atomic_fetch_and_acquire() - atomic bitwise AND with acquire ordering
775+ * @i: int value
776+ * @v: pointer to atomic_t
777+ *
778+ * Atomically updates @v to (@v & @i) with acquire ordering.
779+ *
780+ * Unsafe to use in noinstr code; use raw_atomic_fetch_and_acquire() there.
781+ *
782+ * Return: The original value of @v.
783+ */
336784 static __always_inline int
337785 atomic_fetch_and_acquire(int i, atomic_t *v)
338786 {
339787 instrument_atomic_read_write(v, sizeof(*v));
340− return arch_atomic_fetch_and_acquire(i, v);
788+ return raw_atomic_fetch_and_acquire(i, v);
341789 }
342790
791+/**
792+ * atomic_fetch_and_release() - atomic bitwise AND with release ordering
793+ * @i: int value
794+ * @v: pointer to atomic_t
795+ *
796+ * Atomically updates @v to (@v & @i) with release ordering.
797+ *
798+ * Unsafe to use in noinstr code; use raw_atomic_fetch_and_release() there.
799+ *
800+ * Return: The original value of @v.
801+ */
343802 static __always_inline int
344803 atomic_fetch_and_release(int i, atomic_t *v)
345804 {
346805 kcsan_release();
347806 instrument_atomic_read_write(v, sizeof(*v));
348− return arch_atomic_fetch_and_release(i, v);
807+ return raw_atomic_fetch_and_release(i, v);
349808 }
350809
810+/**
811+ * atomic_fetch_and_relaxed() - atomic bitwise AND with relaxed ordering
812+ * @i: int value
813+ * @v: pointer to atomic_t
814+ *
815+ * Atomically updates @v to (@v & @i) with relaxed ordering.
816+ *
817+ * Unsafe to use in noinstr code; use raw_atomic_fetch_and_relaxed() there.
818+ *
819+ * Return: The original value of @v.
820+ */
351821 static __always_inline int
352822 atomic_fetch_and_relaxed(int i, atomic_t *v)
353823 {
354824 instrument_atomic_read_write(v, sizeof(*v));
355− return arch_atomic_fetch_and_relaxed(i, v);
825+ return raw_atomic_fetch_and_relaxed(i, v);
356826 }
357827
828+/**
829+ * atomic_andnot() - atomic bitwise AND NOT with relaxed ordering
830+ * @i: int value
831+ * @v: pointer to atomic_t
832+ *
833+ * Atomically updates @v to (@v & ~@i) with relaxed ordering.
834+ *
835+ * Unsafe to use in noinstr code; use raw_atomic_andnot() there.
836+ *
837+ * Return: Nothing.
838+ */
358839 static __always_inline void
359840 atomic_andnot(int i, atomic_t *v)
360841 {
361842 instrument_atomic_read_write(v, sizeof(*v));
362− arch_atomic_andnot(i, v);
843+ raw_atomic_andnot(i, v);
363844 }
364845
846+/**
847+ * atomic_fetch_andnot() - atomic bitwise AND NOT with full ordering
848+ * @i: int value
849+ * @v: pointer to atomic_t
850+ *
851+ * Atomically updates @v to (@v & ~@i) with full ordering.
852+ *
853+ * Unsafe to use in noinstr code; use raw_atomic_fetch_andnot() there.
854+ *
855+ * Return: The original value of @v.
856+ */
365857 static __always_inline int
366858 atomic_fetch_andnot(int i, atomic_t *v)
367859 {
368860 kcsan_mb();
369861 instrument_atomic_read_write(v, sizeof(*v));
370− return arch_atomic_fetch_andnot(i, v);
862+ return raw_atomic_fetch_andnot(i, v);
371863 }
372864
865+/**
866+ * atomic_fetch_andnot_acquire() - atomic bitwise AND NOT with acquire ordering
867+ * @i: int value
868+ * @v: pointer to atomic_t
869+ *
870+ * Atomically updates @v to (@v & ~@i) with acquire ordering.
871+ *
872+ * Unsafe to use in noinstr code; use raw_atomic_fetch_andnot_acquire() there.
873+ *
874+ * Return: The original value of @v.
875+ */
373876 static __always_inline int
374877 atomic_fetch_andnot_acquire(int i, atomic_t *v)
375878 {
376879 instrument_atomic_read_write(v, sizeof(*v));
377− return arch_atomic_fetch_andnot_acquire(i, v);
880+ return raw_atomic_fetch_andnot_acquire(i, v);
378881 }
379882
883+/**
884+ * atomic_fetch_andnot_release() - atomic bitwise AND NOT with release ordering
885+ * @i: int value
886+ * @v: pointer to atomic_t
887+ *
888+ * Atomically updates @v to (@v & ~@i) with release ordering.
889+ *
890+ * Unsafe to use in noinstr code; use raw_atomic_fetch_andnot_release() there.
891+ *
892+ * Return: The original value of @v.
893+ */
380894 static __always_inline int
381895 atomic_fetch_andnot_release(int i, atomic_t *v)
382896 {
383897 kcsan_release();
384898 instrument_atomic_read_write(v, sizeof(*v));
385− return arch_atomic_fetch_andnot_release(i, v);
899+ return raw_atomic_fetch_andnot_release(i, v);
386900 }
387901
902+/**
903+ * atomic_fetch_andnot_relaxed() - atomic bitwise AND NOT with relaxed ordering
904+ * @i: int value
905+ * @v: pointer to atomic_t
906+ *
907+ * Atomically updates @v to (@v & ~@i) with relaxed ordering.
908+ *
909+ * Unsafe to use in noinstr code; use raw_atomic_fetch_andnot_relaxed() there.
910+ *
911+ * Return: The original value of @v.
912+ */
388913 static __always_inline int
389914 atomic_fetch_andnot_relaxed(int i, atomic_t *v)
390915 {
391916 instrument_atomic_read_write(v, sizeof(*v));
392− return arch_atomic_fetch_andnot_relaxed(i, v);
917+ return raw_atomic_fetch_andnot_relaxed(i, v);
393918 }
394919
920+/**
921+ * atomic_or() - atomic bitwise OR with relaxed ordering
922+ * @i: int value
923+ * @v: pointer to atomic_t
924+ *
925+ * Atomically updates @v to (@v | @i) with relaxed ordering.
926+ *
927+ * Unsafe to use in noinstr code; use raw_atomic_or() there.
928+ *
929+ * Return: Nothing.
930+ */
395931 static __always_inline void
396932 atomic_or(int i, atomic_t *v)
397933 {
398934 instrument_atomic_read_write(v, sizeof(*v));
399− arch_atomic_or(i, v);
935+ raw_atomic_or(i, v);
400936 }
401937
938+/**
939+ * atomic_fetch_or() - atomic bitwise OR with full ordering
940+ * @i: int value
941+ * @v: pointer to atomic_t
942+ *
943+ * Atomically updates @v to (@v | @i) with full ordering.
944+ *
945+ * Unsafe to use in noinstr code; use raw_atomic_fetch_or() there.
946+ *
947+ * Return: The original value of @v.
948+ */
402949 static __always_inline int
403950 atomic_fetch_or(int i, atomic_t *v)
404951 {
405952 kcsan_mb();
406953 instrument_atomic_read_write(v, sizeof(*v));
407− return arch_atomic_fetch_or(i, v);
954+ return raw_atomic_fetch_or(i, v);
408955 }
409956
957+/**
958+ * atomic_fetch_or_acquire() - atomic bitwise OR with acquire ordering
959+ * @i: int value
960+ * @v: pointer to atomic_t
961+ *
962+ * Atomically updates @v to (@v | @i) with acquire ordering.
963+ *
964+ * Unsafe to use in noinstr code; use raw_atomic_fetch_or_acquire() there.
965+ *
966+ * Return: The original value of @v.
967+ */
410968 static __always_inline int
411969 atomic_fetch_or_acquire(int i, atomic_t *v)
412970 {
413971 instrument_atomic_read_write(v, sizeof(*v));
414− return arch_atomic_fetch_or_acquire(i, v);
972+ return raw_atomic_fetch_or_acquire(i, v);
415973 }
416974
975+/**
976+ * atomic_fetch_or_release() - atomic bitwise OR with release ordering
977+ * @i: int value
978+ * @v: pointer to atomic_t
979+ *
980+ * Atomically updates @v to (@v | @i) with release ordering.
981+ *
982+ * Unsafe to use in noinstr code; use raw_atomic_fetch_or_release() there.
983+ *
984+ * Return: The original value of @v.
985+ */
417986 static __always_inline int
418987 atomic_fetch_or_release(int i, atomic_t *v)
419988 {
420989 kcsan_release();
421990 instrument_atomic_read_write(v, sizeof(*v));
422− return arch_atomic_fetch_or_release(i, v);
991+ return raw_atomic_fetch_or_release(i, v);
423992 }
424993
994+/**
995+ * atomic_fetch_or_relaxed() - atomic bitwise OR with relaxed ordering
996+ * @i: int value
997+ * @v: pointer to atomic_t
998+ *
999+ * Atomically updates @v to (@v | @i) with relaxed ordering.
1000+ *
1001+ * Unsafe to use in noinstr code; use raw_atomic_fetch_or_relaxed() there.
1002+ *
1003+ * Return: The original value of @v.
1004+ */
4251005 static __always_inline int
4261006 atomic_fetch_or_relaxed(int i, atomic_t *v)
4271007 {
4281008 instrument_atomic_read_write(v, sizeof(*v));
429− return arch_atomic_fetch_or_relaxed(i, v);
1009+ return raw_atomic_fetch_or_relaxed(i, v);
4301010 }
4311011
1012+/**
1013+ * atomic_xor() - atomic bitwise XOR with relaxed ordering
1014+ * @i: int value
1015+ * @v: pointer to atomic_t
1016+ *
1017+ * Atomically updates @v to (@v ^ @i) with relaxed ordering.
1018+ *
1019+ * Unsafe to use in noinstr code; use raw_atomic_xor() there.
1020+ *
1021+ * Return: Nothing.
1022+ */
4321023 static __always_inline void
4331024 atomic_xor(int i, atomic_t *v)
4341025 {
4351026 instrument_atomic_read_write(v, sizeof(*v));
436− arch_atomic_xor(i, v);
1027+ raw_atomic_xor(i, v);
4371028 }
4381029
1030+/**
1031+ * atomic_fetch_xor() - atomic bitwise XOR with full ordering
1032+ * @i: int value
1033+ * @v: pointer to atomic_t
1034+ *
1035+ * Atomically updates @v to (@v ^ @i) with full ordering.
1036+ *
1037+ * Unsafe to use in noinstr code; use raw_atomic_fetch_xor() there.
1038+ *
1039+ * Return: The original value of @v.
1040+ */
4391041 static __always_inline int
4401042 atomic_fetch_xor(int i, atomic_t *v)
4411043 {
4421044 kcsan_mb();
4431045 instrument_atomic_read_write(v, sizeof(*v));
444− return arch_atomic_fetch_xor(i, v);
1046+ return raw_atomic_fetch_xor(i, v);
4451047 }
4461048
1049+/**
1050+ * atomic_fetch_xor_acquire() - atomic bitwise XOR with acquire ordering
1051+ * @i: int value
1052+ * @v: pointer to atomic_t
1053+ *
1054+ * Atomically updates @v to (@v ^ @i) with acquire ordering.
1055+ *
1056+ * Unsafe to use in noinstr code; use raw_atomic_fetch_xor_acquire() there.
1057+ *
1058+ * Return: The original value of @v.
1059+ */
4471060 static __always_inline int
4481061 atomic_fetch_xor_acquire(int i, atomic_t *v)
4491062 {
4501063 instrument_atomic_read_write(v, sizeof(*v));
451− return arch_atomic_fetch_xor_acquire(i, v);
1064+ return raw_atomic_fetch_xor_acquire(i, v);
4521065 }
4531066
1067+/**
1068+ * atomic_fetch_xor_release() - atomic bitwise XOR with release ordering
1069+ * @i: int value
1070+ * @v: pointer to atomic_t
1071+ *
1072+ * Atomically updates @v to (@v ^ @i) with release ordering.
1073+ *
1074+ * Unsafe to use in noinstr code; use raw_atomic_fetch_xor_release() there.
1075+ *
1076+ * Return: The original value of @v.
1077+ */
4541078 static __always_inline int
4551079 atomic_fetch_xor_release(int i, atomic_t *v)
4561080 {
4571081 kcsan_release();
4581082 instrument_atomic_read_write(v, sizeof(*v));
459− return arch_atomic_fetch_xor_release(i, v);
1083+ return raw_atomic_fetch_xor_release(i, v);
4601084 }
4611085
1086+/**
1087+ * atomic_fetch_xor_relaxed() - atomic bitwise XOR with relaxed ordering
1088+ * @i: int value
1089+ * @v: pointer to atomic_t
1090+ *
1091+ * Atomically updates @v to (@v ^ @i) with relaxed ordering.
1092+ *
1093+ * Unsafe to use in noinstr code; use raw_atomic_fetch_xor_relaxed() there.
1094+ *
1095+ * Return: The original value of @v.
1096+ */
4621097 static __always_inline int
4631098 atomic_fetch_xor_relaxed(int i, atomic_t *v)
4641099 {
4651100 instrument_atomic_read_write(v, sizeof(*v));
466− return arch_atomic_fetch_xor_relaxed(i, v);
1101+ return raw_atomic_fetch_xor_relaxed(i, v);
4671102 }
4681103
1104+/**
1105+ * atomic_xchg() - atomic exchange with full ordering
1106+ * @v: pointer to atomic_t
1107+ * @new: int value to assign
1108+ *
1109+ * Atomically updates @v to @new with full ordering.
1110+ *
1111+ * Unsafe to use in noinstr code; use raw_atomic_xchg() there.
1112+ *
1113+ * Return: The original value of @v.
1114+ */
4691115 static __always_inline int
470−atomic_xchg(atomic_t *v, int i)
1116+atomic_xchg(atomic_t *v, int new)
4711117 {
4721118 kcsan_mb();
4731119 instrument_atomic_read_write(v, sizeof(*v));
474− return arch_atomic_xchg(v, i);
1120+ return raw_atomic_xchg(v, new);
4751121 }
4761122
1123+/**
1124+ * atomic_xchg_acquire() - atomic exchange with acquire ordering
1125+ * @v: pointer to atomic_t
1126+ * @new: int value to assign
1127+ *
1128+ * Atomically updates @v to @new with acquire ordering.
1129+ *
1130+ * Unsafe to use in noinstr code; use raw_atomic_xchg_acquire() there.
1131+ *
1132+ * Return: The original value of @v.
1133+ */
4771134 static __always_inline int
478−atomic_xchg_acquire(atomic_t *v, int i)
1135+atomic_xchg_acquire(atomic_t *v, int new)
4791136 {
4801137 instrument_atomic_read_write(v, sizeof(*v));
481− return arch_atomic_xchg_acquire(v, i);
1138+ return raw_atomic_xchg_acquire(v, new);
4821139 }
4831140
1141+/**
1142+ * atomic_xchg_release() - atomic exchange with release ordering
1143+ * @v: pointer to atomic_t
1144+ * @new: int value to assign
1145+ *
1146+ * Atomically updates @v to @new with release ordering.
1147+ *
1148+ * Unsafe to use in noinstr code; use raw_atomic_xchg_release() there.
1149+ *
1150+ * Return: The original value of @v.
1151+ */
4841152 static __always_inline int
485−atomic_xchg_release(atomic_t *v, int i)
1153+atomic_xchg_release(atomic_t *v, int new)
4861154 {
4871155 kcsan_release();
4881156 instrument_atomic_read_write(v, sizeof(*v));
489− return arch_atomic_xchg_release(v, i);
1157+ return raw_atomic_xchg_release(v, new);
4901158 }
4911159
1160+/**
1161+ * atomic_xchg_relaxed() - atomic exchange with relaxed ordering
1162+ * @v: pointer to atomic_t
1163+ * @new: int value to assign
1164+ *
1165+ * Atomically updates @v to @new with relaxed ordering.
1166+ *
1167+ * Unsafe to use in noinstr code; use raw_atomic_xchg_relaxed() there.
1168+ *
1169+ * Return: The original value of @v.
1170+ */
4921171 static __always_inline int
493−atomic_xchg_relaxed(atomic_t *v, int i)
1172+atomic_xchg_relaxed(atomic_t *v, int new)
4941173 {
4951174 instrument_atomic_read_write(v, sizeof(*v));
496− return arch_atomic_xchg_relaxed(v, i);
1175+ return raw_atomic_xchg_relaxed(v, new);
4971176 }
4981177
1178+/**
1179+ * atomic_cmpxchg() - atomic compare and exchange with full ordering
1180+ * @v: pointer to atomic_t
1181+ * @old: int value to compare with
1182+ * @new: int value to assign
1183+ *
1184+ * If (@v == @old), atomically updates @v to @new with full ordering.
1185+ *
1186+ * Unsafe to use in noinstr code; use raw_atomic_cmpxchg() there.
1187+ *
1188+ * Return: The original value of @v.
1189+ */
4991190 static __always_inline int
5001191 atomic_cmpxchg(atomic_t *v, int old, int new)
5011192 {
5021193 kcsan_mb();
5031194 instrument_atomic_read_write(v, sizeof(*v));
504− return arch_atomic_cmpxchg(v, old, new);
1195+ return raw_atomic_cmpxchg(v, old, new);
5051196 }
5061197
1198+/**
1199+ * atomic_cmpxchg_acquire() - atomic compare and exchange with acquire ordering
1200+ * @v: pointer to atomic_t
1201+ * @old: int value to compare with
1202+ * @new: int value to assign
1203+ *
1204+ * If (@v == @old), atomically updates @v to @new with acquire ordering.
1205+ *
1206+ * Unsafe to use in noinstr code; use raw_atomic_cmpxchg_acquire() there.
1207+ *
1208+ * Return: The original value of @v.
1209+ */
5071210 static __always_inline int
5081211 atomic_cmpxchg_acquire(atomic_t *v, int old, int new)
5091212 {
5101213 instrument_atomic_read_write(v, sizeof(*v));
511− return arch_atomic_cmpxchg_acquire(v, old, new);
1214+ return raw_atomic_cmpxchg_acquire(v, old, new);
5121215 }
5131216
1217+/**
1218+ * atomic_cmpxchg_release() - atomic compare and exchange with release ordering
1219+ * @v: pointer to atomic_t
1220+ * @old: int value to compare with
1221+ * @new: int value to assign
1222+ *
1223+ * If (@v == @old), atomically updates @v to @new with release ordering.
1224+ *
1225+ * Unsafe to use in noinstr code; use raw_atomic_cmpxchg_release() there.
1226+ *
1227+ * Return: The original value of @v.
1228+ */
5141229 static __always_inline int
5151230 atomic_cmpxchg_release(atomic_t *v, int old, int new)
5161231 {
5171232 kcsan_release();
5181233 instrument_atomic_read_write(v, sizeof(*v));
519− return arch_atomic_cmpxchg_release(v, old, new);
1234+ return raw_atomic_cmpxchg_release(v, old, new);
5201235 }
5211236
1237+/**
1238+ * atomic_cmpxchg_relaxed() - atomic compare and exchange with relaxed ordering
1239+ * @v: pointer to atomic_t
1240+ * @old: int value to compare with
1241+ * @new: int value to assign
1242+ *
1243+ * If (@v == @old), atomically updates @v to @new with relaxed ordering.
1244+ *
1245+ * Unsafe to use in noinstr code; use raw_atomic_cmpxchg_relaxed() there.
1246+ *
1247+ * Return: The original value of @v.
1248+ */
5221249 static __always_inline int
5231250 atomic_cmpxchg_relaxed(atomic_t *v, int old, int new)
5241251 {
5251252 instrument_atomic_read_write(v, sizeof(*v));
526− return arch_atomic_cmpxchg_relaxed(v, old, new);
1253+ return raw_atomic_cmpxchg_relaxed(v, old, new);
5271254 }
5281255
1256+/**
1257+ * atomic_try_cmpxchg() - atomic compare and exchange with full ordering
1258+ * @v: pointer to atomic_t
1259+ * @old: pointer to int value to compare with
1260+ * @new: int value to assign
1261+ *
1262+ * If (@v == @old), atomically updates @v to @new with full ordering.
1263+ * Otherwise, updates @old to the current value of @v.
1264+ *
1265+ * Unsafe to use in noinstr code; use raw_atomic_try_cmpxchg() there.
1266+ *
1267+ * Return: @true if the exchange occured, @false otherwise.
1268+ */
5291269 static __always_inline bool
5301270 atomic_try_cmpxchg(atomic_t *v, int *old, int new)
5311271 {
5321272 kcsan_mb();
5331273 instrument_atomic_read_write(v, sizeof(*v));
5341274 instrument_atomic_read_write(old, sizeof(*old));
535− return arch_atomic_try_cmpxchg(v, old, new);
536−}
537−
1275+ return raw_atomic_try_cmpxchg(v, old, new);
1276+}
1277+
1278+/**
1279+ * atomic_try_cmpxchg_acquire() - atomic compare and exchange with acquire ordering
1280+ * @v: pointer to atomic_t
1281+ * @old: pointer to int value to compare with
1282+ * @new: int value to assign
1283+ *
1284+ * If (@v == @old), atomically updates @v to @new with acquire ordering.
1285+ * Otherwise, updates @old to the current value of @v.
1286+ *
1287+ * Unsafe to use in noinstr code; use raw_atomic_try_cmpxchg_acquire() there.
1288+ *
1289+ * Return: @true if the exchange occured, @false otherwise.
1290+ */
5381291 static __always_inline bool
5391292 atomic_try_cmpxchg_acquire(atomic_t *v, int *old, int new)
5401293 {
5411294 instrument_atomic_read_write(v, sizeof(*v));
5421295 instrument_atomic_read_write(old, sizeof(*old));
543− return arch_atomic_try_cmpxchg_acquire(v, old, new);
544−}
545−
1296+ return raw_atomic_try_cmpxchg_acquire(v, old, new);
1297+}
1298+
1299+/**
1300+ * atomic_try_cmpxchg_release() - atomic compare and exchange with release ordering
1301+ * @v: pointer to atomic_t
1302+ * @old: pointer to int value to compare with
1303+ * @new: int value to assign
1304+ *
1305+ * If (@v == @old), atomically updates @v to @new with release ordering.
1306+ * Otherwise, updates @old to the current value of @v.
1307+ *
1308+ * Unsafe to use in noinstr code; use raw_atomic_try_cmpxchg_release() there.
1309+ *
1310+ * Return: @true if the exchange occured, @false otherwise.
1311+ */
5461312 static __always_inline bool
5471313 atomic_try_cmpxchg_release(atomic_t *v, int *old, int new)
5481314 {
5491315 kcsan_release();
5501316 instrument_atomic_read_write(v, sizeof(*v));
5511317 instrument_atomic_read_write(old, sizeof(*old));
552− return arch_atomic_try_cmpxchg_release(v, old, new);
553−}
554−
1318+ return raw_atomic_try_cmpxchg_release(v, old, new);
1319+}
1320+
1321+/**
1322+ * atomic_try_cmpxchg_relaxed() - atomic compare and exchange with relaxed ordering
1323+ * @v: pointer to atomic_t
1324+ * @old: pointer to int value to compare with
1325+ * @new: int value to assign
1326+ *
1327+ * If (@v == @old), atomically updates @v to @new with relaxed ordering.
1328+ * Otherwise, updates @old to the current value of @v.
1329+ *
1330+ * Unsafe to use in noinstr code; use raw_atomic_try_cmpxchg_relaxed() there.
1331+ *
1332+ * Return: @true if the exchange occured, @false otherwise.
1333+ */
5551334 static __always_inline bool
5561335 atomic_try_cmpxchg_relaxed(atomic_t *v, int *old, int new)
5571336 {
5581337 instrument_atomic_read_write(v, sizeof(*v));
5591338 instrument_atomic_read_write(old, sizeof(*old));
560− return arch_atomic_try_cmpxchg_relaxed(v, old, new);
561−}
562−
1339+ return raw_atomic_try_cmpxchg_relaxed(v, old, new);
1340+}
1341+
1342+/**
1343+ * atomic_sub_and_test() - atomic subtract and test if zero with full ordering
1344+ * @i: int value to add
1345+ * @v: pointer to atomic_t
1346+ *
1347+ * Atomically updates @v to (@v - @i) with full ordering.
1348+ *
1349+ * Unsafe to use in noinstr code; use raw_atomic_sub_and_test() there.
1350+ *
1351+ * Return: @true if the resulting value of @v is zero, @false otherwise.
1352+ */
5631353 static __always_inline bool
5641354 atomic_sub_and_test(int i, atomic_t *v)
5651355 {
5661356 kcsan_mb();
5671357 instrument_atomic_read_write(v, sizeof(*v));
568− return arch_atomic_sub_and_test(i, v);
1358+ return raw_atomic_sub_and_test(i, v);
5691359 }
5701360
1361+/**
1362+ * atomic_dec_and_test() - atomic decrement and test if zero with full ordering
1363+ * @v: pointer to atomic_t
1364+ *
1365+ * Atomically updates @v to (@v - 1) with full ordering.
1366+ *
1367+ * Unsafe to use in noinstr code; use raw_atomic_dec_and_test() there.
1368+ *
1369+ * Return: @true if the resulting value of @v is zero, @false otherwise.
1370+ */
5711371 static __always_inline bool
5721372 atomic_dec_and_test(atomic_t *v)
5731373 {
5741374 kcsan_mb();
5751375 instrument_atomic_read_write(v, sizeof(*v));
576− return arch_atomic_dec_and_test(v);
1376+ return raw_atomic_dec_and_test(v);
5771377 }
5781378
1379+/**
1380+ * atomic_inc_and_test() - atomic increment and test if zero with full ordering
1381+ * @v: pointer to atomic_t
1382+ *
1383+ * Atomically updates @v to (@v + 1) with full ordering.
1384+ *
1385+ * Unsafe to use in noinstr code; use raw_atomic_inc_and_test() there.
1386+ *
1387+ * Return: @true if the resulting value of @v is zero, @false otherwise.
1388+ */
5791389 static __always_inline bool
5801390 atomic_inc_and_test(atomic_t *v)
5811391 {
5821392 kcsan_mb();
5831393 instrument_atomic_read_write(v, sizeof(*v));
584− return arch_atomic_inc_and_test(v);
1394+ return raw_atomic_inc_and_test(v);
5851395 }
5861396
1397+/**
1398+ * atomic_add_negative() - atomic add and test if negative with full ordering
1399+ * @i: int value to add
1400+ * @v: pointer to atomic_t
1401+ *
1402+ * Atomically updates @v to (@v + @i) with full ordering.
1403+ *
1404+ * Unsafe to use in noinstr code; use raw_atomic_add_negative() there.
1405+ *
1406+ * Return: @true if the resulting value of @v is negative, @false otherwise.
1407+ */
5871408 static __always_inline bool
5881409 atomic_add_negative(int i, atomic_t *v)
5891410 {
5901411 kcsan_mb();
5911412 instrument_atomic_read_write(v, sizeof(*v));
592− return arch_atomic_add_negative(i, v);
1413+ return raw_atomic_add_negative(i, v);
5931414 }
5941415
1416+/**
1417+ * atomic_add_negative_acquire() - atomic add and test if negative with acquire ordering
1418+ * @i: int value to add
1419+ * @v: pointer to atomic_t
1420+ *
1421+ * Atomically updates @v to (@v + @i) with acquire ordering.
1422+ *
1423+ * Unsafe to use in noinstr code; use raw_atomic_add_negative_acquire() there.
1424+ *
1425+ * Return: @true if the resulting value of @v is negative, @false otherwise.
1426+ */
5951427 static __always_inline bool
5961428 atomic_add_negative_acquire(int i, atomic_t *v)
5971429 {
5981430 instrument_atomic_read_write(v, sizeof(*v));
599− return arch_atomic_add_negative_acquire(i, v);
1431+ return raw_atomic_add_negative_acquire(i, v);
6001432 }
6011433
1434+/**
1435+ * atomic_add_negative_release() - atomic add and test if negative with release ordering
1436+ * @i: int value to add
1437+ * @v: pointer to atomic_t
1438+ *
1439+ * Atomically updates @v to (@v + @i) with release ordering.
1440+ *
1441+ * Unsafe to use in noinstr code; use raw_atomic_add_negative_release() there.
1442+ *
1443+ * Return: @true if the resulting value of @v is negative, @false otherwise.
1444+ */
6021445 static __always_inline bool
6031446 atomic_add_negative_release(int i, atomic_t *v)
6041447 {
6051448 kcsan_release();
6061449 instrument_atomic_read_write(v, sizeof(*v));
607− return arch_atomic_add_negative_release(i, v);
1450+ return raw_atomic_add_negative_release(i, v);
6081451 }
6091452
1453+/**
1454+ * atomic_add_negative_relaxed() - atomic add and test if negative with relaxed ordering
1455+ * @i: int value to add
1456+ * @v: pointer to atomic_t
1457+ *
1458+ * Atomically updates @v to (@v + @i) with relaxed ordering.
1459+ *
1460+ * Unsafe to use in noinstr code; use raw_atomic_add_negative_relaxed() there.
1461+ *
1462+ * Return: @true if the resulting value of @v is negative, @false otherwise.
1463+ */
6101464 static __always_inline bool
6111465 atomic_add_negative_relaxed(int i, atomic_t *v)
6121466 {
6131467 instrument_atomic_read_write(v, sizeof(*v));
614− return arch_atomic_add_negative_relaxed(i, v);
1468+ return raw_atomic_add_negative_relaxed(i, v);
6151469 }
6161470
1471+/**
1472+ * atomic_fetch_add_unless() - atomic add unless value with full ordering
1473+ * @v: pointer to atomic_t
1474+ * @a: int value to add
1475+ * @u: int value to compare with
1476+ *
1477+ * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
1478+ *
1479+ * Unsafe to use in noinstr code; use raw_atomic_fetch_add_unless() there.
1480+ *
1481+ * Return: The original value of @v.
1482+ */
6171483 static __always_inline int
6181484 atomic_fetch_add_unless(atomic_t *v, int a, int u)
6191485 {
6201486 kcsan_mb();
6211487 instrument_atomic_read_write(v, sizeof(*v));
622− return arch_atomic_fetch_add_unless(v, a, u);
1488+ return raw_atomic_fetch_add_unless(v, a, u);
6231489 }
6241490
1491+/**
1492+ * atomic_add_unless() - atomic add unless value with full ordering
1493+ * @v: pointer to atomic_t
1494+ * @a: int value to add
1495+ * @u: int value to compare with
1496+ *
1497+ * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
1498+ *
1499+ * Unsafe to use in noinstr code; use raw_atomic_add_unless() there.
1500+ *
1501+ * Return: @true if @v was updated, @false otherwise.
1502+ */
6251503 static __always_inline bool
6261504 atomic_add_unless(atomic_t *v, int a, int u)
6271505 {
6281506 kcsan_mb();
6291507 instrument_atomic_read_write(v, sizeof(*v));
630− return arch_atomic_add_unless(v, a, u);
1508+ return raw_atomic_add_unless(v, a, u);
6311509 }
6321510
1511+/**
1512+ * atomic_inc_not_zero() - atomic increment unless zero with full ordering
1513+ * @v: pointer to atomic_t
1514+ *
1515+ * If (@v != 0), atomically updates @v to (@v + 1) with full ordering.
1516+ *
1517+ * Unsafe to use in noinstr code; use raw_atomic_inc_not_zero() there.
1518+ *
1519+ * Return: @true if @v was updated, @false otherwise.
1520+ */
6331521 static __always_inline bool
6341522 atomic_inc_not_zero(atomic_t *v)
6351523 {
6361524 kcsan_mb();
6371525 instrument_atomic_read_write(v, sizeof(*v));
638− return arch_atomic_inc_not_zero(v);
1526+ return raw_atomic_inc_not_zero(v);
6391527 }
6401528
1529+/**
1530+ * atomic_inc_unless_negative() - atomic increment unless negative with full ordering
1531+ * @v: pointer to atomic_t
1532+ *
1533+ * If (@v >= 0), atomically updates @v to (@v + 1) with full ordering.
1534+ *
1535+ * Unsafe to use in noinstr code; use raw_atomic_inc_unless_negative() there.
1536+ *
1537+ * Return: @true if @v was updated, @false otherwise.
1538+ */
6411539 static __always_inline bool
6421540 atomic_inc_unless_negative(atomic_t *v)
6431541 {
6441542 kcsan_mb();
6451543 instrument_atomic_read_write(v, sizeof(*v));
646− return arch_atomic_inc_unless_negative(v);
1544+ return raw_atomic_inc_unless_negative(v);
6471545 }
6481546
1547+/**
1548+ * atomic_dec_unless_positive() - atomic decrement unless positive with full ordering
1549+ * @v: pointer to atomic_t
1550+ *
1551+ * If (@v <= 0), atomically updates @v to (@v - 1) with full ordering.
1552+ *
1553+ * Unsafe to use in noinstr code; use raw_atomic_dec_unless_positive() there.
1554+ *
1555+ * Return: @true if @v was updated, @false otherwise.
1556+ */
6491557 static __always_inline bool
6501558 atomic_dec_unless_positive(atomic_t *v)
6511559 {
6521560 kcsan_mb();
6531561 instrument_atomic_read_write(v, sizeof(*v));
654− return arch_atomic_dec_unless_positive(v);
1562+ return raw_atomic_dec_unless_positive(v);
6551563 }
6561564
1565+/**
1566+ * atomic_dec_if_positive() - atomic decrement if positive with full ordering
1567+ * @v: pointer to atomic_t
1568+ *
1569+ * If (@v > 0), atomically updates @v to (@v - 1) with full ordering.
1570+ *
1571+ * Unsafe to use in noinstr code; use raw_atomic_dec_if_positive() there.
1572+ *
1573+ * Return: The old value of (@v - 1), regardless of whether @v was updated.
1574+ */
6571575 static __always_inline int
6581576 atomic_dec_if_positive(atomic_t *v)
6591577 {
6601578 kcsan_mb();
6611579 instrument_atomic_read_write(v, sizeof(*v));
662− return arch_atomic_dec_if_positive(v);
1580+ return raw_atomic_dec_if_positive(v);
6631581 }
6641582
1583+/**
1584+ * atomic64_read() - atomic load with relaxed ordering
1585+ * @v: pointer to atomic64_t
1586+ *
1587+ * Atomically loads the value of @v with relaxed ordering.
1588+ *
1589+ * Unsafe to use in noinstr code; use raw_atomic64_read() there.
1590+ *
1591+ * Return: The value loaded from @v.
1592+ */
6651593 static __always_inline s64
6661594 atomic64_read(const atomic64_t *v)
6671595 {
6681596 instrument_atomic_read(v, sizeof(*v));
669− return arch_atomic64_read(v);
670−}
671−
1597+ return raw_atomic64_read(v);
1598+}
1599+
1600+/**
1601+ * atomic64_read_acquire() - atomic load with acquire ordering
1602+ * @v: pointer to atomic64_t
1603+ *
1604+ * Atomically loads the value of @v with acquire ordering.
1605+ *
1606+ * Unsafe to use in noinstr code; use raw_atomic64_read_acquire() there.
1607+ *
1608+ * Return: The value loaded from @v.
1609+ */
6721610 static __always_inline s64
6731611 atomic64_read_acquire(const atomic64_t *v)
6741612 {
6751613 instrument_atomic_read(v, sizeof(*v));
676− return arch_atomic64_read_acquire(v);
677−}
678−
1614+ return raw_atomic64_read_acquire(v);
1615+}
1616+
1617+/**
1618+ * atomic64_set() - atomic set with relaxed ordering
1619+ * @v: pointer to atomic64_t
1620+ * @i: s64 value to assign
1621+ *
1622+ * Atomically sets @v to @i with relaxed ordering.
1623+ *
1624+ * Unsafe to use in noinstr code; use raw_atomic64_set() there.
1625+ *
1626+ * Return: Nothing.
1627+ */
6791628 static __always_inline void
6801629 atomic64_set(atomic64_t *v, s64 i)
6811630 {
6821631 instrument_atomic_write(v, sizeof(*v));
683− arch_atomic64_set(v, i);
684−}
685−
1632+ raw_atomic64_set(v, i);
1633+}
1634+
1635+/**
1636+ * atomic64_set_release() - atomic set with release ordering
1637+ * @v: pointer to atomic64_t
1638+ * @i: s64 value to assign
1639+ *
1640+ * Atomically sets @v to @i with release ordering.
1641+ *
1642+ * Unsafe to use in noinstr code; use raw_atomic64_set_release() there.
1643+ *
1644+ * Return: Nothing.
1645+ */
6861646 static __always_inline void
6871647 atomic64_set_release(atomic64_t *v, s64 i)
6881648 {
6891649 kcsan_release();
6901650 instrument_atomic_write(v, sizeof(*v));
691− arch_atomic64_set_release(v, i);
692−}
693−
1651+ raw_atomic64_set_release(v, i);
1652+}
1653+
1654+/**
1655+ * atomic64_add() - atomic add with relaxed ordering
1656+ * @i: s64 value to add
1657+ * @v: pointer to atomic64_t
1658+ *
1659+ * Atomically updates @v to (@v + @i) with relaxed ordering.
1660+ *
1661+ * Unsafe to use in noinstr code; use raw_atomic64_add() there.
1662+ *
1663+ * Return: Nothing.
1664+ */
6941665 static __always_inline void
6951666 atomic64_add(s64 i, atomic64_t *v)
6961667 {
6971668 instrument_atomic_read_write(v, sizeof(*v));
698− arch_atomic64_add(i, v);
1669+ raw_atomic64_add(i, v);
6991670 }
7001671
1672+/**
1673+ * atomic64_add_return() - atomic add with full ordering
1674+ * @i: s64 value to add
1675+ * @v: pointer to atomic64_t
1676+ *
1677+ * Atomically updates @v to (@v + @i) with full ordering.
1678+ *
1679+ * Unsafe to use in noinstr code; use raw_atomic64_add_return() there.
1680+ *
1681+ * Return: The updated value of @v.
1682+ */
7011683 static __always_inline s64
7021684 atomic64_add_return(s64 i, atomic64_t *v)
7031685 {
7041686 kcsan_mb();
7051687 instrument_atomic_read_write(v, sizeof(*v));
706− return arch_atomic64_add_return(i, v);
1688+ return raw_atomic64_add_return(i, v);
7071689 }
7081690
1691+/**
1692+ * atomic64_add_return_acquire() - atomic add with acquire ordering
1693+ * @i: s64 value to add
1694+ * @v: pointer to atomic64_t
1695+ *
1696+ * Atomically updates @v to (@v + @i) with acquire ordering.
1697+ *
1698+ * Unsafe to use in noinstr code; use raw_atomic64_add_return_acquire() there.
1699+ *
1700+ * Return: The updated value of @v.
1701+ */
7091702 static __always_inline s64
7101703 atomic64_add_return_acquire(s64 i, atomic64_t *v)
7111704 {
7121705 instrument_atomic_read_write(v, sizeof(*v));
713− return arch_atomic64_add_return_acquire(i, v);
1706+ return raw_atomic64_add_return_acquire(i, v);
7141707 }
7151708
1709+/**
1710+ * atomic64_add_return_release() - atomic add with release ordering
1711+ * @i: s64 value to add
1712+ * @v: pointer to atomic64_t
1713+ *
1714+ * Atomically updates @v to (@v + @i) with release ordering.
1715+ *
1716+ * Unsafe to use in noinstr code; use raw_atomic64_add_return_release() there.
1717+ *
1718+ * Return: The updated value of @v.
1719+ */
7161720 static __always_inline s64
7171721 atomic64_add_return_release(s64 i, atomic64_t *v)
7181722 {
7191723 kcsan_release();
7201724 instrument_atomic_read_write(v, sizeof(*v));
721− return arch_atomic64_add_return_release(i, v);
1725+ return raw_atomic64_add_return_release(i, v);
7221726 }
7231727
1728+/**
1729+ * atomic64_add_return_relaxed() - atomic add with relaxed ordering
1730+ * @i: s64 value to add
1731+ * @v: pointer to atomic64_t
1732+ *
1733+ * Atomically updates @v to (@v + @i) with relaxed ordering.
1734+ *
1735+ * Unsafe to use in noinstr code; use raw_atomic64_add_return_relaxed() there.
1736+ *
1737+ * Return: The updated value of @v.
1738+ */
7241739 static __always_inline s64
7251740 atomic64_add_return_relaxed(s64 i, atomic64_t *v)
7261741 {
7271742 instrument_atomic_read_write(v, sizeof(*v));
728− return arch_atomic64_add_return_relaxed(i, v);
1743+ return raw_atomic64_add_return_relaxed(i, v);
7291744 }
7301745
1746+/**
1747+ * atomic64_fetch_add() - atomic add with full ordering
1748+ * @i: s64 value to add
1749+ * @v: pointer to atomic64_t
1750+ *
1751+ * Atomically updates @v to (@v + @i) with full ordering.
1752+ *
1753+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_add() there.
1754+ *
1755+ * Return: The original value of @v.
1756+ */
7311757 static __always_inline s64
7321758 atomic64_fetch_add(s64 i, atomic64_t *v)
7331759 {
7341760 kcsan_mb();
7351761 instrument_atomic_read_write(v, sizeof(*v));
736− return arch_atomic64_fetch_add(i, v);
1762+ return raw_atomic64_fetch_add(i, v);
7371763 }
7381764
1765+/**
1766+ * atomic64_fetch_add_acquire() - atomic add with acquire ordering
1767+ * @i: s64 value to add
1768+ * @v: pointer to atomic64_t
1769+ *
1770+ * Atomically updates @v to (@v + @i) with acquire ordering.
1771+ *
1772+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_add_acquire() there.
1773+ *
1774+ * Return: The original value of @v.
1775+ */
7391776 static __always_inline s64
7401777 atomic64_fetch_add_acquire(s64 i, atomic64_t *v)
7411778 {
7421779 instrument_atomic_read_write(v, sizeof(*v));
743− return arch_atomic64_fetch_add_acquire(i, v);
1780+ return raw_atomic64_fetch_add_acquire(i, v);
7441781 }
7451782
1783+/**
1784+ * atomic64_fetch_add_release() - atomic add with release ordering
1785+ * @i: s64 value to add
1786+ * @v: pointer to atomic64_t
1787+ *
1788+ * Atomically updates @v to (@v + @i) with release ordering.
1789+ *
1790+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_add_release() there.
1791+ *
1792+ * Return: The original value of @v.
1793+ */
7461794 static __always_inline s64
7471795 atomic64_fetch_add_release(s64 i, atomic64_t *v)
7481796 {
7491797 kcsan_release();
7501798 instrument_atomic_read_write(v, sizeof(*v));
751− return arch_atomic64_fetch_add_release(i, v);
1799+ return raw_atomic64_fetch_add_release(i, v);
7521800 }
7531801
1802+/**
1803+ * atomic64_fetch_add_relaxed() - atomic add with relaxed ordering
1804+ * @i: s64 value to add
1805+ * @v: pointer to atomic64_t
1806+ *
1807+ * Atomically updates @v to (@v + @i) with relaxed ordering.
1808+ *
1809+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_add_relaxed() there.
1810+ *
1811+ * Return: The original value of @v.
1812+ */
7541813 static __always_inline s64
7551814 atomic64_fetch_add_relaxed(s64 i, atomic64_t *v)
7561815 {
7571816 instrument_atomic_read_write(v, sizeof(*v));
758− return arch_atomic64_fetch_add_relaxed(i, v);
1817+ return raw_atomic64_fetch_add_relaxed(i, v);
7591818 }
7601819
1820+/**
1821+ * atomic64_sub() - atomic subtract with relaxed ordering
1822+ * @i: s64 value to subtract
1823+ * @v: pointer to atomic64_t
1824+ *
1825+ * Atomically updates @v to (@v - @i) with relaxed ordering.
1826+ *
1827+ * Unsafe to use in noinstr code; use raw_atomic64_sub() there.
1828+ *
1829+ * Return: Nothing.
1830+ */
7611831 static __always_inline void
7621832 atomic64_sub(s64 i, atomic64_t *v)
7631833 {
7641834 instrument_atomic_read_write(v, sizeof(*v));
765− arch_atomic64_sub(i, v);
1835+ raw_atomic64_sub(i, v);
7661836 }
7671837
1838+/**
1839+ * atomic64_sub_return() - atomic subtract with full ordering
1840+ * @i: s64 value to subtract
1841+ * @v: pointer to atomic64_t
1842+ *
1843+ * Atomically updates @v to (@v - @i) with full ordering.
1844+ *
1845+ * Unsafe to use in noinstr code; use raw_atomic64_sub_return() there.
1846+ *
1847+ * Return: The updated value of @v.
1848+ */
7681849 static __always_inline s64
7691850 atomic64_sub_return(s64 i, atomic64_t *v)
7701851 {
7711852 kcsan_mb();
7721853 instrument_atomic_read_write(v, sizeof(*v));
773− return arch_atomic64_sub_return(i, v);
1854+ return raw_atomic64_sub_return(i, v);
7741855 }
7751856
1857+/**
1858+ * atomic64_sub_return_acquire() - atomic subtract with acquire ordering
1859+ * @i: s64 value to subtract
1860+ * @v: pointer to atomic64_t
1861+ *
1862+ * Atomically updates @v to (@v - @i) with acquire ordering.
1863+ *
1864+ * Unsafe to use in noinstr code; use raw_atomic64_sub_return_acquire() there.
1865+ *
1866+ * Return: The updated value of @v.
1867+ */
7761868 static __always_inline s64
7771869 atomic64_sub_return_acquire(s64 i, atomic64_t *v)
7781870 {
7791871 instrument_atomic_read_write(v, sizeof(*v));
780− return arch_atomic64_sub_return_acquire(i, v);
1872+ return raw_atomic64_sub_return_acquire(i, v);
7811873 }
7821874
1875+/**
1876+ * atomic64_sub_return_release() - atomic subtract with release ordering
1877+ * @i: s64 value to subtract
1878+ * @v: pointer to atomic64_t
1879+ *
1880+ * Atomically updates @v to (@v - @i) with release ordering.
1881+ *
1882+ * Unsafe to use in noinstr code; use raw_atomic64_sub_return_release() there.
1883+ *
1884+ * Return: The updated value of @v.
1885+ */
7831886 static __always_inline s64
7841887 atomic64_sub_return_release(s64 i, atomic64_t *v)
7851888 {
7861889 kcsan_release();
7871890 instrument_atomic_read_write(v, sizeof(*v));
788− return arch_atomic64_sub_return_release(i, v);
1891+ return raw_atomic64_sub_return_release(i, v);
7891892 }
7901893
1894+/**
1895+ * atomic64_sub_return_relaxed() - atomic subtract with relaxed ordering
1896+ * @i: s64 value to subtract
1897+ * @v: pointer to atomic64_t
1898+ *
1899+ * Atomically updates @v to (@v - @i) with relaxed ordering.
1900+ *
1901+ * Unsafe to use in noinstr code; use raw_atomic64_sub_return_relaxed() there.
1902+ *
1903+ * Return: The updated value of @v.
1904+ */
7911905 static __always_inline s64
7921906 atomic64_sub_return_relaxed(s64 i, atomic64_t *v)
7931907 {
7941908 instrument_atomic_read_write(v, sizeof(*v));
795− return arch_atomic64_sub_return_relaxed(i, v);
1909+ return raw_atomic64_sub_return_relaxed(i, v);
7961910 }
7971911
1912+/**
1913+ * atomic64_fetch_sub() - atomic subtract with full ordering
1914+ * @i: s64 value to subtract
1915+ * @v: pointer to atomic64_t
1916+ *
1917+ * Atomically updates @v to (@v - @i) with full ordering.
1918+ *
1919+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_sub() there.
1920+ *
1921+ * Return: The original value of @v.
1922+ */
7981923 static __always_inline s64
7991924 atomic64_fetch_sub(s64 i, atomic64_t *v)
8001925 {
8011926 kcsan_mb();
8021927 instrument_atomic_read_write(v, sizeof(*v));
803− return arch_atomic64_fetch_sub(i, v);
1928+ return raw_atomic64_fetch_sub(i, v);
8041929 }
8051930
1931+/**
1932+ * atomic64_fetch_sub_acquire() - atomic subtract with acquire ordering
1933+ * @i: s64 value to subtract
1934+ * @v: pointer to atomic64_t
1935+ *
1936+ * Atomically updates @v to (@v - @i) with acquire ordering.
1937+ *
1938+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_sub_acquire() there.
1939+ *
1940+ * Return: The original value of @v.
1941+ */
8061942 static __always_inline s64
8071943 atomic64_fetch_sub_acquire(s64 i, atomic64_t *v)
8081944 {
8091945 instrument_atomic_read_write(v, sizeof(*v));
810− return arch_atomic64_fetch_sub_acquire(i, v);
1946+ return raw_atomic64_fetch_sub_acquire(i, v);
8111947 }
8121948
1949+/**
1950+ * atomic64_fetch_sub_release() - atomic subtract with release ordering
1951+ * @i: s64 value to subtract
1952+ * @v: pointer to atomic64_t
1953+ *
1954+ * Atomically updates @v to (@v - @i) with release ordering.
1955+ *
1956+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_sub_release() there.
1957+ *
1958+ * Return: The original value of @v.
1959+ */
8131960 static __always_inline s64
8141961 atomic64_fetch_sub_release(s64 i, atomic64_t *v)
8151962 {
8161963 kcsan_release();
8171964 instrument_atomic_read_write(v, sizeof(*v));
818− return arch_atomic64_fetch_sub_release(i, v);
1965+ return raw_atomic64_fetch_sub_release(i, v);
8191966 }
8201967
1968+/**
1969+ * atomic64_fetch_sub_relaxed() - atomic subtract with relaxed ordering
1970+ * @i: s64 value to subtract
1971+ * @v: pointer to atomic64_t
1972+ *
1973+ * Atomically updates @v to (@v - @i) with relaxed ordering.
1974+ *
1975+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_sub_relaxed() there.
1976+ *
1977+ * Return: The original value of @v.
1978+ */
8211979 static __always_inline s64
8221980 atomic64_fetch_sub_relaxed(s64 i, atomic64_t *v)
8231981 {
8241982 instrument_atomic_read_write(v, sizeof(*v));
825− return arch_atomic64_fetch_sub_relaxed(i, v);
1983+ return raw_atomic64_fetch_sub_relaxed(i, v);
8261984 }
8271985
1986+/**
1987+ * atomic64_inc() - atomic increment with relaxed ordering
1988+ * @v: pointer to atomic64_t
1989+ *
1990+ * Atomically updates @v to (@v + 1) with relaxed ordering.
1991+ *
1992+ * Unsafe to use in noinstr code; use raw_atomic64_inc() there.
1993+ *
1994+ * Return: Nothing.
1995+ */
8281996 static __always_inline void
8291997 atomic64_inc(atomic64_t *v)
8301998 {
8311999 instrument_atomic_read_write(v, sizeof(*v));
832− arch_atomic64_inc(v);
2000+ raw_atomic64_inc(v);
8332001 }
8342002
2003+/**
2004+ * atomic64_inc_return() - atomic increment with full ordering
2005+ * @v: pointer to atomic64_t
2006+ *
2007+ * Atomically updates @v to (@v + 1) with full ordering.
2008+ *
2009+ * Unsafe to use in noinstr code; use raw_atomic64_inc_return() there.
2010+ *
2011+ * Return: The updated value of @v.
2012+ */
8352013 static __always_inline s64
8362014 atomic64_inc_return(atomic64_t *v)
8372015 {
8382016 kcsan_mb();
8392017 instrument_atomic_read_write(v, sizeof(*v));
840− return arch_atomic64_inc_return(v);
2018+ return raw_atomic64_inc_return(v);
8412019 }
8422020
2021+/**
2022+ * atomic64_inc_return_acquire() - atomic increment with acquire ordering
2023+ * @v: pointer to atomic64_t
2024+ *
2025+ * Atomically updates @v to (@v + 1) with acquire ordering.
2026+ *
2027+ * Unsafe to use in noinstr code; use raw_atomic64_inc_return_acquire() there.
2028+ *
2029+ * Return: The updated value of @v.
2030+ */
8432031 static __always_inline s64
8442032 atomic64_inc_return_acquire(atomic64_t *v)
8452033 {
8462034 instrument_atomic_read_write(v, sizeof(*v));
847− return arch_atomic64_inc_return_acquire(v);
2035+ return raw_atomic64_inc_return_acquire(v);
8482036 }
8492037
2038+/**
2039+ * atomic64_inc_return_release() - atomic increment with release ordering
2040+ * @v: pointer to atomic64_t
2041+ *
2042+ * Atomically updates @v to (@v + 1) with release ordering.
2043+ *
2044+ * Unsafe to use in noinstr code; use raw_atomic64_inc_return_release() there.
2045+ *
2046+ * Return: The updated value of @v.
2047+ */
8502048 static __always_inline s64
8512049 atomic64_inc_return_release(atomic64_t *v)
8522050 {
8532051 kcsan_release();
8542052 instrument_atomic_read_write(v, sizeof(*v));
855− return arch_atomic64_inc_return_release(v);
2053+ return raw_atomic64_inc_return_release(v);
8562054 }
8572055
2056+/**
2057+ * atomic64_inc_return_relaxed() - atomic increment with relaxed ordering
2058+ * @v: pointer to atomic64_t
2059+ *
2060+ * Atomically updates @v to (@v + 1) with relaxed ordering.
2061+ *
2062+ * Unsafe to use in noinstr code; use raw_atomic64_inc_return_relaxed() there.
2063+ *
2064+ * Return: The updated value of @v.
2065+ */
8582066 static __always_inline s64
8592067 atomic64_inc_return_relaxed(atomic64_t *v)
8602068 {
8612069 instrument_atomic_read_write(v, sizeof(*v));
862− return arch_atomic64_inc_return_relaxed(v);
2070+ return raw_atomic64_inc_return_relaxed(v);
8632071 }
8642072
2073+/**
2074+ * atomic64_fetch_inc() - atomic increment with full ordering
2075+ * @v: pointer to atomic64_t
2076+ *
2077+ * Atomically updates @v to (@v + 1) with full ordering.
2078+ *
2079+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_inc() there.
2080+ *
2081+ * Return: The original value of @v.
2082+ */
8652083 static __always_inline s64
8662084 atomic64_fetch_inc(atomic64_t *v)
8672085 {
8682086 kcsan_mb();
8692087 instrument_atomic_read_write(v, sizeof(*v));
870− return arch_atomic64_fetch_inc(v);
2088+ return raw_atomic64_fetch_inc(v);
8712089 }
8722090
2091+/**
2092+ * atomic64_fetch_inc_acquire() - atomic increment with acquire ordering
2093+ * @v: pointer to atomic64_t
2094+ *
2095+ * Atomically updates @v to (@v + 1) with acquire ordering.
2096+ *
2097+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_inc_acquire() there.
2098+ *
2099+ * Return: The original value of @v.
2100+ */
8732101 static __always_inline s64
8742102 atomic64_fetch_inc_acquire(atomic64_t *v)
8752103 {
8762104 instrument_atomic_read_write(v, sizeof(*v));
877− return arch_atomic64_fetch_inc_acquire(v);
2105+ return raw_atomic64_fetch_inc_acquire(v);
8782106 }
8792107
2108+/**
2109+ * atomic64_fetch_inc_release() - atomic increment with release ordering
2110+ * @v: pointer to atomic64_t
2111+ *
2112+ * Atomically updates @v to (@v + 1) with release ordering.
2113+ *
2114+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_inc_release() there.
2115+ *
2116+ * Return: The original value of @v.
2117+ */
8802118 static __always_inline s64
8812119 atomic64_fetch_inc_release(atomic64_t *v)
8822120 {
8832121 kcsan_release();
8842122 instrument_atomic_read_write(v, sizeof(*v));
885− return arch_atomic64_fetch_inc_release(v);
2123+ return raw_atomic64_fetch_inc_release(v);
8862124 }
8872125
2126+/**
2127+ * atomic64_fetch_inc_relaxed() - atomic increment with relaxed ordering
2128+ * @v: pointer to atomic64_t
2129+ *
2130+ * Atomically updates @v to (@v + 1) with relaxed ordering.
2131+ *
2132+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_inc_relaxed() there.
2133+ *
2134+ * Return: The original value of @v.
2135+ */
8882136 static __always_inline s64
8892137 atomic64_fetch_inc_relaxed(atomic64_t *v)
8902138 {
8912139 instrument_atomic_read_write(v, sizeof(*v));
892− return arch_atomic64_fetch_inc_relaxed(v);
2140+ return raw_atomic64_fetch_inc_relaxed(v);
8932141 }
8942142
2143+/**
2144+ * atomic64_dec() - atomic decrement with relaxed ordering
2145+ * @v: pointer to atomic64_t
2146+ *
2147+ * Atomically updates @v to (@v - 1) with relaxed ordering.
2148+ *
2149+ * Unsafe to use in noinstr code; use raw_atomic64_dec() there.
2150+ *
2151+ * Return: Nothing.
2152+ */
8952153 static __always_inline void
8962154 atomic64_dec(atomic64_t *v)
8972155 {
8982156 instrument_atomic_read_write(v, sizeof(*v));
899− arch_atomic64_dec(v);
2157+ raw_atomic64_dec(v);
9002158 }
9012159
2160+/**
2161+ * atomic64_dec_return() - atomic decrement with full ordering
2162+ * @v: pointer to atomic64_t
2163+ *
2164+ * Atomically updates @v to (@v - 1) with full ordering.
2165+ *
2166+ * Unsafe to use in noinstr code; use raw_atomic64_dec_return() there.
2167+ *
2168+ * Return: The updated value of @v.
2169+ */
9022170 static __always_inline s64
9032171 atomic64_dec_return(atomic64_t *v)
9042172 {
9052173 kcsan_mb();
9062174 instrument_atomic_read_write(v, sizeof(*v));
907− return arch_atomic64_dec_return(v);
2175+ return raw_atomic64_dec_return(v);
9082176 }
9092177
2178+/**
2179+ * atomic64_dec_return_acquire() - atomic decrement with acquire ordering
2180+ * @v: pointer to atomic64_t
2181+ *
2182+ * Atomically updates @v to (@v - 1) with acquire ordering.
2183+ *
2184+ * Unsafe to use in noinstr code; use raw_atomic64_dec_return_acquire() there.
2185+ *
2186+ * Return: The updated value of @v.
2187+ */
9102188 static __always_inline s64
9112189 atomic64_dec_return_acquire(atomic64_t *v)
9122190 {
9132191 instrument_atomic_read_write(v, sizeof(*v));
914− return arch_atomic64_dec_return_acquire(v);
2192+ return raw_atomic64_dec_return_acquire(v);
9152193 }
9162194
2195+/**
2196+ * atomic64_dec_return_release() - atomic decrement with release ordering
2197+ * @v: pointer to atomic64_t
2198+ *
2199+ * Atomically updates @v to (@v - 1) with release ordering.
2200+ *
2201+ * Unsafe to use in noinstr code; use raw_atomic64_dec_return_release() there.
2202+ *
2203+ * Return: The updated value of @v.
2204+ */
9172205 static __always_inline s64
9182206 atomic64_dec_return_release(atomic64_t *v)
9192207 {
9202208 kcsan_release();
9212209 instrument_atomic_read_write(v, sizeof(*v));
922− return arch_atomic64_dec_return_release(v);
2210+ return raw_atomic64_dec_return_release(v);
9232211 }
9242212
2213+/**
2214+ * atomic64_dec_return_relaxed() - atomic decrement with relaxed ordering
2215+ * @v: pointer to atomic64_t
2216+ *
2217+ * Atomically updates @v to (@v - 1) with relaxed ordering.
2218+ *
2219+ * Unsafe to use in noinstr code; use raw_atomic64_dec_return_relaxed() there.
2220+ *
2221+ * Return: The updated value of @v.
2222+ */
9252223 static __always_inline s64
9262224 atomic64_dec_return_relaxed(atomic64_t *v)
9272225 {
9282226 instrument_atomic_read_write(v, sizeof(*v));
929− return arch_atomic64_dec_return_relaxed(v);
2227+ return raw_atomic64_dec_return_relaxed(v);
9302228 }
9312229
2230+/**
2231+ * atomic64_fetch_dec() - atomic decrement with full ordering
2232+ * @v: pointer to atomic64_t
2233+ *
2234+ * Atomically updates @v to (@v - 1) with full ordering.
2235+ *
2236+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_dec() there.
2237+ *
2238+ * Return: The original value of @v.
2239+ */
9322240 static __always_inline s64
9332241 atomic64_fetch_dec(atomic64_t *v)
9342242 {
9352243 kcsan_mb();
9362244 instrument_atomic_read_write(v, sizeof(*v));
937− return arch_atomic64_fetch_dec(v);
2245+ return raw_atomic64_fetch_dec(v);
9382246 }
9392247
2248+/**
2249+ * atomic64_fetch_dec_acquire() - atomic decrement with acquire ordering
2250+ * @v: pointer to atomic64_t
2251+ *
2252+ * Atomically updates @v to (@v - 1) with acquire ordering.
2253+ *
2254+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_dec_acquire() there.
2255+ *
2256+ * Return: The original value of @v.
2257+ */
9402258 static __always_inline s64
9412259 atomic64_fetch_dec_acquire(atomic64_t *v)
9422260 {
9432261 instrument_atomic_read_write(v, sizeof(*v));
944− return arch_atomic64_fetch_dec_acquire(v);
2262+ return raw_atomic64_fetch_dec_acquire(v);
9452263 }
9462264
2265+/**
2266+ * atomic64_fetch_dec_release() - atomic decrement with release ordering
2267+ * @v: pointer to atomic64_t
2268+ *
2269+ * Atomically updates @v to (@v - 1) with release ordering.
2270+ *
2271+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_dec_release() there.
2272+ *
2273+ * Return: The original value of @v.
2274+ */
9472275 static __always_inline s64
9482276 atomic64_fetch_dec_release(atomic64_t *v)
9492277 {
9502278 kcsan_release();
9512279 instrument_atomic_read_write(v, sizeof(*v));
952− return arch_atomic64_fetch_dec_release(v);
2280+ return raw_atomic64_fetch_dec_release(v);
9532281 }
9542282
2283+/**
2284+ * atomic64_fetch_dec_relaxed() - atomic decrement with relaxed ordering
2285+ * @v: pointer to atomic64_t
2286+ *
2287+ * Atomically updates @v to (@v - 1) with relaxed ordering.
2288+ *
2289+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_dec_relaxed() there.
2290+ *
2291+ * Return: The original value of @v.
2292+ */
9552293 static __always_inline s64
9562294 atomic64_fetch_dec_relaxed(atomic64_t *v)
9572295 {
9582296 instrument_atomic_read_write(v, sizeof(*v));
959− return arch_atomic64_fetch_dec_relaxed(v);
2297+ return raw_atomic64_fetch_dec_relaxed(v);
9602298 }
9612299
2300+/**
2301+ * atomic64_and() - atomic bitwise AND with relaxed ordering
2302+ * @i: s64 value
2303+ * @v: pointer to atomic64_t
2304+ *
2305+ * Atomically updates @v to (@v & @i) with relaxed ordering.
2306+ *
2307+ * Unsafe to use in noinstr code; use raw_atomic64_and() there.
2308+ *
2309+ * Return: Nothing.
2310+ */
9622311 static __always_inline void
9632312 atomic64_and(s64 i, atomic64_t *v)
9642313 {
9652314 instrument_atomic_read_write(v, sizeof(*v));
966− arch_atomic64_and(i, v);
2315+ raw_atomic64_and(i, v);
9672316 }
9682317
2318+/**
2319+ * atomic64_fetch_and() - atomic bitwise AND with full ordering
2320+ * @i: s64 value
2321+ * @v: pointer to atomic64_t
2322+ *
2323+ * Atomically updates @v to (@v & @i) with full ordering.
2324+ *
2325+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_and() there.
2326+ *
2327+ * Return: The original value of @v.
2328+ */
9692329 static __always_inline s64
9702330 atomic64_fetch_and(s64 i, atomic64_t *v)
9712331 {
9722332 kcsan_mb();
9732333 instrument_atomic_read_write(v, sizeof(*v));
974− return arch_atomic64_fetch_and(i, v);
2334+ return raw_atomic64_fetch_and(i, v);
9752335 }
9762336
2337+/**
2338+ * atomic64_fetch_and_acquire() - atomic bitwise AND with acquire ordering
2339+ * @i: s64 value
2340+ * @v: pointer to atomic64_t
2341+ *
2342+ * Atomically updates @v to (@v & @i) with acquire ordering.
2343+ *
2344+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_and_acquire() there.
2345+ *
2346+ * Return: The original value of @v.
2347+ */
9772348 static __always_inline s64
9782349 atomic64_fetch_and_acquire(s64 i, atomic64_t *v)
9792350 {
9802351 instrument_atomic_read_write(v, sizeof(*v));
981− return arch_atomic64_fetch_and_acquire(i, v);
2352+ return raw_atomic64_fetch_and_acquire(i, v);
9822353 }
9832354
2355+/**
2356+ * atomic64_fetch_and_release() - atomic bitwise AND with release ordering
2357+ * @i: s64 value
2358+ * @v: pointer to atomic64_t
2359+ *
2360+ * Atomically updates @v to (@v & @i) with release ordering.
2361+ *
2362+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_and_release() there.
2363+ *
2364+ * Return: The original value of @v.
2365+ */
9842366 static __always_inline s64
9852367 atomic64_fetch_and_release(s64 i, atomic64_t *v)
9862368 {
9872369 kcsan_release();
9882370 instrument_atomic_read_write(v, sizeof(*v));
989− return arch_atomic64_fetch_and_release(i, v);
2371+ return raw_atomic64_fetch_and_release(i, v);
9902372 }
9912373
2374+/**
2375+ * atomic64_fetch_and_relaxed() - atomic bitwise AND with relaxed ordering
2376+ * @i: s64 value
2377+ * @v: pointer to atomic64_t
2378+ *
2379+ * Atomically updates @v to (@v & @i) with relaxed ordering.
2380+ *
2381+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_and_relaxed() there.
2382+ *
2383+ * Return: The original value of @v.
2384+ */
9922385 static __always_inline s64
9932386 atomic64_fetch_and_relaxed(s64 i, atomic64_t *v)
9942387 {
9952388 instrument_atomic_read_write(v, sizeof(*v));
996− return arch_atomic64_fetch_and_relaxed(i, v);
2389+ return raw_atomic64_fetch_and_relaxed(i, v);
9972390 }
9982391
2392+/**
2393+ * atomic64_andnot() - atomic bitwise AND NOT with relaxed ordering
2394+ * @i: s64 value
2395+ * @v: pointer to atomic64_t
2396+ *
2397+ * Atomically updates @v to (@v & ~@i) with relaxed ordering.
2398+ *
2399+ * Unsafe to use in noinstr code; use raw_atomic64_andnot() there.
2400+ *
2401+ * Return: Nothing.
2402+ */
9992403 static __always_inline void
10002404 atomic64_andnot(s64 i, atomic64_t *v)
10012405 {
10022406 instrument_atomic_read_write(v, sizeof(*v));
1003− arch_atomic64_andnot(i, v);
2407+ raw_atomic64_andnot(i, v);
10042408 }
10052409
2410+/**
2411+ * atomic64_fetch_andnot() - atomic bitwise AND NOT with full ordering
2412+ * @i: s64 value
2413+ * @v: pointer to atomic64_t
2414+ *
2415+ * Atomically updates @v to (@v & ~@i) with full ordering.
2416+ *
2417+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_andnot() there.
2418+ *
2419+ * Return: The original value of @v.
2420+ */
10062421 static __always_inline s64
10072422 atomic64_fetch_andnot(s64 i, atomic64_t *v)
10082423 {
10092424 kcsan_mb();
10102425 instrument_atomic_read_write(v, sizeof(*v));
1011− return arch_atomic64_fetch_andnot(i, v);
2426+ return raw_atomic64_fetch_andnot(i, v);
10122427 }
10132428
2429+/**
2430+ * atomic64_fetch_andnot_acquire() - atomic bitwise AND NOT with acquire ordering
2431+ * @i: s64 value
2432+ * @v: pointer to atomic64_t
2433+ *
2434+ * Atomically updates @v to (@v & ~@i) with acquire ordering.
2435+ *
2436+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_andnot_acquire() there.
2437+ *
2438+ * Return: The original value of @v.
2439+ */
10142440 static __always_inline s64
10152441 atomic64_fetch_andnot_acquire(s64 i, atomic64_t *v)
10162442 {
10172443 instrument_atomic_read_write(v, sizeof(*v));
1018− return arch_atomic64_fetch_andnot_acquire(i, v);
2444+ return raw_atomic64_fetch_andnot_acquire(i, v);
10192445 }
10202446
2447+/**
2448+ * atomic64_fetch_andnot_release() - atomic bitwise AND NOT with release ordering
2449+ * @i: s64 value
2450+ * @v: pointer to atomic64_t
2451+ *
2452+ * Atomically updates @v to (@v & ~@i) with release ordering.
2453+ *
2454+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_andnot_release() there.
2455+ *
2456+ * Return: The original value of @v.
2457+ */
10212458 static __always_inline s64
10222459 atomic64_fetch_andnot_release(s64 i, atomic64_t *v)
10232460 {
10242461 kcsan_release();
10252462 instrument_atomic_read_write(v, sizeof(*v));
1026− return arch_atomic64_fetch_andnot_release(i, v);
2463+ return raw_atomic64_fetch_andnot_release(i, v);
10272464 }
10282465
2466+/**
2467+ * atomic64_fetch_andnot_relaxed() - atomic bitwise AND NOT with relaxed ordering
2468+ * @i: s64 value
2469+ * @v: pointer to atomic64_t
2470+ *
2471+ * Atomically updates @v to (@v & ~@i) with relaxed ordering.
2472+ *
2473+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_andnot_relaxed() there.
2474+ *
2475+ * Return: The original value of @v.
2476+ */
10292477 static __always_inline s64
10302478 atomic64_fetch_andnot_relaxed(s64 i, atomic64_t *v)
10312479 {
10322480 instrument_atomic_read_write(v, sizeof(*v));
1033− return arch_atomic64_fetch_andnot_relaxed(i, v);
2481+ return raw_atomic64_fetch_andnot_relaxed(i, v);
10342482 }
10352483
2484+/**
2485+ * atomic64_or() - atomic bitwise OR with relaxed ordering
2486+ * @i: s64 value
2487+ * @v: pointer to atomic64_t
2488+ *
2489+ * Atomically updates @v to (@v | @i) with relaxed ordering.
2490+ *
2491+ * Unsafe to use in noinstr code; use raw_atomic64_or() there.
2492+ *
2493+ * Return: Nothing.
2494+ */
10362495 static __always_inline void
10372496 atomic64_or(s64 i, atomic64_t *v)
10382497 {
10392498 instrument_atomic_read_write(v, sizeof(*v));
1040− arch_atomic64_or(i, v);
2499+ raw_atomic64_or(i, v);
10412500 }
10422501
2502+/**
2503+ * atomic64_fetch_or() - atomic bitwise OR with full ordering
2504+ * @i: s64 value
2505+ * @v: pointer to atomic64_t
2506+ *
2507+ * Atomically updates @v to (@v | @i) with full ordering.
2508+ *
2509+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_or() there.
2510+ *
2511+ * Return: The original value of @v.
2512+ */
10432513 static __always_inline s64
10442514 atomic64_fetch_or(s64 i, atomic64_t *v)
10452515 {
10462516 kcsan_mb();
10472517 instrument_atomic_read_write(v, sizeof(*v));
1048− return arch_atomic64_fetch_or(i, v);
2518+ return raw_atomic64_fetch_or(i, v);
10492519 }
10502520
2521+/**
2522+ * atomic64_fetch_or_acquire() - atomic bitwise OR with acquire ordering
2523+ * @i: s64 value
2524+ * @v: pointer to atomic64_t
2525+ *
2526+ * Atomically updates @v to (@v | @i) with acquire ordering.
2527+ *
2528+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_or_acquire() there.
2529+ *
2530+ * Return: The original value of @v.
2531+ */
10512532 static __always_inline s64
10522533 atomic64_fetch_or_acquire(s64 i, atomic64_t *v)
10532534 {
10542535 instrument_atomic_read_write(v, sizeof(*v));
1055− return arch_atomic64_fetch_or_acquire(i, v);
2536+ return raw_atomic64_fetch_or_acquire(i, v);
10562537 }
10572538
2539+/**
2540+ * atomic64_fetch_or_release() - atomic bitwise OR with release ordering
2541+ * @i: s64 value
2542+ * @v: pointer to atomic64_t
2543+ *
2544+ * Atomically updates @v to (@v | @i) with release ordering.
2545+ *
2546+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_or_release() there.
2547+ *
2548+ * Return: The original value of @v.
2549+ */
10582550 static __always_inline s64
10592551 atomic64_fetch_or_release(s64 i, atomic64_t *v)
10602552 {
10612553 kcsan_release();
10622554 instrument_atomic_read_write(v, sizeof(*v));
1063− return arch_atomic64_fetch_or_release(i, v);
2555+ return raw_atomic64_fetch_or_release(i, v);
10642556 }
10652557
2558+/**
2559+ * atomic64_fetch_or_relaxed() - atomic bitwise OR with relaxed ordering
2560+ * @i: s64 value
2561+ * @v: pointer to atomic64_t
2562+ *
2563+ * Atomically updates @v to (@v | @i) with relaxed ordering.
2564+ *
2565+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_or_relaxed() there.
2566+ *
2567+ * Return: The original value of @v.
2568+ */
10662569 static __always_inline s64
10672570 atomic64_fetch_or_relaxed(s64 i, atomic64_t *v)
10682571 {
10692572 instrument_atomic_read_write(v, sizeof(*v));
1070− return arch_atomic64_fetch_or_relaxed(i, v);
2573+ return raw_atomic64_fetch_or_relaxed(i, v);
10712574 }
10722575
2576+/**
2577+ * atomic64_xor() - atomic bitwise XOR with relaxed ordering
2578+ * @i: s64 value
2579+ * @v: pointer to atomic64_t
2580+ *
2581+ * Atomically updates @v to (@v ^ @i) with relaxed ordering.
2582+ *
2583+ * Unsafe to use in noinstr code; use raw_atomic64_xor() there.
2584+ *
2585+ * Return: Nothing.
2586+ */
10732587 static __always_inline void
10742588 atomic64_xor(s64 i, atomic64_t *v)
10752589 {
10762590 instrument_atomic_read_write(v, sizeof(*v));
1077− arch_atomic64_xor(i, v);
2591+ raw_atomic64_xor(i, v);
10782592 }
10792593
2594+/**
2595+ * atomic64_fetch_xor() - atomic bitwise XOR with full ordering
2596+ * @i: s64 value
2597+ * @v: pointer to atomic64_t
2598+ *
2599+ * Atomically updates @v to (@v ^ @i) with full ordering.
2600+ *
2601+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_xor() there.
2602+ *
2603+ * Return: The original value of @v.
2604+ */
10802605 static __always_inline s64
10812606 atomic64_fetch_xor(s64 i, atomic64_t *v)
10822607 {
10832608 kcsan_mb();
10842609 instrument_atomic_read_write(v, sizeof(*v));
1085− return arch_atomic64_fetch_xor(i, v);
2610+ return raw_atomic64_fetch_xor(i, v);
10862611 }
10872612
2613+/**
2614+ * atomic64_fetch_xor_acquire() - atomic bitwise XOR with acquire ordering
2615+ * @i: s64 value
2616+ * @v: pointer to atomic64_t
2617+ *
2618+ * Atomically updates @v to (@v ^ @i) with acquire ordering.
2619+ *
2620+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_xor_acquire() there.
2621+ *
2622+ * Return: The original value of @v.
2623+ */
10882624 static __always_inline s64
10892625 atomic64_fetch_xor_acquire(s64 i, atomic64_t *v)
10902626 {
10912627 instrument_atomic_read_write(v, sizeof(*v));
1092− return arch_atomic64_fetch_xor_acquire(i, v);
2628+ return raw_atomic64_fetch_xor_acquire(i, v);
10932629 }
10942630
2631+/**
2632+ * atomic64_fetch_xor_release() - atomic bitwise XOR with release ordering
2633+ * @i: s64 value
2634+ * @v: pointer to atomic64_t
2635+ *
2636+ * Atomically updates @v to (@v ^ @i) with release ordering.
2637+ *
2638+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_xor_release() there.
2639+ *
2640+ * Return: The original value of @v.
2641+ */
10952642 static __always_inline s64
10962643 atomic64_fetch_xor_release(s64 i, atomic64_t *v)
10972644 {
10982645 kcsan_release();
10992646 instrument_atomic_read_write(v, sizeof(*v));
1100− return arch_atomic64_fetch_xor_release(i, v);
2647+ return raw_atomic64_fetch_xor_release(i, v);
11012648 }
11022649
2650+/**
2651+ * atomic64_fetch_xor_relaxed() - atomic bitwise XOR with relaxed ordering
2652+ * @i: s64 value
2653+ * @v: pointer to atomic64_t
2654+ *
2655+ * Atomically updates @v to (@v ^ @i) with relaxed ordering.
2656+ *
2657+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_xor_relaxed() there.
2658+ *
2659+ * Return: The original value of @v.
2660+ */
11032661 static __always_inline s64
11042662 atomic64_fetch_xor_relaxed(s64 i, atomic64_t *v)
11052663 {
11062664 instrument_atomic_read_write(v, sizeof(*v));
1107− return arch_atomic64_fetch_xor_relaxed(i, v);
2665+ return raw_atomic64_fetch_xor_relaxed(i, v);
11082666 }
11092667
2668+/**
2669+ * atomic64_xchg() - atomic exchange with full ordering
2670+ * @v: pointer to atomic64_t
2671+ * @new: s64 value to assign
2672+ *
2673+ * Atomically updates @v to @new with full ordering.
2674+ *
2675+ * Unsafe to use in noinstr code; use raw_atomic64_xchg() there.
2676+ *
2677+ * Return: The original value of @v.
2678+ */
11102679 static __always_inline s64
1111−atomic64_xchg(atomic64_t *v, s64 i)
2680+atomic64_xchg(atomic64_t *v, s64 new)
11122681 {
11132682 kcsan_mb();
11142683 instrument_atomic_read_write(v, sizeof(*v));
1115− return arch_atomic64_xchg(v, i);
2684+ return raw_atomic64_xchg(v, new);
11162685 }
11172686
2687+/**
2688+ * atomic64_xchg_acquire() - atomic exchange with acquire ordering
2689+ * @v: pointer to atomic64_t
2690+ * @new: s64 value to assign
2691+ *
2692+ * Atomically updates @v to @new with acquire ordering.
2693+ *
2694+ * Unsafe to use in noinstr code; use raw_atomic64_xchg_acquire() there.
2695+ *
2696+ * Return: The original value of @v.
2697+ */
11182698 static __always_inline s64
1119−atomic64_xchg_acquire(atomic64_t *v, s64 i)
2699+atomic64_xchg_acquire(atomic64_t *v, s64 new)
11202700 {
11212701 instrument_atomic_read_write(v, sizeof(*v));
1122− return arch_atomic64_xchg_acquire(v, i);
2702+ return raw_atomic64_xchg_acquire(v, new);
11232703 }
11242704
2705+/**
2706+ * atomic64_xchg_release() - atomic exchange with release ordering
2707+ * @v: pointer to atomic64_t
2708+ * @new: s64 value to assign
2709+ *
2710+ * Atomically updates @v to @new with release ordering.
2711+ *
2712+ * Unsafe to use in noinstr code; use raw_atomic64_xchg_release() there.
2713+ *
2714+ * Return: The original value of @v.
2715+ */
11252716 static __always_inline s64
1126−atomic64_xchg_release(atomic64_t *v, s64 i)
2717+atomic64_xchg_release(atomic64_t *v, s64 new)
11272718 {
11282719 kcsan_release();
11292720 instrument_atomic_read_write(v, sizeof(*v));
1130− return arch_atomic64_xchg_release(v, i);
2721+ return raw_atomic64_xchg_release(v, new);
11312722 }
11322723
2724+/**
2725+ * atomic64_xchg_relaxed() - atomic exchange with relaxed ordering
2726+ * @v: pointer to atomic64_t
2727+ * @new: s64 value to assign
2728+ *
2729+ * Atomically updates @v to @new with relaxed ordering.
2730+ *
2731+ * Unsafe to use in noinstr code; use raw_atomic64_xchg_relaxed() there.
2732+ *
2733+ * Return: The original value of @v.
2734+ */
11332735 static __always_inline s64
1134−atomic64_xchg_relaxed(atomic64_t *v, s64 i)
2736+atomic64_xchg_relaxed(atomic64_t *v, s64 new)
11352737 {
11362738 instrument_atomic_read_write(v, sizeof(*v));
1137− return arch_atomic64_xchg_relaxed(v, i);
2739+ return raw_atomic64_xchg_relaxed(v, new);
11382740 }
11392741
2742+/**
2743+ * atomic64_cmpxchg() - atomic compare and exchange with full ordering
2744+ * @v: pointer to atomic64_t
2745+ * @old: s64 value to compare with
2746+ * @new: s64 value to assign
2747+ *
2748+ * If (@v == @old), atomically updates @v to @new with full ordering.
2749+ *
2750+ * Unsafe to use in noinstr code; use raw_atomic64_cmpxchg() there.
2751+ *
2752+ * Return: The original value of @v.
2753+ */
11402754 static __always_inline s64
11412755 atomic64_cmpxchg(atomic64_t *v, s64 old, s64 new)
11422756 {
11432757 kcsan_mb();
11442758 instrument_atomic_read_write(v, sizeof(*v));
1145− return arch_atomic64_cmpxchg(v, old, new);
2759+ return raw_atomic64_cmpxchg(v, old, new);
11462760 }
11472761
2762+/**
2763+ * atomic64_cmpxchg_acquire() - atomic compare and exchange with acquire ordering
2764+ * @v: pointer to atomic64_t
2765+ * @old: s64 value to compare with
2766+ * @new: s64 value to assign
2767+ *
2768+ * If (@v == @old), atomically updates @v to @new with acquire ordering.
2769+ *
2770+ * Unsafe to use in noinstr code; use raw_atomic64_cmpxchg_acquire() there.
2771+ *
2772+ * Return: The original value of @v.
2773+ */
11482774 static __always_inline s64
11492775 atomic64_cmpxchg_acquire(atomic64_t *v, s64 old, s64 new)
11502776 {
11512777 instrument_atomic_read_write(v, sizeof(*v));
1152− return arch_atomic64_cmpxchg_acquire(v, old, new);
2778+ return raw_atomic64_cmpxchg_acquire(v, old, new);
11532779 }
11542780
2781+/**
2782+ * atomic64_cmpxchg_release() - atomic compare and exchange with release ordering
2783+ * @v: pointer to atomic64_t
2784+ * @old: s64 value to compare with
2785+ * @new: s64 value to assign
2786+ *
2787+ * If (@v == @old), atomically updates @v to @new with release ordering.
2788+ *
2789+ * Unsafe to use in noinstr code; use raw_atomic64_cmpxchg_release() there.
2790+ *
2791+ * Return: The original value of @v.
2792+ */
11552793 static __always_inline s64
11562794 atomic64_cmpxchg_release(atomic64_t *v, s64 old, s64 new)
11572795 {
11582796 kcsan_release();
11592797 instrument_atomic_read_write(v, sizeof(*v));
1160− return arch_atomic64_cmpxchg_release(v, old, new);
2798+ return raw_atomic64_cmpxchg_release(v, old, new);
11612799 }
11622800
2801+/**
2802+ * atomic64_cmpxchg_relaxed() - atomic compare and exchange with relaxed ordering
2803+ * @v: pointer to atomic64_t
2804+ * @old: s64 value to compare with
2805+ * @new: s64 value to assign
2806+ *
2807+ * If (@v == @old), atomically updates @v to @new with relaxed ordering.
2808+ *
2809+ * Unsafe to use in noinstr code; use raw_atomic64_cmpxchg_relaxed() there.
2810+ *
2811+ * Return: The original value of @v.
2812+ */
11632813 static __always_inline s64
11642814 atomic64_cmpxchg_relaxed(atomic64_t *v, s64 old, s64 new)
11652815 {
11662816 instrument_atomic_read_write(v, sizeof(*v));
1167− return arch_atomic64_cmpxchg_relaxed(v, old, new);
2817+ return raw_atomic64_cmpxchg_relaxed(v, old, new);
11682818 }
11692819
2820+/**
2821+ * atomic64_try_cmpxchg() - atomic compare and exchange with full ordering
2822+ * @v: pointer to atomic64_t
2823+ * @old: pointer to s64 value to compare with
2824+ * @new: s64 value to assign
2825+ *
2826+ * If (@v == @old), atomically updates @v to @new with full ordering.
2827+ * Otherwise, updates @old to the current value of @v.
2828+ *
2829+ * Unsafe to use in noinstr code; use raw_atomic64_try_cmpxchg() there.
2830+ *
2831+ * Return: @true if the exchange occured, @false otherwise.
2832+ */
11702833 static __always_inline bool
11712834 atomic64_try_cmpxchg(atomic64_t *v, s64 *old, s64 new)
11722835 {
11732836 kcsan_mb();
11742837 instrument_atomic_read_write(v, sizeof(*v));
11752838 instrument_atomic_read_write(old, sizeof(*old));
1176− return arch_atomic64_try_cmpxchg(v, old, new);
1177−}
1178−
2839+ return raw_atomic64_try_cmpxchg(v, old, new);
2840+}
2841+
2842+/**
2843+ * atomic64_try_cmpxchg_acquire() - atomic compare and exchange with acquire ordering
2844+ * @v: pointer to atomic64_t
2845+ * @old: pointer to s64 value to compare with
2846+ * @new: s64 value to assign
2847+ *
2848+ * If (@v == @old), atomically updates @v to @new with acquire ordering.
2849+ * Otherwise, updates @old to the current value of @v.
2850+ *
2851+ * Unsafe to use in noinstr code; use raw_atomic64_try_cmpxchg_acquire() there.
2852+ *
2853+ * Return: @true if the exchange occured, @false otherwise.
2854+ */
11792855 static __always_inline bool
11802856 atomic64_try_cmpxchg_acquire(atomic64_t *v, s64 *old, s64 new)
11812857 {
11822858 instrument_atomic_read_write(v, sizeof(*v));
11832859 instrument_atomic_read_write(old, sizeof(*old));
1184− return arch_atomic64_try_cmpxchg_acquire(v, old, new);
1185−}
1186−
2860+ return raw_atomic64_try_cmpxchg_acquire(v, old, new);
2861+}
2862+
2863+/**
2864+ * atomic64_try_cmpxchg_release() - atomic compare and exchange with release ordering
2865+ * @v: pointer to atomic64_t
2866+ * @old: pointer to s64 value to compare with
2867+ * @new: s64 value to assign
2868+ *
2869+ * If (@v == @old), atomically updates @v to @new with release ordering.
2870+ * Otherwise, updates @old to the current value of @v.
2871+ *
2872+ * Unsafe to use in noinstr code; use raw_atomic64_try_cmpxchg_release() there.
2873+ *
2874+ * Return: @true if the exchange occured, @false otherwise.
2875+ */
11872876 static __always_inline bool
11882877 atomic64_try_cmpxchg_release(atomic64_t *v, s64 *old, s64 new)
11892878 {
11902879 kcsan_release();
11912880 instrument_atomic_read_write(v, sizeof(*v));
11922881 instrument_atomic_read_write(old, sizeof(*old));
1193− return arch_atomic64_try_cmpxchg_release(v, old, new);
1194−}
1195−
2882+ return raw_atomic64_try_cmpxchg_release(v, old, new);
2883+}
2884+
2885+/**
2886+ * atomic64_try_cmpxchg_relaxed() - atomic compare and exchange with relaxed ordering
2887+ * @v: pointer to atomic64_t
2888+ * @old: pointer to s64 value to compare with
2889+ * @new: s64 value to assign
2890+ *
2891+ * If (@v == @old), atomically updates @v to @new with relaxed ordering.
2892+ * Otherwise, updates @old to the current value of @v.
2893+ *
2894+ * Unsafe to use in noinstr code; use raw_atomic64_try_cmpxchg_relaxed() there.
2895+ *
2896+ * Return: @true if the exchange occured, @false otherwise.
2897+ */
11962898 static __always_inline bool
11972899 atomic64_try_cmpxchg_relaxed(atomic64_t *v, s64 *old, s64 new)
11982900 {
11992901 instrument_atomic_read_write(v, sizeof(*v));
12002902 instrument_atomic_read_write(old, sizeof(*old));
1201− return arch_atomic64_try_cmpxchg_relaxed(v, old, new);
1202−}
1203−
2903+ return raw_atomic64_try_cmpxchg_relaxed(v, old, new);
2904+}
2905+
2906+/**
2907+ * atomic64_sub_and_test() - atomic subtract and test if zero with full ordering
2908+ * @i: s64 value to add
2909+ * @v: pointer to atomic64_t
2910+ *
2911+ * Atomically updates @v to (@v - @i) with full ordering.
2912+ *
2913+ * Unsafe to use in noinstr code; use raw_atomic64_sub_and_test() there.
2914+ *
2915+ * Return: @true if the resulting value of @v is zero, @false otherwise.
2916+ */
12042917 static __always_inline bool
12052918 atomic64_sub_and_test(s64 i, atomic64_t *v)
12062919 {
12072920 kcsan_mb();
12082921 instrument_atomic_read_write(v, sizeof(*v));
1209− return arch_atomic64_sub_and_test(i, v);
2922+ return raw_atomic64_sub_and_test(i, v);
12102923 }
12112924
2925+/**
2926+ * atomic64_dec_and_test() - atomic decrement and test if zero with full ordering
2927+ * @v: pointer to atomic64_t
2928+ *
2929+ * Atomically updates @v to (@v - 1) with full ordering.
2930+ *
2931+ * Unsafe to use in noinstr code; use raw_atomic64_dec_and_test() there.
2932+ *
2933+ * Return: @true if the resulting value of @v is zero, @false otherwise.
2934+ */
12122935 static __always_inline bool
12132936 atomic64_dec_and_test(atomic64_t *v)
12142937 {
12152938 kcsan_mb();
12162939 instrument_atomic_read_write(v, sizeof(*v));
1217− return arch_atomic64_dec_and_test(v);
2940+ return raw_atomic64_dec_and_test(v);
12182941 }
12192942
2943+/**
2944+ * atomic64_inc_and_test() - atomic increment and test if zero with full ordering
2945+ * @v: pointer to atomic64_t
2946+ *
2947+ * Atomically updates @v to (@v + 1) with full ordering.
2948+ *
2949+ * Unsafe to use in noinstr code; use raw_atomic64_inc_and_test() there.
2950+ *
2951+ * Return: @true if the resulting value of @v is zero, @false otherwise.
2952+ */
12202953 static __always_inline bool
12212954 atomic64_inc_and_test(atomic64_t *v)
12222955 {
12232956 kcsan_mb();
12242957 instrument_atomic_read_write(v, sizeof(*v));
1225− return arch_atomic64_inc_and_test(v);
2958+ return raw_atomic64_inc_and_test(v);
12262959 }
12272960
2961+/**
2962+ * atomic64_add_negative() - atomic add and test if negative with full ordering
2963+ * @i: s64 value to add
2964+ * @v: pointer to atomic64_t
2965+ *
2966+ * Atomically updates @v to (@v + @i) with full ordering.
2967+ *
2968+ * Unsafe to use in noinstr code; use raw_atomic64_add_negative() there.
2969+ *
2970+ * Return: @true if the resulting value of @v is negative, @false otherwise.
2971+ */
12282972 static __always_inline bool
12292973 atomic64_add_negative(s64 i, atomic64_t *v)
12302974 {
12312975 kcsan_mb();
12322976 instrument_atomic_read_write(v, sizeof(*v));
1233− return arch_atomic64_add_negative(i, v);
2977+ return raw_atomic64_add_negative(i, v);
12342978 }
12352979
2980+/**
2981+ * atomic64_add_negative_acquire() - atomic add and test if negative with acquire ordering
2982+ * @i: s64 value to add
2983+ * @v: pointer to atomic64_t
2984+ *
2985+ * Atomically updates @v to (@v + @i) with acquire ordering.
2986+ *
2987+ * Unsafe to use in noinstr code; use raw_atomic64_add_negative_acquire() there.
2988+ *
2989+ * Return: @true if the resulting value of @v is negative, @false otherwise.
2990+ */
12362991 static __always_inline bool
12372992 atomic64_add_negative_acquire(s64 i, atomic64_t *v)
12382993 {
12392994 instrument_atomic_read_write(v, sizeof(*v));
1240− return arch_atomic64_add_negative_acquire(i, v);
2995+ return raw_atomic64_add_negative_acquire(i, v);
12412996 }
12422997
2998+/**
2999+ * atomic64_add_negative_release() - atomic add and test if negative with release ordering
3000+ * @i: s64 value to add
3001+ * @v: pointer to atomic64_t
3002+ *
3003+ * Atomically updates @v to (@v + @i) with release ordering.
3004+ *
3005+ * Unsafe to use in noinstr code; use raw_atomic64_add_negative_release() there.
3006+ *
3007+ * Return: @true if the resulting value of @v is negative, @false otherwise.
3008+ */
12433009 static __always_inline bool
12443010 atomic64_add_negative_release(s64 i, atomic64_t *v)
12453011 {
12463012 kcsan_release();
12473013 instrument_atomic_read_write(v, sizeof(*v));
1248− return arch_atomic64_add_negative_release(i, v);
3014+ return raw_atomic64_add_negative_release(i, v);
12493015 }
12503016
3017+/**
3018+ * atomic64_add_negative_relaxed() - atomic add and test if negative with relaxed ordering
3019+ * @i: s64 value to add
3020+ * @v: pointer to atomic64_t
3021+ *
3022+ * Atomically updates @v to (@v + @i) with relaxed ordering.
3023+ *
3024+ * Unsafe to use in noinstr code; use raw_atomic64_add_negative_relaxed() there.
3025+ *
3026+ * Return: @true if the resulting value of @v is negative, @false otherwise.
3027+ */
12513028 static __always_inline bool
12523029 atomic64_add_negative_relaxed(s64 i, atomic64_t *v)
12533030 {
12543031 instrument_atomic_read_write(v, sizeof(*v));
1255− return arch_atomic64_add_negative_relaxed(i, v);
3032+ return raw_atomic64_add_negative_relaxed(i, v);
12563033 }
12573034
3035+/**
3036+ * atomic64_fetch_add_unless() - atomic add unless value with full ordering
3037+ * @v: pointer to atomic64_t
3038+ * @a: s64 value to add
3039+ * @u: s64 value to compare with
3040+ *
3041+ * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
3042+ *
3043+ * Unsafe to use in noinstr code; use raw_atomic64_fetch_add_unless() there.
3044+ *
3045+ * Return: The original value of @v.
3046+ */
12583047 static __always_inline s64
12593048 atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u)
12603049 {
12613050 kcsan_mb();
12623051 instrument_atomic_read_write(v, sizeof(*v));
1263− return arch_atomic64_fetch_add_unless(v, a, u);
3052+ return raw_atomic64_fetch_add_unless(v, a, u);
12643053 }
12653054
3055+/**
3056+ * atomic64_add_unless() - atomic add unless value with full ordering
3057+ * @v: pointer to atomic64_t
3058+ * @a: s64 value to add
3059+ * @u: s64 value to compare with
3060+ *
3061+ * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
3062+ *
3063+ * Unsafe to use in noinstr code; use raw_atomic64_add_unless() there.
3064+ *
3065+ * Return: @true if @v was updated, @false otherwise.
3066+ */
12663067 static __always_inline bool
12673068 atomic64_add_unless(atomic64_t *v, s64 a, s64 u)
12683069 {
12693070 kcsan_mb();
12703071 instrument_atomic_read_write(v, sizeof(*v));
1271− return arch_atomic64_add_unless(v, a, u);
3072+ return raw_atomic64_add_unless(v, a, u);
12723073 }
12733074
3075+/**
3076+ * atomic64_inc_not_zero() - atomic increment unless zero with full ordering
3077+ * @v: pointer to atomic64_t
3078+ *
3079+ * If (@v != 0), atomically updates @v to (@v + 1) with full ordering.
3080+ *
3081+ * Unsafe to use in noinstr code; use raw_atomic64_inc_not_zero() there.
3082+ *
3083+ * Return: @true if @v was updated, @false otherwise.
3084+ */
12743085 static __always_inline bool
12753086 atomic64_inc_not_zero(atomic64_t *v)
12763087 {
12773088 kcsan_mb();
12783089 instrument_atomic_read_write(v, sizeof(*v));
1279− return arch_atomic64_inc_not_zero(v);
3090+ return raw_atomic64_inc_not_zero(v);
12803091 }
12813092
3093+/**
3094+ * atomic64_inc_unless_negative() - atomic increment unless negative with full ordering
3095+ * @v: pointer to atomic64_t
3096+ *
3097+ * If (@v >= 0), atomically updates @v to (@v + 1) with full ordering.
3098+ *
3099+ * Unsafe to use in noinstr code; use raw_atomic64_inc_unless_negative() there.
3100+ *
3101+ * Return: @true if @v was updated, @false otherwise.
3102+ */
12823103 static __always_inline bool
12833104 atomic64_inc_unless_negative(atomic64_t *v)
12843105 {
12853106 kcsan_mb();
12863107 instrument_atomic_read_write(v, sizeof(*v));
1287− return arch_atomic64_inc_unless_negative(v);
3108+ return raw_atomic64_inc_unless_negative(v);
12883109 }
12893110
3111+/**
3112+ * atomic64_dec_unless_positive() - atomic decrement unless positive with full ordering
3113+ * @v: pointer to atomic64_t
3114+ *
3115+ * If (@v <= 0), atomically updates @v to (@v - 1) with full ordering.
3116+ *
3117+ * Unsafe to use in noinstr code; use raw_atomic64_dec_unless_positive() there.
3118+ *
3119+ * Return: @true if @v was updated, @false otherwise.
3120+ */
12903121 static __always_inline bool
12913122 atomic64_dec_unless_positive(atomic64_t *v)
12923123 {
12933124 kcsan_mb();
12943125 instrument_atomic_read_write(v, sizeof(*v));
1295− return arch_atomic64_dec_unless_positive(v);
3126+ return raw_atomic64_dec_unless_positive(v);
12963127 }
12973128
3129+/**
3130+ * atomic64_dec_if_positive() - atomic decrement if positive with full ordering
3131+ * @v: pointer to atomic64_t
3132+ *
3133+ * If (@v > 0), atomically updates @v to (@v - 1) with full ordering.
3134+ *
3135+ * Unsafe to use in noinstr code; use raw_atomic64_dec_if_positive() there.
3136+ *
3137+ * Return: The old value of (@v - 1), regardless of whether @v was updated.
3138+ */
12983139 static __always_inline s64
12993140 atomic64_dec_if_positive(atomic64_t *v)
13003141 {
13013142 kcsan_mb();
13023143 instrument_atomic_read_write(v, sizeof(*v));
1303− return arch_atomic64_dec_if_positive(v);
3144+ return raw_atomic64_dec_if_positive(v);
13043145 }
13053146
3147+/**
3148+ * atomic_long_read() - atomic load with relaxed ordering
3149+ * @v: pointer to atomic_long_t
3150+ *
3151+ * Atomically loads the value of @v with relaxed ordering.
3152+ *
3153+ * Unsafe to use in noinstr code; use raw_atomic_long_read() there.
3154+ *
3155+ * Return: The value loaded from @v.
3156+ */
13063157 static __always_inline long
13073158 atomic_long_read(const atomic_long_t *v)
13083159 {
13093160 instrument_atomic_read(v, sizeof(*v));
1310− return arch_atomic_long_read(v);
1311−}
1312−
3161+ return raw_atomic_long_read(v);
3162+}
3163+
3164+/**
3165+ * atomic_long_read_acquire() - atomic load with acquire ordering
3166+ * @v: pointer to atomic_long_t
3167+ *
3168+ * Atomically loads the value of @v with acquire ordering.
3169+ *
3170+ * Unsafe to use in noinstr code; use raw_atomic_long_read_acquire() there.
3171+ *
3172+ * Return: The value loaded from @v.
3173+ */
13133174 static __always_inline long
13143175 atomic_long_read_acquire(const atomic_long_t *v)
13153176 {
13163177 instrument_atomic_read(v, sizeof(*v));
1317− return arch_atomic_long_read_acquire(v);
1318−}
1319−
3178+ return raw_atomic_long_read_acquire(v);
3179+}
3180+
3181+/**
3182+ * atomic_long_set() - atomic set with relaxed ordering
3183+ * @v: pointer to atomic_long_t
3184+ * @i: long value to assign
3185+ *
3186+ * Atomically sets @v to @i with relaxed ordering.
3187+ *
3188+ * Unsafe to use in noinstr code; use raw_atomic_long_set() there.
3189+ *
3190+ * Return: Nothing.
3191+ */
13203192 static __always_inline void
13213193 atomic_long_set(atomic_long_t *v, long i)
13223194 {
13233195 instrument_atomic_write(v, sizeof(*v));
1324− arch_atomic_long_set(v, i);
1325−}
1326−
3196+ raw_atomic_long_set(v, i);
3197+}
3198+
3199+/**
3200+ * atomic_long_set_release() - atomic set with release ordering
3201+ * @v: pointer to atomic_long_t
3202+ * @i: long value to assign
3203+ *
3204+ * Atomically sets @v to @i with release ordering.
3205+ *
3206+ * Unsafe to use in noinstr code; use raw_atomic_long_set_release() there.
3207+ *
3208+ * Return: Nothing.
3209+ */
13273210 static __always_inline void
13283211 atomic_long_set_release(atomic_long_t *v, long i)
13293212 {
13303213 kcsan_release();
13313214 instrument_atomic_write(v, sizeof(*v));
1332− arch_atomic_long_set_release(v, i);
1333−}
1334−
3215+ raw_atomic_long_set_release(v, i);
3216+}
3217+
3218+/**
3219+ * atomic_long_add() - atomic add with relaxed ordering
3220+ * @i: long value to add
3221+ * @v: pointer to atomic_long_t
3222+ *
3223+ * Atomically updates @v to (@v + @i) with relaxed ordering.
3224+ *
3225+ * Unsafe to use in noinstr code; use raw_atomic_long_add() there.
3226+ *
3227+ * Return: Nothing.
3228+ */
13353229 static __always_inline void
13363230 atomic_long_add(long i, atomic_long_t *v)
13373231 {
13383232 instrument_atomic_read_write(v, sizeof(*v));
1339− arch_atomic_long_add(i, v);
3233+ raw_atomic_long_add(i, v);
13403234 }
13413235
3236+/**
3237+ * atomic_long_add_return() - atomic add with full ordering
3238+ * @i: long value to add
3239+ * @v: pointer to atomic_long_t
3240+ *
3241+ * Atomically updates @v to (@v + @i) with full ordering.
3242+ *
3243+ * Unsafe to use in noinstr code; use raw_atomic_long_add_return() there.
3244+ *
3245+ * Return: The updated value of @v.
3246+ */
13423247 static __always_inline long
13433248 atomic_long_add_return(long i, atomic_long_t *v)
13443249 {
13453250 kcsan_mb();
13463251 instrument_atomic_read_write(v, sizeof(*v));
1347− return arch_atomic_long_add_return(i, v);
3252+ return raw_atomic_long_add_return(i, v);
13483253 }
13493254
3255+/**
3256+ * atomic_long_add_return_acquire() - atomic add with acquire ordering
3257+ * @i: long value to add
3258+ * @v: pointer to atomic_long_t
3259+ *
3260+ * Atomically updates @v to (@v + @i) with acquire ordering.
3261+ *
3262+ * Unsafe to use in noinstr code; use raw_atomic_long_add_return_acquire() there.
3263+ *
3264+ * Return: The updated value of @v.
3265+ */
13503266 static __always_inline long
13513267 atomic_long_add_return_acquire(long i, atomic_long_t *v)
13523268 {
13533269 instrument_atomic_read_write(v, sizeof(*v));
1354− return arch_atomic_long_add_return_acquire(i, v);
3270+ return raw_atomic_long_add_return_acquire(i, v);
13553271 }
13563272
3273+/**
3274+ * atomic_long_add_return_release() - atomic add with release ordering
3275+ * @i: long value to add
3276+ * @v: pointer to atomic_long_t
3277+ *
3278+ * Atomically updates @v to (@v + @i) with release ordering.
3279+ *
3280+ * Unsafe to use in noinstr code; use raw_atomic_long_add_return_release() there.
3281+ *
3282+ * Return: The updated value of @v.
3283+ */
13573284 static __always_inline long
13583285 atomic_long_add_return_release(long i, atomic_long_t *v)
13593286 {
13603287 kcsan_release();
13613288 instrument_atomic_read_write(v, sizeof(*v));
1362− return arch_atomic_long_add_return_release(i, v);
3289+ return raw_atomic_long_add_return_release(i, v);
13633290 }
13643291
3292+/**
3293+ * atomic_long_add_return_relaxed() - atomic add with relaxed ordering
3294+ * @i: long value to add
3295+ * @v: pointer to atomic_long_t
3296+ *
3297+ * Atomically updates @v to (@v + @i) with relaxed ordering.
3298+ *
3299+ * Unsafe to use in noinstr code; use raw_atomic_long_add_return_relaxed() there.
3300+ *
3301+ * Return: The updated value of @v.
3302+ */
13653303 static __always_inline long
13663304 atomic_long_add_return_relaxed(long i, atomic_long_t *v)
13673305 {
13683306 instrument_atomic_read_write(v, sizeof(*v));
1369− return arch_atomic_long_add_return_relaxed(i, v);
3307+ return raw_atomic_long_add_return_relaxed(i, v);
13703308 }
13713309
3310+/**
3311+ * atomic_long_fetch_add() - atomic add with full ordering
3312+ * @i: long value to add
3313+ * @v: pointer to atomic_long_t
3314+ *
3315+ * Atomically updates @v to (@v + @i) with full ordering.
3316+ *
3317+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_add() there.
3318+ *
3319+ * Return: The original value of @v.
3320+ */
13723321 static __always_inline long
13733322 atomic_long_fetch_add(long i, atomic_long_t *v)
13743323 {
13753324 kcsan_mb();
13763325 instrument_atomic_read_write(v, sizeof(*v));
1377− return arch_atomic_long_fetch_add(i, v);
3326+ return raw_atomic_long_fetch_add(i, v);
13783327 }
13793328
3329+/**
3330+ * atomic_long_fetch_add_acquire() - atomic add with acquire ordering
3331+ * @i: long value to add
3332+ * @v: pointer to atomic_long_t
3333+ *
3334+ * Atomically updates @v to (@v + @i) with acquire ordering.
3335+ *
3336+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_add_acquire() there.
3337+ *
3338+ * Return: The original value of @v.
3339+ */
13803340 static __always_inline long
13813341 atomic_long_fetch_add_acquire(long i, atomic_long_t *v)
13823342 {
13833343 instrument_atomic_read_write(v, sizeof(*v));
1384− return arch_atomic_long_fetch_add_acquire(i, v);
3344+ return raw_atomic_long_fetch_add_acquire(i, v);
13853345 }
13863346
3347+/**
3348+ * atomic_long_fetch_add_release() - atomic add with release ordering
3349+ * @i: long value to add
3350+ * @v: pointer to atomic_long_t
3351+ *
3352+ * Atomically updates @v to (@v + @i) with release ordering.
3353+ *
3354+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_add_release() there.
3355+ *
3356+ * Return: The original value of @v.
3357+ */
13873358 static __always_inline long
13883359 atomic_long_fetch_add_release(long i, atomic_long_t *v)
13893360 {
13903361 kcsan_release();
13913362 instrument_atomic_read_write(v, sizeof(*v));
1392− return arch_atomic_long_fetch_add_release(i, v);
3363+ return raw_atomic_long_fetch_add_release(i, v);
13933364 }
13943365
3366+/**
3367+ * atomic_long_fetch_add_relaxed() - atomic add with relaxed ordering
3368+ * @i: long value to add
3369+ * @v: pointer to atomic_long_t
3370+ *
3371+ * Atomically updates @v to (@v + @i) with relaxed ordering.
3372+ *
3373+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_add_relaxed() there.
3374+ *
3375+ * Return: The original value of @v.
3376+ */
13953377 static __always_inline long
13963378 atomic_long_fetch_add_relaxed(long i, atomic_long_t *v)
13973379 {
13983380 instrument_atomic_read_write(v, sizeof(*v));
1399− return arch_atomic_long_fetch_add_relaxed(i, v);
3381+ return raw_atomic_long_fetch_add_relaxed(i, v);
14003382 }
14013383
3384+/**
3385+ * atomic_long_sub() - atomic subtract with relaxed ordering
3386+ * @i: long value to subtract
3387+ * @v: pointer to atomic_long_t
3388+ *
3389+ * Atomically updates @v to (@v - @i) with relaxed ordering.
3390+ *
3391+ * Unsafe to use in noinstr code; use raw_atomic_long_sub() there.
3392+ *
3393+ * Return: Nothing.
3394+ */
14023395 static __always_inline void
14033396 atomic_long_sub(long i, atomic_long_t *v)
14043397 {
14053398 instrument_atomic_read_write(v, sizeof(*v));
1406− arch_atomic_long_sub(i, v);
3399+ raw_atomic_long_sub(i, v);
14073400 }
14083401
3402+/**
3403+ * atomic_long_sub_return() - atomic subtract with full ordering
3404+ * @i: long value to subtract
3405+ * @v: pointer to atomic_long_t
3406+ *
3407+ * Atomically updates @v to (@v - @i) with full ordering.
3408+ *
3409+ * Unsafe to use in noinstr code; use raw_atomic_long_sub_return() there.
3410+ *
3411+ * Return: The updated value of @v.
3412+ */
14093413 static __always_inline long
14103414 atomic_long_sub_return(long i, atomic_long_t *v)
14113415 {
14123416 kcsan_mb();
14133417 instrument_atomic_read_write(v, sizeof(*v));
1414− return arch_atomic_long_sub_return(i, v);
3418+ return raw_atomic_long_sub_return(i, v);
14153419 }
14163420
3421+/**
3422+ * atomic_long_sub_return_acquire() - atomic subtract with acquire ordering
3423+ * @i: long value to subtract
3424+ * @v: pointer to atomic_long_t
3425+ *
3426+ * Atomically updates @v to (@v - @i) with acquire ordering.
3427+ *
3428+ * Unsafe to use in noinstr code; use raw_atomic_long_sub_return_acquire() there.
3429+ *
3430+ * Return: The updated value of @v.
3431+ */
14173432 static __always_inline long
14183433 atomic_long_sub_return_acquire(long i, atomic_long_t *v)
14193434 {
14203435 instrument_atomic_read_write(v, sizeof(*v));
1421− return arch_atomic_long_sub_return_acquire(i, v);
3436+ return raw_atomic_long_sub_return_acquire(i, v);
14223437 }
14233438
3439+/**
3440+ * atomic_long_sub_return_release() - atomic subtract with release ordering
3441+ * @i: long value to subtract
3442+ * @v: pointer to atomic_long_t
3443+ *
3444+ * Atomically updates @v to (@v - @i) with release ordering.
3445+ *
3446+ * Unsafe to use in noinstr code; use raw_atomic_long_sub_return_release() there.
3447+ *
3448+ * Return: The updated value of @v.
3449+ */
14243450 static __always_inline long
14253451 atomic_long_sub_return_release(long i, atomic_long_t *v)
14263452 {
14273453 kcsan_release();
14283454 instrument_atomic_read_write(v, sizeof(*v));
1429− return arch_atomic_long_sub_return_release(i, v);
3455+ return raw_atomic_long_sub_return_release(i, v);
14303456 }
14313457
3458+/**
3459+ * atomic_long_sub_return_relaxed() - atomic subtract with relaxed ordering
3460+ * @i: long value to subtract
3461+ * @v: pointer to atomic_long_t
3462+ *
3463+ * Atomically updates @v to (@v - @i) with relaxed ordering.
3464+ *
3465+ * Unsafe to use in noinstr code; use raw_atomic_long_sub_return_relaxed() there.
3466+ *
3467+ * Return: The updated value of @v.
3468+ */
14323469 static __always_inline long
14333470 atomic_long_sub_return_relaxed(long i, atomic_long_t *v)
14343471 {
14353472 instrument_atomic_read_write(v, sizeof(*v));
1436− return arch_atomic_long_sub_return_relaxed(i, v);
3473+ return raw_atomic_long_sub_return_relaxed(i, v);
14373474 }
14383475
3476+/**
3477+ * atomic_long_fetch_sub() - atomic subtract with full ordering
3478+ * @i: long value to subtract
3479+ * @v: pointer to atomic_long_t
3480+ *
3481+ * Atomically updates @v to (@v - @i) with full ordering.
3482+ *
3483+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_sub() there.
3484+ *
3485+ * Return: The original value of @v.
3486+ */
14393487 static __always_inline long
14403488 atomic_long_fetch_sub(long i, atomic_long_t *v)
14413489 {
14423490 kcsan_mb();
14433491 instrument_atomic_read_write(v, sizeof(*v));
1444− return arch_atomic_long_fetch_sub(i, v);
3492+ return raw_atomic_long_fetch_sub(i, v);
14453493 }
14463494
3495+/**
3496+ * atomic_long_fetch_sub_acquire() - atomic subtract with acquire ordering
3497+ * @i: long value to subtract
3498+ * @v: pointer to atomic_long_t
3499+ *
3500+ * Atomically updates @v to (@v - @i) with acquire ordering.
3501+ *
3502+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_sub_acquire() there.
3503+ *
3504+ * Return: The original value of @v.
3505+ */
14473506 static __always_inline long
14483507 atomic_long_fetch_sub_acquire(long i, atomic_long_t *v)
14493508 {
14503509 instrument_atomic_read_write(v, sizeof(*v));
1451− return arch_atomic_long_fetch_sub_acquire(i, v);
3510+ return raw_atomic_long_fetch_sub_acquire(i, v);
14523511 }
14533512
3513+/**
3514+ * atomic_long_fetch_sub_release() - atomic subtract with release ordering
3515+ * @i: long value to subtract
3516+ * @v: pointer to atomic_long_t
3517+ *
3518+ * Atomically updates @v to (@v - @i) with release ordering.
3519+ *
3520+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_sub_release() there.
3521+ *
3522+ * Return: The original value of @v.
3523+ */
14543524 static __always_inline long
14553525 atomic_long_fetch_sub_release(long i, atomic_long_t *v)
14563526 {
14573527 kcsan_release();
14583528 instrument_atomic_read_write(v, sizeof(*v));
1459− return arch_atomic_long_fetch_sub_release(i, v);
3529+ return raw_atomic_long_fetch_sub_release(i, v);
14603530 }
14613531
3532+/**
3533+ * atomic_long_fetch_sub_relaxed() - atomic subtract with relaxed ordering
3534+ * @i: long value to subtract
3535+ * @v: pointer to atomic_long_t
3536+ *
3537+ * Atomically updates @v to (@v - @i) with relaxed ordering.
3538+ *
3539+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_sub_relaxed() there.
3540+ *
3541+ * Return: The original value of @v.
3542+ */
14623543 static __always_inline long
14633544 atomic_long_fetch_sub_relaxed(long i, atomic_long_t *v)
14643545 {
14653546 instrument_atomic_read_write(v, sizeof(*v));
1466− return arch_atomic_long_fetch_sub_relaxed(i, v);
3547+ return raw_atomic_long_fetch_sub_relaxed(i, v);
14673548 }
14683549
3550+/**
3551+ * atomic_long_inc() - atomic increment with relaxed ordering
3552+ * @v: pointer to atomic_long_t
3553+ *
3554+ * Atomically updates @v to (@v + 1) with relaxed ordering.
3555+ *
3556+ * Unsafe to use in noinstr code; use raw_atomic_long_inc() there.
3557+ *
3558+ * Return: Nothing.
3559+ */
14693560 static __always_inline void
14703561 atomic_long_inc(atomic_long_t *v)
14713562 {
14723563 instrument_atomic_read_write(v, sizeof(*v));
1473− arch_atomic_long_inc(v);
3564+ raw_atomic_long_inc(v);
14743565 }
14753566
3567+/**
3568+ * atomic_long_inc_return() - atomic increment with full ordering
3569+ * @v: pointer to atomic_long_t
3570+ *
3571+ * Atomically updates @v to (@v + 1) with full ordering.
3572+ *
3573+ * Unsafe to use in noinstr code; use raw_atomic_long_inc_return() there.
3574+ *
3575+ * Return: The updated value of @v.
3576+ */
14763577 static __always_inline long
14773578 atomic_long_inc_return(atomic_long_t *v)
14783579 {
14793580 kcsan_mb();
14803581 instrument_atomic_read_write(v, sizeof(*v));
1481− return arch_atomic_long_inc_return(v);
3582+ return raw_atomic_long_inc_return(v);
14823583 }
14833584
3585+/**
3586+ * atomic_long_inc_return_acquire() - atomic increment with acquire ordering
3587+ * @v: pointer to atomic_long_t
3588+ *
3589+ * Atomically updates @v to (@v + 1) with acquire ordering.
3590+ *
3591+ * Unsafe to use in noinstr code; use raw_atomic_long_inc_return_acquire() there.
3592+ *
3593+ * Return: The updated value of @v.
3594+ */
14843595 static __always_inline long
14853596 atomic_long_inc_return_acquire(atomic_long_t *v)
14863597 {
14873598 instrument_atomic_read_write(v, sizeof(*v));
1488− return arch_atomic_long_inc_return_acquire(v);
3599+ return raw_atomic_long_inc_return_acquire(v);
14893600 }
14903601
3602+/**
3603+ * atomic_long_inc_return_release() - atomic increment with release ordering
3604+ * @v: pointer to atomic_long_t
3605+ *
3606+ * Atomically updates @v to (@v + 1) with release ordering.
3607+ *
3608+ * Unsafe to use in noinstr code; use raw_atomic_long_inc_return_release() there.
3609+ *
3610+ * Return: The updated value of @v.
3611+ */
14913612 static __always_inline long
14923613 atomic_long_inc_return_release(atomic_long_t *v)
14933614 {
14943615 kcsan_release();
14953616 instrument_atomic_read_write(v, sizeof(*v));
1496− return arch_atomic_long_inc_return_release(v);
3617+ return raw_atomic_long_inc_return_release(v);
14973618 }
14983619
3620+/**
3621+ * atomic_long_inc_return_relaxed() - atomic increment with relaxed ordering
3622+ * @v: pointer to atomic_long_t
3623+ *
3624+ * Atomically updates @v to (@v + 1) with relaxed ordering.
3625+ *
3626+ * Unsafe to use in noinstr code; use raw_atomic_long_inc_return_relaxed() there.
3627+ *
3628+ * Return: The updated value of @v.
3629+ */
14993630 static __always_inline long
15003631 atomic_long_inc_return_relaxed(atomic_long_t *v)
15013632 {
15023633 instrument_atomic_read_write(v, sizeof(*v));
1503− return arch_atomic_long_inc_return_relaxed(v);
3634+ return raw_atomic_long_inc_return_relaxed(v);
15043635 }
15053636
3637+/**
3638+ * atomic_long_fetch_inc() - atomic increment with full ordering
3639+ * @v: pointer to atomic_long_t
3640+ *
3641+ * Atomically updates @v to (@v + 1) with full ordering.
3642+ *
3643+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_inc() there.
3644+ *
3645+ * Return: The original value of @v.
3646+ */
15063647 static __always_inline long
15073648 atomic_long_fetch_inc(atomic_long_t *v)
15083649 {
15093650 kcsan_mb();
15103651 instrument_atomic_read_write(v, sizeof(*v));
1511− return arch_atomic_long_fetch_inc(v);
3652+ return raw_atomic_long_fetch_inc(v);
15123653 }
15133654
3655+/**
3656+ * atomic_long_fetch_inc_acquire() - atomic increment with acquire ordering
3657+ * @v: pointer to atomic_long_t
3658+ *
3659+ * Atomically updates @v to (@v + 1) with acquire ordering.
3660+ *
3661+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_inc_acquire() there.
3662+ *
3663+ * Return: The original value of @v.
3664+ */
15143665 static __always_inline long
15153666 atomic_long_fetch_inc_acquire(atomic_long_t *v)
15163667 {
15173668 instrument_atomic_read_write(v, sizeof(*v));
1518− return arch_atomic_long_fetch_inc_acquire(v);
3669+ return raw_atomic_long_fetch_inc_acquire(v);
15193670 }
15203671
3672+/**
3673+ * atomic_long_fetch_inc_release() - atomic increment with release ordering
3674+ * @v: pointer to atomic_long_t
3675+ *
3676+ * Atomically updates @v to (@v + 1) with release ordering.
3677+ *
3678+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_inc_release() there.
3679+ *
3680+ * Return: The original value of @v.
3681+ */
15213682 static __always_inline long
15223683 atomic_long_fetch_inc_release(atomic_long_t *v)
15233684 {
15243685 kcsan_release();
15253686 instrument_atomic_read_write(v, sizeof(*v));
1526− return arch_atomic_long_fetch_inc_release(v);
3687+ return raw_atomic_long_fetch_inc_release(v);
15273688 }
15283689
3690+/**
3691+ * atomic_long_fetch_inc_relaxed() - atomic increment with relaxed ordering
3692+ * @v: pointer to atomic_long_t
3693+ *
3694+ * Atomically updates @v to (@v + 1) with relaxed ordering.
3695+ *
3696+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_inc_relaxed() there.
3697+ *
3698+ * Return: The original value of @v.
3699+ */
15293700 static __always_inline long
15303701 atomic_long_fetch_inc_relaxed(atomic_long_t *v)
15313702 {
15323703 instrument_atomic_read_write(v, sizeof(*v));
1533− return arch_atomic_long_fetch_inc_relaxed(v);
3704+ return raw_atomic_long_fetch_inc_relaxed(v);
15343705 }
15353706
3707+/**
3708+ * atomic_long_dec() - atomic decrement with relaxed ordering
3709+ * @v: pointer to atomic_long_t
3710+ *
3711+ * Atomically updates @v to (@v - 1) with relaxed ordering.
3712+ *
3713+ * Unsafe to use in noinstr code; use raw_atomic_long_dec() there.
3714+ *
3715+ * Return: Nothing.
3716+ */
15363717 static __always_inline void
15373718 atomic_long_dec(atomic_long_t *v)
15383719 {
15393720 instrument_atomic_read_write(v, sizeof(*v));
1540− arch_atomic_long_dec(v);
3721+ raw_atomic_long_dec(v);
15413722 }
15423723
3724+/**
3725+ * atomic_long_dec_return() - atomic decrement with full ordering
3726+ * @v: pointer to atomic_long_t
3727+ *
3728+ * Atomically updates @v to (@v - 1) with full ordering.
3729+ *
3730+ * Unsafe to use in noinstr code; use raw_atomic_long_dec_return() there.
3731+ *
3732+ * Return: The updated value of @v.
3733+ */
15433734 static __always_inline long
15443735 atomic_long_dec_return(atomic_long_t *v)
15453736 {
15463737 kcsan_mb();
15473738 instrument_atomic_read_write(v, sizeof(*v));
1548− return arch_atomic_long_dec_return(v);
3739+ return raw_atomic_long_dec_return(v);
15493740 }
15503741
3742+/**
3743+ * atomic_long_dec_return_acquire() - atomic decrement with acquire ordering
3744+ * @v: pointer to atomic_long_t
3745+ *
3746+ * Atomically updates @v to (@v - 1) with acquire ordering.
3747+ *
3748+ * Unsafe to use in noinstr code; use raw_atomic_long_dec_return_acquire() there.
3749+ *
3750+ * Return: The updated value of @v.
3751+ */
15513752 static __always_inline long
15523753 atomic_long_dec_return_acquire(atomic_long_t *v)
15533754 {
15543755 instrument_atomic_read_write(v, sizeof(*v));
1555− return arch_atomic_long_dec_return_acquire(v);
3756+ return raw_atomic_long_dec_return_acquire(v);
15563757 }
15573758
3759+/**
3760+ * atomic_long_dec_return_release() - atomic decrement with release ordering
3761+ * @v: pointer to atomic_long_t
3762+ *
3763+ * Atomically updates @v to (@v - 1) with release ordering.
3764+ *
3765+ * Unsafe to use in noinstr code; use raw_atomic_long_dec_return_release() there.
3766+ *
3767+ * Return: The updated value of @v.
3768+ */
15583769 static __always_inline long
15593770 atomic_long_dec_return_release(atomic_long_t *v)
15603771 {
15613772 kcsan_release();
15623773 instrument_atomic_read_write(v, sizeof(*v));
1563− return arch_atomic_long_dec_return_release(v);
3774+ return raw_atomic_long_dec_return_release(v);
15643775 }
15653776
3777+/**
3778+ * atomic_long_dec_return_relaxed() - atomic decrement with relaxed ordering
3779+ * @v: pointer to atomic_long_t
3780+ *
3781+ * Atomically updates @v to (@v - 1) with relaxed ordering.
3782+ *
3783+ * Unsafe to use in noinstr code; use raw_atomic_long_dec_return_relaxed() there.
3784+ *
3785+ * Return: The updated value of @v.
3786+ */
15663787 static __always_inline long
15673788 atomic_long_dec_return_relaxed(atomic_long_t *v)
15683789 {
15693790 instrument_atomic_read_write(v, sizeof(*v));
1570− return arch_atomic_long_dec_return_relaxed(v);
3791+ return raw_atomic_long_dec_return_relaxed(v);
15713792 }
15723793
3794+/**
3795+ * atomic_long_fetch_dec() - atomic decrement with full ordering
3796+ * @v: pointer to atomic_long_t
3797+ *
3798+ * Atomically updates @v to (@v - 1) with full ordering.
3799+ *
3800+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_dec() there.
3801+ *
3802+ * Return: The original value of @v.
3803+ */
15733804 static __always_inline long
15743805 atomic_long_fetch_dec(atomic_long_t *v)
15753806 {
15763807 kcsan_mb();
15773808 instrument_atomic_read_write(v, sizeof(*v));
1578− return arch_atomic_long_fetch_dec(v);
3809+ return raw_atomic_long_fetch_dec(v);
15793810 }
15803811
3812+/**
3813+ * atomic_long_fetch_dec_acquire() - atomic decrement with acquire ordering
3814+ * @v: pointer to atomic_long_t
3815+ *
3816+ * Atomically updates @v to (@v - 1) with acquire ordering.
3817+ *
3818+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_dec_acquire() there.
3819+ *
3820+ * Return: The original value of @v.
3821+ */
15813822 static __always_inline long
15823823 atomic_long_fetch_dec_acquire(atomic_long_t *v)
15833824 {
15843825 instrument_atomic_read_write(v, sizeof(*v));
1585− return arch_atomic_long_fetch_dec_acquire(v);
3826+ return raw_atomic_long_fetch_dec_acquire(v);
15863827 }
15873828
3829+/**
3830+ * atomic_long_fetch_dec_release() - atomic decrement with release ordering
3831+ * @v: pointer to atomic_long_t
3832+ *
3833+ * Atomically updates @v to (@v - 1) with release ordering.
3834+ *
3835+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_dec_release() there.
3836+ *
3837+ * Return: The original value of @v.
3838+ */
15883839 static __always_inline long
15893840 atomic_long_fetch_dec_release(atomic_long_t *v)
15903841 {
15913842 kcsan_release();
15923843 instrument_atomic_read_write(v, sizeof(*v));
1593− return arch_atomic_long_fetch_dec_release(v);
3844+ return raw_atomic_long_fetch_dec_release(v);
15943845 }
15953846
3847+/**
3848+ * atomic_long_fetch_dec_relaxed() - atomic decrement with relaxed ordering
3849+ * @v: pointer to atomic_long_t
3850+ *
3851+ * Atomically updates @v to (@v - 1) with relaxed ordering.
3852+ *
3853+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_dec_relaxed() there.
3854+ *
3855+ * Return: The original value of @v.
3856+ */
15963857 static __always_inline long
15973858 atomic_long_fetch_dec_relaxed(atomic_long_t *v)
15983859 {
15993860 instrument_atomic_read_write(v, sizeof(*v));
1600− return arch_atomic_long_fetch_dec_relaxed(v);
3861+ return raw_atomic_long_fetch_dec_relaxed(v);
16013862 }
16023863
3864+/**
3865+ * atomic_long_and() - atomic bitwise AND with relaxed ordering
3866+ * @i: long value
3867+ * @v: pointer to atomic_long_t
3868+ *
3869+ * Atomically updates @v to (@v & @i) with relaxed ordering.
3870+ *
3871+ * Unsafe to use in noinstr code; use raw_atomic_long_and() there.
3872+ *
3873+ * Return: Nothing.
3874+ */
16033875 static __always_inline void
16043876 atomic_long_and(long i, atomic_long_t *v)
16053877 {
16063878 instrument_atomic_read_write(v, sizeof(*v));
1607− arch_atomic_long_and(i, v);
3879+ raw_atomic_long_and(i, v);
16083880 }
16093881
3882+/**
3883+ * atomic_long_fetch_and() - atomic bitwise AND with full ordering
3884+ * @i: long value
3885+ * @v: pointer to atomic_long_t
3886+ *
3887+ * Atomically updates @v to (@v & @i) with full ordering.
3888+ *
3889+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_and() there.
3890+ *
3891+ * Return: The original value of @v.
3892+ */
16103893 static __always_inline long
16113894 atomic_long_fetch_and(long i, atomic_long_t *v)
16123895 {
16133896 kcsan_mb();
16143897 instrument_atomic_read_write(v, sizeof(*v));
1615− return arch_atomic_long_fetch_and(i, v);
3898+ return raw_atomic_long_fetch_and(i, v);
16163899 }
16173900
3901+/**
3902+ * atomic_long_fetch_and_acquire() - atomic bitwise AND with acquire ordering
3903+ * @i: long value
3904+ * @v: pointer to atomic_long_t
3905+ *
3906+ * Atomically updates @v to (@v & @i) with acquire ordering.
3907+ *
3908+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_and_acquire() there.
3909+ *
3910+ * Return: The original value of @v.
3911+ */
16183912 static __always_inline long
16193913 atomic_long_fetch_and_acquire(long i, atomic_long_t *v)
16203914 {
16213915 instrument_atomic_read_write(v, sizeof(*v));
1622− return arch_atomic_long_fetch_and_acquire(i, v);
3916+ return raw_atomic_long_fetch_and_acquire(i, v);
16233917 }
16243918
3919+/**
3920+ * atomic_long_fetch_and_release() - atomic bitwise AND with release ordering
3921+ * @i: long value
3922+ * @v: pointer to atomic_long_t
3923+ *
3924+ * Atomically updates @v to (@v & @i) with release ordering.
3925+ *
3926+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_and_release() there.
3927+ *
3928+ * Return: The original value of @v.
3929+ */
16253930 static __always_inline long
16263931 atomic_long_fetch_and_release(long i, atomic_long_t *v)
16273932 {
16283933 kcsan_release();
16293934 instrument_atomic_read_write(v, sizeof(*v));
1630− return arch_atomic_long_fetch_and_release(i, v);
3935+ return raw_atomic_long_fetch_and_release(i, v);
16313936 }
16323937
3938+/**
3939+ * atomic_long_fetch_and_relaxed() - atomic bitwise AND with relaxed ordering
3940+ * @i: long value
3941+ * @v: pointer to atomic_long_t
3942+ *
3943+ * Atomically updates @v to (@v & @i) with relaxed ordering.
3944+ *
3945+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_and_relaxed() there.
3946+ *
3947+ * Return: The original value of @v.
3948+ */
16333949 static __always_inline long
16343950 atomic_long_fetch_and_relaxed(long i, atomic_long_t *v)
16353951 {
16363952 instrument_atomic_read_write(v, sizeof(*v));
1637− return arch_atomic_long_fetch_and_relaxed(i, v);
3953+ return raw_atomic_long_fetch_and_relaxed(i, v);
16383954 }
16393955
3956+/**
3957+ * atomic_long_andnot() - atomic bitwise AND NOT with relaxed ordering
3958+ * @i: long value
3959+ * @v: pointer to atomic_long_t
3960+ *
3961+ * Atomically updates @v to (@v & ~@i) with relaxed ordering.
3962+ *
3963+ * Unsafe to use in noinstr code; use raw_atomic_long_andnot() there.
3964+ *
3965+ * Return: Nothing.
3966+ */
16403967 static __always_inline void
16413968 atomic_long_andnot(long i, atomic_long_t *v)
16423969 {
16433970 instrument_atomic_read_write(v, sizeof(*v));
1644− arch_atomic_long_andnot(i, v);
3971+ raw_atomic_long_andnot(i, v);
16453972 }
16463973
3974+/**
3975+ * atomic_long_fetch_andnot() - atomic bitwise AND NOT with full ordering
3976+ * @i: long value
3977+ * @v: pointer to atomic_long_t
3978+ *
3979+ * Atomically updates @v to (@v & ~@i) with full ordering.
3980+ *
3981+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_andnot() there.
3982+ *
3983+ * Return: The original value of @v.
3984+ */
16473985 static __always_inline long
16483986 atomic_long_fetch_andnot(long i, atomic_long_t *v)
16493987 {
16503988 kcsan_mb();
16513989 instrument_atomic_read_write(v, sizeof(*v));
1652− return arch_atomic_long_fetch_andnot(i, v);
3990+ return raw_atomic_long_fetch_andnot(i, v);
16533991 }
16543992
3993+/**
3994+ * atomic_long_fetch_andnot_acquire() - atomic bitwise AND NOT with acquire ordering
3995+ * @i: long value
3996+ * @v: pointer to atomic_long_t
3997+ *
3998+ * Atomically updates @v to (@v & ~@i) with acquire ordering.
3999+ *
4000+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_andnot_acquire() there.
4001+ *
4002+ * Return: The original value of @v.
4003+ */
16554004 static __always_inline long
16564005 atomic_long_fetch_andnot_acquire(long i, atomic_long_t *v)
16574006 {
16584007 instrument_atomic_read_write(v, sizeof(*v));
1659− return arch_atomic_long_fetch_andnot_acquire(i, v);
4008+ return raw_atomic_long_fetch_andnot_acquire(i, v);
16604009 }
16614010
4011+/**
4012+ * atomic_long_fetch_andnot_release() - atomic bitwise AND NOT with release ordering
4013+ * @i: long value
4014+ * @v: pointer to atomic_long_t
4015+ *
4016+ * Atomically updates @v to (@v & ~@i) with release ordering.
4017+ *
4018+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_andnot_release() there.
4019+ *
4020+ * Return: The original value of @v.
4021+ */
16624022 static __always_inline long
16634023 atomic_long_fetch_andnot_release(long i, atomic_long_t *v)
16644024 {
16654025 kcsan_release();
16664026 instrument_atomic_read_write(v, sizeof(*v));
1667− return arch_atomic_long_fetch_andnot_release(i, v);
4027+ return raw_atomic_long_fetch_andnot_release(i, v);
16684028 }
16694029
4030+/**
4031+ * atomic_long_fetch_andnot_relaxed() - atomic bitwise AND NOT with relaxed ordering
4032+ * @i: long value
4033+ * @v: pointer to atomic_long_t
4034+ *
4035+ * Atomically updates @v to (@v & ~@i) with relaxed ordering.
4036+ *
4037+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_andnot_relaxed() there.
4038+ *
4039+ * Return: The original value of @v.
4040+ */
16704041 static __always_inline long
16714042 atomic_long_fetch_andnot_relaxed(long i, atomic_long_t *v)
16724043 {
16734044 instrument_atomic_read_write(v, sizeof(*v));
1674− return arch_atomic_long_fetch_andnot_relaxed(i, v);
4045+ return raw_atomic_long_fetch_andnot_relaxed(i, v);
16754046 }
16764047
4048+/**
4049+ * atomic_long_or() - atomic bitwise OR with relaxed ordering
4050+ * @i: long value
4051+ * @v: pointer to atomic_long_t
4052+ *
4053+ * Atomically updates @v to (@v | @i) with relaxed ordering.
4054+ *
4055+ * Unsafe to use in noinstr code; use raw_atomic_long_or() there.
4056+ *
4057+ * Return: Nothing.
4058+ */
16774059 static __always_inline void
16784060 atomic_long_or(long i, atomic_long_t *v)
16794061 {
16804062 instrument_atomic_read_write(v, sizeof(*v));
1681− arch_atomic_long_or(i, v);
4063+ raw_atomic_long_or(i, v);
16824064 }
16834065
4066+/**
4067+ * atomic_long_fetch_or() - atomic bitwise OR with full ordering
4068+ * @i: long value
4069+ * @v: pointer to atomic_long_t
4070+ *
4071+ * Atomically updates @v to (@v | @i) with full ordering.
4072+ *
4073+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_or() there.
4074+ *
4075+ * Return: The original value of @v.
4076+ */
16844077 static __always_inline long
16854078 atomic_long_fetch_or(long i, atomic_long_t *v)
16864079 {
16874080 kcsan_mb();
16884081 instrument_atomic_read_write(v, sizeof(*v));
1689− return arch_atomic_long_fetch_or(i, v);
4082+ return raw_atomic_long_fetch_or(i, v);
16904083 }
16914084
4085+/**
4086+ * atomic_long_fetch_or_acquire() - atomic bitwise OR with acquire ordering
4087+ * @i: long value
4088+ * @v: pointer to atomic_long_t
4089+ *
4090+ * Atomically updates @v to (@v | @i) with acquire ordering.
4091+ *
4092+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_or_acquire() there.
4093+ *
4094+ * Return: The original value of @v.
4095+ */
16924096 static __always_inline long
16934097 atomic_long_fetch_or_acquire(long i, atomic_long_t *v)
16944098 {
16954099 instrument_atomic_read_write(v, sizeof(*v));
1696− return arch_atomic_long_fetch_or_acquire(i, v);
4100+ return raw_atomic_long_fetch_or_acquire(i, v);
16974101 }
16984102
4103+/**
4104+ * atomic_long_fetch_or_release() - atomic bitwise OR with release ordering
4105+ * @i: long value
4106+ * @v: pointer to atomic_long_t
4107+ *
4108+ * Atomically updates @v to (@v | @i) with release ordering.
4109+ *
4110+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_or_release() there.
4111+ *
4112+ * Return: The original value of @v.
4113+ */
16994114 static __always_inline long
17004115 atomic_long_fetch_or_release(long i, atomic_long_t *v)
17014116 {
17024117 kcsan_release();
17034118 instrument_atomic_read_write(v, sizeof(*v));
1704− return arch_atomic_long_fetch_or_release(i, v);
4119+ return raw_atomic_long_fetch_or_release(i, v);
17054120 }
17064121
4122+/**
4123+ * atomic_long_fetch_or_relaxed() - atomic bitwise OR with relaxed ordering
4124+ * @i: long value
4125+ * @v: pointer to atomic_long_t
4126+ *
4127+ * Atomically updates @v to (@v | @i) with relaxed ordering.
4128+ *
4129+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_or_relaxed() there.
4130+ *
4131+ * Return: The original value of @v.
4132+ */
17074133 static __always_inline long
17084134 atomic_long_fetch_or_relaxed(long i, atomic_long_t *v)
17094135 {
17104136 instrument_atomic_read_write(v, sizeof(*v));
1711− return arch_atomic_long_fetch_or_relaxed(i, v);
4137+ return raw_atomic_long_fetch_or_relaxed(i, v);
17124138 }
17134139
4140+/**
4141+ * atomic_long_xor() - atomic bitwise XOR with relaxed ordering
4142+ * @i: long value
4143+ * @v: pointer to atomic_long_t
4144+ *
4145+ * Atomically updates @v to (@v ^ @i) with relaxed ordering.
4146+ *
4147+ * Unsafe to use in noinstr code; use raw_atomic_long_xor() there.
4148+ *
4149+ * Return: Nothing.
4150+ */
17144151 static __always_inline void
17154152 atomic_long_xor(long i, atomic_long_t *v)
17164153 {
17174154 instrument_atomic_read_write(v, sizeof(*v));
1718− arch_atomic_long_xor(i, v);
4155+ raw_atomic_long_xor(i, v);
17194156 }
17204157
4158+/**
4159+ * atomic_long_fetch_xor() - atomic bitwise XOR with full ordering
4160+ * @i: long value
4161+ * @v: pointer to atomic_long_t
4162+ *
4163+ * Atomically updates @v to (@v ^ @i) with full ordering.
4164+ *
4165+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_xor() there.
4166+ *
4167+ * Return: The original value of @v.
4168+ */
17214169 static __always_inline long
17224170 atomic_long_fetch_xor(long i, atomic_long_t *v)
17234171 {
17244172 kcsan_mb();
17254173 instrument_atomic_read_write(v, sizeof(*v));
1726− return arch_atomic_long_fetch_xor(i, v);
4174+ return raw_atomic_long_fetch_xor(i, v);
17274175 }
17284176
4177+/**
4178+ * atomic_long_fetch_xor_acquire() - atomic bitwise XOR with acquire ordering
4179+ * @i: long value
4180+ * @v: pointer to atomic_long_t
4181+ *
4182+ * Atomically updates @v to (@v ^ @i) with acquire ordering.
4183+ *
4184+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_xor_acquire() there.
4185+ *
4186+ * Return: The original value of @v.
4187+ */
17294188 static __always_inline long
17304189 atomic_long_fetch_xor_acquire(long i, atomic_long_t *v)
17314190 {
17324191 instrument_atomic_read_write(v, sizeof(*v));
1733− return arch_atomic_long_fetch_xor_acquire(i, v);
4192+ return raw_atomic_long_fetch_xor_acquire(i, v);
17344193 }
17354194
4195+/**
4196+ * atomic_long_fetch_xor_release() - atomic bitwise XOR with release ordering
4197+ * @i: long value
4198+ * @v: pointer to atomic_long_t
4199+ *
4200+ * Atomically updates @v to (@v ^ @i) with release ordering.
4201+ *
4202+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_xor_release() there.
4203+ *
4204+ * Return: The original value of @v.
4205+ */
17364206 static __always_inline long
17374207 atomic_long_fetch_xor_release(long i, atomic_long_t *v)
17384208 {
17394209 kcsan_release();
17404210 instrument_atomic_read_write(v, sizeof(*v));
1741− return arch_atomic_long_fetch_xor_release(i, v);
4211+ return raw_atomic_long_fetch_xor_release(i, v);
17424212 }
17434213
4214+/**
4215+ * atomic_long_fetch_xor_relaxed() - atomic bitwise XOR with relaxed ordering
4216+ * @i: long value
4217+ * @v: pointer to atomic_long_t
4218+ *
4219+ * Atomically updates @v to (@v ^ @i) with relaxed ordering.
4220+ *
4221+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_xor_relaxed() there.
4222+ *
4223+ * Return: The original value of @v.
4224+ */
17444225 static __always_inline long
17454226 atomic_long_fetch_xor_relaxed(long i, atomic_long_t *v)
17464227 {
17474228 instrument_atomic_read_write(v, sizeof(*v));
1748− return arch_atomic_long_fetch_xor_relaxed(i, v);
4229+ return raw_atomic_long_fetch_xor_relaxed(i, v);
17494230 }
17504231
4232+/**
4233+ * atomic_long_xchg() - atomic exchange with full ordering
4234+ * @v: pointer to atomic_long_t
4235+ * @new: long value to assign
4236+ *
4237+ * Atomically updates @v to @new with full ordering.
4238+ *
4239+ * Unsafe to use in noinstr code; use raw_atomic_long_xchg() there.
4240+ *
4241+ * Return: The original value of @v.
4242+ */
17514243 static __always_inline long
1752−atomic_long_xchg(atomic_long_t *v, long i)
4244+atomic_long_xchg(atomic_long_t *v, long new)
17534245 {
17544246 kcsan_mb();
17554247 instrument_atomic_read_write(v, sizeof(*v));
1756− return arch_atomic_long_xchg(v, i);
4248+ return raw_atomic_long_xchg(v, new);
17574249 }
17584250
4251+/**
4252+ * atomic_long_xchg_acquire() - atomic exchange with acquire ordering
4253+ * @v: pointer to atomic_long_t
4254+ * @new: long value to assign
4255+ *
4256+ * Atomically updates @v to @new with acquire ordering.
4257+ *
4258+ * Unsafe to use in noinstr code; use raw_atomic_long_xchg_acquire() there.
4259+ *
4260+ * Return: The original value of @v.
4261+ */
17594262 static __always_inline long
1760−atomic_long_xchg_acquire(atomic_long_t *v, long i)
4263+atomic_long_xchg_acquire(atomic_long_t *v, long new)
17614264 {
17624265 instrument_atomic_read_write(v, sizeof(*v));
1763− return arch_atomic_long_xchg_acquire(v, i);
4266+ return raw_atomic_long_xchg_acquire(v, new);
17644267 }
17654268
4269+/**
4270+ * atomic_long_xchg_release() - atomic exchange with release ordering
4271+ * @v: pointer to atomic_long_t
4272+ * @new: long value to assign
4273+ *
4274+ * Atomically updates @v to @new with release ordering.
4275+ *
4276+ * Unsafe to use in noinstr code; use raw_atomic_long_xchg_release() there.
4277+ *
4278+ * Return: The original value of @v.
4279+ */
17664280 static __always_inline long
1767−atomic_long_xchg_release(atomic_long_t *v, long i)
4281+atomic_long_xchg_release(atomic_long_t *v, long new)
17684282 {
17694283 kcsan_release();
17704284 instrument_atomic_read_write(v, sizeof(*v));
1771− return arch_atomic_long_xchg_release(v, i);
4285+ return raw_atomic_long_xchg_release(v, new);
17724286 }
17734287
4288+/**
4289+ * atomic_long_xchg_relaxed() - atomic exchange with relaxed ordering
4290+ * @v: pointer to atomic_long_t
4291+ * @new: long value to assign
4292+ *
4293+ * Atomically updates @v to @new with relaxed ordering.
4294+ *
4295+ * Unsafe to use in noinstr code; use raw_atomic_long_xchg_relaxed() there.
4296+ *
4297+ * Return: The original value of @v.
4298+ */
17744299 static __always_inline long
1775−atomic_long_xchg_relaxed(atomic_long_t *v, long i)
4300+atomic_long_xchg_relaxed(atomic_long_t *v, long new)
17764301 {
17774302 instrument_atomic_read_write(v, sizeof(*v));
1778− return arch_atomic_long_xchg_relaxed(v, i);
4303+ return raw_atomic_long_xchg_relaxed(v, new);
17794304 }
17804305
4306+/**
4307+ * atomic_long_cmpxchg() - atomic compare and exchange with full ordering
4308+ * @v: pointer to atomic_long_t
4309+ * @old: long value to compare with
4310+ * @new: long value to assign
4311+ *
4312+ * If (@v == @old), atomically updates @v to @new with full ordering.
4313+ *
4314+ * Unsafe to use in noinstr code; use raw_atomic_long_cmpxchg() there.
4315+ *
4316+ * Return: The original value of @v.
4317+ */
17814318 static __always_inline long
17824319 atomic_long_cmpxchg(atomic_long_t *v, long old, long new)
17834320 {
17844321 kcsan_mb();
17854322 instrument_atomic_read_write(v, sizeof(*v));
1786− return arch_atomic_long_cmpxchg(v, old, new);
4323+ return raw_atomic_long_cmpxchg(v, old, new);
17874324 }
17884325
4326+/**
4327+ * atomic_long_cmpxchg_acquire() - atomic compare and exchange with acquire ordering
4328+ * @v: pointer to atomic_long_t
4329+ * @old: long value to compare with
4330+ * @new: long value to assign
4331+ *
4332+ * If (@v == @old), atomically updates @v to @new with acquire ordering.
4333+ *
4334+ * Unsafe to use in noinstr code; use raw_atomic_long_cmpxchg_acquire() there.
4335+ *
4336+ * Return: The original value of @v.
4337+ */
17894338 static __always_inline long
17904339 atomic_long_cmpxchg_acquire(atomic_long_t *v, long old, long new)
17914340 {
17924341 instrument_atomic_read_write(v, sizeof(*v));
1793− return arch_atomic_long_cmpxchg_acquire(v, old, new);
4342+ return raw_atomic_long_cmpxchg_acquire(v, old, new);
17944343 }
17954344
4345+/**
4346+ * atomic_long_cmpxchg_release() - atomic compare and exchange with release ordering
4347+ * @v: pointer to atomic_long_t
4348+ * @old: long value to compare with
4349+ * @new: long value to assign
4350+ *
4351+ * If (@v == @old), atomically updates @v to @new with release ordering.
4352+ *
4353+ * Unsafe to use in noinstr code; use raw_atomic_long_cmpxchg_release() there.
4354+ *
4355+ * Return: The original value of @v.
4356+ */
17964357 static __always_inline long
17974358 atomic_long_cmpxchg_release(atomic_long_t *v, long old, long new)
17984359 {
17994360 kcsan_release();
18004361 instrument_atomic_read_write(v, sizeof(*v));
1801− return arch_atomic_long_cmpxchg_release(v, old, new);
4362+ return raw_atomic_long_cmpxchg_release(v, old, new);
18024363 }
18034364
4365+/**
4366+ * atomic_long_cmpxchg_relaxed() - atomic compare and exchange with relaxed ordering
4367+ * @v: pointer to atomic_long_t
4368+ * @old: long value to compare with
4369+ * @new: long value to assign
4370+ *
4371+ * If (@v == @old), atomically updates @v to @new with relaxed ordering.
4372+ *
4373+ * Unsafe to use in noinstr code; use raw_atomic_long_cmpxchg_relaxed() there.
4374+ *
4375+ * Return: The original value of @v.
4376+ */
18044377 static __always_inline long
18054378 atomic_long_cmpxchg_relaxed(atomic_long_t *v, long old, long new)
18064379 {
18074380 instrument_atomic_read_write(v, sizeof(*v));
1808− return arch_atomic_long_cmpxchg_relaxed(v, old, new);
4381+ return raw_atomic_long_cmpxchg_relaxed(v, old, new);
18094382 }
18104383
4384+/**
4385+ * atomic_long_try_cmpxchg() - atomic compare and exchange with full ordering
4386+ * @v: pointer to atomic_long_t
4387+ * @old: pointer to long value to compare with
4388+ * @new: long value to assign
4389+ *
4390+ * If (@v == @old), atomically updates @v to @new with full ordering.
4391+ * Otherwise, updates @old to the current value of @v.
4392+ *
4393+ * Unsafe to use in noinstr code; use raw_atomic_long_try_cmpxchg() there.
4394+ *
4395+ * Return: @true if the exchange occured, @false otherwise.
4396+ */
18114397 static __always_inline bool
18124398 atomic_long_try_cmpxchg(atomic_long_t *v, long *old, long new)
18134399 {
18144400 kcsan_mb();
18154401 instrument_atomic_read_write(v, sizeof(*v));
18164402 instrument_atomic_read_write(old, sizeof(*old));
1817− return arch_atomic_long_try_cmpxchg(v, old, new);
1818−}
1819−
4403+ return raw_atomic_long_try_cmpxchg(v, old, new);
4404+}
4405+
4406+/**
4407+ * atomic_long_try_cmpxchg_acquire() - atomic compare and exchange with acquire ordering
4408+ * @v: pointer to atomic_long_t
4409+ * @old: pointer to long value to compare with
4410+ * @new: long value to assign
4411+ *
4412+ * If (@v == @old), atomically updates @v to @new with acquire ordering.
4413+ * Otherwise, updates @old to the current value of @v.
4414+ *
4415+ * Unsafe to use in noinstr code; use raw_atomic_long_try_cmpxchg_acquire() there.
4416+ *
4417+ * Return: @true if the exchange occured, @false otherwise.
4418+ */
18204419 static __always_inline bool
18214420 atomic_long_try_cmpxchg_acquire(atomic_long_t *v, long *old, long new)
18224421 {
18234422 instrument_atomic_read_write(v, sizeof(*v));
18244423 instrument_atomic_read_write(old, sizeof(*old));
1825− return arch_atomic_long_try_cmpxchg_acquire(v, old, new);
1826−}
1827−
4424+ return raw_atomic_long_try_cmpxchg_acquire(v, old, new);
4425+}
4426+
4427+/**
4428+ * atomic_long_try_cmpxchg_release() - atomic compare and exchange with release ordering
4429+ * @v: pointer to atomic_long_t
4430+ * @old: pointer to long value to compare with
4431+ * @new: long value to assign
4432+ *
4433+ * If (@v == @old), atomically updates @v to @new with release ordering.
4434+ * Otherwise, updates @old to the current value of @v.
4435+ *
4436+ * Unsafe to use in noinstr code; use raw_atomic_long_try_cmpxchg_release() there.
4437+ *
4438+ * Return: @true if the exchange occured, @false otherwise.
4439+ */
18284440 static __always_inline bool
18294441 atomic_long_try_cmpxchg_release(atomic_long_t *v, long *old, long new)
18304442 {
18314443 kcsan_release();
18324444 instrument_atomic_read_write(v, sizeof(*v));
18334445 instrument_atomic_read_write(old, sizeof(*old));
1834− return arch_atomic_long_try_cmpxchg_release(v, old, new);
1835−}
1836−
4446+ return raw_atomic_long_try_cmpxchg_release(v, old, new);
4447+}
4448+
4449+/**
4450+ * atomic_long_try_cmpxchg_relaxed() - atomic compare and exchange with relaxed ordering
4451+ * @v: pointer to atomic_long_t
4452+ * @old: pointer to long value to compare with
4453+ * @new: long value to assign
4454+ *
4455+ * If (@v == @old), atomically updates @v to @new with relaxed ordering.
4456+ * Otherwise, updates @old to the current value of @v.
4457+ *
4458+ * Unsafe to use in noinstr code; use raw_atomic_long_try_cmpxchg_relaxed() there.
4459+ *
4460+ * Return: @true if the exchange occured, @false otherwise.
4461+ */
18374462 static __always_inline bool
18384463 atomic_long_try_cmpxchg_relaxed(atomic_long_t *v, long *old, long new)
18394464 {
18404465 instrument_atomic_read_write(v, sizeof(*v));
18414466 instrument_atomic_read_write(old, sizeof(*old));
1842− return arch_atomic_long_try_cmpxchg_relaxed(v, old, new);
1843−}
1844−
4467+ return raw_atomic_long_try_cmpxchg_relaxed(v, old, new);
4468+}
4469+
4470+/**
4471+ * atomic_long_sub_and_test() - atomic subtract and test if zero with full ordering
4472+ * @i: long value to add
4473+ * @v: pointer to atomic_long_t
4474+ *
4475+ * Atomically updates @v to (@v - @i) with full ordering.
4476+ *
4477+ * Unsafe to use in noinstr code; use raw_atomic_long_sub_and_test() there.
4478+ *
4479+ * Return: @true if the resulting value of @v is zero, @false otherwise.
4480+ */
18454481 static __always_inline bool
18464482 atomic_long_sub_and_test(long i, atomic_long_t *v)
18474483 {
18484484 kcsan_mb();
18494485 instrument_atomic_read_write(v, sizeof(*v));
1850− return arch_atomic_long_sub_and_test(i, v);
4486+ return raw_atomic_long_sub_and_test(i, v);
18514487 }
18524488
4489+/**
4490+ * atomic_long_dec_and_test() - atomic decrement and test if zero with full ordering
4491+ * @v: pointer to atomic_long_t
4492+ *
4493+ * Atomically updates @v to (@v - 1) with full ordering.
4494+ *
4495+ * Unsafe to use in noinstr code; use raw_atomic_long_dec_and_test() there.
4496+ *
4497+ * Return: @true if the resulting value of @v is zero, @false otherwise.
4498+ */
18534499 static __always_inline bool
18544500 atomic_long_dec_and_test(atomic_long_t *v)
18554501 {
18564502 kcsan_mb();
18574503 instrument_atomic_read_write(v, sizeof(*v));
1858− return arch_atomic_long_dec_and_test(v);
4504+ return raw_atomic_long_dec_and_test(v);
18594505 }
18604506
4507+/**
4508+ * atomic_long_inc_and_test() - atomic increment and test if zero with full ordering
4509+ * @v: pointer to atomic_long_t
4510+ *
4511+ * Atomically updates @v to (@v + 1) with full ordering.
4512+ *
4513+ * Unsafe to use in noinstr code; use raw_atomic_long_inc_and_test() there.
4514+ *
4515+ * Return: @true if the resulting value of @v is zero, @false otherwise.
4516+ */
18614517 static __always_inline bool
18624518 atomic_long_inc_and_test(atomic_long_t *v)
18634519 {
18644520 kcsan_mb();
18654521 instrument_atomic_read_write(v, sizeof(*v));
1866− return arch_atomic_long_inc_and_test(v);
4522+ return raw_atomic_long_inc_and_test(v);
18674523 }
18684524
4525+/**
4526+ * atomic_long_add_negative() - atomic add and test if negative with full ordering
4527+ * @i: long value to add
4528+ * @v: pointer to atomic_long_t
4529+ *
4530+ * Atomically updates @v to (@v + @i) with full ordering.
4531+ *
4532+ * Unsafe to use in noinstr code; use raw_atomic_long_add_negative() there.
4533+ *
4534+ * Return: @true if the resulting value of @v is negative, @false otherwise.
4535+ */
18694536 static __always_inline bool
18704537 atomic_long_add_negative(long i, atomic_long_t *v)
18714538 {
18724539 kcsan_mb();
18734540 instrument_atomic_read_write(v, sizeof(*v));
1874− return arch_atomic_long_add_negative(i, v);
4541+ return raw_atomic_long_add_negative(i, v);
18754542 }
18764543
4544+/**
4545+ * atomic_long_add_negative_acquire() - atomic add and test if negative with acquire ordering
4546+ * @i: long value to add
4547+ * @v: pointer to atomic_long_t
4548+ *
4549+ * Atomically updates @v to (@v + @i) with acquire ordering.
4550+ *
4551+ * Unsafe to use in noinstr code; use raw_atomic_long_add_negative_acquire() there.
4552+ *
4553+ * Return: @true if the resulting value of @v is negative, @false otherwise.
4554+ */
18774555 static __always_inline bool
18784556 atomic_long_add_negative_acquire(long i, atomic_long_t *v)
18794557 {
18804558 instrument_atomic_read_write(v, sizeof(*v));
1881− return arch_atomic_long_add_negative_acquire(i, v);
4559+ return raw_atomic_long_add_negative_acquire(i, v);
18824560 }
18834561
4562+/**
4563+ * atomic_long_add_negative_release() - atomic add and test if negative with release ordering
4564+ * @i: long value to add
4565+ * @v: pointer to atomic_long_t
4566+ *
4567+ * Atomically updates @v to (@v + @i) with release ordering.
4568+ *
4569+ * Unsafe to use in noinstr code; use raw_atomic_long_add_negative_release() there.
4570+ *
4571+ * Return: @true if the resulting value of @v is negative, @false otherwise.
4572+ */
18844573 static __always_inline bool
18854574 atomic_long_add_negative_release(long i, atomic_long_t *v)
18864575 {
18874576 kcsan_release();
18884577 instrument_atomic_read_write(v, sizeof(*v));
1889− return arch_atomic_long_add_negative_release(i, v);
4578+ return raw_atomic_long_add_negative_release(i, v);
18904579 }
18914580
4581+/**
4582+ * atomic_long_add_negative_relaxed() - atomic add and test if negative with relaxed ordering
4583+ * @i: long value to add
4584+ * @v: pointer to atomic_long_t
4585+ *
4586+ * Atomically updates @v to (@v + @i) with relaxed ordering.
4587+ *
4588+ * Unsafe to use in noinstr code; use raw_atomic_long_add_negative_relaxed() there.
4589+ *
4590+ * Return: @true if the resulting value of @v is negative, @false otherwise.
4591+ */
18924592 static __always_inline bool
18934593 atomic_long_add_negative_relaxed(long i, atomic_long_t *v)
18944594 {
18954595 instrument_atomic_read_write(v, sizeof(*v));
1896− return arch_atomic_long_add_negative_relaxed(i, v);
4596+ return raw_atomic_long_add_negative_relaxed(i, v);
18974597 }
18984598
4599+/**
4600+ * atomic_long_fetch_add_unless() - atomic add unless value with full ordering
4601+ * @v: pointer to atomic_long_t
4602+ * @a: long value to add
4603+ * @u: long value to compare with
4604+ *
4605+ * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
4606+ *
4607+ * Unsafe to use in noinstr code; use raw_atomic_long_fetch_add_unless() there.
4608+ *
4609+ * Return: The original value of @v.
4610+ */
18994611 static __always_inline long
19004612 atomic_long_fetch_add_unless(atomic_long_t *v, long a, long u)
19014613 {
19024614 kcsan_mb();
19034615 instrument_atomic_read_write(v, sizeof(*v));
1904− return arch_atomic_long_fetch_add_unless(v, a, u);
4616+ return raw_atomic_long_fetch_add_unless(v, a, u);
19054617 }
19064618
4619+/**
4620+ * atomic_long_add_unless() - atomic add unless value with full ordering
4621+ * @v: pointer to atomic_long_t
4622+ * @a: long value to add
4623+ * @u: long value to compare with
4624+ *
4625+ * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
4626+ *
4627+ * Unsafe to use in noinstr code; use raw_atomic_long_add_unless() there.
4628+ *
4629+ * Return: @true if @v was updated, @false otherwise.
4630+ */
19074631 static __always_inline bool
19084632 atomic_long_add_unless(atomic_long_t *v, long a, long u)
19094633 {
19104634 kcsan_mb();
19114635 instrument_atomic_read_write(v, sizeof(*v));
1912− return arch_atomic_long_add_unless(v, a, u);
4636+ return raw_atomic_long_add_unless(v, a, u);
19134637 }
19144638
4639+/**
4640+ * atomic_long_inc_not_zero() - atomic increment unless zero with full ordering
4641+ * @v: pointer to atomic_long_t
4642+ *
4643+ * If (@v != 0), atomically updates @v to (@v + 1) with full ordering.
4644+ *
4645+ * Unsafe to use in noinstr code; use raw_atomic_long_inc_not_zero() there.
4646+ *
4647+ * Return: @true if @v was updated, @false otherwise.
4648+ */
19154649 static __always_inline bool
19164650 atomic_long_inc_not_zero(atomic_long_t *v)
19174651 {
19184652 kcsan_mb();
19194653 instrument_atomic_read_write(v, sizeof(*v));
1920− return arch_atomic_long_inc_not_zero(v);
4654+ return raw_atomic_long_inc_not_zero(v);
19214655 }
19224656
4657+/**
4658+ * atomic_long_inc_unless_negative() - atomic increment unless negative with full ordering
4659+ * @v: pointer to atomic_long_t
4660+ *
4661+ * If (@v >= 0), atomically updates @v to (@v + 1) with full ordering.
4662+ *
4663+ * Unsafe to use in noinstr code; use raw_atomic_long_inc_unless_negative() there.
4664+ *
4665+ * Return: @true if @v was updated, @false otherwise.
4666+ */
19234667 static __always_inline bool
19244668 atomic_long_inc_unless_negative(atomic_long_t *v)
19254669 {
19264670 kcsan_mb();
19274671 instrument_atomic_read_write(v, sizeof(*v));
1928− return arch_atomic_long_inc_unless_negative(v);
4672+ return raw_atomic_long_inc_unless_negative(v);
19294673 }
19304674
4675+/**
4676+ * atomic_long_dec_unless_positive() - atomic decrement unless positive with full ordering
4677+ * @v: pointer to atomic_long_t
4678+ *
4679+ * If (@v <= 0), atomically updates @v to (@v - 1) with full ordering.
4680+ *
4681+ * Unsafe to use in noinstr code; use raw_atomic_long_dec_unless_positive() there.

347 more lines aren’t shown here.

include/linux/atomic/atomic-long.h+1435−687
@@ -21,1030 +21,1778 @@ typedef atomic_t atomic_long_t; · 20 unmodified lines
2121 #define atomic_long_cond_read_relaxed atomic_cond_read_relaxed
2222 #endif
2323
24−#ifdef CONFIG_64BIT
25−
26−static __always_inline long
27−arch_atomic_long_read(const atomic_long_t *v)
28−{
29− return arch_atomic64_read(v);
30−}
31−
32−static __always_inline long
33−arch_atomic_long_read_acquire(const atomic_long_t *v)
34−{
35− return arch_atomic64_read_acquire(v);
36−}
37−
38−static __always_inline void
39−arch_atomic_long_set(atomic_long_t *v, long i)
40−{
41− arch_atomic64_set(v, i);
42−}
43−
44−static __always_inline void
45−arch_atomic_long_set_release(atomic_long_t *v, long i)
46−{
47− arch_atomic64_set_release(v, i);
48−}
49−
50−static __always_inline void
51−arch_atomic_long_add(long i, atomic_long_t *v)
52−{
53− arch_atomic64_add(i, v);
54−}
55−
56−static __always_inline long
57−arch_atomic_long_add_return(long i, atomic_long_t *v)
58−{
59− return arch_atomic64_add_return(i, v);
60−}
61−
62−static __always_inline long
63−arch_atomic_long_add_return_acquire(long i, atomic_long_t *v)
64−{
65− return arch_atomic64_add_return_acquire(i, v);
66−}
67−
68−static __always_inline long
69−arch_atomic_long_add_return_release(long i, atomic_long_t *v)
70−{
71− return arch_atomic64_add_return_release(i, v);
72−}
73−
74−static __always_inline long
75−arch_atomic_long_add_return_relaxed(long i, atomic_long_t *v)
76−{
77− return arch_atomic64_add_return_relaxed(i, v);
78−}
79−
80−static __always_inline long
81−arch_atomic_long_fetch_add(long i, atomic_long_t *v)
82−{
83− return arch_atomic64_fetch_add(i, v);
84−}
85−
86−static __always_inline long
87−arch_atomic_long_fetch_add_acquire(long i, atomic_long_t *v)
88−{
89− return arch_atomic64_fetch_add_acquire(i, v);
90−}
91−
92−static __always_inline long
93−arch_atomic_long_fetch_add_release(long i, atomic_long_t *v)
94−{
95− return arch_atomic64_fetch_add_release(i, v);
96−}
97−
98−static __always_inline long
99−arch_atomic_long_fetch_add_relaxed(long i, atomic_long_t *v)
100−{
101− return arch_atomic64_fetch_add_relaxed(i, v);
102−}
103−
104−static __always_inline void
105−arch_atomic_long_sub(long i, atomic_long_t *v)
106−{
107− arch_atomic64_sub(i, v);
108−}
109−
110−static __always_inline long
111−arch_atomic_long_sub_return(long i, atomic_long_t *v)
112−{
113− return arch_atomic64_sub_return(i, v);
114−}
115−
116−static __always_inline long
117−arch_atomic_long_sub_return_acquire(long i, atomic_long_t *v)
118−{
119− return arch_atomic64_sub_return_acquire(i, v);
120−}
121−
122−static __always_inline long
123−arch_atomic_long_sub_return_release(long i, atomic_long_t *v)
124−{
125− return arch_atomic64_sub_return_release(i, v);
126−}
127−
128−static __always_inline long
129−arch_atomic_long_sub_return_relaxed(long i, atomic_long_t *v)
130−{
131− return arch_atomic64_sub_return_relaxed(i, v);
132−}
133−
134−static __always_inline long
135−arch_atomic_long_fetch_sub(long i, atomic_long_t *v)
136−{
137− return arch_atomic64_fetch_sub(i, v);
138−}
139−
140−static __always_inline long
141−arch_atomic_long_fetch_sub_acquire(long i, atomic_long_t *v)
142−{
143− return arch_atomic64_fetch_sub_acquire(i, v);
144−}
145−
146−static __always_inline long
147−arch_atomic_long_fetch_sub_release(long i, atomic_long_t *v)
148−{
149− return arch_atomic64_fetch_sub_release(i, v);
150−}
151−
152−static __always_inline long
153−arch_atomic_long_fetch_sub_relaxed(long i, atomic_long_t *v)
154−{
155− return arch_atomic64_fetch_sub_relaxed(i, v);
156−}
157−
158−static __always_inline void
159−arch_atomic_long_inc(atomic_long_t *v)
160−{
161− arch_atomic64_inc(v);
162−}
163−
164−static __always_inline long
165−arch_atomic_long_inc_return(atomic_long_t *v)
166−{
167− return arch_atomic64_inc_return(v);
168−}
169−
170−static __always_inline long
171−arch_atomic_long_inc_return_acquire(atomic_long_t *v)
172−{
173− return arch_atomic64_inc_return_acquire(v);
174−}
175−
176−static __always_inline long
177−arch_atomic_long_inc_return_release(atomic_long_t *v)
178−{
179− return arch_atomic64_inc_return_release(v);
180−}
181−
182−static __always_inline long
183−arch_atomic_long_inc_return_relaxed(atomic_long_t *v)
184−{
185− return arch_atomic64_inc_return_relaxed(v);
186−}
187−
188−static __always_inline long
189−arch_atomic_long_fetch_inc(atomic_long_t *v)
190−{
191− return arch_atomic64_fetch_inc(v);
192−}
193−
194−static __always_inline long
195−arch_atomic_long_fetch_inc_acquire(atomic_long_t *v)
196−{
197− return arch_atomic64_fetch_inc_acquire(v);
198−}
199−
200−static __always_inline long
201−arch_atomic_long_fetch_inc_release(atomic_long_t *v)
202−{
203− return arch_atomic64_fetch_inc_release(v);
204−}
205−
206−static __always_inline long
207−arch_atomic_long_fetch_inc_relaxed(atomic_long_t *v)
208−{
209− return arch_atomic64_fetch_inc_relaxed(v);
210−}
211−
212−static __always_inline void
213−arch_atomic_long_dec(atomic_long_t *v)
214−{
215− arch_atomic64_dec(v);
216−}
217−
218−static __always_inline long
219−arch_atomic_long_dec_return(atomic_long_t *v)
220−{
221− return arch_atomic64_dec_return(v);
222−}
223−
224−static __always_inline long
225−arch_atomic_long_dec_return_acquire(atomic_long_t *v)
226−{
227− return arch_atomic64_dec_return_acquire(v);
228−}
229−
230−static __always_inline long
231−arch_atomic_long_dec_return_release(atomic_long_t *v)
232−{
233− return arch_atomic64_dec_return_release(v);
234−}
235−
236−static __always_inline long
237−arch_atomic_long_dec_return_relaxed(atomic_long_t *v)
238−{
239− return arch_atomic64_dec_return_relaxed(v);
240−}
241−
242−static __always_inline long
243−arch_atomic_long_fetch_dec(atomic_long_t *v)
244−{
245− return arch_atomic64_fetch_dec(v);
246−}
247−
248−static __always_inline long
249−arch_atomic_long_fetch_dec_acquire(atomic_long_t *v)
250−{
251− return arch_atomic64_fetch_dec_acquire(v);
252−}
253−
254−static __always_inline long
255−arch_atomic_long_fetch_dec_release(atomic_long_t *v)
256−{
257− return arch_atomic64_fetch_dec_release(v);
258−}
259−
260−static __always_inline long
261−arch_atomic_long_fetch_dec_relaxed(atomic_long_t *v)
262−{
263− return arch_atomic64_fetch_dec_relaxed(v);
264−}
265−
266−static __always_inline void
267−arch_atomic_long_and(long i, atomic_long_t *v)
268−{
269− arch_atomic64_and(i, v);
270−}
271−
272−static __always_inline long
273−arch_atomic_long_fetch_and(long i, atomic_long_t *v)
274−{
275− return arch_atomic64_fetch_and(i, v);
276−}
277−
278−static __always_inline long
279−arch_atomic_long_fetch_and_acquire(long i, atomic_long_t *v)
280−{
281− return arch_atomic64_fetch_and_acquire(i, v);
282−}
283−
284−static __always_inline long
285−arch_atomic_long_fetch_and_release(long i, atomic_long_t *v)
286−{
287− return arch_atomic64_fetch_and_release(i, v);
288−}
289−
290−static __always_inline long
291−arch_atomic_long_fetch_and_relaxed(long i, atomic_long_t *v)
292−{
293− return arch_atomic64_fetch_and_relaxed(i, v);
294−}
295−
296−static __always_inline void
297−arch_atomic_long_andnot(long i, atomic_long_t *v)
298−{
299− arch_atomic64_andnot(i, v);
300−}
301−
302−static __always_inline long
303−arch_atomic_long_fetch_andnot(long i, atomic_long_t *v)
304−{
305− return arch_atomic64_fetch_andnot(i, v);
306−}
307−
308−static __always_inline long
309−arch_atomic_long_fetch_andnot_acquire(long i, atomic_long_t *v)
310−{
311− return arch_atomic64_fetch_andnot_acquire(i, v);
312−}
313−
314−static __always_inline long
315−arch_atomic_long_fetch_andnot_release(long i, atomic_long_t *v)
316−{
317− return arch_atomic64_fetch_andnot_release(i, v);
318−}
319−
320−static __always_inline long
321−arch_atomic_long_fetch_andnot_relaxed(long i, atomic_long_t *v)
322−{
323− return arch_atomic64_fetch_andnot_relaxed(i, v);
324−}
325−
326−static __always_inline void
327−arch_atomic_long_or(long i, atomic_long_t *v)
328−{
329− arch_atomic64_or(i, v);
330−}
331−
332−static __always_inline long
333−arch_atomic_long_fetch_or(long i, atomic_long_t *v)
334−{
335− return arch_atomic64_fetch_or(i, v);
336−}
337−
338−static __always_inline long
339−arch_atomic_long_fetch_or_acquire(long i, atomic_long_t *v)
340−{
341− return arch_atomic64_fetch_or_acquire(i, v);
342−}
343−
344−static __always_inline long
345−arch_atomic_long_fetch_or_release(long i, atomic_long_t *v)
346−{
347− return arch_atomic64_fetch_or_release(i, v);
348−}
349−
350−static __always_inline long
351−arch_atomic_long_fetch_or_relaxed(long i, atomic_long_t *v)
352−{
353− return arch_atomic64_fetch_or_relaxed(i, v);
354−}
355−
356−static __always_inline void
357−arch_atomic_long_xor(long i, atomic_long_t *v)
358−{
359− arch_atomic64_xor(i, v);
360−}
361−
362−static __always_inline long
363−arch_atomic_long_fetch_xor(long i, atomic_long_t *v)
364−{
365− return arch_atomic64_fetch_xor(i, v);
366−}
367−
368−static __always_inline long
369−arch_atomic_long_fetch_xor_acquire(long i, atomic_long_t *v)
370−{
371− return arch_atomic64_fetch_xor_acquire(i, v);
372−}
373−
374−static __always_inline long
375−arch_atomic_long_fetch_xor_release(long i, atomic_long_t *v)
376−{
377− return arch_atomic64_fetch_xor_release(i, v);
378−}
379−
380−static __always_inline long
381−arch_atomic_long_fetch_xor_relaxed(long i, atomic_long_t *v)
382−{
383− return arch_atomic64_fetch_xor_relaxed(i, v);
384−}
385−
386−static __always_inline long
387−arch_atomic_long_xchg(atomic_long_t *v, long i)
388−{
389− return arch_atomic64_xchg(v, i);
390−}
391−
392−static __always_inline long
393−arch_atomic_long_xchg_acquire(atomic_long_t *v, long i)
394−{
395− return arch_atomic64_xchg_acquire(v, i);
396−}
397−
398−static __always_inline long
399−arch_atomic_long_xchg_release(atomic_long_t *v, long i)
400−{
401− return arch_atomic64_xchg_release(v, i);
402−}
403−
404−static __always_inline long
405−arch_atomic_long_xchg_relaxed(atomic_long_t *v, long i)
406−{
407− return arch_atomic64_xchg_relaxed(v, i);
408−}
409−
410−static __always_inline long
411−arch_atomic_long_cmpxchg(atomic_long_t *v, long old, long new)
412−{
413− return arch_atomic64_cmpxchg(v, old, new);
414−}
415−
416−static __always_inline long
417−arch_atomic_long_cmpxchg_acquire(atomic_long_t *v, long old, long new)
418−{
419− return arch_atomic64_cmpxchg_acquire(v, old, new);
420−}
421−
422−static __always_inline long
423−arch_atomic_long_cmpxchg_release(atomic_long_t *v, long old, long new)
424−{
425− return arch_atomic64_cmpxchg_release(v, old, new);
426−}
427−
428−static __always_inline long
429−arch_atomic_long_cmpxchg_relaxed(atomic_long_t *v, long old, long new)
430−{
431− return arch_atomic64_cmpxchg_relaxed(v, old, new);
432−}
433−
434−static __always_inline bool
435−arch_atomic_long_try_cmpxchg(atomic_long_t *v, long *old, long new)
436−{
437− return arch_atomic64_try_cmpxchg(v, (s64 *)old, new);
438−}
439−
440−static __always_inline bool
441−arch_atomic_long_try_cmpxchg_acquire(atomic_long_t *v, long *old, long new)
442−{
443− return arch_atomic64_try_cmpxchg_acquire(v, (s64 *)old, new);
444−}
445−
446−static __always_inline bool
447−arch_atomic_long_try_cmpxchg_release(atomic_long_t *v, long *old, long new)
448−{
449− return arch_atomic64_try_cmpxchg_release(v, (s64 *)old, new);
450−}
451−
452−static __always_inline bool
453−arch_atomic_long_try_cmpxchg_relaxed(atomic_long_t *v, long *old, long new)
454−{
455− return arch_atomic64_try_cmpxchg_relaxed(v, (s64 *)old, new);
456−}
457−
458−static __always_inline bool
459−arch_atomic_long_sub_and_test(long i, atomic_long_t *v)
460−{
461− return arch_atomic64_sub_and_test(i, v);
462−}
463−
464−static __always_inline bool
465−arch_atomic_long_dec_and_test(atomic_long_t *v)
466−{
467− return arch_atomic64_dec_and_test(v);
468−}
469−
470−static __always_inline bool
471−arch_atomic_long_inc_and_test(atomic_long_t *v)
472−{
473− return arch_atomic64_inc_and_test(v);
474−}
475−
476−static __always_inline bool
477−arch_atomic_long_add_negative(long i, atomic_long_t *v)
478−{
479− return arch_atomic64_add_negative(i, v);
480−}
481−
482−static __always_inline bool
483−arch_atomic_long_add_negative_acquire(long i, atomic_long_t *v)
484−{
485− return arch_atomic64_add_negative_acquire(i, v);
486−}
487−
488−static __always_inline bool
489−arch_atomic_long_add_negative_release(long i, atomic_long_t *v)
490−{
491− return arch_atomic64_add_negative_release(i, v);
492−}
493−
494−static __always_inline bool
495−arch_atomic_long_add_negative_relaxed(long i, atomic_long_t *v)
496−{
497− return arch_atomic64_add_negative_relaxed(i, v);
498−}
499−
500−static __always_inline long
501−arch_atomic_long_fetch_add_unless(atomic_long_t *v, long a, long u)
502−{
503− return arch_atomic64_fetch_add_unless(v, a, u);
504−}
505−
506−static __always_inline bool
507−arch_atomic_long_add_unless(atomic_long_t *v, long a, long u)
508−{
509− return arch_atomic64_add_unless(v, a, u);
510−}
511−
512−static __always_inline bool
513−arch_atomic_long_inc_not_zero(atomic_long_t *v)
514−{
515− return arch_atomic64_inc_not_zero(v);
516−}
517−
518−static __always_inline bool
519−arch_atomic_long_inc_unless_negative(atomic_long_t *v)
520−{
521− return arch_atomic64_inc_unless_negative(v);
522−}
523−
524−static __always_inline bool
525−arch_atomic_long_dec_unless_positive(atomic_long_t *v)
526−{
527− return arch_atomic64_dec_unless_positive(v);
528−}
529−
530−static __always_inline long
531−arch_atomic_long_dec_if_positive(atomic_long_t *v)
532−{
533− return arch_atomic64_dec_if_positive(v);
534−}
535−
536−#else /* CONFIG_64BIT */
537−
538−static __always_inline long
539−arch_atomic_long_read(const atomic_long_t *v)
24+/**
25+ * raw_atomic_long_read() - atomic load with relaxed ordering
26+ * @v: pointer to atomic_long_t
27+ *
28+ * Atomically loads the value of @v with relaxed ordering.
29+ *
30+ * Safe to use in noinstr code; prefer atomic_long_read() elsewhere.
31+ *
32+ * Return: The value loaded from @v.
33+ */
34+static __always_inline long
35+raw_atomic_long_read(const atomic_long_t *v)
54036 {
541− return arch_atomic_read(v);
37+#ifdef CONFIG_64BIT
38+ return raw_atomic64_read(v);
39+#else
40+ return raw_atomic_read(v);
41+#endif
54242 }
54343
44+/**
45+ * raw_atomic_long_read_acquire() - atomic load with acquire ordering
46+ * @v: pointer to atomic_long_t
47+ *
48+ * Atomically loads the value of @v with acquire ordering.
49+ *
50+ * Safe to use in noinstr code; prefer atomic_long_read_acquire() elsewhere.
51+ *
52+ * Return: The value loaded from @v.
53+ */
54454 static __always_inline long
545−arch_atomic_long_read_acquire(const atomic_long_t *v)
55+raw_atomic_long_read_acquire(const atomic_long_t *v)
54656 {
547− return arch_atomic_read_acquire(v);
57+#ifdef CONFIG_64BIT
58+ return raw_atomic64_read_acquire(v);
59+#else
60+ return raw_atomic_read_acquire(v);
61+#endif
54862 }
54963
64+/**
65+ * raw_atomic_long_set() - atomic set with relaxed ordering
66+ * @v: pointer to atomic_long_t
67+ * @i: long value to assign
68+ *
69+ * Atomically sets @v to @i with relaxed ordering.
70+ *
71+ * Safe to use in noinstr code; prefer atomic_long_set() elsewhere.
72+ *
73+ * Return: Nothing.
74+ */
55075 static __always_inline void
551−arch_atomic_long_set(atomic_long_t *v, long i)
76+raw_atomic_long_set(atomic_long_t *v, long i)
55277 {
553− arch_atomic_set(v, i);
78+#ifdef CONFIG_64BIT
79+ raw_atomic64_set(v, i);
80+#else
81+ raw_atomic_set(v, i);
82+#endif
55483 }
55584
85+/**
86+ * raw_atomic_long_set_release() - atomic set with release ordering
87+ * @v: pointer to atomic_long_t
88+ * @i: long value to assign
89+ *
90+ * Atomically sets @v to @i with release ordering.
91+ *
92+ * Safe to use in noinstr code; prefer atomic_long_set_release() elsewhere.
93+ *
94+ * Return: Nothing.
95+ */
55696 static __always_inline void
557−arch_atomic_long_set_release(atomic_long_t *v, long i)
97+raw_atomic_long_set_release(atomic_long_t *v, long i)
55898 {
559− arch_atomic_set_release(v, i);
99+#ifdef CONFIG_64BIT
100+ raw_atomic64_set_release(v, i);
101+#else
102+ raw_atomic_set_release(v, i);
103+#endif
560104 }
561105
106+/**
107+ * raw_atomic_long_add() - atomic add with relaxed ordering
108+ * @i: long value to add
109+ * @v: pointer to atomic_long_t
110+ *
111+ * Atomically updates @v to (@v + @i) with relaxed ordering.
112+ *
113+ * Safe to use in noinstr code; prefer atomic_long_add() elsewhere.
114+ *
115+ * Return: Nothing.
116+ */
562117 static __always_inline void
563−arch_atomic_long_add(long i, atomic_long_t *v)
118+raw_atomic_long_add(long i, atomic_long_t *v)
564119 {
565− arch_atomic_add(i, v);
120+#ifdef CONFIG_64BIT
121+ raw_atomic64_add(i, v);
122+#else
123+ raw_atomic_add(i, v);
124+#endif
566125 }
567126
127+/**
128+ * raw_atomic_long_add_return() - atomic add with full ordering
129+ * @i: long value to add
130+ * @v: pointer to atomic_long_t
131+ *
132+ * Atomically updates @v to (@v + @i) with full ordering.
133+ *
134+ * Safe to use in noinstr code; prefer atomic_long_add_return() elsewhere.
135+ *
136+ * Return: The updated value of @v.
137+ */
568138 static __always_inline long
569−arch_atomic_long_add_return(long i, atomic_long_t *v)
139+raw_atomic_long_add_return(long i, atomic_long_t *v)
570140 {
571− return arch_atomic_add_return(i, v);
141+#ifdef CONFIG_64BIT
142+ return raw_atomic64_add_return(i, v);
143+#else
144+ return raw_atomic_add_return(i, v);
145+#endif
572146 }
573147
148+/**
149+ * raw_atomic_long_add_return_acquire() - atomic add with acquire ordering
150+ * @i: long value to add
151+ * @v: pointer to atomic_long_t
152+ *
153+ * Atomically updates @v to (@v + @i) with acquire ordering.
154+ *
155+ * Safe to use in noinstr code; prefer atomic_long_add_return_acquire() elsewhere.
156+ *
157+ * Return: The updated value of @v.
158+ */
574159 static __always_inline long
575−arch_atomic_long_add_return_acquire(long i, atomic_long_t *v)
160+raw_atomic_long_add_return_acquire(long i, atomic_long_t *v)
576161 {
577− return arch_atomic_add_return_acquire(i, v);
162+#ifdef CONFIG_64BIT
163+ return raw_atomic64_add_return_acquire(i, v);
164+#else
165+ return raw_atomic_add_return_acquire(i, v);
166+#endif
578167 }
579168
169+/**
170+ * raw_atomic_long_add_return_release() - atomic add with release ordering
171+ * @i: long value to add
172+ * @v: pointer to atomic_long_t
173+ *
174+ * Atomically updates @v to (@v + @i) with release ordering.
175+ *
176+ * Safe to use in noinstr code; prefer atomic_long_add_return_release() elsewhere.
177+ *
178+ * Return: The updated value of @v.
179+ */
580180 static __always_inline long
581−arch_atomic_long_add_return_release(long i, atomic_long_t *v)
181+raw_atomic_long_add_return_release(long i, atomic_long_t *v)
582182 {
583− return arch_atomic_add_return_release(i, v);
183+#ifdef CONFIG_64BIT
184+ return raw_atomic64_add_return_release(i, v);
185+#else
186+ return raw_atomic_add_return_release(i, v);
187+#endif
584188 }
585189
190+/**
191+ * raw_atomic_long_add_return_relaxed() - atomic add with relaxed ordering
192+ * @i: long value to add
193+ * @v: pointer to atomic_long_t
194+ *
195+ * Atomically updates @v to (@v + @i) with relaxed ordering.
196+ *
197+ * Safe to use in noinstr code; prefer atomic_long_add_return_relaxed() elsewhere.
198+ *
199+ * Return: The updated value of @v.
200+ */
586201 static __always_inline long
587−arch_atomic_long_add_return_relaxed(long i, atomic_long_t *v)
202+raw_atomic_long_add_return_relaxed(long i, atomic_long_t *v)
588203 {
589− return arch_atomic_add_return_relaxed(i, v);
204+#ifdef CONFIG_64BIT
205+ return raw_atomic64_add_return_relaxed(i, v);
206+#else
207+ return raw_atomic_add_return_relaxed(i, v);
208+#endif
590209 }
591210
211+/**
212+ * raw_atomic_long_fetch_add() - atomic add with full ordering
213+ * @i: long value to add
214+ * @v: pointer to atomic_long_t
215+ *
216+ * Atomically updates @v to (@v + @i) with full ordering.
217+ *
218+ * Safe to use in noinstr code; prefer atomic_long_fetch_add() elsewhere.
219+ *
220+ * Return: The original value of @v.
221+ */
592222 static __always_inline long
593−arch_atomic_long_fetch_add(long i, atomic_long_t *v)
223+raw_atomic_long_fetch_add(long i, atomic_long_t *v)
594224 {
595− return arch_atomic_fetch_add(i, v);
225+#ifdef CONFIG_64BIT
226+ return raw_atomic64_fetch_add(i, v);
227+#else
228+ return raw_atomic_fetch_add(i, v);
229+#endif
596230 }
597231
232+/**
233+ * raw_atomic_long_fetch_add_acquire() - atomic add with acquire ordering
234+ * @i: long value to add
235+ * @v: pointer to atomic_long_t
236+ *
237+ * Atomically updates @v to (@v + @i) with acquire ordering.
238+ *
239+ * Safe to use in noinstr code; prefer atomic_long_fetch_add_acquire() elsewhere.
240+ *
241+ * Return: The original value of @v.
242+ */
598243 static __always_inline long
599−arch_atomic_long_fetch_add_acquire(long i, atomic_long_t *v)
244+raw_atomic_long_fetch_add_acquire(long i, atomic_long_t *v)
600245 {
601− return arch_atomic_fetch_add_acquire(i, v);
246+#ifdef CONFIG_64BIT
247+ return raw_atomic64_fetch_add_acquire(i, v);
248+#else
249+ return raw_atomic_fetch_add_acquire(i, v);
250+#endif
602251 }
603252
253+/**
254+ * raw_atomic_long_fetch_add_release() - atomic add with release ordering
255+ * @i: long value to add
256+ * @v: pointer to atomic_long_t
257+ *
258+ * Atomically updates @v to (@v + @i) with release ordering.
259+ *
260+ * Safe to use in noinstr code; prefer atomic_long_fetch_add_release() elsewhere.
261+ *
262+ * Return: The original value of @v.
263+ */
604264 static __always_inline long
605−arch_atomic_long_fetch_add_release(long i, atomic_long_t *v)
265+raw_atomic_long_fetch_add_release(long i, atomic_long_t *v)
606266 {
607− return arch_atomic_fetch_add_release(i, v);
267+#ifdef CONFIG_64BIT
268+ return raw_atomic64_fetch_add_release(i, v);
269+#else
270+ return raw_atomic_fetch_add_release(i, v);
271+#endif
608272 }
609273
274+/**
275+ * raw_atomic_long_fetch_add_relaxed() - atomic add with relaxed ordering
276+ * @i: long value to add
277+ * @v: pointer to atomic_long_t
278+ *
279+ * Atomically updates @v to (@v + @i) with relaxed ordering.
280+ *
281+ * Safe to use in noinstr code; prefer atomic_long_fetch_add_relaxed() elsewhere.
282+ *
283+ * Return: The original value of @v.
284+ */
610285 static __always_inline long
611−arch_atomic_long_fetch_add_relaxed(long i, atomic_long_t *v)
286+raw_atomic_long_fetch_add_relaxed(long i, atomic_long_t *v)
612287 {
613− return arch_atomic_fetch_add_relaxed(i, v);
288+#ifdef CONFIG_64BIT
289+ return raw_atomic64_fetch_add_relaxed(i, v);
290+#else
291+ return raw_atomic_fetch_add_relaxed(i, v);
292+#endif
614293 }
615294
295+/**
296+ * raw_atomic_long_sub() - atomic subtract with relaxed ordering
297+ * @i: long value to subtract
298+ * @v: pointer to atomic_long_t
299+ *
300+ * Atomically updates @v to (@v - @i) with relaxed ordering.
301+ *
302+ * Safe to use in noinstr code; prefer atomic_long_sub() elsewhere.
303+ *
304+ * Return: Nothing.
305+ */
616306 static __always_inline void
617−arch_atomic_long_sub(long i, atomic_long_t *v)
307+raw_atomic_long_sub(long i, atomic_long_t *v)
618308 {
619− arch_atomic_sub(i, v);
309+#ifdef CONFIG_64BIT
310+ raw_atomic64_sub(i, v);
311+#else
312+ raw_atomic_sub(i, v);
313+#endif
620314 }
621315
316+/**
317+ * raw_atomic_long_sub_return() - atomic subtract with full ordering
318+ * @i: long value to subtract
319+ * @v: pointer to atomic_long_t
320+ *
321+ * Atomically updates @v to (@v - @i) with full ordering.
322+ *
323+ * Safe to use in noinstr code; prefer atomic_long_sub_return() elsewhere.
324+ *
325+ * Return: The updated value of @v.
326+ */
622327 static __always_inline long
623−arch_atomic_long_sub_return(long i, atomic_long_t *v)
328+raw_atomic_long_sub_return(long i, atomic_long_t *v)
624329 {
625− return arch_atomic_sub_return(i, v);
330+#ifdef CONFIG_64BIT
331+ return raw_atomic64_sub_return(i, v);
332+#else
333+ return raw_atomic_sub_return(i, v);
334+#endif
626335 }
627336
337+/**
338+ * raw_atomic_long_sub_return_acquire() - atomic subtract with acquire ordering
339+ * @i: long value to subtract
340+ * @v: pointer to atomic_long_t
341+ *
342+ * Atomically updates @v to (@v - @i) with acquire ordering.
343+ *
344+ * Safe to use in noinstr code; prefer atomic_long_sub_return_acquire() elsewhere.
345+ *
346+ * Return: The updated value of @v.
347+ */
628348 static __always_inline long
629−arch_atomic_long_sub_return_acquire(long i, atomic_long_t *v)
349+raw_atomic_long_sub_return_acquire(long i, atomic_long_t *v)
630350 {
631− return arch_atomic_sub_return_acquire(i, v);
351+#ifdef CONFIG_64BIT
352+ return raw_atomic64_sub_return_acquire(i, v);
353+#else
354+ return raw_atomic_sub_return_acquire(i, v);
355+#endif
632356 }
633357
358+/**
359+ * raw_atomic_long_sub_return_release() - atomic subtract with release ordering
360+ * @i: long value to subtract
361+ * @v: pointer to atomic_long_t
362+ *
363+ * Atomically updates @v to (@v - @i) with release ordering.
364+ *
365+ * Safe to use in noinstr code; prefer atomic_long_sub_return_release() elsewhere.
366+ *
367+ * Return: The updated value of @v.
368+ */
634369 static __always_inline long
635−arch_atomic_long_sub_return_release(long i, atomic_long_t *v)
370+raw_atomic_long_sub_return_release(long i, atomic_long_t *v)
636371 {
637− return arch_atomic_sub_return_release(i, v);
372+#ifdef CONFIG_64BIT
373+ return raw_atomic64_sub_return_release(i, v);
374+#else
375+ return raw_atomic_sub_return_release(i, v);
376+#endif
638377 }
639378
379+/**
380+ * raw_atomic_long_sub_return_relaxed() - atomic subtract with relaxed ordering
381+ * @i: long value to subtract
382+ * @v: pointer to atomic_long_t
383+ *
384+ * Atomically updates @v to (@v - @i) with relaxed ordering.
385+ *
386+ * Safe to use in noinstr code; prefer atomic_long_sub_return_relaxed() elsewhere.
387+ *
388+ * Return: The updated value of @v.
389+ */
640390 static __always_inline long
641−arch_atomic_long_sub_return_relaxed(long i, atomic_long_t *v)
391+raw_atomic_long_sub_return_relaxed(long i, atomic_long_t *v)
642392 {
643− return arch_atomic_sub_return_relaxed(i, v);
393+#ifdef CONFIG_64BIT
394+ return raw_atomic64_sub_return_relaxed(i, v);
395+#else
396+ return raw_atomic_sub_return_relaxed(i, v);
397+#endif
644398 }
645399
400+/**
401+ * raw_atomic_long_fetch_sub() - atomic subtract with full ordering
402+ * @i: long value to subtract
403+ * @v: pointer to atomic_long_t
404+ *
405+ * Atomically updates @v to (@v - @i) with full ordering.
406+ *
407+ * Safe to use in noinstr code; prefer atomic_long_fetch_sub() elsewhere.
408+ *
409+ * Return: The original value of @v.
410+ */
646411 static __always_inline long
647−arch_atomic_long_fetch_sub(long i, atomic_long_t *v)
412+raw_atomic_long_fetch_sub(long i, atomic_long_t *v)
648413 {
649− return arch_atomic_fetch_sub(i, v);
414+#ifdef CONFIG_64BIT
415+ return raw_atomic64_fetch_sub(i, v);
416+#else
417+ return raw_atomic_fetch_sub(i, v);
418+#endif
650419 }
651420
421+/**
422+ * raw_atomic_long_fetch_sub_acquire() - atomic subtract with acquire ordering
423+ * @i: long value to subtract
424+ * @v: pointer to atomic_long_t
425+ *
426+ * Atomically updates @v to (@v - @i) with acquire ordering.
427+ *
428+ * Safe to use in noinstr code; prefer atomic_long_fetch_sub_acquire() elsewhere.
429+ *
430+ * Return: The original value of @v.
431+ */
652432 static __always_inline long
653−arch_atomic_long_fetch_sub_acquire(long i, atomic_long_t *v)
433+raw_atomic_long_fetch_sub_acquire(long i, atomic_long_t *v)
654434 {
655− return arch_atomic_fetch_sub_acquire(i, v);
435+#ifdef CONFIG_64BIT
436+ return raw_atomic64_fetch_sub_acquire(i, v);
437+#else
438+ return raw_atomic_fetch_sub_acquire(i, v);
439+#endif
656440 }
657441
442+/**
443+ * raw_atomic_long_fetch_sub_release() - atomic subtract with release ordering
444+ * @i: long value to subtract
445+ * @v: pointer to atomic_long_t
446+ *
447+ * Atomically updates @v to (@v - @i) with release ordering.
448+ *
449+ * Safe to use in noinstr code; prefer atomic_long_fetch_sub_release() elsewhere.
450+ *
451+ * Return: The original value of @v.
452+ */
658453 static __always_inline long
659−arch_atomic_long_fetch_sub_release(long i, atomic_long_t *v)
454+raw_atomic_long_fetch_sub_release(long i, atomic_long_t *v)
660455 {
661− return arch_atomic_fetch_sub_release(i, v);
456+#ifdef CONFIG_64BIT
457+ return raw_atomic64_fetch_sub_release(i, v);
458+#else
459+ return raw_atomic_fetch_sub_release(i, v);
460+#endif
662461 }
663462
463+/**
464+ * raw_atomic_long_fetch_sub_relaxed() - atomic subtract with relaxed ordering
465+ * @i: long value to subtract
466+ * @v: pointer to atomic_long_t
467+ *
468+ * Atomically updates @v to (@v - @i) with relaxed ordering.
469+ *
470+ * Safe to use in noinstr code; prefer atomic_long_fetch_sub_relaxed() elsewhere.
471+ *
472+ * Return: The original value of @v.
473+ */
664474 static __always_inline long
665−arch_atomic_long_fetch_sub_relaxed(long i, atomic_long_t *v)
475+raw_atomic_long_fetch_sub_relaxed(long i, atomic_long_t *v)
666476 {
667− return arch_atomic_fetch_sub_relaxed(i, v);
477+#ifdef CONFIG_64BIT
478+ return raw_atomic64_fetch_sub_relaxed(i, v);
479+#else
480+ return raw_atomic_fetch_sub_relaxed(i, v);
481+#endif
668482 }
669483
484+/**
485+ * raw_atomic_long_inc() - atomic increment with relaxed ordering
486+ * @v: pointer to atomic_long_t
487+ *
488+ * Atomically updates @v to (@v + 1) with relaxed ordering.
489+ *
490+ * Safe to use in noinstr code; prefer atomic_long_inc() elsewhere.
491+ *
492+ * Return: Nothing.
493+ */
670494 static __always_inline void
671−arch_atomic_long_inc(atomic_long_t *v)
495+raw_atomic_long_inc(atomic_long_t *v)
672496 {
673− arch_atomic_inc(v);
497+#ifdef CONFIG_64BIT
498+ raw_atomic64_inc(v);
499+#else
500+ raw_atomic_inc(v);
501+#endif
674502 }
675503
504+/**
505+ * raw_atomic_long_inc_return() - atomic increment with full ordering
506+ * @v: pointer to atomic_long_t
507+ *
508+ * Atomically updates @v to (@v + 1) with full ordering.
509+ *
510+ * Safe to use in noinstr code; prefer atomic_long_inc_return() elsewhere.
511+ *
512+ * Return: The updated value of @v.
513+ */
676514 static __always_inline long
677−arch_atomic_long_inc_return(atomic_long_t *v)
515+raw_atomic_long_inc_return(atomic_long_t *v)
678516 {
679− return arch_atomic_inc_return(v);
517+#ifdef CONFIG_64BIT
518+ return raw_atomic64_inc_return(v);
519+#else
520+ return raw_atomic_inc_return(v);
521+#endif
680522 }
681523
524+/**
525+ * raw_atomic_long_inc_return_acquire() - atomic increment with acquire ordering
526+ * @v: pointer to atomic_long_t
527+ *
528+ * Atomically updates @v to (@v + 1) with acquire ordering.
529+ *
530+ * Safe to use in noinstr code; prefer atomic_long_inc_return_acquire() elsewhere.
531+ *
532+ * Return: The updated value of @v.
533+ */
682534 static __always_inline long
683−arch_atomic_long_inc_return_acquire(atomic_long_t *v)
535+raw_atomic_long_inc_return_acquire(atomic_long_t *v)
684536 {
685− return arch_atomic_inc_return_acquire(v);
537+#ifdef CONFIG_64BIT
538+ return raw_atomic64_inc_return_acquire(v);
539+#else
540+ return raw_atomic_inc_return_acquire(v);
541+#endif
686542 }
687543
544+/**
545+ * raw_atomic_long_inc_return_release() - atomic increment with release ordering
546+ * @v: pointer to atomic_long_t
547+ *
548+ * Atomically updates @v to (@v + 1) with release ordering.
549+ *
550+ * Safe to use in noinstr code; prefer atomic_long_inc_return_release() elsewhere.
551+ *
552+ * Return: The updated value of @v.
553+ */
688554 static __always_inline long
689−arch_atomic_long_inc_return_release(atomic_long_t *v)
555+raw_atomic_long_inc_return_release(atomic_long_t *v)
690556 {
691− return arch_atomic_inc_return_release(v);
557+#ifdef CONFIG_64BIT
558+ return raw_atomic64_inc_return_release(v);
559+#else
560+ return raw_atomic_inc_return_release(v);
561+#endif
692562 }
693563
564+/**
565+ * raw_atomic_long_inc_return_relaxed() - atomic increment with relaxed ordering
566+ * @v: pointer to atomic_long_t
567+ *
568+ * Atomically updates @v to (@v + 1) with relaxed ordering.
569+ *
570+ * Safe to use in noinstr code; prefer atomic_long_inc_return_relaxed() elsewhere.
571+ *
572+ * Return: The updated value of @v.
573+ */
694574 static __always_inline long
695−arch_atomic_long_inc_return_relaxed(atomic_long_t *v)
575+raw_atomic_long_inc_return_relaxed(atomic_long_t *v)
696576 {
697− return arch_atomic_inc_return_relaxed(v);
577+#ifdef CONFIG_64BIT
578+ return raw_atomic64_inc_return_relaxed(v);
579+#else
580+ return raw_atomic_inc_return_relaxed(v);
581+#endif
698582 }
699583
584+/**
585+ * raw_atomic_long_fetch_inc() - atomic increment with full ordering
586+ * @v: pointer to atomic_long_t
587+ *
588+ * Atomically updates @v to (@v + 1) with full ordering.
589+ *
590+ * Safe to use in noinstr code; prefer atomic_long_fetch_inc() elsewhere.
591+ *
592+ * Return: The original value of @v.
593+ */
700594 static __always_inline long
701−arch_atomic_long_fetch_inc(atomic_long_t *v)
595+raw_atomic_long_fetch_inc(atomic_long_t *v)
702596 {
703− return arch_atomic_fetch_inc(v);
597+#ifdef CONFIG_64BIT
598+ return raw_atomic64_fetch_inc(v);
599+#else
600+ return raw_atomic_fetch_inc(v);
601+#endif
704602 }
705603
604+/**
605+ * raw_atomic_long_fetch_inc_acquire() - atomic increment with acquire ordering
606+ * @v: pointer to atomic_long_t
607+ *
608+ * Atomically updates @v to (@v + 1) with acquire ordering.
609+ *
610+ * Safe to use in noinstr code; prefer atomic_long_fetch_inc_acquire() elsewhere.
611+ *
612+ * Return: The original value of @v.
613+ */
706614 static __always_inline long
707−arch_atomic_long_fetch_inc_acquire(atomic_long_t *v)
615+raw_atomic_long_fetch_inc_acquire(atomic_long_t *v)
708616 {
709− return arch_atomic_fetch_inc_acquire(v);
617+#ifdef CONFIG_64BIT
618+ return raw_atomic64_fetch_inc_acquire(v);
619+#else
620+ return raw_atomic_fetch_inc_acquire(v);
621+#endif
710622 }
711623
624+/**
625+ * raw_atomic_long_fetch_inc_release() - atomic increment with release ordering
626+ * @v: pointer to atomic_long_t
627+ *
628+ * Atomically updates @v to (@v + 1) with release ordering.
629+ *
630+ * Safe to use in noinstr code; prefer atomic_long_fetch_inc_release() elsewhere.
631+ *
632+ * Return: The original value of @v.
633+ */
712634 static __always_inline long
713−arch_atomic_long_fetch_inc_release(atomic_long_t *v)
635+raw_atomic_long_fetch_inc_release(atomic_long_t *v)
714636 {
715− return arch_atomic_fetch_inc_release(v);
637+#ifdef CONFIG_64BIT
638+ return raw_atomic64_fetch_inc_release(v);
639+#else
640+ return raw_atomic_fetch_inc_release(v);
641+#endif
716642 }
717643
644+/**
645+ * raw_atomic_long_fetch_inc_relaxed() - atomic increment with relaxed ordering
646+ * @v: pointer to atomic_long_t
647+ *
648+ * Atomically updates @v to (@v + 1) with relaxed ordering.
649+ *
650+ * Safe to use in noinstr code; prefer atomic_long_fetch_inc_relaxed() elsewhere.
651+ *
652+ * Return: The original value of @v.
653+ */
718654 static __always_inline long
719−arch_atomic_long_fetch_inc_relaxed(atomic_long_t *v)
655+raw_atomic_long_fetch_inc_relaxed(atomic_long_t *v)
720656 {
721− return arch_atomic_fetch_inc_relaxed(v);
657+#ifdef CONFIG_64BIT
658+ return raw_atomic64_fetch_inc_relaxed(v);
659+#else
660+ return raw_atomic_fetch_inc_relaxed(v);
661+#endif
722662 }
723663
664+/**
665+ * raw_atomic_long_dec() - atomic decrement with relaxed ordering
666+ * @v: pointer to atomic_long_t
667+ *
668+ * Atomically updates @v to (@v - 1) with relaxed ordering.
669+ *
670+ * Safe to use in noinstr code; prefer atomic_long_dec() elsewhere.
671+ *
672+ * Return: Nothing.
673+ */
724674 static __always_inline void
725−arch_atomic_long_dec(atomic_long_t *v)
675+raw_atomic_long_dec(atomic_long_t *v)
726676 {
727− arch_atomic_dec(v);
677+#ifdef CONFIG_64BIT
678+ raw_atomic64_dec(v);
679+#else
680+ raw_atomic_dec(v);
681+#endif
728682 }
729683
684+/**
685+ * raw_atomic_long_dec_return() - atomic decrement with full ordering
686+ * @v: pointer to atomic_long_t
687+ *
688+ * Atomically updates @v to (@v - 1) with full ordering.
689+ *
690+ * Safe to use in noinstr code; prefer atomic_long_dec_return() elsewhere.
691+ *
692+ * Return: The updated value of @v.
693+ */
730694 static __always_inline long
731−arch_atomic_long_dec_return(atomic_long_t *v)
695+raw_atomic_long_dec_return(atomic_long_t *v)
732696 {
733− return arch_atomic_dec_return(v);
697+#ifdef CONFIG_64BIT
698+ return raw_atomic64_dec_return(v);
699+#else
700+ return raw_atomic_dec_return(v);
701+#endif
734702 }
735703
704+/**
705+ * raw_atomic_long_dec_return_acquire() - atomic decrement with acquire ordering
706+ * @v: pointer to atomic_long_t
707+ *
708+ * Atomically updates @v to (@v - 1) with acquire ordering.
709+ *
710+ * Safe to use in noinstr code; prefer atomic_long_dec_return_acquire() elsewhere.
711+ *
712+ * Return: The updated value of @v.
713+ */
736714 static __always_inline long
737−arch_atomic_long_dec_return_acquire(atomic_long_t *v)
715+raw_atomic_long_dec_return_acquire(atomic_long_t *v)
738716 {
739− return arch_atomic_dec_return_acquire(v);
717+#ifdef CONFIG_64BIT
718+ return raw_atomic64_dec_return_acquire(v);
719+#else
720+ return raw_atomic_dec_return_acquire(v);
721+#endif
740722 }
741723
724+/**
725+ * raw_atomic_long_dec_return_release() - atomic decrement with release ordering
726+ * @v: pointer to atomic_long_t
727+ *
728+ * Atomically updates @v to (@v - 1) with release ordering.
729+ *
730+ * Safe to use in noinstr code; prefer atomic_long_dec_return_release() elsewhere.
731+ *
732+ * Return: The updated value of @v.
733+ */
742734 static __always_inline long
743−arch_atomic_long_dec_return_release(atomic_long_t *v)
735+raw_atomic_long_dec_return_release(atomic_long_t *v)
744736 {
745− return arch_atomic_dec_return_release(v);
737+#ifdef CONFIG_64BIT
738+ return raw_atomic64_dec_return_release(v);
739+#else
740+ return raw_atomic_dec_return_release(v);
741+#endif
746742 }
747743
744+/**
745+ * raw_atomic_long_dec_return_relaxed() - atomic decrement with relaxed ordering
746+ * @v: pointer to atomic_long_t
747+ *
748+ * Atomically updates @v to (@v - 1) with relaxed ordering.
749+ *
750+ * Safe to use in noinstr code; prefer atomic_long_dec_return_relaxed() elsewhere.
751+ *
752+ * Return: The updated value of @v.
753+ */
748754 static __always_inline long
749−arch_atomic_long_dec_return_relaxed(atomic_long_t *v)
755+raw_atomic_long_dec_return_relaxed(atomic_long_t *v)
750756 {
751− return arch_atomic_dec_return_relaxed(v);
757+#ifdef CONFIG_64BIT
758+ return raw_atomic64_dec_return_relaxed(v);
759+#else
760+ return raw_atomic_dec_return_relaxed(v);
761+#endif
752762 }
753763
764+/**
765+ * raw_atomic_long_fetch_dec() - atomic decrement with full ordering
766+ * @v: pointer to atomic_long_t
767+ *
768+ * Atomically updates @v to (@v - 1) with full ordering.
769+ *
770+ * Safe to use in noinstr code; prefer atomic_long_fetch_dec() elsewhere.
771+ *
772+ * Return: The original value of @v.
773+ */
754774 static __always_inline long
755−arch_atomic_long_fetch_dec(atomic_long_t *v)
775+raw_atomic_long_fetch_dec(atomic_long_t *v)
756776 {
757− return arch_atomic_fetch_dec(v);
777+#ifdef CONFIG_64BIT
778+ return raw_atomic64_fetch_dec(v);
779+#else
780+ return raw_atomic_fetch_dec(v);
781+#endif
758782 }
759783
784+/**
785+ * raw_atomic_long_fetch_dec_acquire() - atomic decrement with acquire ordering
786+ * @v: pointer to atomic_long_t
787+ *
788+ * Atomically updates @v to (@v - 1) with acquire ordering.
789+ *
790+ * Safe to use in noinstr code; prefer atomic_long_fetch_dec_acquire() elsewhere.
791+ *
792+ * Return: The original value of @v.
793+ */
760794 static __always_inline long
761−arch_atomic_long_fetch_dec_acquire(atomic_long_t *v)
795+raw_atomic_long_fetch_dec_acquire(atomic_long_t *v)
762796 {
763− return arch_atomic_fetch_dec_acquire(v);
797+#ifdef CONFIG_64BIT
798+ return raw_atomic64_fetch_dec_acquire(v);
799+#else
800+ return raw_atomic_fetch_dec_acquire(v);
801+#endif
764802 }
765803
804+/**
805+ * raw_atomic_long_fetch_dec_release() - atomic decrement with release ordering
806+ * @v: pointer to atomic_long_t
807+ *
808+ * Atomically updates @v to (@v - 1) with release ordering.
809+ *
810+ * Safe to use in noinstr code; prefer atomic_long_fetch_dec_release() elsewhere.
811+ *
812+ * Return: The original value of @v.
813+ */
766814 static __always_inline long
767−arch_atomic_long_fetch_dec_release(atomic_long_t *v)
815+raw_atomic_long_fetch_dec_release(atomic_long_t *v)
768816 {
769− return arch_atomic_fetch_dec_release(v);
817+#ifdef CONFIG_64BIT
818+ return raw_atomic64_fetch_dec_release(v);
819+#else
820+ return raw_atomic_fetch_dec_release(v);
821+#endif
770822 }
771823
824+/**
825+ * raw_atomic_long_fetch_dec_relaxed() - atomic decrement with relaxed ordering
826+ * @v: pointer to atomic_long_t
827+ *
828+ * Atomically updates @v to (@v - 1) with relaxed ordering.
829+ *
830+ * Safe to use in noinstr code; prefer atomic_long_fetch_dec_relaxed() elsewhere.
831+ *
832+ * Return: The original value of @v.
833+ */
772834 static __always_inline long
773−arch_atomic_long_fetch_dec_relaxed(atomic_long_t *v)
835+raw_atomic_long_fetch_dec_relaxed(atomic_long_t *v)
774836 {
775− return arch_atomic_fetch_dec_relaxed(v);
837+#ifdef CONFIG_64BIT
838+ return raw_atomic64_fetch_dec_relaxed(v);
839+#else
840+ return raw_atomic_fetch_dec_relaxed(v);
841+#endif
776842 }
777843
844+/**
845+ * raw_atomic_long_and() - atomic bitwise AND with relaxed ordering
846+ * @i: long value
847+ * @v: pointer to atomic_long_t
848+ *
849+ * Atomically updates @v to (@v & @i) with relaxed ordering.
850+ *
851+ * Safe to use in noinstr code; prefer atomic_long_and() elsewhere.
852+ *
853+ * Return: Nothing.
854+ */
778855 static __always_inline void
779−arch_atomic_long_and(long i, atomic_long_t *v)
856+raw_atomic_long_and(long i, atomic_long_t *v)
780857 {
781− arch_atomic_and(i, v);
858+#ifdef CONFIG_64BIT
859+ raw_atomic64_and(i, v);
860+#else
861+ raw_atomic_and(i, v);
862+#endif
782863 }
783864
865+/**
866+ * raw_atomic_long_fetch_and() - atomic bitwise AND with full ordering
867+ * @i: long value
868+ * @v: pointer to atomic_long_t
869+ *
870+ * Atomically updates @v to (@v & @i) with full ordering.
871+ *
872+ * Safe to use in noinstr code; prefer atomic_long_fetch_and() elsewhere.
873+ *
874+ * Return: The original value of @v.
875+ */
784876 static __always_inline long
785−arch_atomic_long_fetch_and(long i, atomic_long_t *v)
877+raw_atomic_long_fetch_and(long i, atomic_long_t *v)
786878 {
787− return arch_atomic_fetch_and(i, v);
879+#ifdef CONFIG_64BIT
880+ return raw_atomic64_fetch_and(i, v);
881+#else
882+ return raw_atomic_fetch_and(i, v);
883+#endif
788884 }
789885
886+/**
887+ * raw_atomic_long_fetch_and_acquire() - atomic bitwise AND with acquire ordering
888+ * @i: long value
889+ * @v: pointer to atomic_long_t
890+ *
891+ * Atomically updates @v to (@v & @i) with acquire ordering.
892+ *
893+ * Safe to use in noinstr code; prefer atomic_long_fetch_and_acquire() elsewhere.
894+ *
895+ * Return: The original value of @v.
896+ */
790897 static __always_inline long
791−arch_atomic_long_fetch_and_acquire(long i, atomic_long_t *v)
898+raw_atomic_long_fetch_and_acquire(long i, atomic_long_t *v)
792899 {
793− return arch_atomic_fetch_and_acquire(i, v);
900+#ifdef CONFIG_64BIT
901+ return raw_atomic64_fetch_and_acquire(i, v);
902+#else
903+ return raw_atomic_fetch_and_acquire(i, v);
904+#endif
794905 }
795906
907+/**
908+ * raw_atomic_long_fetch_and_release() - atomic bitwise AND with release ordering
909+ * @i: long value
910+ * @v: pointer to atomic_long_t
911+ *
912+ * Atomically updates @v to (@v & @i) with release ordering.
913+ *
914+ * Safe to use in noinstr code; prefer atomic_long_fetch_and_release() elsewhere.
915+ *
916+ * Return: The original value of @v.
917+ */
796918 static __always_inline long
797−arch_atomic_long_fetch_and_release(long i, atomic_long_t *v)
919+raw_atomic_long_fetch_and_release(long i, atomic_long_t *v)
798920 {
799− return arch_atomic_fetch_and_release(i, v);
921+#ifdef CONFIG_64BIT
922+ return raw_atomic64_fetch_and_release(i, v);
923+#else
924+ return raw_atomic_fetch_and_release(i, v);
925+#endif
800926 }
801927
928+/**
929+ * raw_atomic_long_fetch_and_relaxed() - atomic bitwise AND with relaxed ordering
930+ * @i: long value
931+ * @v: pointer to atomic_long_t
932+ *
933+ * Atomically updates @v to (@v & @i) with relaxed ordering.
934+ *
935+ * Safe to use in noinstr code; prefer atomic_long_fetch_and_relaxed() elsewhere.
936+ *
937+ * Return: The original value of @v.
938+ */
802939 static __always_inline long
803−arch_atomic_long_fetch_and_relaxed(long i, atomic_long_t *v)
940+raw_atomic_long_fetch_and_relaxed(long i, atomic_long_t *v)
804941 {
805− return arch_atomic_fetch_and_relaxed(i, v);
942+#ifdef CONFIG_64BIT
943+ return raw_atomic64_fetch_and_relaxed(i, v);
944+#else
945+ return raw_atomic_fetch_and_relaxed(i, v);
946+#endif
806947 }
807948
949+/**
950+ * raw_atomic_long_andnot() - atomic bitwise AND NOT with relaxed ordering
951+ * @i: long value
952+ * @v: pointer to atomic_long_t
953+ *
954+ * Atomically updates @v to (@v & ~@i) with relaxed ordering.
955+ *
956+ * Safe to use in noinstr code; prefer atomic_long_andnot() elsewhere.
957+ *
958+ * Return: Nothing.
959+ */
808960 static __always_inline void
809−arch_atomic_long_andnot(long i, atomic_long_t *v)
961+raw_atomic_long_andnot(long i, atomic_long_t *v)
810962 {
811− arch_atomic_andnot(i, v);
963+#ifdef CONFIG_64BIT
964+ raw_atomic64_andnot(i, v);
965+#else
966+ raw_atomic_andnot(i, v);
967+#endif
812968 }
813969
970+/**
971+ * raw_atomic_long_fetch_andnot() - atomic bitwise AND NOT with full ordering
972+ * @i: long value
973+ * @v: pointer to atomic_long_t
974+ *
975+ * Atomically updates @v to (@v & ~@i) with full ordering.
976+ *
977+ * Safe to use in noinstr code; prefer atomic_long_fetch_andnot() elsewhere.
978+ *
979+ * Return: The original value of @v.
980+ */
814981 static __always_inline long
815−arch_atomic_long_fetch_andnot(long i, atomic_long_t *v)
982+raw_atomic_long_fetch_andnot(long i, atomic_long_t *v)
816983 {
817− return arch_atomic_fetch_andnot(i, v);
984+#ifdef CONFIG_64BIT
985+ return raw_atomic64_fetch_andnot(i, v);
986+#else
987+ return raw_atomic_fetch_andnot(i, v);
988+#endif
818989 }
819990
991+/**
992+ * raw_atomic_long_fetch_andnot_acquire() - atomic bitwise AND NOT with acquire ordering
993+ * @i: long value
994+ * @v: pointer to atomic_long_t
995+ *
996+ * Atomically updates @v to (@v & ~@i) with acquire ordering.
997+ *
998+ * Safe to use in noinstr code; prefer atomic_long_fetch_andnot_acquire() elsewhere.
999+ *
1000+ * Return: The original value of @v.
1001+ */
8201002 static __always_inline long
821−arch_atomic_long_fetch_andnot_acquire(long i, atomic_long_t *v)
1003+raw_atomic_long_fetch_andnot_acquire(long i, atomic_long_t *v)
8221004 {
823− return arch_atomic_fetch_andnot_acquire(i, v);
1005+#ifdef CONFIG_64BIT
1006+ return raw_atomic64_fetch_andnot_acquire(i, v);
1007+#else
1008+ return raw_atomic_fetch_andnot_acquire(i, v);
1009+#endif
8241010 }
8251011
1012+/**
1013+ * raw_atomic_long_fetch_andnot_release() - atomic bitwise AND NOT with release ordering
1014+ * @i: long value
1015+ * @v: pointer to atomic_long_t
1016+ *
1017+ * Atomically updates @v to (@v & ~@i) with release ordering.
1018+ *
1019+ * Safe to use in noinstr code; prefer atomic_long_fetch_andnot_release() elsewhere.
1020+ *
1021+ * Return: The original value of @v.
1022+ */
8261023 static __always_inline long
827−arch_atomic_long_fetch_andnot_release(long i, atomic_long_t *v)
1024+raw_atomic_long_fetch_andnot_release(long i, atomic_long_t *v)
8281025 {
829− return arch_atomic_fetch_andnot_release(i, v);
1026+#ifdef CONFIG_64BIT
1027+ return raw_atomic64_fetch_andnot_release(i, v);
1028+#else
1029+ return raw_atomic_fetch_andnot_release(i, v);
1030+#endif
8301031 }
8311032
1033+/**
1034+ * raw_atomic_long_fetch_andnot_relaxed() - atomic bitwise AND NOT with relaxed ordering
1035+ * @i: long value
1036+ * @v: pointer to atomic_long_t
1037+ *
1038+ * Atomically updates @v to (@v & ~@i) with relaxed ordering.
1039+ *
1040+ * Safe to use in noinstr code; prefer atomic_long_fetch_andnot_relaxed() elsewhere.
1041+ *
1042+ * Return: The original value of @v.
1043+ */
8321044 static __always_inline long
833−arch_atomic_long_fetch_andnot_relaxed(long i, atomic_long_t *v)
1045+raw_atomic_long_fetch_andnot_relaxed(long i, atomic_long_t *v)
8341046 {
835− return arch_atomic_fetch_andnot_relaxed(i, v);
1047+#ifdef CONFIG_64BIT
1048+ return raw_atomic64_fetch_andnot_relaxed(i, v);
1049+#else
1050+ return raw_atomic_fetch_andnot_relaxed(i, v);
1051+#endif
8361052 }
8371053
1054+/**
1055+ * raw_atomic_long_or() - atomic bitwise OR with relaxed ordering
1056+ * @i: long value
1057+ * @v: pointer to atomic_long_t
1058+ *
1059+ * Atomically updates @v to (@v | @i) with relaxed ordering.
1060+ *
1061+ * Safe to use in noinstr code; prefer atomic_long_or() elsewhere.
1062+ *
1063+ * Return: Nothing.
1064+ */
8381065 static __always_inline void
839−arch_atomic_long_or(long i, atomic_long_t *v)
1066+raw_atomic_long_or(long i, atomic_long_t *v)
8401067 {
841− arch_atomic_or(i, v);
1068+#ifdef CONFIG_64BIT
1069+ raw_atomic64_or(i, v);
1070+#else
1071+ raw_atomic_or(i, v);
1072+#endif
8421073 }
8431074
1075+/**
1076+ * raw_atomic_long_fetch_or() - atomic bitwise OR with full ordering
1077+ * @i: long value
1078+ * @v: pointer to atomic_long_t
1079+ *
1080+ * Atomically updates @v to (@v | @i) with full ordering.
1081+ *
1082+ * Safe to use in noinstr code; prefer atomic_long_fetch_or() elsewhere.
1083+ *
1084+ * Return: The original value of @v.
1085+ */
8441086 static __always_inline long
845−arch_atomic_long_fetch_or(long i, atomic_long_t *v)
1087+raw_atomic_long_fetch_or(long i, atomic_long_t *v)
8461088 {
847− return arch_atomic_fetch_or(i, v);
1089+#ifdef CONFIG_64BIT
1090+ return raw_atomic64_fetch_or(i, v);
1091+#else
1092+ return raw_atomic_fetch_or(i, v);
1093+#endif
8481094 }
8491095
1096+/**
1097+ * raw_atomic_long_fetch_or_acquire() - atomic bitwise OR with acquire ordering
1098+ * @i: long value
1099+ * @v: pointer to atomic_long_t
1100+ *
1101+ * Atomically updates @v to (@v | @i) with acquire ordering.
1102+ *
1103+ * Safe to use in noinstr code; prefer atomic_long_fetch_or_acquire() elsewhere.
1104+ *
1105+ * Return: The original value of @v.
1106+ */
8501107 static __always_inline long
851−arch_atomic_long_fetch_or_acquire(long i, atomic_long_t *v)
1108+raw_atomic_long_fetch_or_acquire(long i, atomic_long_t *v)
8521109 {
853− return arch_atomic_fetch_or_acquire(i, v);
1110+#ifdef CONFIG_64BIT
1111+ return raw_atomic64_fetch_or_acquire(i, v);
1112+#else
1113+ return raw_atomic_fetch_or_acquire(i, v);
1114+#endif
8541115 }
8551116
1117+/**
1118+ * raw_atomic_long_fetch_or_release() - atomic bitwise OR with release ordering
1119+ * @i: long value
1120+ * @v: pointer to atomic_long_t
1121+ *
1122+ * Atomically updates @v to (@v | @i) with release ordering.
1123+ *
1124+ * Safe to use in noinstr code; prefer atomic_long_fetch_or_release() elsewhere.
1125+ *
1126+ * Return: The original value of @v.
1127+ */
8561128 static __always_inline long
857−arch_atomic_long_fetch_or_release(long i, atomic_long_t *v)
1129+raw_atomic_long_fetch_or_release(long i, atomic_long_t *v)
8581130 {
859− return arch_atomic_fetch_or_release(i, v);
1131+#ifdef CONFIG_64BIT
1132+ return raw_atomic64_fetch_or_release(i, v);
1133+#else
1134+ return raw_atomic_fetch_or_release(i, v);
1135+#endif
8601136 }
8611137
1138+/**
1139+ * raw_atomic_long_fetch_or_relaxed() - atomic bitwise OR with relaxed ordering
1140+ * @i: long value
1141+ * @v: pointer to atomic_long_t
1142+ *
1143+ * Atomically updates @v to (@v | @i) with relaxed ordering.
1144+ *
1145+ * Safe to use in noinstr code; prefer atomic_long_fetch_or_relaxed() elsewhere.
1146+ *
1147+ * Return: The original value of @v.
1148+ */
8621149 static __always_inline long
863−arch_atomic_long_fetch_or_relaxed(long i, atomic_long_t *v)
1150+raw_atomic_long_fetch_or_relaxed(long i, atomic_long_t *v)
8641151 {
865− return arch_atomic_fetch_or_relaxed(i, v);
1152+#ifdef CONFIG_64BIT
1153+ return raw_atomic64_fetch_or_relaxed(i, v);
1154+#else
1155+ return raw_atomic_fetch_or_relaxed(i, v);
1156+#endif
8661157 }
8671158
1159+/**
1160+ * raw_atomic_long_xor() - atomic bitwise XOR with relaxed ordering
1161+ * @i: long value
1162+ * @v: pointer to atomic_long_t
1163+ *
1164+ * Atomically updates @v to (@v ^ @i) with relaxed ordering.
1165+ *
1166+ * Safe to use in noinstr code; prefer atomic_long_xor() elsewhere.
1167+ *
1168+ * Return: Nothing.
1169+ */
8681170 static __always_inline void
869−arch_atomic_long_xor(long i, atomic_long_t *v)
1171+raw_atomic_long_xor(long i, atomic_long_t *v)
8701172 {
871− arch_atomic_xor(i, v);
1173+#ifdef CONFIG_64BIT
1174+ raw_atomic64_xor(i, v);
1175+#else
1176+ raw_atomic_xor(i, v);
1177+#endif
8721178 }
8731179
1180+/**
1181+ * raw_atomic_long_fetch_xor() - atomic bitwise XOR with full ordering
1182+ * @i: long value
1183+ * @v: pointer to atomic_long_t
1184+ *
1185+ * Atomically updates @v to (@v ^ @i) with full ordering.
1186+ *
1187+ * Safe to use in noinstr code; prefer atomic_long_fetch_xor() elsewhere.
1188+ *
1189+ * Return: The original value of @v.
1190+ */
8741191 static __always_inline long
875−arch_atomic_long_fetch_xor(long i, atomic_long_t *v)
1192+raw_atomic_long_fetch_xor(long i, atomic_long_t *v)
8761193 {
877− return arch_atomic_fetch_xor(i, v);
1194+#ifdef CONFIG_64BIT
1195+ return raw_atomic64_fetch_xor(i, v);
1196+#else
1197+ return raw_atomic_fetch_xor(i, v);
1198+#endif
8781199 }
8791200
1201+/**
1202+ * raw_atomic_long_fetch_xor_acquire() - atomic bitwise XOR with acquire ordering
1203+ * @i: long value
1204+ * @v: pointer to atomic_long_t
1205+ *
1206+ * Atomically updates @v to (@v ^ @i) with acquire ordering.
1207+ *
1208+ * Safe to use in noinstr code; prefer atomic_long_fetch_xor_acquire() elsewhere.
1209+ *
1210+ * Return: The original value of @v.
1211+ */
8801212 static __always_inline long
881−arch_atomic_long_fetch_xor_acquire(long i, atomic_long_t *v)
1213+raw_atomic_long_fetch_xor_acquire(long i, atomic_long_t *v)
8821214 {
883− return arch_atomic_fetch_xor_acquire(i, v);
1215+#ifdef CONFIG_64BIT
1216+ return raw_atomic64_fetch_xor_acquire(i, v);
1217+#else
1218+ return raw_atomic_fetch_xor_acquire(i, v);
1219+#endif
8841220 }
8851221
1222+/**
1223+ * raw_atomic_long_fetch_xor_release() - atomic bitwise XOR with release ordering
1224+ * @i: long value
1225+ * @v: pointer to atomic_long_t
1226+ *
1227+ * Atomically updates @v to (@v ^ @i) with release ordering.
1228+ *
1229+ * Safe to use in noinstr code; prefer atomic_long_fetch_xor_release() elsewhere.
1230+ *
1231+ * Return: The original value of @v.
1232+ */
8861233 static __always_inline long
887−arch_atomic_long_fetch_xor_release(long i, atomic_long_t *v)
1234+raw_atomic_long_fetch_xor_release(long i, atomic_long_t *v)
8881235 {
889− return arch_atomic_fetch_xor_release(i, v);
1236+#ifdef CONFIG_64BIT
1237+ return raw_atomic64_fetch_xor_release(i, v);
1238+#else
1239+ return raw_atomic_fetch_xor_release(i, v);
1240+#endif
8901241 }
8911242
1243+/**
1244+ * raw_atomic_long_fetch_xor_relaxed() - atomic bitwise XOR with relaxed ordering
1245+ * @i: long value
1246+ * @v: pointer to atomic_long_t
1247+ *
1248+ * Atomically updates @v to (@v ^ @i) with relaxed ordering.
1249+ *
1250+ * Safe to use in noinstr code; prefer atomic_long_fetch_xor_relaxed() elsewhere.
1251+ *
1252+ * Return: The original value of @v.
1253+ */
8921254 static __always_inline long
893−arch_atomic_long_fetch_xor_relaxed(long i, atomic_long_t *v)
1255+raw_atomic_long_fetch_xor_relaxed(long i, atomic_long_t *v)
8941256 {
895− return arch_atomic_fetch_xor_relaxed(i, v);
1257+#ifdef CONFIG_64BIT
1258+ return raw_atomic64_fetch_xor_relaxed(i, v);
1259+#else
1260+ return raw_atomic_fetch_xor_relaxed(i, v);
1261+#endif
8961262 }
8971263
1264+/**
1265+ * raw_atomic_long_xchg() - atomic exchange with full ordering
1266+ * @v: pointer to atomic_long_t
1267+ * @new: long value to assign
1268+ *
1269+ * Atomically updates @v to @new with full ordering.
1270+ *
1271+ * Safe to use in noinstr code; prefer atomic_long_xchg() elsewhere.
1272+ *
1273+ * Return: The original value of @v.
1274+ */
8981275 static __always_inline long
899−arch_atomic_long_xchg(atomic_long_t *v, long i)
1276+raw_atomic_long_xchg(atomic_long_t *v, long new)
9001277 {
901− return arch_atomic_xchg(v, i);
1278+#ifdef CONFIG_64BIT
1279+ return raw_atomic64_xchg(v, new);
1280+#else
1281+ return raw_atomic_xchg(v, new);
1282+#endif
9021283 }
9031284
1285+/**
1286+ * raw_atomic_long_xchg_acquire() - atomic exchange with acquire ordering
1287+ * @v: pointer to atomic_long_t
1288+ * @new: long value to assign
1289+ *
1290+ * Atomically updates @v to @new with acquire ordering.
1291+ *
1292+ * Safe to use in noinstr code; prefer atomic_long_xchg_acquire() elsewhere.
1293+ *
1294+ * Return: The original value of @v.
1295+ */
9041296 static __always_inline long
905−arch_atomic_long_xchg_acquire(atomic_long_t *v, long i)
1297+raw_atomic_long_xchg_acquire(atomic_long_t *v, long new)
9061298 {
907− return arch_atomic_xchg_acquire(v, i);
1299+#ifdef CONFIG_64BIT
1300+ return raw_atomic64_xchg_acquire(v, new);
1301+#else
1302+ return raw_atomic_xchg_acquire(v, new);
1303+#endif
9081304 }
9091305
1306+/**
1307+ * raw_atomic_long_xchg_release() - atomic exchange with release ordering
1308+ * @v: pointer to atomic_long_t
1309+ * @new: long value to assign
1310+ *
1311+ * Atomically updates @v to @new with release ordering.
1312+ *
1313+ * Safe to use in noinstr code; prefer atomic_long_xchg_release() elsewhere.
1314+ *
1315+ * Return: The original value of @v.
1316+ */
9101317 static __always_inline long
911−arch_atomic_long_xchg_release(atomic_long_t *v, long i)
1318+raw_atomic_long_xchg_release(atomic_long_t *v, long new)
9121319 {
913− return arch_atomic_xchg_release(v, i);
1320+#ifdef CONFIG_64BIT
1321+ return raw_atomic64_xchg_release(v, new);
1322+#else
1323+ return raw_atomic_xchg_release(v, new);
1324+#endif
9141325 }
9151326
1327+/**
1328+ * raw_atomic_long_xchg_relaxed() - atomic exchange with relaxed ordering
1329+ * @v: pointer to atomic_long_t
1330+ * @new: long value to assign
1331+ *
1332+ * Atomically updates @v to @new with relaxed ordering.
1333+ *
1334+ * Safe to use in noinstr code; prefer atomic_long_xchg_relaxed() elsewhere.
1335+ *
1336+ * Return: The original value of @v.
1337+ */
9161338 static __always_inline long
917−arch_atomic_long_xchg_relaxed(atomic_long_t *v, long i)
1339+raw_atomic_long_xchg_relaxed(atomic_long_t *v, long new)
9181340 {
919− return arch_atomic_xchg_relaxed(v, i);
1341+#ifdef CONFIG_64BIT
1342+ return raw_atomic64_xchg_relaxed(v, new);
1343+#else
1344+ return raw_atomic_xchg_relaxed(v, new);
1345+#endif
9201346 }
9211347
1348+/**
1349+ * raw_atomic_long_cmpxchg() - atomic compare and exchange with full ordering
1350+ * @v: pointer to atomic_long_t
1351+ * @old: long value to compare with
1352+ * @new: long value to assign
1353+ *
1354+ * If (@v == @old), atomically updates @v to @new with full ordering.
1355+ *
1356+ * Safe to use in noinstr code; prefer atomic_long_cmpxchg() elsewhere.
1357+ *
1358+ * Return: The original value of @v.
1359+ */
9221360 static __always_inline long
923−arch_atomic_long_cmpxchg(atomic_long_t *v, long old, long new)
1361+raw_atomic_long_cmpxchg(atomic_long_t *v, long old, long new)
9241362 {
925− return arch_atomic_cmpxchg(v, old, new);
1363+#ifdef CONFIG_64BIT
1364+ return raw_atomic64_cmpxchg(v, old, new);
1365+#else
1366+ return raw_atomic_cmpxchg(v, old, new);
1367+#endif
9261368 }
9271369
1370+/**
1371+ * raw_atomic_long_cmpxchg_acquire() - atomic compare and exchange with acquire ordering
1372+ * @v: pointer to atomic_long_t
1373+ * @old: long value to compare with
1374+ * @new: long value to assign
1375+ *
1376+ * If (@v == @old), atomically updates @v to @new with acquire ordering.
1377+ *
1378+ * Safe to use in noinstr code; prefer atomic_long_cmpxchg_acquire() elsewhere.
1379+ *
1380+ * Return: The original value of @v.
1381+ */
9281382 static __always_inline long
929−arch_atomic_long_cmpxchg_acquire(atomic_long_t *v, long old, long new)
1383+raw_atomic_long_cmpxchg_acquire(atomic_long_t *v, long old, long new)
9301384 {
931− return arch_atomic_cmpxchg_acquire(v, old, new);
1385+#ifdef CONFIG_64BIT
1386+ return raw_atomic64_cmpxchg_acquire(v, old, new);
1387+#else
1388+ return raw_atomic_cmpxchg_acquire(v, old, new);
1389+#endif
9321390 }
9331391
1392+/**
1393+ * raw_atomic_long_cmpxchg_release() - atomic compare and exchange with release ordering
1394+ * @v: pointer to atomic_long_t
1395+ * @old: long value to compare with
1396+ * @new: long value to assign
1397+ *
1398+ * If (@v == @old), atomically updates @v to @new with release ordering.
1399+ *
1400+ * Safe to use in noinstr code; prefer atomic_long_cmpxchg_release() elsewhere.
1401+ *
1402+ * Return: The original value of @v.
1403+ */
9341404 static __always_inline long
935−arch_atomic_long_cmpxchg_release(atomic_long_t *v, long old, long new)
1405+raw_atomic_long_cmpxchg_release(atomic_long_t *v, long old, long new)
9361406 {
937− return arch_atomic_cmpxchg_release(v, old, new);
1407+#ifdef CONFIG_64BIT
1408+ return raw_atomic64_cmpxchg_release(v, old, new);
1409+#else
1410+ return raw_atomic_cmpxchg_release(v, old, new);
1411+#endif
9381412 }
9391413
1414+/**
1415+ * raw_atomic_long_cmpxchg_relaxed() - atomic compare and exchange with relaxed ordering
1416+ * @v: pointer to atomic_long_t
1417+ * @old: long value to compare with
1418+ * @new: long value to assign
1419+ *
1420+ * If (@v == @old), atomically updates @v to @new with relaxed ordering.
1421+ *
1422+ * Safe to use in noinstr code; prefer atomic_long_cmpxchg_relaxed() elsewhere.
1423+ *
1424+ * Return: The original value of @v.
1425+ */
9401426 static __always_inline long
941−arch_atomic_long_cmpxchg_relaxed(atomic_long_t *v, long old, long new)
1427+raw_atomic_long_cmpxchg_relaxed(atomic_long_t *v, long old, long new)
9421428 {
943− return arch_atomic_cmpxchg_relaxed(v, old, new);
1429+#ifdef CONFIG_64BIT
1430+ return raw_atomic64_cmpxchg_relaxed(v, old, new);
1431+#else
1432+ return raw_atomic_cmpxchg_relaxed(v, old, new);
1433+#endif
9441434 }
9451435
1436+/**
1437+ * raw_atomic_long_try_cmpxchg() - atomic compare and exchange with full ordering
1438+ * @v: pointer to atomic_long_t
1439+ * @old: pointer to long value to compare with
1440+ * @new: long value to assign
1441+ *
1442+ * If (@v == @old), atomically updates @v to @new with full ordering.
1443+ * Otherwise, updates @old to the current value of @v.
1444+ *
1445+ * Safe to use in noinstr code; prefer atomic_long_try_cmpxchg() elsewhere.
1446+ *
1447+ * Return: @true if the exchange occured, @false otherwise.
1448+ */
9461449 static __always_inline bool
947−arch_atomic_long_try_cmpxchg(atomic_long_t *v, long *old, long new)
1450+raw_atomic_long_try_cmpxchg(atomic_long_t *v, long *old, long new)
9481451 {
949− return arch_atomic_try_cmpxchg(v, (int *)old, new);
1452+#ifdef CONFIG_64BIT
1453+ return raw_atomic64_try_cmpxchg(v, (s64 *)old, new);
1454+#else
1455+ return raw_atomic_try_cmpxchg(v, (int *)old, new);
1456+#endif
9501457 }
9511458
1459+/**
1460+ * raw_atomic_long_try_cmpxchg_acquire() - atomic compare and exchange with acquire ordering
1461+ * @v: pointer to atomic_long_t
1462+ * @old: pointer to long value to compare with
1463+ * @new: long value to assign
1464+ *
1465+ * If (@v == @old), atomically updates @v to @new with acquire ordering.
1466+ * Otherwise, updates @old to the current value of @v.
1467+ *
1468+ * Safe to use in noinstr code; prefer atomic_long_try_cmpxchg_acquire() elsewhere.
1469+ *
1470+ * Return: @true if the exchange occured, @false otherwise.
1471+ */
9521472 static __always_inline bool
953−arch_atomic_long_try_cmpxchg_acquire(atomic_long_t *v, long *old, long new)
1473+raw_atomic_long_try_cmpxchg_acquire(atomic_long_t *v, long *old, long new)
9541474 {
955− return arch_atomic_try_cmpxchg_acquire(v, (int *)old, new);
1475+#ifdef CONFIG_64BIT
1476+ return raw_atomic64_try_cmpxchg_acquire(v, (s64 *)old, new);
1477+#else
1478+ return raw_atomic_try_cmpxchg_acquire(v, (int *)old, new);
1479+#endif
9561480 }
9571481
1482+/**
1483+ * raw_atomic_long_try_cmpxchg_release() - atomic compare and exchange with release ordering
1484+ * @v: pointer to atomic_long_t
1485+ * @old: pointer to long value to compare with
1486+ * @new: long value to assign
1487+ *
1488+ * If (@v == @old), atomically updates @v to @new with release ordering.
1489+ * Otherwise, updates @old to the current value of @v.
1490+ *
1491+ * Safe to use in noinstr code; prefer atomic_long_try_cmpxchg_release() elsewhere.
1492+ *
1493+ * Return: @true if the exchange occured, @false otherwise.
1494+ */
9581495 static __always_inline bool
959−arch_atomic_long_try_cmpxchg_release(atomic_long_t *v, long *old, long new)
1496+raw_atomic_long_try_cmpxchg_release(atomic_long_t *v, long *old, long new)
9601497 {
961− return arch_atomic_try_cmpxchg_release(v, (int *)old, new);
1498+#ifdef CONFIG_64BIT
1499+ return raw_atomic64_try_cmpxchg_release(v, (s64 *)old, new);
1500+#else
1501+ return raw_atomic_try_cmpxchg_release(v, (int *)old, new);
1502+#endif
9621503 }
9631504
1505+/**
1506+ * raw_atomic_long_try_cmpxchg_relaxed() - atomic compare and exchange with relaxed ordering
1507+ * @v: pointer to atomic_long_t
1508+ * @old: pointer to long value to compare with
1509+ * @new: long value to assign
1510+ *
1511+ * If (@v == @old), atomically updates @v to @new with relaxed ordering.
1512+ * Otherwise, updates @old to the current value of @v.
1513+ *
1514+ * Safe to use in noinstr code; prefer atomic_long_try_cmpxchg_relaxed() elsewhere.
1515+ *
1516+ * Return: @true if the exchange occured, @false otherwise.
1517+ */
9641518 static __always_inline bool
965−arch_atomic_long_try_cmpxchg_relaxed(atomic_long_t *v, long *old, long new)
1519+raw_atomic_long_try_cmpxchg_relaxed(atomic_long_t *v, long *old, long new)
9661520 {
967− return arch_atomic_try_cmpxchg_relaxed(v, (int *)old, new);
1521+#ifdef CONFIG_64BIT
1522+ return raw_atomic64_try_cmpxchg_relaxed(v, (s64 *)old, new);
1523+#else
1524+ return raw_atomic_try_cmpxchg_relaxed(v, (int *)old, new);
1525+#endif
9681526 }
9691527
1528+/**
1529+ * raw_atomic_long_sub_and_test() - atomic subtract and test if zero with full ordering
1530+ * @i: long value to add
1531+ * @v: pointer to atomic_long_t
1532+ *
1533+ * Atomically updates @v to (@v - @i) with full ordering.
1534+ *
1535+ * Safe to use in noinstr code; prefer atomic_long_sub_and_test() elsewhere.
1536+ *
1537+ * Return: @true if the resulting value of @v is zero, @false otherwise.
1538+ */
9701539 static __always_inline bool
971−arch_atomic_long_sub_and_test(long i, atomic_long_t *v)
1540+raw_atomic_long_sub_and_test(long i, atomic_long_t *v)
9721541 {
973− return arch_atomic_sub_and_test(i, v);
1542+#ifdef CONFIG_64BIT
1543+ return raw_atomic64_sub_and_test(i, v);
1544+#else
1545+ return raw_atomic_sub_and_test(i, v);
1546+#endif
9741547 }
9751548
1549+/**
1550+ * raw_atomic_long_dec_and_test() - atomic decrement and test if zero with full ordering
1551+ * @v: pointer to atomic_long_t
1552+ *
1553+ * Atomically updates @v to (@v - 1) with full ordering.
1554+ *
1555+ * Safe to use in noinstr code; prefer atomic_long_dec_and_test() elsewhere.
1556+ *
1557+ * Return: @true if the resulting value of @v is zero, @false otherwise.
1558+ */
9761559 static __always_inline bool
977−arch_atomic_long_dec_and_test(atomic_long_t *v)
1560+raw_atomic_long_dec_and_test(atomic_long_t *v)
9781561 {
979− return arch_atomic_dec_and_test(v);
1562+#ifdef CONFIG_64BIT
1563+ return raw_atomic64_dec_and_test(v);
1564+#else
1565+ return raw_atomic_dec_and_test(v);
1566+#endif
9801567 }
9811568
1569+/**
1570+ * raw_atomic_long_inc_and_test() - atomic increment and test if zero with full ordering
1571+ * @v: pointer to atomic_long_t
1572+ *
1573+ * Atomically updates @v to (@v + 1) with full ordering.
1574+ *
1575+ * Safe to use in noinstr code; prefer atomic_long_inc_and_test() elsewhere.
1576+ *
1577+ * Return: @true if the resulting value of @v is zero, @false otherwise.
1578+ */
9821579 static __always_inline bool
983−arch_atomic_long_inc_and_test(atomic_long_t *v)
1580+raw_atomic_long_inc_and_test(atomic_long_t *v)
9841581 {
985− return arch_atomic_inc_and_test(v);
1582+#ifdef CONFIG_64BIT
1583+ return raw_atomic64_inc_and_test(v);
1584+#else
1585+ return raw_atomic_inc_and_test(v);
1586+#endif
9861587 }
9871588
1589+/**
1590+ * raw_atomic_long_add_negative() - atomic add and test if negative with full ordering
1591+ * @i: long value to add
1592+ * @v: pointer to atomic_long_t
1593+ *
1594+ * Atomically updates @v to (@v + @i) with full ordering.
1595+ *
1596+ * Safe to use in noinstr code; prefer atomic_long_add_negative() elsewhere.
1597+ *
1598+ * Return: @true if the resulting value of @v is negative, @false otherwise.
1599+ */
9881600 static __always_inline bool
989−arch_atomic_long_add_negative(long i, atomic_long_t *v)
1601+raw_atomic_long_add_negative(long i, atomic_long_t *v)
9901602 {
991− return arch_atomic_add_negative(i, v);
1603+#ifdef CONFIG_64BIT
1604+ return raw_atomic64_add_negative(i, v);
1605+#else
1606+ return raw_atomic_add_negative(i, v);
1607+#endif
9921608 }
9931609
1610+/**
1611+ * raw_atomic_long_add_negative_acquire() - atomic add and test if negative with acquire ordering
1612+ * @i: long value to add
1613+ * @v: pointer to atomic_long_t
1614+ *
1615+ * Atomically updates @v to (@v + @i) with acquire ordering.
1616+ *
1617+ * Safe to use in noinstr code; prefer atomic_long_add_negative_acquire() elsewhere.
1618+ *
1619+ * Return: @true if the resulting value of @v is negative, @false otherwise.
1620+ */
9941621 static __always_inline bool
995−arch_atomic_long_add_negative_acquire(long i, atomic_long_t *v)
1622+raw_atomic_long_add_negative_acquire(long i, atomic_long_t *v)
9961623 {
997− return arch_atomic_add_negative_acquire(i, v);
1624+#ifdef CONFIG_64BIT
1625+ return raw_atomic64_add_negative_acquire(i, v);
1626+#else
1627+ return raw_atomic_add_negative_acquire(i, v);
1628+#endif
9981629 }
9991630
1631+/**
1632+ * raw_atomic_long_add_negative_release() - atomic add and test if negative with release ordering
1633+ * @i: long value to add
1634+ * @v: pointer to atomic_long_t
1635+ *
1636+ * Atomically updates @v to (@v + @i) with release ordering.
1637+ *
1638+ * Safe to use in noinstr code; prefer atomic_long_add_negative_release() elsewhere.
1639+ *
1640+ * Return: @true if the resulting value of @v is negative, @false otherwise.
1641+ */
10001642 static __always_inline bool
1001−arch_atomic_long_add_negative_release(long i, atomic_long_t *v)
1643+raw_atomic_long_add_negative_release(long i, atomic_long_t *v)
10021644 {
1003− return arch_atomic_add_negative_release(i, v);
1645+#ifdef CONFIG_64BIT
1646+ return raw_atomic64_add_negative_release(i, v);
1647+#else
1648+ return raw_atomic_add_negative_release(i, v);
1649+#endif
10041650 }
10051651
1652+/**
1653+ * raw_atomic_long_add_negative_relaxed() - atomic add and test if negative with relaxed ordering
1654+ * @i: long value to add
1655+ * @v: pointer to atomic_long_t
1656+ *
1657+ * Atomically updates @v to (@v + @i) with relaxed ordering.
1658+ *
1659+ * Safe to use in noinstr code; prefer atomic_long_add_negative_relaxed() elsewhere.
1660+ *
1661+ * Return: @true if the resulting value of @v is negative, @false otherwise.
1662+ */
10061663 static __always_inline bool
1007−arch_atomic_long_add_negative_relaxed(long i, atomic_long_t *v)
1664+raw_atomic_long_add_negative_relaxed(long i, atomic_long_t *v)
10081665 {
1009− return arch_atomic_add_negative_relaxed(i, v);
1666+#ifdef CONFIG_64BIT
1667+ return raw_atomic64_add_negative_relaxed(i, v);
1668+#else
1669+ return raw_atomic_add_negative_relaxed(i, v);
1670+#endif
10101671 }
10111672
1673+/**
1674+ * raw_atomic_long_fetch_add_unless() - atomic add unless value with full ordering
1675+ * @v: pointer to atomic_long_t
1676+ * @a: long value to add
1677+ * @u: long value to compare with
1678+ *
1679+ * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
1680+ *
1681+ * Safe to use in noinstr code; prefer atomic_long_fetch_add_unless() elsewhere.
1682+ *
1683+ * Return: The original value of @v.
1684+ */
10121685 static __always_inline long
1013−arch_atomic_long_fetch_add_unless(atomic_long_t *v, long a, long u)
1686+raw_atomic_long_fetch_add_unless(atomic_long_t *v, long a, long u)
10141687 {
1015− return arch_atomic_fetch_add_unless(v, a, u);
1688+#ifdef CONFIG_64BIT
1689+ return raw_atomic64_fetch_add_unless(v, a, u);
1690+#else
1691+ return raw_atomic_fetch_add_unless(v, a, u);
1692+#endif
10161693 }
10171694
1695+/**
1696+ * raw_atomic_long_add_unless() - atomic add unless value with full ordering
1697+ * @v: pointer to atomic_long_t
1698+ * @a: long value to add
1699+ * @u: long value to compare with
1700+ *
1701+ * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
1702+ *
1703+ * Safe to use in noinstr code; prefer atomic_long_add_unless() elsewhere.
1704+ *
1705+ * Return: @true if @v was updated, @false otherwise.
1706+ */
10181707 static __always_inline bool
1019−arch_atomic_long_add_unless(atomic_long_t *v, long a, long u)
1708+raw_atomic_long_add_unless(atomic_long_t *v, long a, long u)
10201709 {
1021− return arch_atomic_add_unless(v, a, u);
1710+#ifdef CONFIG_64BIT
1711+ return raw_atomic64_add_unless(v, a, u);
1712+#else
1713+ return raw_atomic_add_unless(v, a, u);
1714+#endif
10221715 }
10231716
1717+/**
1718+ * raw_atomic_long_inc_not_zero() - atomic increment unless zero with full ordering
1719+ * @v: pointer to atomic_long_t
1720+ *
1721+ * If (@v != 0), atomically updates @v to (@v + 1) with full ordering.
1722+ *
1723+ * Safe to use in noinstr code; prefer atomic_long_inc_not_zero() elsewhere.
1724+ *
1725+ * Return: @true if @v was updated, @false otherwise.
1726+ */
10241727 static __always_inline bool
1025−arch_atomic_long_inc_not_zero(atomic_long_t *v)
1728+raw_atomic_long_inc_not_zero(atomic_long_t *v)
10261729 {
1027− return arch_atomic_inc_not_zero(v);
1730+#ifdef CONFIG_64BIT
1731+ return raw_atomic64_inc_not_zero(v);
1732+#else
1733+ return raw_atomic_inc_not_zero(v);
1734+#endif
10281735 }
10291736
1737+/**
1738+ * raw_atomic_long_inc_unless_negative() - atomic increment unless negative with full ordering
1739+ * @v: pointer to atomic_long_t
1740+ *
1741+ * If (@v >= 0), atomically updates @v to (@v + 1) with full ordering.
1742+ *
1743+ * Safe to use in noinstr code; prefer atomic_long_inc_unless_negative() elsewhere.
1744+ *
1745+ * Return: @true if @v was updated, @false otherwise.
1746+ */
10301747 static __always_inline bool
1031−arch_atomic_long_inc_unless_negative(atomic_long_t *v)
1748+raw_atomic_long_inc_unless_negative(atomic_long_t *v)
10321749 {
1033− return arch_atomic_inc_unless_negative(v);
1750+#ifdef CONFIG_64BIT
1751+ return raw_atomic64_inc_unless_negative(v);
1752+#else
1753+ return raw_atomic_inc_unless_negative(v);
1754+#endif
10341755 }
10351756
1757+/**
1758+ * raw_atomic_long_dec_unless_positive() - atomic decrement unless positive with full ordering
1759+ * @v: pointer to atomic_long_t
1760+ *
1761+ * If (@v <= 0), atomically updates @v to (@v - 1) with full ordering.
1762+ *
1763+ * Safe to use in noinstr code; prefer atomic_long_dec_unless_positive() elsewhere.
1764+ *
1765+ * Return: @true if @v was updated, @false otherwise.
1766+ */
10361767 static __always_inline bool
1037−arch_atomic_long_dec_unless_positive(atomic_long_t *v)
1768+raw_atomic_long_dec_unless_positive(atomic_long_t *v)
10381769 {
1039− return arch_atomic_dec_unless_positive(v);
1770+#ifdef CONFIG_64BIT
1771+ return raw_atomic64_dec_unless_positive(v);
1772+#else
1773+ return raw_atomic_dec_unless_positive(v);
1774+#endif
10401775 }
10411776
1777+/**
1778+ * raw_atomic_long_dec_if_positive() - atomic decrement if positive with full ordering
1779+ * @v: pointer to atomic_long_t
1780+ *
1781+ * If (@v > 0), atomically updates @v to (@v - 1) with full ordering.
1782+ *
1783+ * Safe to use in noinstr code; prefer atomic_long_dec_if_positive() elsewhere.
1784+ *
1785+ * Return: The old value of (@v - 1), regardless of whether @v was updated.
1786+ */
10421787 static __always_inline long
1043−arch_atomic_long_dec_if_positive(atomic_long_t *v)
1788+raw_atomic_long_dec_if_positive(atomic_long_t *v)
10441789 {
1045− return arch_atomic_dec_if_positive(v);
1790+#ifdef CONFIG_64BIT
1791+ return raw_atomic64_dec_if_positive(v);
1792+#else
1793+ return raw_atomic_dec_if_positive(v);
1794+#endif
10461795 }
10471796
1048−#endif /* CONFIG_64BIT */
10491797 #endif /* _LINUX_ATOMIC_LONG_H */
1050−// a194c07d7d2f4b0e178d3c118c919775d5d65f50
1798+// 4ef23f98c73cff96d239896175fd26b10b88899e
include/linux/context_tracking.h+2−2
@@ -119,7 +119,7 @@ extern void ct_idle_exit(void); · 118 unmodified lines
119119 */
120120 static __always_inline bool rcu_dynticks_curr_cpu_in_eqs(void)
121121 {
122− return !(arch_atomic_read(this_cpu_ptr(&context_tracking.state)) & RCU_DYNTICKS_IDX);
122+ return !(raw_atomic_read(this_cpu_ptr(&context_tracking.state)) & RCU_DYNTICKS_IDX);
123123 }
124124
125125 /*
@@ -128,7 +128,7 @@ static __always_inline bool rcu_dynticks_curr_cpu_in_eqs(void) · 2 unmodified lines
128128 */
129129 static __always_inline unsigned long ct_state_inc(int incby)
130130 {
131− return arch_atomic_add_return(incby, this_cpu_ptr(&context_tracking.state));
131+ return raw_atomic_add_return(incby, this_cpu_ptr(&context_tracking.state));
132132 }
133133
134134 static __always_inline bool warn_rcu_enter(void)
include/linux/context_tracking_state.h+1−1
@@ -51,7 +51,7 @@ DECLARE_PER_CPU(struct context_tracking, context_tracking); · 50 unmodified lines
5151 #ifdef CONFIG_CONTEXT_TRACKING_USER
5252 static __always_inline int __ct_state(void)
5353 {
54− return arch_atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK;
54+ return raw_atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK;
5555 }
5656 #endif
5757
include/linux/cpumask.h+1−1
@@ -1071,7 +1071,7 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu) · 1070 unmodified lines
10711071 */
10721072 static __always_inline unsigned int num_online_cpus(void)
10731073 {
1074− return arch_atomic_read(&__num_online_cpus);
1074+ return raw_atomic_read(&__num_online_cpus);
10751075 }
10761076 #define num_possible_cpus() cpumask_weight(cpu_possible_mask)
10771077 #define num_present_cpus() cpumask_weight(cpu_present_mask)
include/linux/dmar.h+66−59
@@ -202,67 +202,74 @@ static inline void detect_intel_iommu(void) · 201 unmodified lines
202202
203203 struct irte {
204204 union {
205− /* Shared between remapped and posted mode*/
206205 struct {
207− __u64 present : 1, /* 0 */
208− fpd : 1, /* 1 */
209− __res0 : 6, /* 2 - 6 */
210− avail : 4, /* 8 - 11 */
211− __res1 : 3, /* 12 - 14 */
212− pst : 1, /* 15 */
213− vector : 8, /* 16 - 23 */
214− __res2 : 40; /* 24 - 63 */
206+ union {
207+ /* Shared between remapped and posted mode*/
208+ struct {
209+ __u64 present : 1, /* 0 */
210+ fpd : 1, /* 1 */
211+ __res0 : 6, /* 2 - 6 */
212+ avail : 4, /* 8 - 11 */
213+ __res1 : 3, /* 12 - 14 */
214+ pst : 1, /* 15 */
215+ vector : 8, /* 16 - 23 */
216+ __res2 : 40; /* 24 - 63 */
217+ };
218+
219+ /* Remapped mode */
220+ struct {
221+ __u64 r_present : 1, /* 0 */
222+ r_fpd : 1, /* 1 */
223+ dst_mode : 1, /* 2 */
224+ redir_hint : 1, /* 3 */
225+ trigger_mode : 1, /* 4 */
226+ dlvry_mode : 3, /* 5 - 7 */
227+ r_avail : 4, /* 8 - 11 */
228+ r_res0 : 4, /* 12 - 15 */
229+ r_vector : 8, /* 16 - 23 */
230+ r_res1 : 8, /* 24 - 31 */
231+ dest_id : 32; /* 32 - 63 */
232+ };
233+
234+ /* Posted mode */
235+ struct {
236+ __u64 p_present : 1, /* 0 */
237+ p_fpd : 1, /* 1 */
238+ p_res0 : 6, /* 2 - 7 */
239+ p_avail : 4, /* 8 - 11 */
240+ p_res1 : 2, /* 12 - 13 */
241+ p_urgent : 1, /* 14 */
242+ p_pst : 1, /* 15 */
243+ p_vector : 8, /* 16 - 23 */
244+ p_res2 : 14, /* 24 - 37 */
245+ pda_l : 26; /* 38 - 63 */
246+ };
247+ __u64 low;
248+ };
249+
250+ union {
251+ /* Shared between remapped and posted mode*/
252+ struct {
253+ __u64 sid : 16, /* 64 - 79 */
254+ sq : 2, /* 80 - 81 */
255+ svt : 2, /* 82 - 83 */
256+ __res3 : 44; /* 84 - 127 */
257+ };
258+
259+ /* Posted mode*/
260+ struct {
261+ __u64 p_sid : 16, /* 64 - 79 */
262+ p_sq : 2, /* 80 - 81 */
263+ p_svt : 2, /* 82 - 83 */
264+ p_res3 : 12, /* 84 - 95 */
265+ pda_h : 32; /* 96 - 127 */
266+ };
267+ __u64 high;
268+ };
215269 };
216−
217− /* Remapped mode */
218− struct {
219− __u64 r_present : 1, /* 0 */
220− r_fpd : 1, /* 1 */
221− dst_mode : 1, /* 2 */
222− redir_hint : 1, /* 3 */
223− trigger_mode : 1, /* 4 */
224− dlvry_mode : 3, /* 5 - 7 */
225− r_avail : 4, /* 8 - 11 */
226− r_res0 : 4, /* 12 - 15 */
227− r_vector : 8, /* 16 - 23 */
228− r_res1 : 8, /* 24 - 31 */
229− dest_id : 32; /* 32 - 63 */
230− };
231−
232− /* Posted mode */
233− struct {
234− __u64 p_present : 1, /* 0 */
235− p_fpd : 1, /* 1 */
236− p_res0 : 6, /* 2 - 7 */
237− p_avail : 4, /* 8 - 11 */
238− p_res1 : 2, /* 12 - 13 */
239− p_urgent : 1, /* 14 */
240− p_pst : 1, /* 15 */
241− p_vector : 8, /* 16 - 23 */
242− p_res2 : 14, /* 24 - 37 */
243− pda_l : 26; /* 38 - 63 */
244− };
245− __u64 low;
246− };
247−
248− union {
249− /* Shared between remapped and posted mode*/
250− struct {
251− __u64 sid : 16, /* 64 - 79 */
252− sq : 2, /* 80 - 81 */
253− svt : 2, /* 82 - 83 */
254− __res3 : 44; /* 84 - 127 */
255− };
256−
257− /* Posted mode*/
258− struct {
259− __u64 p_sid : 16, /* 64 - 79 */
260− p_sq : 2, /* 80 - 81 */
261− p_svt : 2, /* 82 - 83 */
262− p_res3 : 12, /* 84 - 95 */
263− pda_h : 32; /* 96 - 127 */
264− };
265− __u64 high;
270+#ifdef CONFIG_IRQ_REMAP
271+ __u128 irte;
272+#endif
266273 };
267274 };
268275
include/linux/jump_label.h+1−1
@@ -257,7 +257,7 @@ extern enum jump_label_type jump_label_init_type(struct jump_entry *entry); · 256 unmodified lines
257257
258258 static __always_inline int static_key_count(struct static_key *key)
259259 {
260− return arch_atomic_read(&key->enabled);
260+ return raw_atomic_read(&key->enabled);
261261 }
262262
263263 static __always_inline void jump_label_init(void)
include/linux/lockdep.h+8−0
@@ -447,6 +447,14 @@ extern int lockdep_is_held(const void *); · 446 unmodified lines
447447
448448 #endif /* !LOCKDEP */
449449
450+#ifdef CONFIG_PROVE_LOCKING
451+void lockdep_set_lock_cmp_fn(struct lockdep_map *, lock_cmp_fn, lock_print_fn);
452+
453+#define lock_set_cmp_fn(lock, ...) lockdep_set_lock_cmp_fn(&(lock)->dep_map, __VA_ARGS__)
454+#else
455+#define lock_set_cmp_fn(lock, ...) do { } while (0)
456+#endif
457+
450458 enum xhlock_context_t {
451459 XHLOCK_HARD,
452460 XHLOCK_SOFT,
include/linux/lockdep_types.h+8−0
@@ -85,6 +85,11 @@ struct lock_trace; · 84 unmodified lines
8585
8686 #define LOCKSTAT_POINTS 4
8787
88+struct lockdep_map;
89+typedef int (*lock_cmp_fn)(const struct lockdep_map *a,
90+ const struct lockdep_map *b);
91+typedef void (*lock_print_fn)(const struct lockdep_map *map);
92+
8893 /*
8994 * The lock-class itself. The order of the structure members matters.
9095 * reinit_class() zeroes the key member and all subsequent members.
@@ -110,6 +115,9 @@ struct lock_class { · 19 unmodified lines
110115 struct list_head locks_after, locks_before;
111116
112117 const struct lockdep_subclass_key *key;
118+ lock_cmp_fn cmp_fn;
119+ lock_print_fn print_fn;
120+
113121 unsigned int subclass;
114122 unsigned int dep_gen_id;
115123
include/linux/percpu-defs.h+13−32
@@ -343,31 +343,19 @@ static __always_inline void __this_cpu_preempt_check(const char *op) { } · 342 unmodified lines
343343 pscr2_ret__; \
344344 })
345345
346−/*
347− * Special handling for cmpxchg_double. cmpxchg_double is passed two
348− * percpu variables. The first has to be aligned to a double word
349− * boundary and the second has to follow directly thereafter.
350− * We enforce this on all architectures even if they don't support
351− * a double cmpxchg instruction, since it's a cheap requirement, and it
352− * avoids breaking the requirement for architectures with the instruction.
353− */
354−#define __pcpu_double_call_return_bool(stem, pcp1, pcp2, ...) \
346+#define __pcpu_size_call_return2bool(stem, variable, ...) \
355347 ({ \
356− bool pdcrb_ret__; \
357− __verify_pcpu_ptr(&(pcp1)); \
358− BUILD_BUG_ON(sizeof(pcp1) != sizeof(pcp2)); \
359− VM_BUG_ON((unsigned long)(&(pcp1)) % (2 * sizeof(pcp1))); \
360− VM_BUG_ON((unsigned long)(&(pcp2)) != \
361− (unsigned long)(&(pcp1)) + sizeof(pcp1)); \
362− switch(sizeof(pcp1)) { \
363− case 1: pdcrb_ret__ = stem##1(pcp1, pcp2, __VA_ARGS__); break; \
364− case 2: pdcrb_ret__ = stem##2(pcp1, pcp2, __VA_ARGS__); break; \
365− case 4: pdcrb_ret__ = stem##4(pcp1, pcp2, __VA_ARGS__); break; \
366− case 8: pdcrb_ret__ = stem##8(pcp1, pcp2, __VA_ARGS__); break; \
348+ bool pscr2_ret__; \
349+ __verify_pcpu_ptr(&(variable)); \
350+ switch(sizeof(variable)) { \
351+ case 1: pscr2_ret__ = stem##1(variable, __VA_ARGS__); break; \
352+ case 2: pscr2_ret__ = stem##2(variable, __VA_ARGS__); break; \
353+ case 4: pscr2_ret__ = stem##4(variable, __VA_ARGS__); break; \
354+ case 8: pscr2_ret__ = stem##8(variable, __VA_ARGS__); break; \
367355 default: \
368356 __bad_size_call_parameter(); break; \
369357 } \
370− pdcrb_ret__; \
358+ pscr2_ret__; \
371359 })
372360
373361 #define __pcpu_size_call(stem, variable, ...) \
@@ -426,9 +414,8 @@ do { \ · 52 unmodified lines
426414 #define raw_cpu_xchg(pcp, nval) __pcpu_size_call_return2(raw_cpu_xchg_, pcp, nval)
427415 #define raw_cpu_cmpxchg(pcp, oval, nval) \
428416 __pcpu_size_call_return2(raw_cpu_cmpxchg_, pcp, oval, nval)
429−#define raw_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
430− __pcpu_double_call_return_bool(raw_cpu_cmpxchg_double_, pcp1, pcp2, oval1, oval2, nval1, nval2)
431−
417+#define raw_cpu_try_cmpxchg(pcp, ovalp, nval) \
418+ __pcpu_size_call_return2bool(raw_cpu_try_cmpxchg_, pcp, ovalp, nval)
432419 #define raw_cpu_sub(pcp, val) raw_cpu_add(pcp, -(val))
433420 #define raw_cpu_inc(pcp) raw_cpu_add(pcp, 1)
434421 #define raw_cpu_dec(pcp) raw_cpu_sub(pcp, 1)
@@ -488,11 +475,6 @@ do { \ · 53 unmodified lines
488475 raw_cpu_cmpxchg(pcp, oval, nval); \
489476 })
490477
491−#define __this_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
492−({ __this_cpu_preempt_check("cmpxchg_double"); \
493− raw_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2); \
494−})
495−
496478 #define __this_cpu_sub(pcp, val) __this_cpu_add(pcp, -(typeof(pcp))(val))
497479 #define __this_cpu_inc(pcp) __this_cpu_add(pcp, 1)
498480 #define __this_cpu_dec(pcp) __this_cpu_sub(pcp, 1)
@@ -513,9 +495,8 @@ do { \ · 14 unmodified lines
513495 #define this_cpu_xchg(pcp, nval) __pcpu_size_call_return2(this_cpu_xchg_, pcp, nval)
514496 #define this_cpu_cmpxchg(pcp, oval, nval) \
515497 __pcpu_size_call_return2(this_cpu_cmpxchg_, pcp, oval, nval)
516−#define this_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
517− __pcpu_double_call_return_bool(this_cpu_cmpxchg_double_, pcp1, pcp2, oval1, oval2, nval1, nval2)
518−
498+#define this_cpu_try_cmpxchg(pcp, ovalp, nval) \
499+ __pcpu_size_call_return2bool(this_cpu_try_cmpxchg_, pcp, ovalp, nval)
519500 #define this_cpu_sub(pcp, val) this_cpu_add(pcp, -(typeof(pcp))(val))
520501 #define this_cpu_inc(pcp) this_cpu_add(pcp, 1)
521502 #define this_cpu_dec(pcp) this_cpu_sub(pcp, 1)
include/linux/slub_def.h+9−3
@@ -39,7 +39,8 @@ enum stat_item { · 38 unmodified lines
3939 CPU_PARTIAL_FREE, /* Refill cpu partial on free */
4040 CPU_PARTIAL_NODE, /* Refill cpu partial from node partial */
4141 CPU_PARTIAL_DRAIN, /* Drain cpu partial to node partial */
42− NR_SLUB_STAT_ITEMS };
42+ NR_SLUB_STAT_ITEMS
43+};
4344
4445 #ifndef CONFIG_SLUB_TINY
4546 /*
@@ -47,8 +48,13 @@ enum stat_item { · 1 unmodified line
4748 * with this_cpu_cmpxchg_double() alignment requirements.
4849 */
4950 struct kmem_cache_cpu {
50− void **freelist; /* Pointer to next available object */
51− unsigned long tid; /* Globally unique transaction id */
51+ union {
52+ struct {
53+ void **freelist; /* Pointer to next available object */
54+ unsigned long tid; /* Globally unique transaction id */
55+ };
56+ freelist_aba_t freelist_tid;
57+ };
5258 struct slab *slab; /* The slab from which we are allocating */
5359 #ifdef CONFIG_SLUB_CPU_PARTIAL
5460 struct slab *partial; /* Partially allocated frozen slabs */
include/linux/types.h+5−0
@@ -10,6 +10,11 @@ · 9 unmodified lines
1010 #define DECLARE_BITMAP(name,bits) \
1111 unsigned long name[BITS_TO_LONGS(bits)]
1212
13+#ifdef __SIZEOF_INT128__
14+typedef __s128 s128;
15+typedef __u128 u128;
16+#endif
17+
1318 typedef u32 __kernel_dev_t;
1419
1520 typedef __kernel_fd_set fd_set;
include/uapi/linux/types.h+4−0
@@ -13,6 +13,10 @@ · 12 unmodified lines
1313
1414 #include <linux/posix_types.h>
1515
16+#ifdef __SIZEOF_INT128__
17+typedef __signed__ __int128 __s128 __attribute__((aligned(16)));
18+typedef unsigned __int128 __u128 __attribute__((aligned(16)));
19+#endif
1620
1721 /*
1822 * Below are truly Linux-specific types that should never collide with
kernel/context_tracking.c+6−6
@@ -510,7 +510,7 @@ void noinstr __ct_user_enter(enum ctx_state state) · 509 unmodified lines
510510 * In this we case we don't care about any concurrency/ordering.
511511 */
512512 if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
513− arch_atomic_set(&ct->state, state);
513+ raw_atomic_set(&ct->state, state);
514514 } else {
515515 /*
516516 * Even if context tracking is disabled on this CPU, because it's outside
@@ -527,7 +527,7 @@ void noinstr __ct_user_enter(enum ctx_state state) · 10 unmodified lines
527527 */
528528 if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
529529 /* Tracking for vtime only, no concurrent RCU EQS accounting */
530− arch_atomic_set(&ct->state, state);
530+ raw_atomic_set(&ct->state, state);
531531 } else {
532532 /*
533533 * Tracking for vtime and RCU EQS. Make sure we don't race
@@ -535,7 +535,7 @@ void noinstr __ct_user_enter(enum ctx_state state) · 1 unmodified line
535535 * RCU only requires RCU_DYNTICKS_IDX increments to be fully
536536 * ordered.
537537 */
538− arch_atomic_add(state, &ct->state);
538+ raw_atomic_add(state, &ct->state);
539539 }
540540 }
541541 }
@@ -630,12 +630,12 @@ void noinstr __ct_user_exit(enum ctx_state state) · 88 unmodified lines
630630 * In this we case we don't care about any concurrency/ordering.
631631 */
632632 if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
633− arch_atomic_set(&ct->state, CONTEXT_KERNEL);
633+ raw_atomic_set(&ct->state, CONTEXT_KERNEL);
634634
635635 } else {
636636 if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
637637 /* Tracking for vtime only, no concurrent RCU EQS accounting */
638− arch_atomic_set(&ct->state, CONTEXT_KERNEL);
638+ raw_atomic_set(&ct->state, CONTEXT_KERNEL);
639639 } else {
640640 /*
641641 * Tracking for vtime and RCU EQS. Make sure we don't race
@@ -643,7 +643,7 @@ void noinstr __ct_user_exit(enum ctx_state state) · 1 unmodified line
643643 * RCU only requires RCU_DYNTICKS_IDX increments to be fully
644644 * ordered.
645645 */
646− arch_atomic_sub(state, &ct->state);
646+ raw_atomic_sub(state, &ct->state);
647647 }
648648 }
649649 }
kernel/locking/lockdep.c+87−31
@@ -709,7 +709,7 @@ void get_usage_chars(struct lock_class *class, char usage[LOCK_USAGE_CHARS]) · 708 unmodified lines
709709 usage[i] = '\0';
710710 }
711711
712−static void __print_lock_name(struct lock_class *class)
712+static void __print_lock_name(struct held_lock *hlock, struct lock_class *class)
713713 {
714714 char str[KSYM_NAME_LEN];
715715 const char *name;
@@ -724,17 +724,19 @@ static void __print_lock_name(struct lock_class *class) · 8 unmodified lines
724724 printk(KERN_CONT "#%d", class->name_version);
725725 if (class->subclass)
726726 printk(KERN_CONT "/%d", class->subclass);
727+ if (hlock && class->print_fn)
728+ class->print_fn(hlock->instance);
727729 }
728730 }
729731
730−static void print_lock_name(struct lock_class *class)
732+static void print_lock_name(struct held_lock *hlock, struct lock_class *class)
731733 {
732734 char usage[LOCK_USAGE_CHARS];
733735
734736 get_usage_chars(class, usage);
735737
736738 printk(KERN_CONT " (");
737− __print_lock_name(class);
739+ __print_lock_name(hlock, class);
738740 printk(KERN_CONT "){%s}-{%d:%d}", usage,
739741 class->wait_type_outer ?: class->wait_type_inner,
740742 class->wait_type_inner);
@@ -772,7 +774,7 @@ static void print_lock(struct held_lock *hlock) · 31 unmodified lines
772774 }
773775
774776 printk(KERN_CONT "%px", hlock->instance);
775− print_lock_name(lock);
777+ print_lock_name(hlock, lock);
776778 printk(KERN_CONT ", at: %pS\n", (void *)hlock->acquire_ip);
777779 }
778780
@@ -1868,7 +1870,7 @@ print_circular_bug_entry(struct lock_list *target, int depth) · 1089 unmodified lines
18681870 if (debug_locks_silent)
18691871 return;
18701872 printk("\n-> #%u", depth);
1871− print_lock_name(target->class);
1873+ print_lock_name(NULL, target->class);
18721874 printk(KERN_CONT ":\n");
18731875 print_lock_trace(target->trace, 6);
18741876 }
@@ -1899,11 +1901,11 @@ print_circular_lock_scenario(struct held_lock *src, · 24 unmodified lines
18991901 */
19001902 if (parent != source) {
19011903 printk("Chain exists of:\n ");
1902− __print_lock_name(source);
1904+ __print_lock_name(src, source);
19031905 printk(KERN_CONT " --> ");
1904− __print_lock_name(parent);
1906+ __print_lock_name(NULL, parent);
19051907 printk(KERN_CONT " --> ");
1906− __print_lock_name(target);
1908+ __print_lock_name(tgt, target);
19071909 printk(KERN_CONT "\n\n");
19081910 }
19091911
@@ -1914,13 +1916,13 @@ print_circular_lock_scenario(struct held_lock *src, · 4 unmodified lines
19141916 printk(" rlock(");
19151917 else
19161918 printk(" lock(");
1917− __print_lock_name(target);
1919+ __print_lock_name(tgt, target);
19181920 printk(KERN_CONT ");\n");
19191921 printk(" lock(");
1920− __print_lock_name(parent);
1922+ __print_lock_name(NULL, parent);
19211923 printk(KERN_CONT ");\n");
19221924 printk(" lock(");
1923− __print_lock_name(target);
1925+ __print_lock_name(tgt, target);
19241926 printk(KERN_CONT ");\n");
19251927 if (src_read != 0)
19261928 printk(" rlock(");
@@ -1928,7 +1930,7 @@ print_circular_lock_scenario(struct held_lock *src, · 1 unmodified line
19281930 printk(" sync(");
19291931 else
19301932 printk(" lock(");
1931− __print_lock_name(source);
1933+ __print_lock_name(src, source);
19321934 printk(KERN_CONT ");\n");
19331935 printk("\n *** DEADLOCK ***\n\n");
19341936 }
@@ -2154,6 +2156,8 @@ check_path(struct held_lock *target, struct lock_list *src_entry, · 219 unmodified lines
21542156 return ret;
21552157 }
21562158
2159+static void print_deadlock_bug(struct task_struct *, struct held_lock *, struct held_lock *);
2160+
21572161 /*
21582162 * Prove that the dependency graph starting at <src> can not
21592163 * lead to <target>. If it can, there is a circle when adding
@@ -2185,7 +2189,10 @@ check_noncircular(struct held_lock *src, struct held_lock *target, · 25 unmodified lines
21852189 *trace = save_trace();
21862190 }
21872191
2188− print_circular_bug(&src_entry, target_entry, src, target);
2192+ if (src->class_idx == target->class_idx)
2193+ print_deadlock_bug(current, src, target);
2194+ else
2195+ print_circular_bug(&src_entry, target_entry, src, target);
21892196 }
21902197
21912198 return ret;
@@ -2346,7 +2353,7 @@ static void print_lock_class_header(struct lock_class *class, int depth) · 154 unmodified lines
23462353 int bit;
23472354
23482355 printk("%*s->", depth, "");
2349− print_lock_name(class);
2356+ print_lock_name(NULL, class);
23502357 #ifdef CONFIG_DEBUG_LOCKDEP
23512358 printk(KERN_CONT " ops: %lu", debug_class_ops_read(class));
23522359 #endif
@@ -2528,11 +2535,11 @@ print_irq_lock_scenario(struct lock_list *safe_entry, · 175 unmodified lines
25282535 */
25292536 if (middle_class != unsafe_class) {
25302537 printk("Chain exists of:\n ");
2531− __print_lock_name(safe_class);
2538+ __print_lock_name(NULL, safe_class);
25322539 printk(KERN_CONT " --> ");
2533− __print_lock_name(middle_class);
2540+ __print_lock_name(NULL, middle_class);
25342541 printk(KERN_CONT " --> ");
2535− __print_lock_name(unsafe_class);
2542+ __print_lock_name(NULL, unsafe_class);
25362543 printk(KERN_CONT "\n\n");
25372544 }
25382545
@@ -2540,18 +2547,18 @@ print_irq_lock_scenario(struct lock_list *safe_entry, · 1 unmodified line
25402547 printk(" CPU0 CPU1\n");
25412548 printk(" ---- ----\n");
25422549 printk(" lock(");
2543− __print_lock_name(unsafe_class);
2550+ __print_lock_name(NULL, unsafe_class);
25442551 printk(KERN_CONT ");\n");
25452552 printk(" local_irq_disable();\n");
25462553 printk(" lock(");
2547− __print_lock_name(safe_class);
2554+ __print_lock_name(NULL, safe_class);
25482555 printk(KERN_CONT ");\n");
25492556 printk(" lock(");
2550− __print_lock_name(middle_class);
2557+ __print_lock_name(NULL, middle_class);
25512558 printk(KERN_CONT ");\n");
25522559 printk(" <Interrupt>\n");
25532560 printk(" lock(");
2554− __print_lock_name(safe_class);
2561+ __print_lock_name(NULL, safe_class);
25552562 printk(KERN_CONT ");\n");
25562563 printk("\n *** DEADLOCK ***\n\n");
25572564 }
@@ -2588,20 +2595,20 @@ print_bad_irq_dependency(struct task_struct *curr, · 30 unmodified lines
25882595 pr_warn("\nand this task is already holding:\n");
25892596 print_lock(prev);
25902597 pr_warn("which would create a new lock dependency:\n");
2591− print_lock_name(hlock_class(prev));
2598+ print_lock_name(prev, hlock_class(prev));
25922599 pr_cont(" ->");
2593− print_lock_name(hlock_class(next));
2600+ print_lock_name(next, hlock_class(next));
25942601 pr_cont("\n");
25952602
25962603 pr_warn("\nbut this new dependency connects a %s-irq-safe lock:\n",
25972604 irqclass);
2598− print_lock_name(backwards_entry->class);
2605+ print_lock_name(NULL, backwards_entry->class);
25992606 pr_warn("\n... which became %s-irq-safe at:\n", irqclass);
26002607
26012608 print_lock_trace(backwards_entry->class->usage_traces[bit1], 1);
26022609
26032610 pr_warn("\nto a %s-irq-unsafe lock:\n", irqclass);
2604− print_lock_name(forwards_entry->class);
2611+ print_lock_name(NULL, forwards_entry->class);
26052612 pr_warn("\n... which became %s-irq-unsafe at:\n", irqclass);
26062613 pr_warn("...");
26072614
@@ -2971,10 +2978,10 @@ print_deadlock_scenario(struct held_lock *nxt, struct held_lock *prv) · 363 unmodified lines
29712978 printk(" CPU0\n");
29722979 printk(" ----\n");
29732980 printk(" lock(");
2974− __print_lock_name(prev);
2981+ __print_lock_name(prv, prev);
29752982 printk(KERN_CONT ");\n");
29762983 printk(" lock(");
2977− __print_lock_name(next);
2984+ __print_lock_name(nxt, next);
29782985 printk(KERN_CONT ");\n");
29792986 printk("\n *** DEADLOCK ***\n\n");
29802987 printk(" May be due to missing lock nesting notation\n\n");
@@ -2984,6 +2991,8 @@ static void · 3 unmodified lines
29842991 print_deadlock_bug(struct task_struct *curr, struct held_lock *prev,
29852992 struct held_lock *next)
29862993 {
2994+ struct lock_class *class = hlock_class(prev);
2995+
29872996 if (!debug_locks_off_graph_unlock() || debug_locks_silent)
29882997 return;
29892998
@@ -2998,6 +3007,11 @@ print_deadlock_bug(struct task_struct *curr, struct held_lock *prev, · 8 unmodified lines
29983007 pr_warn("\nbut task is already holding lock:\n");
29993008 print_lock(prev);
30003009
3010+ if (class->cmp_fn) {
3011+ pr_warn("and the lock comparison function returns %i:\n",
3012+ class->cmp_fn(prev->instance, next->instance));
3013+ }
3014+
30013015 pr_warn("\nother info that might help us debug this:\n");
30023016 print_deadlock_scenario(next, prev);
30033017 lockdep_print_held_locks(curr);
@@ -3019,6 +3033,7 @@ print_deadlock_bug(struct task_struct *curr, struct held_lock *prev, · 15 unmodified lines
30193033 static int
30203034 check_deadlock(struct task_struct *curr, struct held_lock *next)
30213035 {
3036+ struct lock_class *class;
30223037 struct held_lock *prev;
30233038 struct held_lock *nest = NULL;
30243039 int i;
@@ -3039,6 +3054,12 @@ check_deadlock(struct task_struct *curr, struct held_lock *next) · 14 unmodified lines
30393054 if ((next->read == 2) && prev->read)
30403055 continue;
30413056
3057+ class = hlock_class(prev);
3058+
3059+ if (class->cmp_fn &&
3060+ class->cmp_fn(prev->instance, next->instance) < 0)
3061+ continue;
3062+
30423063 /*
30433064 * We're holding the nest_lock, which serializes this lock's
30443065 * nesting behaviour.
@@ -3100,6 +3121,14 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev, · 55 unmodified lines
31003121 return 2;
31013122 }
31023123
3124+ if (prev->class_idx == next->class_idx) {
3125+ struct lock_class *class = hlock_class(prev);
3126+
3127+ if (class->cmp_fn &&
3128+ class->cmp_fn(prev->instance, next->instance) < 0)
3129+ return 2;
3130+ }
3131+
31033132 /*
31043133 * Prove that the new <prev> -> <next> dependency would not
31053134 * create a circular dependency in the graph. (We do this by
@@ -3576,7 +3605,7 @@ static void print_chain_keys_chain(struct lock_chain *chain) · 470 unmodified lines
35763605 hlock_id = chain_hlocks[chain->base + i];
35773606 chain_key = print_chain_key_iteration(hlock_id, chain_key);
35783607
3579− print_lock_name(lock_classes + chain_hlock_class_idx(hlock_id));
3608+ print_lock_name(NULL, lock_classes + chain_hlock_class_idx(hlock_id));
35803609 printk("\n");
35813610 }
35823611 }
@@ -3933,11 +3962,11 @@ static void print_usage_bug_scenario(struct held_lock *lock) · 350 unmodified lines
39333962 printk(" CPU0\n");
39343963 printk(" ----\n");
39353964 printk(" lock(");
3936− __print_lock_name(class);
3965+ __print_lock_name(lock, class);
39373966 printk(KERN_CONT ");\n");
39383967 printk(" <Interrupt>\n");
39393968 printk(" lock(");
3940− __print_lock_name(class);
3969+ __print_lock_name(lock, class);
39413970 printk(KERN_CONT ");\n");
39423971 printk("\n *** DEADLOCK ***\n\n");
39433972 }
@@ -4023,7 +4052,7 @@ print_irq_inversion_bug(struct task_struct *curr, · 79 unmodified lines
40234052 pr_warn("but this lock took another, %s-unsafe lock in the past:\n", irqclass);
40244053 else
40254054 pr_warn("but this lock was taken by another, %s-safe lock in the past:\n", irqclass);
4026− print_lock_name(other->class);
4055+ print_lock_name(NULL, other->class);
40274056 pr_warn("\n\nand interrupts could create inverse lock ordering between them.\n\n");
40284057
40294058 pr_warn("\nother info that might help us debug this:\n");
@@ -4896,6 +4925,33 @@ EXPORT_SYMBOL_GPL(lockdep_init_map_type); · 866 unmodified lines
48964925 struct lock_class_key __lockdep_no_validate__;
48974926 EXPORT_SYMBOL_GPL(__lockdep_no_validate__);
48984927
4928+#ifdef CONFIG_PROVE_LOCKING
4929+void lockdep_set_lock_cmp_fn(struct lockdep_map *lock, lock_cmp_fn cmp_fn,
4930+ lock_print_fn print_fn)
4931+{
4932+ struct lock_class *class = lock->class_cache[0];
4933+ unsigned long flags;
4934+
4935+ raw_local_irq_save(flags);
4936+ lockdep_recursion_inc();
4937+
4938+ if (!class)
4939+ class = register_lock_class(lock, 0, 0);
4940+
4941+ if (class) {
4942+ WARN_ON(class->cmp_fn && class->cmp_fn != cmp_fn);
4943+ WARN_ON(class->print_fn && class->print_fn != print_fn);
4944+
4945+ class->cmp_fn = cmp_fn;
4946+ class->print_fn = print_fn;
4947+ }
4948+
4949+ lockdep_recursion_finish();
4950+ raw_local_irq_restore(flags);
4951+}
4952+EXPORT_SYMBOL_GPL(lockdep_set_lock_cmp_fn);
4953+#endif
4954+
48994955 static void
49004956 print_lock_nested_lock_not_held(struct task_struct *curr,
49014957 struct held_lock *hlock)
kernel/sched/clock.c+1−1
@@ -287,7 +287,7 @@ again: · 286 unmodified lines
287287 clock = wrap_max(clock, min_clock);
288288 clock = wrap_min(clock, max_clock);
289289
290− if (!arch_try_cmpxchg64(&scd->clock, &old_clock, clock))
290+ if (!raw_try_cmpxchg64(&scd->clock, &old_clock, clock))
291291 goto again;
292292
293293 return clock;
lib/crypto/curve25519-hacl64.c+0−2
@@ -14,8 +14,6 @@ · 13 unmodified lines
1414 #include <crypto/curve25519.h>
1515 #include <linux/string.h>
1616
17−typedef __uint128_t u128;
18−
1917 static __always_inline u64 u64_eq_mask(u64 a, u64 b)
2018 {
2119 u64 x = a ^ b;
lib/crypto/poly1305-donna64.c+0−2
@@ -10,8 +10,6 @@ · 9 unmodified lines
1010 #include <asm/unaligned.h>
1111 #include <crypto/internal/poly1305.h>
1212
13−typedef __uint128_t u128;
14−
1513 void poly1305_core_setkey(struct poly1305_core_key *key,
1614 const u8 raw_key[POLY1305_BLOCK_SIZE])
1715 {
mm/slab.h+46−7
@@ -6,6 +6,38 @@ · 5 unmodified lines
66 */
77 void __init kmem_cache_init(void);
88
9+#ifdef CONFIG_64BIT
10+# ifdef system_has_cmpxchg128
11+# define system_has_freelist_aba() system_has_cmpxchg128()
12+# define try_cmpxchg_freelist try_cmpxchg128
13+# endif
14+#define this_cpu_try_cmpxchg_freelist this_cpu_try_cmpxchg128
15+typedef u128 freelist_full_t;
16+#else /* CONFIG_64BIT */
17+# ifdef system_has_cmpxchg64
18+# define system_has_freelist_aba() system_has_cmpxchg64()
19+# define try_cmpxchg_freelist try_cmpxchg64
20+# endif
21+#define this_cpu_try_cmpxchg_freelist this_cpu_try_cmpxchg64
22+typedef u64 freelist_full_t;
23+#endif /* CONFIG_64BIT */
24+
25+#if defined(system_has_freelist_aba) && !defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE)
26+#undef system_has_freelist_aba
27+#endif
28+
29+/*
30+ * Freelist pointer and counter to cmpxchg together, avoids the typical ABA
31+ * problems with cmpxchg of just a pointer.
32+ */
33+typedef union {
34+ struct {
35+ void *freelist;
36+ unsigned long counter;
37+ };
38+ freelist_full_t full;
39+} freelist_aba_t;
40+
941 /* Reuses the bits in struct page */
1042 struct slab {
1143 unsigned long __page_flags;
@@ -38,14 +70,21 @@ struct slab { · 26 unmodified lines
3870 #endif
3971 };
4072 /* Double-word boundary */
41− void *freelist; /* first free object */
4273 union {
43− unsigned long counters;
4474 struct {
45− unsigned inuse:16;
46− unsigned objects:15;
47− unsigned frozen:1;
75+ void *freelist; /* first free object */
76+ union {
77+ unsigned long counters;
78+ struct {
79+ unsigned inuse:16;
80+ unsigned objects:15;
81+ unsigned frozen:1;
82+ };
83+ };
4884 };
85+#ifdef system_has_freelist_aba
86+ freelist_aba_t freelist_counter;
87+#endif
4988 };
5089 };
5190 struct rcu_head rcu_head;
@@ -72,8 +111,8 @@ SLAB_MATCH(memcg_data, memcg_data); · 20 unmodified lines
72111 #endif
73112 #undef SLAB_MATCH
74113 static_assert(sizeof(struct slab) <= sizeof(struct page));
75−#if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && defined(CONFIG_SLUB)
76−static_assert(IS_ALIGNED(offsetof(struct slab, freelist), 2*sizeof(void *)));
114+#if defined(system_has_freelist_aba) && defined(CONFIG_SLUB)
115+static_assert(IS_ALIGNED(offsetof(struct slab, freelist), sizeof(freelist_aba_t)));
77116 #endif
78117
79118 /**
mm/slub.c+82−57
@@ -292,7 +292,12 @@ static inline bool kmem_cache_has_cpu_partial(struct kmem_cache *s) · 291 unmodified lines
292292 /* Poison object */
293293 #define __OBJECT_POISON ((slab_flags_t __force)0x80000000U)
294294 /* Use cmpxchg_double */
295+
296+#ifdef system_has_freelist_aba
295297 #define __CMPXCHG_DOUBLE ((slab_flags_t __force)0x40000000U)
298+#else
299+#define __CMPXCHG_DOUBLE ((slab_flags_t __force)0U)
300+#endif
296301
297302 /*
298303 * Tracking user of a slab.
@@ -512,6 +517,40 @@ static __always_inline void slab_unlock(struct slab *slab) · 213 unmodified lines
512517 __bit_spin_unlock(PG_locked, &page->flags);
513518 }
514519
520+static inline bool
521+__update_freelist_fast(struct slab *slab,
522+ void *freelist_old, unsigned long counters_old,
523+ void *freelist_new, unsigned long counters_new)
524+{
525+#ifdef system_has_freelist_aba
526+ freelist_aba_t old = { .freelist = freelist_old, .counter = counters_old };
527+ freelist_aba_t new = { .freelist = freelist_new, .counter = counters_new };
528+
529+ return try_cmpxchg_freelist(&slab->freelist_counter.full, &old.full, new.full);
530+#else
531+ return false;
532+#endif
533+}
534+
535+static inline bool
536+__update_freelist_slow(struct slab *slab,
537+ void *freelist_old, unsigned long counters_old,
538+ void *freelist_new, unsigned long counters_new)
539+{
540+ bool ret = false;
541+
542+ slab_lock(slab);
543+ if (slab->freelist == freelist_old &&
544+ slab->counters == counters_old) {
545+ slab->freelist = freelist_new;
546+ slab->counters = counters_new;
547+ ret = true;
548+ }
549+ slab_unlock(slab);
550+
551+ return ret;
552+}
553+
515554 /*
516555 * Interrupts must be disabled (for the fallback code to work right), typically
517556 * by an _irqsave() lock variant. On PREEMPT_RT the preempt_disable(), which is
@@ -519,33 +558,25 @@ static __always_inline void slab_unlock(struct slab *slab) · 1 unmodified line
519558 * allocation/ free operation in hardirq context. Therefore nothing can
520559 * interrupt the operation.
521560 */
522−static inline bool __cmpxchg_double_slab(struct kmem_cache *s, struct slab *slab,
561+static inline bool __slab_update_freelist(struct kmem_cache *s, struct slab *slab,
523562 void *freelist_old, unsigned long counters_old,
524563 void *freelist_new, unsigned long counters_new,
525564 const char *n)
526565 {
566+ bool ret;
567+
527568 if (USE_LOCKLESS_FAST_PATH())
528569 lockdep_assert_irqs_disabled();
529−#if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && \
530− defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE)
570+
531571 if (s->flags & __CMPXCHG_DOUBLE) {
532− if (cmpxchg_double(&slab->freelist, &slab->counters,
533− freelist_old, counters_old,
534− freelist_new, counters_new))
535− return true;
536− } else
537−#endif
538− {
539− slab_lock(slab);
540− if (slab->freelist == freelist_old &&
541− slab->counters == counters_old) {
542− slab->freelist = freelist_new;
543− slab->counters = counters_new;
544− slab_unlock(slab);
545− return true;
546− }
547− slab_unlock(slab);
572+ ret = __update_freelist_fast(slab, freelist_old, counters_old,
573+ freelist_new, counters_new);
574+ } else {
575+ ret = __update_freelist_slow(slab, freelist_old, counters_old,
576+ freelist_new, counters_new);
548577 }
578+ if (likely(ret))
579+ return true;
549580
550581 cpu_relax();
551582 stat(s, CMPXCHG_DOUBLE_FAIL);
@@ -557,36 +588,26 @@ static inline bool __cmpxchg_double_slab(struct kmem_cache *s, struct slab *slab · 5 unmodified lines
557588 return false;
558589 }
559590
560−static inline bool cmpxchg_double_slab(struct kmem_cache *s, struct slab *slab,
591+static inline bool slab_update_freelist(struct kmem_cache *s, struct slab *slab,
561592 void *freelist_old, unsigned long counters_old,
562593 void *freelist_new, unsigned long counters_new,
563594 const char *n)
564595 {
565−#if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && \
566− defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE)
596+ bool ret;
597+
567598 if (s->flags & __CMPXCHG_DOUBLE) {
568− if (cmpxchg_double(&slab->freelist, &slab->counters,
569− freelist_old, counters_old,
570− freelist_new, counters_new))
571− return true;
572− } else
573−#endif
574− {
599+ ret = __update_freelist_fast(slab, freelist_old, counters_old,
600+ freelist_new, counters_new);
601+ } else {
575602 unsigned long flags;
576603
577604 local_irq_save(flags);
578− slab_lock(slab);
579− if (slab->freelist == freelist_old &&
580− slab->counters == counters_old) {
581− slab->freelist = freelist_new;
582− slab->counters = counters_new;
583− slab_unlock(slab);
584− local_irq_restore(flags);
585− return true;
586− }
587− slab_unlock(slab);
605+ ret = __update_freelist_slow(slab, freelist_old, counters_old,
606+ freelist_new, counters_new);
588607 local_irq_restore(flags);
589608 }
609+ if (likely(ret))
610+ return true;
590611
591612 cpu_relax();
592613 stat(s, CMPXCHG_DOUBLE_FAIL);
@@ -2228,7 +2249,7 @@ static inline void *acquire_slab(struct kmem_cache *s, · 1635 unmodified lines
22282249 VM_BUG_ON(new.frozen);
22292250 new.frozen = 1;
22302251
2231− if (!__cmpxchg_double_slab(s, slab,
2252+ if (!__slab_update_freelist(s, slab,
22322253 freelist, counters,
22332254 new.freelist, new.counters,
22342255 "acquire_slab"))
@@ -2554,7 +2575,7 @@ redo: · 319 unmodified lines
25542575 }
25552576
25562577
2557− if (!cmpxchg_double_slab(s, slab,
2578+ if (!slab_update_freelist(s, slab,
25582579 old.freelist, old.counters,
25592580 new.freelist, new.counters,
25602581 "unfreezing slab")) {
@@ -2611,7 +2632,7 @@ static void __unfreeze_partials(struct kmem_cache *s, struct slab *partial_slab) · 50 unmodified lines
26112632
26122633 new.frozen = 0;
26132634
2614− } while (!__cmpxchg_double_slab(s, slab,
2635+ } while (!__slab_update_freelist(s, slab,
26152636 old.freelist, old.counters,
26162637 new.freelist, new.counters,
26172638 "unfreezing slab"));
@@ -3008,6 +3029,18 @@ static inline bool pfmemalloc_match(struct slab *slab, gfp_t gfpflags) · 390 unmodified lines
30083029 }
30093030
30103031 #ifndef CONFIG_SLUB_TINY
3032+static inline bool
3033+__update_cpu_freelist_fast(struct kmem_cache *s,
3034+ void *freelist_old, void *freelist_new,
3035+ unsigned long tid)
3036+{
3037+ freelist_aba_t old = { .freelist = freelist_old, .counter = tid };
3038+ freelist_aba_t new = { .freelist = freelist_new, .counter = next_tid(tid) };
3039+
3040+ return this_cpu_try_cmpxchg_freelist(s->cpu_slab->freelist_tid.full,
3041+ &old.full, new.full);
3042+}
3043+
30113044 /*
30123045 * Check the slab->freelist and either transfer the freelist to the
30133046 * per cpu freelist or deactivate the slab.
@@ -3034,7 +3067,7 @@ static inline void *get_freelist(struct kmem_cache *s, struct slab *slab) · 20 unmodified lines
30343067 new.inuse = slab->objects;
30353068 new.frozen = freelist != NULL;
30363069
3037− } while (!__cmpxchg_double_slab(s, slab,
3070+ } while (!__slab_update_freelist(s, slab,
30383071 freelist, counters,
30393072 NULL, new.counters,
30403073 "get_freelist"));
@@ -3359,11 +3392,7 @@ redo: · 318 unmodified lines
33593392 * against code executing on this cpu *not* from access by
33603393 * other cpus.
33613394 */
3362− if (unlikely(!this_cpu_cmpxchg_double(
3363− s->cpu_slab->freelist, s->cpu_slab->tid,
3364− object, tid,
3365− next_object, next_tid(tid)))) {
3366−
3395+ if (unlikely(!__update_cpu_freelist_fast(s, object, next_object, tid))) {
33673396 note_cmpxchg_failure("slab_alloc", s, tid);
33683397 goto redo;
33693398 }
@@ -3631,7 +3660,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab, · 261 unmodified lines
36313660 }
36323661 }
36333662
3634− } while (!cmpxchg_double_slab(s, slab,
3663+ } while (!slab_update_freelist(s, slab,
36353664 prior, counters,
36363665 head, new.counters,
36373666 "__slab_free"));
@@ -3736,11 +3765,7 @@ redo: · 98 unmodified lines
37363765
37373766 set_freepointer(s, tail_obj, freelist);
37383767
3739− if (unlikely(!this_cpu_cmpxchg_double(
3740− s->cpu_slab->freelist, s->cpu_slab->tid,
3741− freelist, tid,
3742− head, next_tid(tid)))) {
3743−
3768+ if (unlikely(!__update_cpu_freelist_fast(s, freelist, head, tid))) {
37443769 note_cmpxchg_failure("slab_free", s, tid);
37453770 goto redo;
37463771 }
@@ -4505,11 +4530,11 @@ static int kmem_cache_open(struct kmem_cache *s, slab_flags_t flags) · 758 unmodified lines
45054530 }
45064531 }
45074532
4508−#if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && \
4509− defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE)
4510− if (system_has_cmpxchg_double() && (s->flags & SLAB_NO_CMPXCHG) == 0)
4533+#ifdef system_has_freelist_aba
4534+ if (system_has_freelist_aba() && !(s->flags & SLAB_NO_CMPXCHG)) {
45114535 /* Enable fast mode */
45124536 s->flags |= __CMPXCHG_DOUBLE;
4537+ }
45134538 #endif
45144539
45154540 /*
scripts/atomic/atomic-tbl.sh+108−4
@@ -36,9 +36,16 @@ meta_has_relaxed() · 35 unmodified lines
3636 meta_in "$1" "BFIR"
3737 }
3838
39−#find_fallback_template(pfx, name, sfx, order)
40−find_fallback_template()
39+#meta_is_implicitly_relaxed(meta)
40+meta_is_implicitly_relaxed()
4141 {
42+ meta_in "$1" "vls"
43+}
44+
45+#find_template(tmpltype, pfx, name, sfx, order)
46+find_template()
47+{
48+ local tmpltype="$1"; shift
4249 local pfx="$1"; shift
4350 local name="$1"; shift
4451 local sfx="$1"; shift
@@ -52,8 +59,8 @@ find_fallback_template() · 7 unmodified lines
5259 #
5360 # Start at the most specific, and fall back to the most general. Once
5461 # we find a specific fallback, don't bother looking for more.
55− for base in "${pfx}${name}${sfx}${order}" "${name}"; do
56− file="${ATOMICDIR}/fallbacks/${base}"
62+ for base in "${pfx}${name}${sfx}${order}" "${pfx}${name}${sfx}" "${name}"; do
63+ file="${ATOMICDIR}/${tmpltype}/${base}"
5764
5865 if [ -f "${file}" ]; then
5966 printf "${file}"
@@ -62,6 +69,18 @@ find_fallback_template() · 2 unmodified lines
6269 done
6370 }
6471
72+#find_fallback_template(pfx, name, sfx, order)
73+find_fallback_template()
74+{
75+ find_template "fallbacks" "$@"
76+}
77+
78+#find_kerneldoc_template(pfx, name, sfx, order)
79+find_kerneldoc_template()
80+{
81+ find_template "kerneldoc" "$@"
82+}
83+
6584 #gen_ret_type(meta, int)
6685 gen_ret_type() {
6786 local meta="$1"; shift
@@ -142,6 +161,91 @@ gen_args() · 74 unmodified lines
142161 done
143162 }
144163
164+#gen_desc_return(meta)
165+gen_desc_return()
166+{
167+ local meta="$1"; shift
168+
169+ case "${meta}" in
170+ [v])
171+ printf "Return: Nothing."
172+ ;;
173+ [Ff])
174+ printf "Return: The original value of @v."
175+ ;;
176+ [R])
177+ printf "Return: The updated value of @v."
178+ ;;
179+ [l])
180+ printf "Return: The value of @v."
181+ ;;
182+ esac
183+}
184+
185+#gen_template_kerneldoc(template, class, meta, pfx, name, sfx, order, atomic, int, args...)
186+gen_template_kerneldoc()
187+{
188+ local template="$1"; shift
189+ local class="$1"; shift
190+ local meta="$1"; shift
191+ local pfx="$1"; shift
192+ local name="$1"; shift
193+ local sfx="$1"; shift
194+ local order="$1"; shift
195+ local atomic="$1"; shift
196+ local int="$1"; shift
197+
198+ local atomicname="${atomic}_${pfx}${name}${sfx}${order}"
199+
200+ local ret="$(gen_ret_type "${meta}" "${int}")"
201+ local retstmt="$(gen_ret_stmt "${meta}")"
202+ local params="$(gen_params "${int}" "${atomic}" "$@")"
203+ local args="$(gen_args "$@")"
204+ local desc_order=""
205+ local desc_instrumentation=""
206+ local desc_return=""
207+
208+ if [ ! -z "${order}" ]; then
209+ desc_order="${order##_}"
210+ elif meta_is_implicitly_relaxed "${meta}"; then
211+ desc_order="relaxed"
212+ else
213+ desc_order="full"
214+ fi
215+
216+ if [ -z "${class}" ]; then
217+ desc_noinstr="Unsafe to use in noinstr code; use raw_${atomicname}() there."
218+ else
219+ desc_noinstr="Safe to use in noinstr code; prefer ${atomicname}() elsewhere."
220+ fi
221+
222+ desc_return="$(gen_desc_return "${meta}")"
223+
224+ . ${template}
225+}
226+
227+#gen_kerneldoc(class, meta, pfx, name, sfx, order, atomic, int, args...)
228+gen_kerneldoc()
229+{
230+ local class="$1"; shift
231+ local meta="$1"; shift
232+ local pfx="$1"; shift
233+ local name="$1"; shift
234+ local sfx="$1"; shift
235+ local order="$1"; shift
236+
237+ local atomicname="${atomic}_${pfx}${name}${sfx}${order}"
238+
239+ local tmpl="$(find_kerneldoc_template "${pfx}" "${name}" "${sfx}" "${order}")"
240+ if [ -z "${tmpl}" ]; then
241+ printf "/*\n"
242+ printf " * No kerneldoc available for ${class}${atomicname}\n"
243+ printf " */\n"
244+ else
245+ gen_template_kerneldoc "${tmpl}" "${class}" "${meta}" "${pfx}" "${name}" "${sfx}" "${order}" "$@"
246+ fi
247+}
248+
145249 #gen_proto_order_variants(meta, pfx, name, sfx, ...)
146250 gen_proto_order_variants()
147251 {
scripts/atomic/atomics.tbl+1−1
@@ -27,7 +27,7 @@ and vF i v · 26 unmodified lines
2727 andnot vF i v
2828 or vF i v
2929 xor vF i v
30−xchg I v i
30+xchg I v i:new
3131 cmpxchg I v i:old i:new
3232 try_cmpxchg B v p:old i:new
3333 sub_and_test b i v
scripts/atomic/fallbacks/acquire+0−4
@@ -1,9 +1,5 @@
11 cat <<EOF
2−static __always_inline ${ret}
3−arch_${atomic}_${pfx}${name}${sfx}_acquire(${params})
4−{
52 ${ret} ret = arch_${atomic}_${pfx}${name}${sfx}_relaxed(${args});
63 __atomic_acquire_fence();
74 return ret;
8−}
95 EOF
scripts/atomic/fallbacks/add_negative+1−13
@@ -1,15 +1,3 @@
11 cat <<EOF
2−/**
3− * arch_${atomic}_add_negative${order} - Add and test if negative
4− * @i: integer value to add
5− * @v: pointer of type ${atomic}_t
6− *
7− * Atomically adds @i to @v and returns true if the result is negative,
8− * or false when the result is greater than or equal to zero.
9− */
10−static __always_inline bool
11−arch_${atomic}_add_negative${order}(${int} i, ${atomic}_t *v)
12−{
13− return arch_${atomic}_add_return${order}(i, v) < 0;
14−}
2+ return raw_${atomic}_add_return${order}(i, v) < 0;
153 EOF
scripts/atomic/fallbacks/add_unless+1−14
@@ -1,16 +1,3 @@
11 cat << EOF
2−/**
3− * arch_${atomic}_add_unless - add unless the number is already a given value
4− * @v: pointer of type ${atomic}_t
5− * @a: the amount to add to v...
6− * @u: ...unless v is equal to u.
7− *
8− * Atomically adds @a to @v, if @v was not already @u.
9− * Returns true if the addition was done.
10− */
11−static __always_inline bool
12−arch_${atomic}_add_unless(${atomic}_t *v, ${int} a, ${int} u)
13−{
14− return arch_${atomic}_fetch_add_unless(v, a, u) != u;
15−}
2+ return raw_${atomic}_fetch_add_unless(v, a, u) != u;
163 EOF
scripts/atomic/fallbacks/andnot+1−5
@@ -1,7 +1,3 @@
11 cat <<EOF
2−static __always_inline ${ret}
3−arch_${atomic}_${pfx}andnot${sfx}${order}(${int} i, ${atomic}_t *v)
4−{
5− ${retstmt}arch_${atomic}_${pfx}and${sfx}${order}(~i, v);
6−}
2+ ${retstmt}raw_${atomic}_${pfx}and${sfx}${order}(~i, v);
73 EOF
scripts/atomic/fallbacks/cmpxchg+3−0
@@ -0,0 +1,3 @@
1+cat <<EOF
2+ return raw_cmpxchg${order}(&v->counter, old, new);
3+EOF
scripts/atomic/fallbacks/dec+1−5
@@ -1,7 +1,3 @@
11 cat <<EOF
2−static __always_inline ${ret}
3−arch_${atomic}_${pfx}dec${sfx}${order}(${atomic}_t *v)
4−{
5− ${retstmt}arch_${atomic}_${pfx}sub${sfx}${order}(1, v);
6−}
2+ ${retstmt}raw_${atomic}_${pfx}sub${sfx}${order}(1, v);
73 EOF
scripts/atomic/fallbacks/dec_and_test+1−13
@@ -1,15 +1,3 @@
11 cat <<EOF
2−/**
3− * arch_${atomic}_dec_and_test - decrement and test
4− * @v: pointer of type ${atomic}_t
5− *
6− * Atomically decrements @v by 1 and
7− * returns true if the result is 0, or false for all other
8− * cases.
9− */
10−static __always_inline bool
11−arch_${atomic}_dec_and_test(${atomic}_t *v)
12−{
13− return arch_${atomic}_dec_return(v) == 0;
14−}
2+ return raw_${atomic}_dec_return(v) == 0;
153 EOF
scripts/atomic/fallbacks/dec_if_positive+2−6
@@ -1,15 +1,11 @@
11 cat <<EOF
2−static __always_inline ${ret}
3−arch_${atomic}_dec_if_positive(${atomic}_t *v)
4−{
5− ${int} dec, c = arch_${atomic}_read(v);
2+ ${int} dec, c = raw_${atomic}_read(v);
63
74 do {
85 dec = c - 1;
96 if (unlikely(dec < 0))
107 break;
11− } while (!arch_${atomic}_try_cmpxchg(v, &c, dec));
8+ } while (!raw_${atomic}_try_cmpxchg(v, &c, dec));
129
1310 return dec;
14−}
1511 EOF
scripts/atomic/fallbacks/dec_unless_positive+2−6
@@ -1,14 +1,10 @@
11 cat <<EOF
2−static __always_inline bool
3−arch_${atomic}_dec_unless_positive(${atomic}_t *v)
4−{
5− ${int} c = arch_${atomic}_read(v);
2+ ${int} c = raw_${atomic}_read(v);
63
74 do {
85 if (unlikely(c > 0))
96 return false;
10− } while (!arch_${atomic}_try_cmpxchg(v, &c, c - 1));
7+ } while (!raw_${atomic}_try_cmpxchg(v, &c, c - 1));
118
129 return true;
13−}
1410 EOF
scripts/atomic/fallbacks/fence+0−4
@@ -1,11 +1,7 @@
11 cat <<EOF
2−static __always_inline ${ret}
3−arch_${atomic}_${pfx}${name}${sfx}(${params})
4−{
52 ${ret} ret;
63 __atomic_pre_full_fence();
74 ret = arch_${atomic}_${pfx}${name}${sfx}_relaxed(${args});
85 __atomic_post_full_fence();
96 return ret;
10−}
117 EOF
scripts/atomic/fallbacks/fetch_add_unless+2−15
@@ -1,23 +1,10 @@
11 cat << EOF
2−/**
3− * arch_${atomic}_fetch_add_unless - add unless the number is already a given value
4− * @v: pointer of type ${atomic}_t
5− * @a: the amount to add to v...
6− * @u: ...unless v is equal to u.
7− *
8− * Atomically adds @a to @v, so long as @v was not already @u.
9− * Returns original value of @v
10− */
11−static __always_inline ${int}
12−arch_${atomic}_fetch_add_unless(${atomic}_t *v, ${int} a, ${int} u)
13−{
14− ${int} c = arch_${atomic}_read(v);
2+ ${int} c = raw_${atomic}_read(v);
153
164 do {
175 if (unlikely(c == u))
186 break;
19− } while (!arch_${atomic}_try_cmpxchg(v, &c, c + a));
7+ } while (!raw_${atomic}_try_cmpxchg(v, &c, c + a));
208
219 return c;
22−}
2310 EOF
scripts/atomic/fallbacks/inc+1−5
@@ -1,7 +1,3 @@
11 cat <<EOF
2−static __always_inline ${ret}
3−arch_${atomic}_${pfx}inc${sfx}${order}(${atomic}_t *v)
4−{
5− ${retstmt}arch_${atomic}_${pfx}add${sfx}${order}(1, v);
6−}
2+ ${retstmt}raw_${atomic}_${pfx}add${sfx}${order}(1, v);
73 EOF
scripts/atomic/fallbacks/inc_and_test+1−13
@@ -1,15 +1,3 @@
11 cat <<EOF
2−/**
3− * arch_${atomic}_inc_and_test - increment and test
4− * @v: pointer of type ${atomic}_t
5− *
6− * Atomically increments @v by 1
7− * and returns true if the result is zero, or false for all
8− * other cases.
9− */
10−static __always_inline bool
11−arch_${atomic}_inc_and_test(${atomic}_t *v)
12−{
13− return arch_${atomic}_inc_return(v) == 0;
14−}
2+ return raw_${atomic}_inc_return(v) == 0;
153 EOF
scripts/atomic/fallbacks/inc_not_zero+1−12
@@ -1,14 +1,3 @@
11 cat <<EOF
2−/**
3− * arch_${atomic}_inc_not_zero - increment unless the number is zero
4− * @v: pointer of type ${atomic}_t
5− *
6− * Atomically increments @v by 1, if @v is non-zero.
7− * Returns true if the increment was done.
8− */
9−static __always_inline bool
10−arch_${atomic}_inc_not_zero(${atomic}_t *v)
11−{
12− return arch_${atomic}_add_unless(v, 1, 0);
13−}
2+ return raw_${atomic}_add_unless(v, 1, 0);
143 EOF
scripts/atomic/fallbacks/inc_unless_negative+2−6
@@ -1,14 +1,10 @@
11 cat <<EOF
2−static __always_inline bool
3−arch_${atomic}_inc_unless_negative(${atomic}_t *v)
4−{
5− ${int} c = arch_${atomic}_read(v);
2+ ${int} c = raw_${atomic}_read(v);
63
74 do {
85 if (unlikely(c < 0))
96 return false;
10− } while (!arch_${atomic}_try_cmpxchg(v, &c, c + 1));
7+ } while (!raw_${atomic}_try_cmpxchg(v, &c, c + 1));
118
129 return true;
13−}
1410 EOF
scripts/atomic/fallbacks/read_acquire+1−5
@@ -1,16 +1,12 @@
11 cat <<EOF
2−static __always_inline ${ret}
3−arch_${atomic}_read_acquire(const ${atomic}_t *v)
4−{
52 ${int} ret;
63
74 if (__native_word(${atomic}_t)) {
85 ret = smp_load_acquire(&(v)->counter);
96 } else {
10− ret = arch_${atomic}_read(v);
7+ ret = raw_${atomic}_read(v);
118 __atomic_acquire_fence();
129 }
1310
1411 return ret;
15−}
1612 EOF
scripts/atomic/fallbacks/release+0−4
@@ -1,8 +1,4 @@
11 cat <<EOF
2−static __always_inline ${ret}
3−arch_${atomic}_${pfx}${name}${sfx}_release(${params})
4−{
52 __atomic_release_fence();
63 ${retstmt}arch_${atomic}_${pfx}${name}${sfx}_relaxed(${args});
7−}
84 EOF
scripts/atomic/fallbacks/set_release+1−5
@@ -1,12 +1,8 @@
11 cat <<EOF
2−static __always_inline void
3−arch_${atomic}_set_release(${atomic}_t *v, ${int} i)
4−{
52 if (__native_word(${atomic}_t)) {
63 smp_store_release(&(v)->counter, i);
74 } else {
85 __atomic_release_fence();
9− arch_${atomic}_set(v, i);
6+ raw_${atomic}_set(v, i);
107 }
11−}
128 EOF
scripts/atomic/fallbacks/sub_and_test+1−14
@@ -1,16 +1,3 @@
11 cat <<EOF
2−/**
3− * arch_${atomic}_sub_and_test - subtract value from variable and test result
4− * @i: integer value to subtract
5− * @v: pointer of type ${atomic}_t
6− *
7− * Atomically subtracts @i from @v and returns
8− * true if the result is zero, or false for all
9− * other cases.
10− */
11−static __always_inline bool
12−arch_${atomic}_sub_and_test(${int} i, ${atomic}_t *v)
13−{
14− return arch_${atomic}_sub_return(i, v) == 0;
15−}
2+ return raw_${atomic}_sub_return(i, v) == 0;
163 EOF
scripts/atomic/fallbacks/try_cmpxchg+1−5
@@ -1,11 +1,7 @@
11 cat <<EOF
2−static __always_inline bool
3−arch_${atomic}_try_cmpxchg${order}(${atomic}_t *v, ${int} *old, ${int} new)
4−{
52 ${int} r, o = *old;
6− r = arch_${atomic}_cmpxchg${order}(v, o, new);
3+ r = raw_${atomic}_cmpxchg${order}(v, o, new);
74 if (unlikely(r != o))
85 *old = r;
96 return likely(r == o);
10−}
117 EOF
scripts/atomic/fallbacks/xchg+3−0
@@ -0,0 +1,3 @@
1+cat <<EOF
2+ return raw_xchg${order}(&v->counter, new);
3+EOF
scripts/atomic/gen-atomic-fallback.sh+175−91
@@ -17,23 +17,16 @@ gen_template_fallback() · 16 unmodified lines
1717 local atomic="$1"; shift
1818 local int="$1"; shift
1919
20− local atomicname="arch_${atomic}_${pfx}${name}${sfx}${order}"
21−
2220 local ret="$(gen_ret_type "${meta}" "${int}")"
2321 local retstmt="$(gen_ret_stmt "${meta}")"
2422 local params="$(gen_params "${int}" "${atomic}" "$@")"
2523 local args="$(gen_args "$@")"
2624
27− if [ ! -z "${template}" ]; then
28− printf "#ifndef ${atomicname}\n"
29− . ${template}
30− printf "#define ${atomicname} ${atomicname}\n"
31− printf "#endif\n\n"
32− fi
25+ . ${template}
3326 }
3427
35−#gen_proto_fallback(meta, pfx, name, sfx, order, atomic, int, args...)
36−gen_proto_fallback()
28+#gen_order_fallback(meta, pfx, name, sfx, order, atomic, int, args...)
29+gen_order_fallback()
3730 {
3831 local meta="$1"; shift
3932 local pfx="$1"; shift
@@ -41,87 +34,124 @@ gen_proto_fallback() · 1 unmodified line
4134 local sfx="$1"; shift
4235 local order="$1"; shift
4336
44− local tmpl="$(find_fallback_template "${pfx}" "${name}" "${sfx}" "${order}")"
37+ local tmpl_order=${order#_}
38+ local tmpl="${ATOMICDIR}/fallbacks/${tmpl_order:-fence}"
4539 gen_template_fallback "${tmpl}" "${meta}" "${pfx}" "${name}" "${sfx}" "${order}" "$@"
4640 }
4741
48−#gen_basic_fallbacks(basename)
49−gen_basic_fallbacks()
50−{
51− local basename="$1"; shift
52−cat << EOF
53−#define ${basename}_acquire ${basename}
54−#define ${basename}_release ${basename}
55−#define ${basename}_relaxed ${basename}
56−EOF
57−}
58−
59−gen_proto_order_variant()
42+#gen_proto_fallback(meta, pfx, name, sfx, order, atomic, int, args...)
43+gen_proto_fallback()
6044 {
6145 local meta="$1"; shift
6246 local pfx="$1"; shift
6347 local name="$1"; shift
6448 local sfx="$1"; shift
6549 local order="$1"; shift
66− local atomic="$1"
6750
68− local basename="arch_${atomic}_${pfx}${name}${sfx}"
69−
70− printf "#define ${basename}${order} ${basename}${order}\n"
51+ local tmpl="$(find_fallback_template "${pfx}" "${name}" "${sfx}" "${order}")"
52+ gen_template_fallback "${tmpl}" "${meta}" "${pfx}" "${name}" "${sfx}" "${order}" "$@"
7153 }
7254
73−#gen_proto_order_variants(meta, pfx, name, sfx, atomic, int, args...)
74−gen_proto_order_variants()
55+#gen_proto_order_variant(meta, pfx, name, sfx, order, atomic, int, args...)
56+gen_proto_order_variant()
7557 {
7658 local meta="$1"; shift
7759 local pfx="$1"; shift
7860 local name="$1"; shift
7961 local sfx="$1"; shift
80− local atomic="$1"
62+ local order="$1"; shift
63+ local atomic="$1"; shift
64+ local int="$1"; shift
8165
82− local basename="arch_${atomic}_${pfx}${name}${sfx}"
66+ local atomicname="${atomic}_${pfx}${name}${sfx}${order}"
67+ local basename="${atomic}_${pfx}${name}${sfx}"
8368
8469 local template="$(find_fallback_template "${pfx}" "${name}" "${sfx}" "${order}")"
8570
86− # If we don't have relaxed atomics, then we don't bother with ordering fallbacks
87− # read_acquire and set_release need to be templated, though
88− if ! meta_has_relaxed "${meta}"; then
89− gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "" "$@"
71+ local ret="$(gen_ret_type "${meta}" "${int}")"
72+ local retstmt="$(gen_ret_stmt "${meta}")"
73+ local params="$(gen_params "${int}" "${atomic}" "$@")"
74+ local args="$(gen_args "$@")"
9075
91− if meta_has_acquire "${meta}"; then
92− gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_acquire" "$@"
93− fi
76+ gen_kerneldoc "raw_" "${meta}" "${pfx}" "${name}" "${sfx}" "${order}" "${atomic}" "${int}" "$@"
77+
78+ printf "static __always_inline ${ret}\n"
79+ printf "raw_${atomicname}(${params})\n"
80+ printf "{\n"
81+
82+ # Where there is no possible fallback, this order variant is mandatory
83+ # and must be provided by arch code. Add a comment to the header to
84+ # make this obvious.
85+ #
86+ # Ideally we'd error on a missing definition, but arch code might
87+ # define this order variant as a C function without a preprocessor
88+ # symbol.
89+ if [ -z ${template} ] && [ -z "${order}" ] && ! meta_has_relaxed "${meta}"; then
90+ printf "\t${retstmt}arch_${atomicname}(${args});\n"
91+ printf "}\n\n"
92+ return
93+ fi
9494
95− if meta_has_release "${meta}"; then
96− gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_release" "$@"
97− fi
95+ printf "#if defined(arch_${atomicname})\n"
96+ printf "\t${retstmt}arch_${atomicname}(${args});\n"
9897
99− return
98+ # Allow FULL/ACQUIRE/RELEASE ops to be defined in terms of RELAXED ops
99+ if [ "${order}" != "_relaxed" ] && meta_has_relaxed "${meta}"; then
100+ printf "#elif defined(arch_${basename}_relaxed)\n"
101+ gen_order_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "${order}" "${atomic}" "${int}" "$@"
100102 fi
101103
102− printf "#ifndef ${basename}_relaxed\n"
104+ # Allow ACQUIRE/RELEASE/RELAXED ops to be defined in terms of FULL ops
105+ if [ ! -z "${order}" ]; then
106+ printf "#elif defined(arch_${basename})\n"
107+ printf "\t${retstmt}arch_${basename}(${args});\n"
108+ fi
103109
110+ printf "#else\n"
104111 if [ ! -z "${template}" ]; then
105− printf "#ifdef ${basename}\n"
112+ gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "${order}" "${atomic}" "${int}" "$@"
113+ else
114+ printf "#error \"Unable to define raw_${atomicname}\"\n"
106115 fi
107116
108− gen_basic_fallbacks "${basename}"
117+ printf "#endif\n"
118+ printf "}\n\n"
119+}
109120
110− if [ ! -z "${template}" ]; then
111− printf "#endif /* ${basename} */\n\n"
112− gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "" "$@"
113− gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_acquire" "$@"
114− gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_release" "$@"
115− gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_relaxed" "$@"
121+
122+#gen_proto_order_variants(meta, pfx, name, sfx, atomic, int, args...)
123+gen_proto_order_variants()
124+{
125+ local meta="$1"; shift
126+ local pfx="$1"; shift
127+ local name="$1"; shift
128+ local sfx="$1"; shift
129+ local atomic="$1"
130+
131+ gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "" "$@"
132+
133+ if meta_has_acquire "${meta}"; then
134+ gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "_acquire" "$@"
116135 fi
117136
118− printf "#else /* ${basename}_relaxed */\n\n"
137+ if meta_has_release "${meta}"; then
138+ gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "_release" "$@"
139+ fi
119140
120− gen_template_fallback "${ATOMICDIR}/fallbacks/acquire" "${meta}" "${pfx}" "${name}" "${sfx}" "_acquire" "$@"
121− gen_template_fallback "${ATOMICDIR}/fallbacks/release" "${meta}" "${pfx}" "${name}" "${sfx}" "_release" "$@"
122− gen_template_fallback "${ATOMICDIR}/fallbacks/fence" "${meta}" "${pfx}" "${name}" "${sfx}" "" "$@"
141+ if meta_has_relaxed "${meta}"; then
142+ gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "_relaxed" "$@"
143+ fi
144+}
123145
124− printf "#endif /* ${basename}_relaxed */\n\n"
146+#gen_basic_fallbacks(basename)
147+gen_basic_fallbacks()
148+{
149+ local basename="$1"; shift
150+cat << EOF
151+#define raw_${basename}_acquire arch_${basename}
152+#define raw_${basename}_release arch_${basename}
153+#define raw_${basename}_relaxed arch_${basename}
154+EOF
125155 }
126156
127157 gen_order_fallbacks()
@@ -130,36 +160,65 @@ gen_order_fallbacks() · 2 unmodified lines
130160
131161 cat <<EOF
132162
133−#ifndef ${xchg}_acquire
134−#define ${xchg}_acquire(...) \\
135− __atomic_op_acquire(${xchg}, __VA_ARGS__)
163+#define raw_${xchg}_relaxed arch_${xchg}_relaxed
164+
165+#ifdef arch_${xchg}_acquire
166+#define raw_${xchg}_acquire arch_${xchg}_acquire
167+#else
168+#define raw_${xchg}_acquire(...) \\
169+ __atomic_op_acquire(arch_${xchg}, __VA_ARGS__)
136170 #endif
137171
138−#ifndef ${xchg}_release
139−#define ${xchg}_release(...) \\
140− __atomic_op_release(${xchg}, __VA_ARGS__)
172+#ifdef arch_${xchg}_release
173+#define raw_${xchg}_release arch_${xchg}_release
174+#else
175+#define raw_${xchg}_release(...) \\
176+ __atomic_op_release(arch_${xchg}, __VA_ARGS__)
141177 #endif
142178
143−#ifndef ${xchg}
144−#define ${xchg}(...) \\
145− __atomic_op_fence(${xchg}, __VA_ARGS__)
179+#ifdef arch_${xchg}
180+#define raw_${xchg} arch_${xchg}
181+#else
182+#define raw_${xchg}(...) \\
183+ __atomic_op_fence(arch_${xchg}, __VA_ARGS__)
146184 #endif
147185
148186 EOF
149187 }
150188
151−gen_xchg_fallbacks()
189+gen_xchg_order_fallback()
152190 {
153191 local xchg="$1"; shift
154− printf "#ifndef ${xchg}_relaxed\n"
192+ local order="$1"; shift
193+ local forder="${order:-_fence}"
155194
156− gen_basic_fallbacks ${xchg}
195+ printf "#if defined(arch_${xchg}${order})\n"
196+ printf "#define raw_${xchg}${order} arch_${xchg}${order}\n"
157197
158− printf "#else /* ${xchg}_relaxed */\n"
198+ if [ "${order}" != "_relaxed" ]; then
199+ printf "#elif defined(arch_${xchg}_relaxed)\n"
200+ printf "#define raw_${xchg}${order}(...) \\\\\n"
201+ printf " __atomic_op${forder}(arch_${xchg}, __VA_ARGS__)\n"
202+ fi
203+
204+ if [ ! -z "${order}" ]; then
205+ printf "#elif defined(arch_${xchg})\n"
206+ printf "#define raw_${xchg}${order} arch_${xchg}\n"
207+ fi
159208
160− gen_order_fallbacks ${xchg}
209+ printf "#else\n"
210+ printf "extern void raw_${xchg}${order}_not_implemented(void);\n"
211+ printf "#define raw_${xchg}${order}(...) raw_${xchg}${order}_not_implemented()\n"
212+ printf "#endif\n\n"
213+}
214+
215+gen_xchg_fallbacks()
216+{
217+ local xchg="$1"; shift
161218
162− printf "#endif /* ${xchg}_relaxed */\n\n"
219+ for order in "" "_acquire" "_release" "_relaxed"; do
220+ gen_xchg_order_fallback "${xchg}" "${order}"
221+ done
163222 }
164223
165224 gen_try_cmpxchg_fallback()
@@ -168,40 +227,61 @@ gen_try_cmpxchg_fallback() · 2 unmodified lines
168227 local order="$1"; shift;
169228
170229 cat <<EOF
171−#ifndef arch_try_${cmpxchg}${order}
172−#define arch_try_${cmpxchg}${order}(_ptr, _oldp, _new) \\
230+#define raw_try_${cmpxchg}${order}(_ptr, _oldp, _new) \\
173231 ({ \\
174232 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \\
175− ___r = arch_${cmpxchg}${order}((_ptr), ___o, (_new)); \\
233+ ___r = raw_${cmpxchg}${order}((_ptr), ___o, (_new)); \\
176234 if (unlikely(___r != ___o)) \\
177235 *___op = ___r; \\
178236 likely(___r == ___o); \\
179237 })
180−#endif /* arch_try_${cmpxchg}${order} */
181−
182238 EOF
183239 }
184240
185−gen_try_cmpxchg_fallbacks()
241+gen_try_cmpxchg_order_fallback()
186242 {
187− local cmpxchg="$1"; shift;
243+ local cmpxchg="$1"; shift
244+ local order="$1"; shift
245+ local forder="${order:-_fence}"
188246
189− printf "#ifndef arch_try_${cmpxchg}_relaxed\n"
190− printf "#ifdef arch_try_${cmpxchg}\n"
247+ printf "#if defined(arch_try_${cmpxchg}${order})\n"
248+ printf "#define raw_try_${cmpxchg}${order} arch_try_${cmpxchg}${order}\n"
249+
250+ if [ "${order}" != "_relaxed" ]; then
251+ printf "#elif defined(arch_try_${cmpxchg}_relaxed)\n"
252+ printf "#define raw_try_${cmpxchg}${order}(...) \\\\\n"
253+ printf " __atomic_op${forder}(arch_try_${cmpxchg}, __VA_ARGS__)\n"
254+ fi
191255
192− gen_basic_fallbacks "arch_try_${cmpxchg}"
256+ if [ ! -z "${order}" ]; then
257+ printf "#elif defined(arch_try_${cmpxchg})\n"
258+ printf "#define raw_try_${cmpxchg}${order} arch_try_${cmpxchg}\n"
259+ fi
193260
194− printf "#endif /* arch_try_${cmpxchg} */\n\n"
261+ printf "#else\n"
262+ gen_try_cmpxchg_fallback "${cmpxchg}" "${order}"
263+ printf "#endif\n\n"
264+}
265+
266+gen_try_cmpxchg_fallbacks()
267+{
268+ local cmpxchg="$1"; shift;
195269
196270 for order in "" "_acquire" "_release" "_relaxed"; do
197− gen_try_cmpxchg_fallback "${cmpxchg}" "${order}"
271+ gen_try_cmpxchg_order_fallback "${cmpxchg}" "${order}"
198272 done
273+}
199274
200− printf "#else /* arch_try_${cmpxchg}_relaxed */\n"
201−
202− gen_order_fallbacks "arch_try_${cmpxchg}"
275+gen_cmpxchg_local_fallbacks()
276+{
277+ local cmpxchg="$1"; shift
203278
204− printf "#endif /* arch_try_${cmpxchg}_relaxed */\n\n"
279+ printf "#define raw_${cmpxchg} arch_${cmpxchg}\n\n"
280+ printf "#ifdef arch_try_${cmpxchg}\n"
281+ printf "#define raw_try_${cmpxchg} arch_try_${cmpxchg}\n"
282+ printf "#else\n"
283+ gen_try_cmpxchg_fallback "${cmpxchg}" ""
284+ printf "#endif\n\n"
205285 }
206286
207287 cat << EOF
@@ -217,16 +297,20 @@ cat << EOF · 9 unmodified lines
217297
218298 EOF
219299
220−for xchg in "arch_xchg" "arch_cmpxchg" "arch_cmpxchg64"; do
300+for xchg in "xchg" "cmpxchg" "cmpxchg64" "cmpxchg128"; do
221301 gen_xchg_fallbacks "${xchg}"
222302 done
223303
224−for cmpxchg in "cmpxchg" "cmpxchg64"; do
304+for cmpxchg in "cmpxchg" "cmpxchg64" "cmpxchg128"; do
225305 gen_try_cmpxchg_fallbacks "${cmpxchg}"
226306 done
227307
228−for cmpxchg in "cmpxchg_local" "cmpxchg64_local"; do
229− gen_try_cmpxchg_fallback "${cmpxchg}" ""
308+for cmpxchg in "cmpxchg_local" "cmpxchg64_local" "cmpxchg128_local"; do
309+ gen_cmpxchg_local_fallbacks "${cmpxchg}" ""
310+done
311+
312+for cmpxchg in "sync_cmpxchg"; do
313+ printf "#define raw_${cmpxchg} arch_${cmpxchg}\n\n"
230314 done
231315
232316 grep '^[a-z]' "$1" | while read name meta args; do
scripts/atomic/gen-atomic-instrumented.sh+16−26
@@ -68,12 +68,14 @@ gen_proto_order_variant() · 67 unmodified lines
6868 local args="$(gen_args "$@")"
6969 local retstmt="$(gen_ret_stmt "${meta}")"
7070
71+ gen_kerneldoc "" "${meta}" "${pfx}" "${name}" "${sfx}" "${order}" "${atomic}" "${int}" "$@"
72+
7173 cat <<EOF
7274 static __always_inline ${ret}
7375 ${atomicname}(${params})
7476 {
7577 ${checks}
76− ${retstmt}arch_${atomicname}(${args});
78+ ${retstmt}raw_${atomicname}(${args});
7779 }
7880 EOF
7981
@@ -84,7 +86,6 @@ gen_xchg() · 4 unmodified lines
8486 {
8587 local xchg="$1"; shift
8688 local order="$1"; shift
87− local mult="$1"; shift
8889
8990 kcsan_barrier=""
9091 if [ "${xchg%_local}" = "${xchg}" ]; then
@@ -104,9 +105,9 @@ cat <<EOF · 13 unmodified lines
104105 EOF
105106 [ -n "$kcsan_barrier" ] && printf "\t${kcsan_barrier}; \\\\\n"
106107 cat <<EOF
107− instrument_atomic_read_write(__ai_ptr, ${mult}sizeof(*__ai_ptr)); \\
108− instrument_read_write(__ai_oldp, ${mult}sizeof(*__ai_oldp)); \\
109− arch_${xchg}${order}(__ai_ptr, __ai_oldp, __VA_ARGS__); \\
108+ instrument_atomic_read_write(__ai_ptr, sizeof(*__ai_ptr)); \\
109+ instrument_read_write(__ai_oldp, sizeof(*__ai_oldp)); \\
110+ raw_${xchg}${order}(__ai_ptr, __ai_oldp, __VA_ARGS__); \\
110111 })
111112 EOF
112113
@@ -119,8 +120,8 @@ cat <<EOF · 6 unmodified lines
119120 EOF
120121 [ -n "$kcsan_barrier" ] && printf "\t${kcsan_barrier}; \\\\\n"
121122 cat <<EOF
122− instrument_atomic_read_write(__ai_ptr, ${mult}sizeof(*__ai_ptr)); \\
123− arch_${xchg}${order}(__ai_ptr, __VA_ARGS__); \\
123+ instrument_atomic_read_write(__ai_ptr, sizeof(*__ai_ptr)); \\
124+ raw_${xchg}${order}(__ai_ptr, __VA_ARGS__); \\
124125 })
125126 EOF
126127
@@ -134,15 +135,10 @@ cat << EOF · 7 unmodified lines
134135 // DO NOT MODIFY THIS FILE DIRECTLY
135136
136137 /*
137− * This file provides wrappers with KASAN instrumentation for atomic operations.
138− * To use this functionality an arch's atomic.h file needs to define all
139− * atomic operations with arch_ prefix (e.g. arch_atomic_read()) and include
140− * this file at the end. This file provides atomic_read() that forwards to
141− * arch_atomic_read() for actual atomic operation.
142− * Note: if an arch atomic operation is implemented by means of other atomic
143− * operations (e.g. atomic_read()/atomic_cmpxchg() loop), then it needs to use
144− * arch_ variants (i.e. arch_atomic_read()/arch_atomic_cmpxchg()) to avoid
145− * double instrumentation.
138+ * This file provoides atomic operations with explicit instrumentation (e.g.
139+ * KASAN, KCSAN), which should be used unless it is necessary to avoid
140+ * instrumentation. Where it is necessary to aovid instrumenation, the
141+ * raw_atomic*() operations should be used.
146142 */
147143 #ifndef _LINUX_ATOMIC_INSTRUMENTED_H
148144 #define _LINUX_ATOMIC_INSTRUMENTED_H
@@ -166,24 +162,18 @@ grep '^[a-z]' "$1" | while read name meta args; do · 17 unmodified lines
166162 done
167163
168164
169−for xchg in "xchg" "cmpxchg" "cmpxchg64" "try_cmpxchg" "try_cmpxchg64"; do
165+for xchg in "xchg" "cmpxchg" "cmpxchg64" "cmpxchg128" "try_cmpxchg" "try_cmpxchg64" "try_cmpxchg128"; do
170166 for order in "" "_acquire" "_release" "_relaxed"; do
171− gen_xchg "${xchg}" "${order}" ""
167+ gen_xchg "${xchg}" "${order}"
172168 printf "\n"
173169 done
174170 done
175171
176−for xchg in "cmpxchg_local" "cmpxchg64_local" "sync_cmpxchg" "try_cmpxchg_local" "try_cmpxchg64_local" ; do
177− gen_xchg "${xchg}" "" ""
172+for xchg in "cmpxchg_local" "cmpxchg64_local" "cmpxchg128_local" "sync_cmpxchg" "try_cmpxchg_local" "try_cmpxchg64_local" "try_cmpxchg128_local"; do
173+ gen_xchg "${xchg}" ""
178174 printf "\n"
179175 done
180176
181−gen_xchg "cmpxchg_double" "" "2 * "
182−
183−printf "\n\n"
184−
185−gen_xchg "cmpxchg_double_local" "" "2 * "
186−
187177 cat <<EOF
188178
189179 #endif /* _LINUX_ATOMIC_INSTRUMENTED_H */
scripts/atomic/gen-atomic-long.sh+18−20
@@ -32,24 +32,34 @@ gen_args_cast() · 31 unmodified lines
3232 done
3333 }
3434
35−#gen_proto_order_variant(meta, pfx, name, sfx, order, atomic, int, arg...)
35+#gen_proto_order_variant(meta, pfx, name, sfx, order, arg...)
3636 gen_proto_order_variant()
3737 {
3838 local meta="$1"; shift
39− local name="$1$2$3$4"; shift; shift; shift; shift
40− local atomic="$1"; shift
41− local int="$1"; shift
39+ local pfx="$1"; shift
40+ local name="$1"; shift
41+ local sfx="$1"; shift
42+ local order="$1"; shift
43+
44+ local atomicname="${pfx}${name}${sfx}${order}"
4245
4346 local ret="$(gen_ret_type "${meta}" "long")"
4447 local params="$(gen_params "long" "atomic_long" "$@")"
45− local argscast="$(gen_args_cast "${int}" "${atomic}" "$@")"
48+ local argscast_32="$(gen_args_cast "int" "atomic" "$@")"
49+ local argscast_64="$(gen_args_cast "s64" "atomic64" "$@")"
4650 local retstmt="$(gen_ret_stmt "${meta}")"
4751
52+ gen_kerneldoc "raw_" "${meta}" "${pfx}" "${name}" "${sfx}" "${order}" "atomic_long" "long" "$@"
53+
4854 cat <<EOF
4955 static __always_inline ${ret}
50−arch_atomic_long_${name}(${params})
56+raw_atomic_long_${atomicname}(${params})
5157 {
52− ${retstmt}arch_${atomic}_${name}(${argscast});
58+#ifdef CONFIG_64BIT
59+ ${retstmt}raw_atomic64_${atomicname}(${argscast_64});
60+#else
61+ ${retstmt}raw_atomic_${atomicname}(${argscast_32});
62+#endif
5363 }
5464
5565 EOF
@@ -79,24 +89,12 @@ typedef atomic_t atomic_long_t; · 23 unmodified lines
7989 #define atomic_long_cond_read_relaxed atomic_cond_read_relaxed
8090 #endif
8191
82−#ifdef CONFIG_64BIT
83−
84−EOF
85−
86−grep '^[a-z]' "$1" | while read name meta args; do
87− gen_proto "${meta}" "${name}" "atomic64" "s64" ${args}
88−done
89−
90−cat <<EOF
91−#else /* CONFIG_64BIT */
92−
9392 EOF
9493
9594 grep '^[a-z]' "$1" | while read name meta args; do
96− gen_proto "${meta}" "${name}" "atomic" "int" ${args}
95+ gen_proto "${meta}" "${name}" ${args}
9796 done
9897
9998 cat <<EOF
100−#endif /* CONFIG_64BIT */
10199 #endif /* _LINUX_ATOMIC_LONG_H */
102100 EOF
scripts/atomic/kerneldoc/add+13−0
@@ -0,0 +1,13 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic add with ${desc_order} ordering
4+ * @i: ${int} value to add
5+ * @v: pointer to ${atomic}_t
6+ *
7+ * Atomically updates @v to (@v + @i) with ${desc_order} ordering.
8+ *
9+ * ${desc_noinstr}
10+ *
11+ * ${desc_return}
12+ */
13+EOF
scripts/atomic/kerneldoc/add_negative+13−0
@@ -0,0 +1,13 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic add and test if negative with ${desc_order} ordering
4+ * @i: ${int} value to add
5+ * @v: pointer to ${atomic}_t
6+ *
7+ * Atomically updates @v to (@v + @i) with ${desc_order} ordering.
8+ *
9+ * ${desc_noinstr}
10+ *
11+ * Return: @true if the resulting value of @v is negative, @false otherwise.
12+ */
13+EOF
scripts/atomic/kerneldoc/add_unless+18−0
@@ -0,0 +1,18 @@
1+if [ -z "${pfx}" ]; then
2+ desc_return="Return: @true if @v was updated, @false otherwise."
3+fi
4+
5+cat <<EOF
6+/**
7+ * ${class}${atomicname}() - atomic add unless value with ${desc_order} ordering
8+ * @v: pointer to ${atomic}_t
9+ * @a: ${int} value to add
10+ * @u: ${int} value to compare with
11+ *
12+ * If (@v != @u), atomically updates @v to (@v + @a) with ${desc_order} ordering.
13+ *
14+ * ${desc_noinstr}
15+ *
16+ * ${desc_return}
17+ */
18+EOF
scripts/atomic/kerneldoc/and+13−0
@@ -0,0 +1,13 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic bitwise AND with ${desc_order} ordering
4+ * @i: ${int} value
5+ * @v: pointer to ${atomic}_t
6+ *
7+ * Atomically updates @v to (@v & @i) with ${desc_order} ordering.
8+ *
9+ * ${desc_noinstr}
10+ *
11+ * ${desc_return}
12+ */
13+EOF
scripts/atomic/kerneldoc/andnot+13−0
@@ -0,0 +1,13 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic bitwise AND NOT with ${desc_order} ordering
4+ * @i: ${int} value
5+ * @v: pointer to ${atomic}_t
6+ *
7+ * Atomically updates @v to (@v & ~@i) with ${desc_order} ordering.
8+ *
9+ * ${desc_noinstr}
10+ *
11+ * ${desc_return}
12+ */
13+EOF
scripts/atomic/kerneldoc/cmpxchg+14−0
@@ -0,0 +1,14 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic compare and exchange with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ * @old: ${int} value to compare with
6+ * @new: ${int} value to assign
7+ *
8+ * If (@v == @old), atomically updates @v to @new with ${desc_order} ordering.
9+ *
10+ * ${desc_noinstr}
11+ *
12+ * Return: The original value of @v.
13+ */
14+EOF
scripts/atomic/kerneldoc/dec+12−0
@@ -0,0 +1,12 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic decrement with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ *
6+ * Atomically updates @v to (@v - 1) with ${desc_order} ordering.
7+ *
8+ * ${desc_noinstr}
9+ *
10+ * ${desc_return}
11+ */
12+EOF
scripts/atomic/kerneldoc/dec_and_test+12−0
@@ -0,0 +1,12 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic decrement and test if zero with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ *
6+ * Atomically updates @v to (@v - 1) with ${desc_order} ordering.
7+ *
8+ * ${desc_noinstr}
9+ *
10+ * Return: @true if the resulting value of @v is zero, @false otherwise.
11+ */
12+EOF
scripts/atomic/kerneldoc/dec_if_positive+12−0
@@ -0,0 +1,12 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic decrement if positive with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ *
6+ * If (@v > 0), atomically updates @v to (@v - 1) with ${desc_order} ordering.
7+ *
8+ * ${desc_noinstr}
9+ *
10+ * Return: The old value of (@v - 1), regardless of whether @v was updated.
11+ */
12+EOF
scripts/atomic/kerneldoc/dec_unless_positive+12−0
@@ -0,0 +1,12 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic decrement unless positive with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ *
6+ * If (@v <= 0), atomically updates @v to (@v - 1) with ${desc_order} ordering.
7+ *
8+ * ${desc_noinstr}
9+ *
10+ * Return: @true if @v was updated, @false otherwise.
11+ */
12+EOF
scripts/atomic/kerneldoc/inc+12−0
@@ -0,0 +1,12 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic increment with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ *
6+ * Atomically updates @v to (@v + 1) with ${desc_order} ordering.
7+ *
8+ * ${desc_noinstr}
9+ *
10+ * ${desc_return}
11+ */
12+EOF
scripts/atomic/kerneldoc/inc_and_test+12−0
@@ -0,0 +1,12 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic increment and test if zero with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ *
6+ * Atomically updates @v to (@v + 1) with ${desc_order} ordering.
7+ *
8+ * ${desc_noinstr}
9+ *
10+ * Return: @true if the resulting value of @v is zero, @false otherwise.
11+ */
12+EOF
scripts/atomic/kerneldoc/inc_not_zero+12−0
@@ -0,0 +1,12 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic increment unless zero with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ *
6+ * If (@v != 0), atomically updates @v to (@v + 1) with ${desc_order} ordering.
7+ *
8+ * ${desc_noinstr}
9+ *
10+ * Return: @true if @v was updated, @false otherwise.
11+ */
12+EOF
scripts/atomic/kerneldoc/inc_unless_negative+12−0
@@ -0,0 +1,12 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic increment unless negative with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ *
6+ * If (@v >= 0), atomically updates @v to (@v + 1) with ${desc_order} ordering.
7+ *
8+ * ${desc_noinstr}
9+ *
10+ * Return: @true if @v was updated, @false otherwise.
11+ */
12+EOF
scripts/atomic/kerneldoc/or+13−0
@@ -0,0 +1,13 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic bitwise OR with ${desc_order} ordering
4+ * @i: ${int} value
5+ * @v: pointer to ${atomic}_t
6+ *
7+ * Atomically updates @v to (@v | @i) with ${desc_order} ordering.
8+ *
9+ * ${desc_noinstr}
10+ *
11+ * ${desc_return}
12+ */
13+EOF
scripts/atomic/kerneldoc/read+12−0
@@ -0,0 +1,12 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic load with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ *
6+ * Atomically loads the value of @v with ${desc_order} ordering.
7+ *
8+ * ${desc_noinstr}
9+ *
10+ * Return: The value loaded from @v.
11+ */
12+EOF
scripts/atomic/kerneldoc/set+13−0
@@ -0,0 +1,13 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic set with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ * @i: ${int} value to assign
6+ *
7+ * Atomically sets @v to @i with ${desc_order} ordering.
8+ *
9+ * ${desc_noinstr}
10+ *
11+ * Return: Nothing.
12+ */
13+EOF
scripts/atomic/kerneldoc/sub+13−0
@@ -0,0 +1,13 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic subtract with ${desc_order} ordering
4+ * @i: ${int} value to subtract
5+ * @v: pointer to ${atomic}_t
6+ *
7+ * Atomically updates @v to (@v - @i) with ${desc_order} ordering.
8+ *
9+ * ${desc_noinstr}
10+ *
11+ * ${desc_return}
12+ */
13+EOF
scripts/atomic/kerneldoc/sub_and_test+13−0
@@ -0,0 +1,13 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic subtract and test if zero with ${desc_order} ordering
4+ * @i: ${int} value to add
5+ * @v: pointer to ${atomic}_t
6+ *
7+ * Atomically updates @v to (@v - @i) with ${desc_order} ordering.
8+ *
9+ * ${desc_noinstr}
10+ *
11+ * Return: @true if the resulting value of @v is zero, @false otherwise.
12+ */
13+EOF
scripts/atomic/kerneldoc/try_cmpxchg+15−0
@@ -0,0 +1,15 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic compare and exchange with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ * @old: pointer to ${int} value to compare with
6+ * @new: ${int} value to assign
7+ *
8+ * If (@v == @old), atomically updates @v to @new with ${desc_order} ordering.
9+ * Otherwise, updates @old to the current value of @v.
10+ *
11+ * ${desc_noinstr}
12+ *
13+ * Return: @true if the exchange occured, @false otherwise.
14+ */
15+EOF
scripts/atomic/kerneldoc/xchg+13−0
@@ -0,0 +1,13 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic exchange with ${desc_order} ordering
4+ * @v: pointer to ${atomic}_t
5+ * @new: ${int} value to assign
6+ *
7+ * Atomically updates @v to @new with ${desc_order} ordering.
8+ *
9+ * ${desc_noinstr}
10+ *
11+ * Return: The original value of @v.
12+ */
13+EOF
scripts/atomic/kerneldoc/xor+13−0
@@ -0,0 +1,13 @@
1+cat <<EOF
2+/**
3+ * ${class}${atomicname}() - atomic bitwise XOR with ${desc_order} ordering
4+ * @i: ${int} value
5+ * @v: pointer to ${atomic}_t
6+ *
7+ * Atomically updates @v to (@v ^ @i) with ${desc_order} ordering.
8+ *
9+ * ${desc_noinstr}
10+ *
11+ * ${desc_return}
12+ */
13+EOF
scripts/kernel-doc+1−1
@@ -64,7 +64,7 @@ my $type_constant = '\b``([^\`]+)``\b'; · 63 unmodified lines
6464 my $type_constant2 = '\%([-_\w]+)';
6565 my $type_func = '(\w+)\(\)';
6666 my $type_param = '\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
67−my $type_param_ref = '([\!]?)\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
67+my $type_param_ref = '([\!~]?)\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
6868 my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params
6969 my $type_fp_param2 = '\@(\w+->\S+)\(\)'; # Special RST handling for structs with func ptr params
7070 my $type_env = '(\$\w+)';
scripts/min-tool-version.sh+5−1
@@ -17,7 +17,11 @@ binutils) · 16 unmodified lines
1717 echo 2.25.0
1818 ;;
1919 gcc)
20− echo 5.1.0
20+ if [ "$SRCARCH" = parisc ]; then
21+ echo 11.0.0
22+ else
23+ echo 5.1.0
24+ fi
2125 ;;
2226 llvm)
2327 if [ "$SRCARCH" = s390 ]; then