Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

locking/atomic: remove ARCH_ATOMIC remanants

Now that gen-atomic-fallback.sh is only used to generate the arch_*
fallbacks, we don't need to also generate the non-arch_* forms, and can
removethe infrastructure this needed.

There is no change to any of the generated headers as a result of this
patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210713105253.7615-3-mark.rutland@arm.com

authored by

Mark Rutland and committed by
Peter Zijlstra
f3e615b4 47401d94

+71 -91
+2 -2
scripts/atomic/fallbacks/acquire
··· 1 1 cat <<EOF 2 2 static __always_inline ${ret} 3 - ${arch}${atomic}_${pfx}${name}${sfx}_acquire(${params}) 3 + arch_${atomic}_${pfx}${name}${sfx}_acquire(${params}) 4 4 { 5 - ${ret} ret = ${arch}${atomic}_${pfx}${name}${sfx}_relaxed(${args}); 5 + ${ret} ret = arch_${atomic}_${pfx}${name}${sfx}_relaxed(${args}); 6 6 __atomic_acquire_fence(); 7 7 return ret; 8 8 }
+3 -3
scripts/atomic/fallbacks/add_negative
··· 1 1 cat <<EOF 2 2 /** 3 - * ${arch}${atomic}_add_negative - add and test if negative 3 + * arch_${atomic}_add_negative - add and test if negative 4 4 * @i: integer value to add 5 5 * @v: pointer of type ${atomic}_t 6 6 * ··· 9 9 * result is greater than or equal to zero. 10 10 */ 11 11 static __always_inline bool 12 - ${arch}${atomic}_add_negative(${int} i, ${atomic}_t *v) 12 + arch_${atomic}_add_negative(${int} i, ${atomic}_t *v) 13 13 { 14 - return ${arch}${atomic}_add_return(i, v) < 0; 14 + return arch_${atomic}_add_return(i, v) < 0; 15 15 } 16 16 EOF
+3 -3
scripts/atomic/fallbacks/add_unless
··· 1 1 cat << EOF 2 2 /** 3 - * ${arch}${atomic}_add_unless - add unless the number is already a given value 3 + * arch_${atomic}_add_unless - add unless the number is already a given value 4 4 * @v: pointer of type ${atomic}_t 5 5 * @a: the amount to add to v... 6 6 * @u: ...unless v is equal to u. ··· 9 9 * Returns true if the addition was done. 10 10 */ 11 11 static __always_inline bool 12 - ${arch}${atomic}_add_unless(${atomic}_t *v, ${int} a, ${int} u) 12 + arch_${atomic}_add_unless(${atomic}_t *v, ${int} a, ${int} u) 13 13 { 14 - return ${arch}${atomic}_fetch_add_unless(v, a, u) != u; 14 + return arch_${atomic}_fetch_add_unless(v, a, u) != u; 15 15 } 16 16 EOF
+2 -2
scripts/atomic/fallbacks/andnot
··· 1 1 cat <<EOF 2 2 static __always_inline ${ret} 3 - ${arch}${atomic}_${pfx}andnot${sfx}${order}(${int} i, ${atomic}_t *v) 3 + arch_${atomic}_${pfx}andnot${sfx}${order}(${int} i, ${atomic}_t *v) 4 4 { 5 - ${retstmt}${arch}${atomic}_${pfx}and${sfx}${order}(~i, v); 5 + ${retstmt}arch_${atomic}_${pfx}and${sfx}${order}(~i, v); 6 6 } 7 7 EOF
+2 -2
scripts/atomic/fallbacks/dec
··· 1 1 cat <<EOF 2 2 static __always_inline ${ret} 3 - ${arch}${atomic}_${pfx}dec${sfx}${order}(${atomic}_t *v) 3 + arch_${atomic}_${pfx}dec${sfx}${order}(${atomic}_t *v) 4 4 { 5 - ${retstmt}${arch}${atomic}_${pfx}sub${sfx}${order}(1, v); 5 + ${retstmt}arch_${atomic}_${pfx}sub${sfx}${order}(1, v); 6 6 } 7 7 EOF
+3 -3
scripts/atomic/fallbacks/dec_and_test
··· 1 1 cat <<EOF 2 2 /** 3 - * ${arch}${atomic}_dec_and_test - decrement and test 3 + * arch_${atomic}_dec_and_test - decrement and test 4 4 * @v: pointer of type ${atomic}_t 5 5 * 6 6 * Atomically decrements @v by 1 and ··· 8 8 * cases. 9 9 */ 10 10 static __always_inline bool 11 - ${arch}${atomic}_dec_and_test(${atomic}_t *v) 11 + arch_${atomic}_dec_and_test(${atomic}_t *v) 12 12 { 13 - return ${arch}${atomic}_dec_return(v) == 0; 13 + return arch_${atomic}_dec_return(v) == 0; 14 14 } 15 15 EOF
+3 -3
scripts/atomic/fallbacks/dec_if_positive
··· 1 1 cat <<EOF 2 2 static __always_inline ${ret} 3 - ${arch}${atomic}_dec_if_positive(${atomic}_t *v) 3 + arch_${atomic}_dec_if_positive(${atomic}_t *v) 4 4 { 5 - ${int} dec, c = ${arch}${atomic}_read(v); 5 + ${int} dec, c = arch_${atomic}_read(v); 6 6 7 7 do { 8 8 dec = c - 1; 9 9 if (unlikely(dec < 0)) 10 10 break; 11 - } while (!${arch}${atomic}_try_cmpxchg(v, &c, dec)); 11 + } while (!arch_${atomic}_try_cmpxchg(v, &c, dec)); 12 12 13 13 return dec; 14 14 }
+3 -3
scripts/atomic/fallbacks/dec_unless_positive
··· 1 1 cat <<EOF 2 2 static __always_inline bool 3 - ${arch}${atomic}_dec_unless_positive(${atomic}_t *v) 3 + arch_${atomic}_dec_unless_positive(${atomic}_t *v) 4 4 { 5 - ${int} c = ${arch}${atomic}_read(v); 5 + ${int} c = arch_${atomic}_read(v); 6 6 7 7 do { 8 8 if (unlikely(c > 0)) 9 9 return false; 10 - } while (!${arch}${atomic}_try_cmpxchg(v, &c, c - 1)); 10 + } while (!arch_${atomic}_try_cmpxchg(v, &c, c - 1)); 11 11 12 12 return true; 13 13 }
+2 -2
scripts/atomic/fallbacks/fence
··· 1 1 cat <<EOF 2 2 static __always_inline ${ret} 3 - ${arch}${atomic}_${pfx}${name}${sfx}(${params}) 3 + arch_${atomic}_${pfx}${name}${sfx}(${params}) 4 4 { 5 5 ${ret} ret; 6 6 __atomic_pre_full_fence(); 7 - ret = ${arch}${atomic}_${pfx}${name}${sfx}_relaxed(${args}); 7 + ret = arch_${atomic}_${pfx}${name}${sfx}_relaxed(${args}); 8 8 __atomic_post_full_fence(); 9 9 return ret; 10 10 }
+4 -4
scripts/atomic/fallbacks/fetch_add_unless
··· 1 1 cat << EOF 2 2 /** 3 - * ${arch}${atomic}_fetch_add_unless - add unless the number is already a given value 3 + * arch_${atomic}_fetch_add_unless - add unless the number is already a given value 4 4 * @v: pointer of type ${atomic}_t 5 5 * @a: the amount to add to v... 6 6 * @u: ...unless v is equal to u. ··· 9 9 * Returns original value of @v 10 10 */ 11 11 static __always_inline ${int} 12 - ${arch}${atomic}_fetch_add_unless(${atomic}_t *v, ${int} a, ${int} u) 12 + arch_${atomic}_fetch_add_unless(${atomic}_t *v, ${int} a, ${int} u) 13 13 { 14 - ${int} c = ${arch}${atomic}_read(v); 14 + ${int} c = arch_${atomic}_read(v); 15 15 16 16 do { 17 17 if (unlikely(c == u)) 18 18 break; 19 - } while (!${arch}${atomic}_try_cmpxchg(v, &c, c + a)); 19 + } while (!arch_${atomic}_try_cmpxchg(v, &c, c + a)); 20 20 21 21 return c; 22 22 }
+2 -2
scripts/atomic/fallbacks/inc
··· 1 1 cat <<EOF 2 2 static __always_inline ${ret} 3 - ${arch}${atomic}_${pfx}inc${sfx}${order}(${atomic}_t *v) 3 + arch_${atomic}_${pfx}inc${sfx}${order}(${atomic}_t *v) 4 4 { 5 - ${retstmt}${arch}${atomic}_${pfx}add${sfx}${order}(1, v); 5 + ${retstmt}arch_${atomic}_${pfx}add${sfx}${order}(1, v); 6 6 } 7 7 EOF
+3 -3
scripts/atomic/fallbacks/inc_and_test
··· 1 1 cat <<EOF 2 2 /** 3 - * ${arch}${atomic}_inc_and_test - increment and test 3 + * arch_${atomic}_inc_and_test - increment and test 4 4 * @v: pointer of type ${atomic}_t 5 5 * 6 6 * Atomically increments @v by 1 ··· 8 8 * other cases. 9 9 */ 10 10 static __always_inline bool 11 - ${arch}${atomic}_inc_and_test(${atomic}_t *v) 11 + arch_${atomic}_inc_and_test(${atomic}_t *v) 12 12 { 13 - return ${arch}${atomic}_inc_return(v) == 0; 13 + return arch_${atomic}_inc_return(v) == 0; 14 14 } 15 15 EOF
+3 -3
scripts/atomic/fallbacks/inc_not_zero
··· 1 1 cat <<EOF 2 2 /** 3 - * ${arch}${atomic}_inc_not_zero - increment unless the number is zero 3 + * arch_${atomic}_inc_not_zero - increment unless the number is zero 4 4 * @v: pointer of type ${atomic}_t 5 5 * 6 6 * Atomically increments @v by 1, if @v is non-zero. 7 7 * Returns true if the increment was done. 8 8 */ 9 9 static __always_inline bool 10 - ${arch}${atomic}_inc_not_zero(${atomic}_t *v) 10 + arch_${atomic}_inc_not_zero(${atomic}_t *v) 11 11 { 12 - return ${arch}${atomic}_add_unless(v, 1, 0); 12 + return arch_${atomic}_add_unless(v, 1, 0); 13 13 } 14 14 EOF
+3 -3
scripts/atomic/fallbacks/inc_unless_negative
··· 1 1 cat <<EOF 2 2 static __always_inline bool 3 - ${arch}${atomic}_inc_unless_negative(${atomic}_t *v) 3 + arch_${atomic}_inc_unless_negative(${atomic}_t *v) 4 4 { 5 - ${int} c = ${arch}${atomic}_read(v); 5 + ${int} c = arch_${atomic}_read(v); 6 6 7 7 do { 8 8 if (unlikely(c < 0)) 9 9 return false; 10 - } while (!${arch}${atomic}_try_cmpxchg(v, &c, c + 1)); 10 + } while (!arch_${atomic}_try_cmpxchg(v, &c, c + 1)); 11 11 12 12 return true; 13 13 }
+1 -1
scripts/atomic/fallbacks/read_acquire
··· 1 1 cat <<EOF 2 2 static __always_inline ${ret} 3 - ${arch}${atomic}_read_acquire(const ${atomic}_t *v) 3 + arch_${atomic}_read_acquire(const ${atomic}_t *v) 4 4 { 5 5 return smp_load_acquire(&(v)->counter); 6 6 }
+2 -2
scripts/atomic/fallbacks/release
··· 1 1 cat <<EOF 2 2 static __always_inline ${ret} 3 - ${arch}${atomic}_${pfx}${name}${sfx}_release(${params}) 3 + arch_${atomic}_${pfx}${name}${sfx}_release(${params}) 4 4 { 5 5 __atomic_release_fence(); 6 - ${retstmt}${arch}${atomic}_${pfx}${name}${sfx}_relaxed(${args}); 6 + ${retstmt}arch_${atomic}_${pfx}${name}${sfx}_relaxed(${args}); 7 7 } 8 8 EOF
+1 -1
scripts/atomic/fallbacks/set_release
··· 1 1 cat <<EOF 2 2 static __always_inline void 3 - ${arch}${atomic}_set_release(${atomic}_t *v, ${int} i) 3 + arch_${atomic}_set_release(${atomic}_t *v, ${int} i) 4 4 { 5 5 smp_store_release(&(v)->counter, i); 6 6 }
+3 -3
scripts/atomic/fallbacks/sub_and_test
··· 1 1 cat <<EOF 2 2 /** 3 - * ${arch}${atomic}_sub_and_test - subtract value from variable and test result 3 + * arch_${atomic}_sub_and_test - subtract value from variable and test result 4 4 * @i: integer value to subtract 5 5 * @v: pointer of type ${atomic}_t 6 6 * ··· 9 9 * other cases. 10 10 */ 11 11 static __always_inline bool 12 - ${arch}${atomic}_sub_and_test(${int} i, ${atomic}_t *v) 12 + arch_${atomic}_sub_and_test(${int} i, ${atomic}_t *v) 13 13 { 14 - return ${arch}${atomic}_sub_return(i, v) == 0; 14 + return arch_${atomic}_sub_return(i, v) == 0; 15 15 } 16 16 EOF
+2 -2
scripts/atomic/fallbacks/try_cmpxchg
··· 1 1 cat <<EOF 2 2 static __always_inline bool 3 - ${arch}${atomic}_try_cmpxchg${order}(${atomic}_t *v, ${int} *old, ${int} new) 3 + arch_${atomic}_try_cmpxchg${order}(${atomic}_t *v, ${int} *old, ${int} new) 4 4 { 5 5 ${int} r, o = *old; 6 - r = ${arch}${atomic}_cmpxchg${order}(v, o, new); 6 + r = arch_${atomic}_cmpxchg${order}(v, o, new); 7 7 if (unlikely(r != o)) 8 8 *old = r; 9 9 return likely(r == o);
+23 -43
scripts/atomic/gen-atomic-fallback.sh
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 4 ATOMICDIR=$(dirname $0) 5 - ARCH=$2 6 5 7 6 . ${ATOMICDIR}/atomic-tbl.sh 8 7 9 - #gen_template_fallback(template, meta, pfx, name, sfx, order, arch, atomic, int, args...) 8 + #gen_template_fallback(template, meta, pfx, name, sfx, order, atomic, int, args...) 10 9 gen_template_fallback() 11 10 { 12 11 local template="$1"; shift ··· 14 15 local name="$1"; shift 15 16 local sfx="$1"; shift 16 17 local order="$1"; shift 17 - local arch="$1"; shift 18 18 local atomic="$1"; shift 19 19 local int="$1"; shift 20 20 21 - local atomicname="${arch}${atomic}_${pfx}${name}${sfx}${order}" 21 + local atomicname="arch_${atomic}_${pfx}${name}${sfx}${order}" 22 22 23 23 local ret="$(gen_ret_type "${meta}" "${int}")" 24 24 local retstmt="$(gen_ret_stmt "${meta}")" ··· 32 34 fi 33 35 } 34 36 35 - #gen_proto_fallback(meta, pfx, name, sfx, order, arch, atomic, int, args...) 37 + #gen_proto_fallback(meta, pfx, name, sfx, order, atomic, int, args...) 36 38 gen_proto_fallback() 37 39 { 38 40 local meta="$1"; shift ··· 63 65 local name="$1"; shift 64 66 local sfx="$1"; shift 65 67 local order="$1"; shift 66 - local arch="$1" 67 - local atomic="$2" 68 + local atomic="$1" 68 69 69 - local basename="${arch}${atomic}_${pfx}${name}${sfx}" 70 + local basename="arch_${atomic}_${pfx}${name}${sfx}" 70 71 71 - printf "#define arch_${basename}${order} ${basename}${order}\n" 72 + printf "#define ${basename}${order} ${basename}${order}\n" 72 73 } 73 74 74 - #gen_proto_order_variants(meta, pfx, name, sfx, arch, atomic, int, args...) 75 + #gen_proto_order_variants(meta, pfx, name, sfx, atomic, int, args...) 75 76 gen_proto_order_variants() 76 77 { 77 78 local meta="$1"; shift 78 79 local pfx="$1"; shift 79 80 local name="$1"; shift 80 81 local sfx="$1"; shift 81 - local arch="$1" 82 - local atomic="$2" 82 + local atomic="$1" 83 83 84 - local basename="${arch}${atomic}_${pfx}${name}${sfx}" 84 + local basename="arch_${atomic}_${pfx}${name}${sfx}" 85 85 86 86 local template="$(find_fallback_template "${pfx}" "${name}" "${sfx}" "${order}")" 87 - 88 - if [ -z "$arch" ]; then 89 - gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "" "$@" 90 - 91 - if meta_has_acquire "${meta}"; then 92 - gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "_acquire" "$@" 93 - fi 94 - if meta_has_release "${meta}"; then 95 - gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "_release" "$@" 96 - fi 97 - if meta_has_relaxed "${meta}"; then 98 - gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "_relaxed" "$@" 99 - fi 100 - 101 - echo "" 102 - fi 103 87 104 88 # If we don't have relaxed atomics, then we don't bother with ordering fallbacks 105 89 # read_acquire and set_release need to be templated, though ··· 167 187 local order="$1"; shift; 168 188 169 189 cat <<EOF 170 - #ifndef ${ARCH}try_cmpxchg${order} 171 - #define ${ARCH}try_cmpxchg${order}(_ptr, _oldp, _new) \\ 190 + #ifndef arch_try_cmpxchg${order} 191 + #define arch_try_cmpxchg${order}(_ptr, _oldp, _new) \\ 172 192 ({ \\ 173 193 typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \\ 174 - ___r = ${ARCH}cmpxchg${order}((_ptr), ___o, (_new)); \\ 194 + ___r = arch_cmpxchg${order}((_ptr), ___o, (_new)); \\ 175 195 if (unlikely(___r != ___o)) \\ 176 196 *___op = ___r; \\ 177 197 likely(___r == ___o); \\ 178 198 }) 179 - #endif /* ${ARCH}try_cmpxchg${order} */ 199 + #endif /* arch_try_cmpxchg${order} */ 180 200 181 201 EOF 182 202 } 183 203 184 204 gen_try_cmpxchg_fallbacks() 185 205 { 186 - printf "#ifndef ${ARCH}try_cmpxchg_relaxed\n" 187 - printf "#ifdef ${ARCH}try_cmpxchg\n" 206 + printf "#ifndef arch_try_cmpxchg_relaxed\n" 207 + printf "#ifdef arch_try_cmpxchg\n" 188 208 189 - gen_basic_fallbacks "${ARCH}try_cmpxchg" 209 + gen_basic_fallbacks "arch_try_cmpxchg" 190 210 191 - printf "#endif /* ${ARCH}try_cmpxchg */\n\n" 211 + printf "#endif /* arch_try_cmpxchg */\n\n" 192 212 193 213 for order in "" "_acquire" "_release" "_relaxed"; do 194 214 gen_try_cmpxchg_fallback "${order}" 195 215 done 196 216 197 - printf "#else /* ${ARCH}try_cmpxchg_relaxed */\n" 217 + printf "#else /* arch_try_cmpxchg_relaxed */\n" 198 218 199 - gen_order_fallbacks "${ARCH}try_cmpxchg" 219 + gen_order_fallbacks "arch_try_cmpxchg" 200 220 201 - printf "#endif /* ${ARCH}try_cmpxchg_relaxed */\n\n" 221 + printf "#endif /* arch_try_cmpxchg_relaxed */\n\n" 202 222 } 203 223 204 224 cat << EOF ··· 214 234 215 235 EOF 216 236 217 - for xchg in "${ARCH}xchg" "${ARCH}cmpxchg" "${ARCH}cmpxchg64"; do 237 + for xchg in "arch_xchg" "arch_cmpxchg" "arch_cmpxchg64"; do 218 238 gen_xchg_fallbacks "${xchg}" 219 239 done 220 240 221 241 gen_try_cmpxchg_fallbacks 222 242 223 243 grep '^[a-z]' "$1" | while read name meta args; do 224 - gen_proto "${meta}" "${name}" "${ARCH}" "atomic" "int" ${args} 244 + gen_proto "${meta}" "${name}" "atomic" "int" ${args} 225 245 done 226 246 227 247 cat <<EOF ··· 232 252 EOF 233 253 234 254 grep '^[a-z]' "$1" | while read name meta args; do 235 - gen_proto "${meta}" "${name}" "${ARCH}" "atomic64" "s64" ${args} 255 + gen_proto "${meta}" "${name}" "atomic64" "s64" ${args} 236 256 done 237 257 238 258 cat <<EOF
+1 -1
scripts/atomic/gen-atomics.sh
··· 10 10 cat <<EOF | 11 11 gen-atomic-instrumented.sh asm-generic/atomic-instrumented.h 12 12 gen-atomic-long.sh asm-generic/atomic-long.h 13 - gen-atomic-fallback.sh linux/atomic-arch-fallback.h arch_ 13 + gen-atomic-fallback.sh linux/atomic-arch-fallback.h 14 14 EOF 15 15 while read script header args; do 16 16 /bin/sh ${ATOMICDIR}/${script} ${ATOMICTBL} ${args} > ${LINUXDIR}/include/${header}