Pull atomics rework from Thomas Gleixner: "Peter Zijlstras rework of atomics and fallbacks. This solves two problems: 1) Compilers uninline small atomic_* static inline functions which can expose them to instrumentation. 2) The instrumentation of atomic primitives was done at the architecture level while composites or fallbacks were provided at the generic level. As a result there are no uninstrumented variants of the fallbacks. Both issues were in the way of fully isolating fragile entry code pathes and especially the text poke int3 handler which is prone to an endless recursion problem when anything in that code path is about to be instrumented. This was always a problem, but got elevated due to the new batch mode updates of tracing. The solution is to mark the functions __always_inline and to flip the fallback and instrumentation so the non-instrumented variants are at the architecture level and the instrumentation is done in generic code. The latter introduces another fallback variant which will go away once all architectures have been moved over to arch_atomic_*" * tag 'locking-urgent-2020-06-11' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: locking/atomics: Flip fallbacks and instrumentation asm-generic/atomic: Use __always_inline for fallback wrappers
Showing the changes to scripts (21 of 28 files). Show all
Unified · Split
| @@ -1,8 +1,8 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline ${ret} | 2 | static __always_inline ${ret} |
| 3 | ${atomic}_${pfx}${name}${sfx}_acquire(${params}) | 3 | ${arch}${atomic}_${pfx}${name}${sfx}_acquire(${params}) |
| 4 | { | 4 | { |
| 5 | ${ret} ret = ${atomic}_${pfx}${name}${sfx}_relaxed(${args}); | 5 | ${ret} ret = ${arch}${atomic}_${pfx}${name}${sfx}_relaxed(${args}); |
| 6 | __atomic_acquire_fence(); | 6 | __atomic_acquire_fence(); |
| 7 | return ret; | 7 | return ret; |
| 8 | } | 8 | } |
| @@ -1,6 +1,6 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | /** | 2 | /** |
| 3 | * ${atomic}_add_negative - add and test if negative | 3 | * ${arch}${atomic}_add_negative - add and test if negative |
| 4 | * @i: integer value to add | 4 | * @i: integer value to add |
| 5 | * @v: pointer of type ${atomic}_t | 5 | * @v: pointer of type ${atomic}_t |
| 6 | * | 6 | * |
| @@ -8,9 +8,9 @@ cat <<EOF · 1 unmodified line | |||
| 8 | * if the result is negative, or false when | 8 | * if the result is negative, or false when |
| 9 | * result is greater than or equal to zero. | 9 | * result is greater than or equal to zero. |
| 10 | */ | 10 | */ |
| 11 | static inline bool | 11 | static __always_inline bool |
| 12 | ${atomic}_add_negative(${int} i, ${atomic}_t *v) | 12 | ${arch}${atomic}_add_negative(${int} i, ${atomic}_t *v) |
| 13 | { | 13 | { |
| 14 | return ${atomic}_add_return(i, v) < 0; | 14 | return ${arch}${atomic}_add_return(i, v) < 0; |
| 15 | } | 15 | } |
| 16 | EOF | 16 | EOF |
| @@ -1,6 +1,6 @@ | |||
| 1 | cat << EOF | 1 | cat << EOF |
| 2 | /** | 2 | /** |
| 3 | * ${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 | * @v: pointer of type ${atomic}_t | 4 | * @v: pointer of type ${atomic}_t |
| 5 | * @a: the amount to add to v... | 5 | * @a: the amount to add to v... |
| 6 | * @u: ...unless v is equal to u. | 6 | * @u: ...unless v is equal to u. |
| @@ -8,9 +8,9 @@ cat << EOF · 1 unmodified line | |||
| 8 | * Atomically adds @a to @v, if @v was not already @u. | 8 | * Atomically adds @a to @v, if @v was not already @u. |
| 9 | * Returns true if the addition was done. | 9 | * Returns true if the addition was done. |
| 10 | */ | 10 | */ |
| 11 | static inline bool | 11 | static __always_inline bool |
| 12 | ${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 ${atomic}_fetch_add_unless(v, a, u) != u; | 14 | return ${arch}${atomic}_fetch_add_unless(v, a, u) != u; |
| 15 | } | 15 | } |
| 16 | EOF | 16 | EOF |
| @@ -1,7 +1,7 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline ${ret} | 2 | static __always_inline ${ret} |
| 3 | ${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}${atomic}_${pfx}and${sfx}${order}(~i, v); | 5 | ${retstmt}${arch}${atomic}_${pfx}and${sfx}${order}(~i, v); |
| 6 | } | 6 | } |
| 7 | EOF | 7 | EOF |
| @@ -1,7 +1,7 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline ${ret} | 2 | static __always_inline ${ret} |
| 3 | ${atomic}_${pfx}dec${sfx}${order}(${atomic}_t *v) | 3 | ${arch}${atomic}_${pfx}dec${sfx}${order}(${atomic}_t *v) |
| 4 | { | 4 | { |
| 5 | ${retstmt}${atomic}_${pfx}sub${sfx}${order}(1, v); | 5 | ${retstmt}${arch}${atomic}_${pfx}sub${sfx}${order}(1, v); |
| 6 | } | 6 | } |
| 7 | EOF | 7 | EOF |
| @@ -1,15 +1,15 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | /** | 2 | /** |
| 3 | * ${atomic}_dec_and_test - decrement and test | 3 | * ${arch}${atomic}_dec_and_test - decrement and test |
| 4 | * @v: pointer of type ${atomic}_t | 4 | * @v: pointer of type ${atomic}_t |
| 5 | * | 5 | * |
| 6 | * Atomically decrements @v by 1 and | 6 | * Atomically decrements @v by 1 and |
| 7 | * returns true if the result is 0, or false for all other | 7 | * returns true if the result is 0, or false for all other |
| 8 | * cases. | 8 | * cases. |
| 9 | */ | 9 | */ |
| 10 | static inline bool | 10 | static __always_inline bool |
| 11 | ${atomic}_dec_and_test(${atomic}_t *v) | 11 | ${arch}${atomic}_dec_and_test(${atomic}_t *v) |
| 12 | { | 12 | { |
| 13 | return ${atomic}_dec_return(v) == 0; | 13 | return ${arch}${atomic}_dec_return(v) == 0; |
| 14 | } | 14 | } |
| 15 | EOF | 15 | EOF |
| @@ -1,14 +1,14 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline ${ret} | 2 | static __always_inline ${ret} |
| 3 | ${atomic}_dec_if_positive(${atomic}_t *v) | 3 | ${arch}${atomic}_dec_if_positive(${atomic}_t *v) |
| 4 | { | 4 | { |
| 5 | ${int} dec, c = ${atomic}_read(v); | 5 | ${int} dec, c = ${arch}${atomic}_read(v); |
| 6 | 6 | ||
| 7 | do { | 7 | do { |
| 8 | dec = c - 1; | 8 | dec = c - 1; |
| 9 | if (unlikely(dec < 0)) | 9 | if (unlikely(dec < 0)) |
| 10 | break; | 10 | break; |
| 11 | } while (!${atomic}_try_cmpxchg(v, &c, dec)); | 11 | } while (!${arch}${atomic}_try_cmpxchg(v, &c, dec)); |
| 12 | 12 | ||
| 13 | return dec; | 13 | return dec; |
| 14 | } | 14 | } |
| @@ -1,13 +1,13 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline bool | 2 | static __always_inline bool |
| 3 | ${atomic}_dec_unless_positive(${atomic}_t *v) | 3 | ${arch}${atomic}_dec_unless_positive(${atomic}_t *v) |
| 4 | { | 4 | { |
| 5 | ${int} c = ${atomic}_read(v); | 5 | ${int} c = ${arch}${atomic}_read(v); |
| 6 | 6 | ||
| 7 | do { | 7 | do { |
| 8 | if (unlikely(c > 0)) | 8 | if (unlikely(c > 0)) |
| 9 | return false; | 9 | return false; |
| 10 | } while (!${atomic}_try_cmpxchg(v, &c, c - 1)); | 10 | } while (!${arch}${atomic}_try_cmpxchg(v, &c, c - 1)); |
| 11 | 11 | ||
| 12 | return true; | 12 | return true; |
| 13 | } | 13 | } |
| @@ -1,10 +1,10 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline ${ret} | 2 | static __always_inline ${ret} |
| 3 | ${atomic}_${pfx}${name}${sfx}(${params}) | 3 | ${arch}${atomic}_${pfx}${name}${sfx}(${params}) |
| 4 | { | 4 | { |
| 5 | ${ret} ret; | 5 | ${ret} ret; |
| 6 | __atomic_pre_full_fence(); | 6 | __atomic_pre_full_fence(); |
| 7 | ret = ${atomic}_${pfx}${name}${sfx}_relaxed(${args}); | 7 | ret = ${arch}${atomic}_${pfx}${name}${sfx}_relaxed(${args}); |
| 8 | __atomic_post_full_fence(); | 8 | __atomic_post_full_fence(); |
| 9 | return ret; | 9 | return ret; |
| 10 | } | 10 | } |
| @@ -1,6 +1,6 @@ | |||
| 1 | cat << EOF | 1 | cat << EOF |
| 2 | /** | 2 | /** |
| 3 | * ${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 | * @v: pointer of type ${atomic}_t | 4 | * @v: pointer of type ${atomic}_t |
| 5 | * @a: the amount to add to v... | 5 | * @a: the amount to add to v... |
| 6 | * @u: ...unless v is equal to u. | 6 | * @u: ...unless v is equal to u. |
| @@ -8,15 +8,15 @@ cat << EOF · 1 unmodified line | |||
| 8 | * Atomically adds @a to @v, so long as @v was not already @u. | 8 | * Atomically adds @a to @v, so long as @v was not already @u. |
| 9 | * Returns original value of @v | 9 | * Returns original value of @v |
| 10 | */ | 10 | */ |
| 11 | static inline ${int} | 11 | static __always_inline ${int} |
| 12 | ${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 = ${atomic}_read(v); | 14 | ${int} c = ${arch}${atomic}_read(v); |
| 15 | 15 | ||
| 16 | do { | 16 | do { |
| 17 | if (unlikely(c == u)) | 17 | if (unlikely(c == u)) |
| 18 | break; | 18 | break; |
| 19 | } while (!${atomic}_try_cmpxchg(v, &c, c + a)); | 19 | } while (!${arch}${atomic}_try_cmpxchg(v, &c, c + a)); |
| 20 | 20 | ||
| 21 | return c; | 21 | return c; |
| 22 | } | 22 | } |
| @@ -1,7 +1,7 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline ${ret} | 2 | static __always_inline ${ret} |
| 3 | ${atomic}_${pfx}inc${sfx}${order}(${atomic}_t *v) | 3 | ${arch}${atomic}_${pfx}inc${sfx}${order}(${atomic}_t *v) |
| 4 | { | 4 | { |
| 5 | ${retstmt}${atomic}_${pfx}add${sfx}${order}(1, v); | 5 | ${retstmt}${arch}${atomic}_${pfx}add${sfx}${order}(1, v); |
| 6 | } | 6 | } |
| 7 | EOF | 7 | EOF |
| @@ -1,15 +1,15 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | /** | 2 | /** |
| 3 | * ${atomic}_inc_and_test - increment and test | 3 | * ${arch}${atomic}_inc_and_test - increment and test |
| 4 | * @v: pointer of type ${atomic}_t | 4 | * @v: pointer of type ${atomic}_t |
| 5 | * | 5 | * |
| 6 | * Atomically increments @v by 1 | 6 | * Atomically increments @v by 1 |
| 7 | * and returns true if the result is zero, or false for all | 7 | * and returns true if the result is zero, or false for all |
| 8 | * other cases. | 8 | * other cases. |
| 9 | */ | 9 | */ |
| 10 | static inline bool | 10 | static __always_inline bool |
| 11 | ${atomic}_inc_and_test(${atomic}_t *v) | 11 | ${arch}${atomic}_inc_and_test(${atomic}_t *v) |
| 12 | { | 12 | { |
| 13 | return ${atomic}_inc_return(v) == 0; | 13 | return ${arch}${atomic}_inc_return(v) == 0; |
| 14 | } | 14 | } |
| 15 | EOF | 15 | EOF |
| @@ -1,14 +1,14 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | /** | 2 | /** |
| 3 | * ${atomic}_inc_not_zero - increment unless the number is zero | 3 | * ${arch}${atomic}_inc_not_zero - increment unless the number is zero |
| 4 | * @v: pointer of type ${atomic}_t | 4 | * @v: pointer of type ${atomic}_t |
| 5 | * | 5 | * |
| 6 | * Atomically increments @v by 1, if @v is non-zero. | 6 | * Atomically increments @v by 1, if @v is non-zero. |
| 7 | * Returns true if the increment was done. | 7 | * Returns true if the increment was done. |
| 8 | */ | 8 | */ |
| 9 | static inline bool | 9 | static __always_inline bool |
| 10 | ${atomic}_inc_not_zero(${atomic}_t *v) | 10 | ${arch}${atomic}_inc_not_zero(${atomic}_t *v) |
| 11 | { | 11 | { |
| 12 | return ${atomic}_add_unless(v, 1, 0); | 12 | return ${arch}${atomic}_add_unless(v, 1, 0); |
| 13 | } | 13 | } |
| 14 | EOF | 14 | EOF |
| @@ -1,13 +1,13 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline bool | 2 | static __always_inline bool |
| 3 | ${atomic}_inc_unless_negative(${atomic}_t *v) | 3 | ${arch}${atomic}_inc_unless_negative(${atomic}_t *v) |
| 4 | { | 4 | { |
| 5 | ${int} c = ${atomic}_read(v); | 5 | ${int} c = ${arch}${atomic}_read(v); |
| 6 | 6 | ||
| 7 | do { | 7 | do { |
| 8 | if (unlikely(c < 0)) | 8 | if (unlikely(c < 0)) |
| 9 | return false; | 9 | return false; |
| 10 | } while (!${atomic}_try_cmpxchg(v, &c, c + 1)); | 10 | } while (!${arch}${atomic}_try_cmpxchg(v, &c, c + 1)); |
| 11 | 11 | ||
| 12 | return true; | 12 | return true; |
| 13 | } | 13 | } |
| @@ -1,6 +1,6 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline ${ret} | 2 | static __always_inline ${ret} |
| 3 | ${atomic}_read_acquire(const ${atomic}_t *v) | 3 | ${arch}${atomic}_read_acquire(const ${atomic}_t *v) |
| 4 | { | 4 | { |
| 5 | return smp_load_acquire(&(v)->counter); | 5 | return smp_load_acquire(&(v)->counter); |
| 6 | } | 6 | } |
| @@ -1,8 +1,8 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline ${ret} | 2 | static __always_inline ${ret} |
| 3 | ${atomic}_${pfx}${name}${sfx}_release(${params}) | 3 | ${arch}${atomic}_${pfx}${name}${sfx}_release(${params}) |
| 4 | { | 4 | { |
| 5 | __atomic_release_fence(); | 5 | __atomic_release_fence(); |
| 6 | ${retstmt}${atomic}_${pfx}${name}${sfx}_relaxed(${args}); | 6 | ${retstmt}${arch}${atomic}_${pfx}${name}${sfx}_relaxed(${args}); |
| 7 | } | 7 | } |
| 8 | EOF | 8 | EOF |
| @@ -1,6 +1,6 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline void | 2 | static __always_inline void |
| 3 | ${atomic}_set_release(${atomic}_t *v, ${int} i) | 3 | ${arch}${atomic}_set_release(${atomic}_t *v, ${int} i) |
| 4 | { | 4 | { |
| 5 | smp_store_release(&(v)->counter, i); | 5 | smp_store_release(&(v)->counter, i); |
| 6 | } | 6 | } |
| @@ -1,6 +1,6 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | /** | 2 | /** |
| 3 | * ${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 | * @i: integer value to subtract | 4 | * @i: integer value to subtract |
| 5 | * @v: pointer of type ${atomic}_t | 5 | * @v: pointer of type ${atomic}_t |
| 6 | * | 6 | * |
| @@ -8,9 +8,9 @@ cat <<EOF · 1 unmodified line | |||
| 8 | * true if the result is zero, or false for all | 8 | * true if the result is zero, or false for all |
| 9 | * other cases. | 9 | * other cases. |
| 10 | */ | 10 | */ |
| 11 | static inline bool | 11 | static __always_inline bool |
| 12 | ${atomic}_sub_and_test(${int} i, ${atomic}_t *v) | 12 | ${arch}${atomic}_sub_and_test(${int} i, ${atomic}_t *v) |
| 13 | { | 13 | { |
| 14 | return ${atomic}_sub_return(i, v) == 0; | 14 | return ${arch}${atomic}_sub_return(i, v) == 0; |
| 15 | } | 15 | } |
| 16 | EOF | 16 | EOF |
| @@ -1,9 +1,9 @@ | |||
| 1 | cat <<EOF | 1 | cat <<EOF |
| 2 | static inline bool | 2 | static __always_inline bool |
| 3 | ${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 | ${int} r, o = *old; | 5 | ${int} r, o = *old; |
| 6 | r = ${atomic}_cmpxchg${order}(v, o, new); | 6 | r = ${arch}${atomic}_cmpxchg${order}(v, o, new); |
| 7 | if (unlikely(r != o)) | 7 | if (unlikely(r != o)) |
| 8 | *old = r; | 8 | *old = r; |
| 9 | return likely(r == o); | 9 | return likely(r == o); |
| @@ -2,10 +2,11 @@ · 1 unmodified line | |||
| 2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | 3 | ||
| 4 | ATOMICDIR=$(dirname $0) | 4 | ATOMICDIR=$(dirname $0) |
| 5 | ARCH=$2 | ||
| 5 | 6 | ||
| 6 | . ${ATOMICDIR}/atomic-tbl.sh | 7 | . ${ATOMICDIR}/atomic-tbl.sh |
| 7 | 8 | ||
| 8 | #gen_template_fallback(template, meta, pfx, name, sfx, order, atomic, int, args...) | 9 | #gen_template_fallback(template, meta, pfx, name, sfx, order, arch, atomic, int, args...) |
| 9 | gen_template_fallback() | 10 | gen_template_fallback() |
| 10 | { | 11 | { |
| 11 | local template="$1"; shift | 12 | local template="$1"; shift |
| @@ -14,10 +15,11 @@ gen_template_fallback() · 2 unmodified lines | |||
| 14 | local name="$1"; shift | 15 | local name="$1"; shift |
| 15 | local sfx="$1"; shift | 16 | local sfx="$1"; shift |
| 16 | local order="$1"; shift | 17 | local order="$1"; shift |
| 18 | local arch="$1"; shift | ||
| 17 | local atomic="$1"; shift | 19 | local atomic="$1"; shift |
| 18 | local int="$1"; shift | 20 | local int="$1"; shift |
| 19 | 21 | ||
| 20 | local atomicname="${atomic}_${pfx}${name}${sfx}${order}" | 22 | local atomicname="${arch}${atomic}_${pfx}${name}${sfx}${order}" |
| 21 | 23 | ||
| 22 | local ret="$(gen_ret_type "${meta}" "${int}")" | 24 | local ret="$(gen_ret_type "${meta}" "${int}")" |
| 23 | local retstmt="$(gen_ret_stmt "${meta}")" | 25 | local retstmt="$(gen_ret_stmt "${meta}")" |
| @@ -32,7 +34,7 @@ gen_template_fallback() · 8 unmodified lines | |||
| 32 | fi | 34 | fi |
| 33 | } | 35 | } |
| 34 | 36 | ||
| 35 | #gen_proto_fallback(meta, pfx, name, sfx, order, atomic, int, args...) | 37 | #gen_proto_fallback(meta, pfx, name, sfx, order, arch, atomic, int, args...) |
| 36 | gen_proto_fallback() | 38 | gen_proto_fallback() |
| 37 | { | 39 | { |
| 38 | local meta="$1"; shift | 40 | local meta="$1"; shift |
| @@ -56,16 +58,17 @@ cat << EOF · 17 unmodified lines | |||
| 56 | EOF | 58 | EOF |
| 57 | } | 59 | } |
| 58 | 60 | ||
| 59 | #gen_proto_order_variants(meta, pfx, name, sfx, atomic, int, args...) | 61 | #gen_proto_order_variants(meta, pfx, name, sfx, arch, atomic, int, args...) |
| 60 | gen_proto_order_variants() | 62 | gen_proto_order_variants() |
| 61 | { | 63 | { |
| 62 | local meta="$1"; shift | 64 | local meta="$1"; shift |
| 63 | local pfx="$1"; shift | 65 | local pfx="$1"; shift |
| 64 | local name="$1"; shift | 66 | local name="$1"; shift |
| 65 | local sfx="$1"; shift | 67 | local sfx="$1"; shift |
| 66 | local atomic="$1" | 68 | local arch="$1" |
| 69 | local atomic="$2" | ||
| 67 | 70 | ||
| 68 | local basename="${atomic}_${pfx}${name}${sfx}" | 71 | local basename="${arch}${atomic}_${pfx}${name}${sfx}" |
| 69 | 72 | ||
| 70 | local template="$(find_fallback_template "${pfx}" "${name}" "${sfx}" "${order}")" | 73 | local template="$(find_fallback_template "${pfx}" "${name}" "${sfx}" "${order}")" |
| 71 | 74 | ||
| @@ -94,7 +97,7 @@ gen_proto_order_variants() · 22 unmodified lines | |||
| 94 | gen_basic_fallbacks "${basename}" | 97 | gen_basic_fallbacks "${basename}" |
| 95 | 98 | ||
| 96 | if [ ! -z "${template}" ]; then | 99 | if [ ! -z "${template}" ]; then |
| 97 | printf "#endif /* ${atomic}_${pfx}${name}${sfx} */\n\n" | 100 | printf "#endif /* ${arch}${atomic}_${pfx}${name}${sfx} */\n\n" |
| 98 | gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "" "$@" | 101 | gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "" "$@" |
| 99 | gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_acquire" "$@" | 102 | gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_acquire" "$@" |
| 100 | gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_release" "$@" | 103 | gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_release" "$@" |
| @@ -149,20 +152,19 @@ cat << EOF · 48 unmodified lines | |||
| 149 | #ifndef _LINUX_ATOMIC_FALLBACK_H | 152 | #ifndef _LINUX_ATOMIC_FALLBACK_H |
| 150 | #define _LINUX_ATOMIC_FALLBACK_H | 153 | #define _LINUX_ATOMIC_FALLBACK_H |
| 151 | 154 | ||
| 155 | #include <linux/compiler.h> | ||
| 156 | |||
| 152 | EOF | 157 | EOF |
| 153 | 158 | ||
| 154 | for xchg in "xchg" "cmpxchg" "cmpxchg64"; do | 159 | for xchg in "${ARCH}xchg" "${ARCH}cmpxchg" "${ARCH}cmpxchg64"; do |
| 155 | gen_xchg_fallbacks "${xchg}" | 160 | gen_xchg_fallbacks "${xchg}" |
| 156 | done | 161 | done |
| 157 | 162 | ||
| 158 | grep '^[a-z]' "$1" | while read name meta args; do | 163 | grep '^[a-z]' "$1" | while read name meta args; do |
| 159 | gen_proto "${meta}" "${name}" "atomic" "int" ${args} | 164 | gen_proto "${meta}" "${name}" "${ARCH}" "atomic" "int" ${args} |
| 160 | done | 165 | done |
| 161 | 166 | ||
| 162 | cat <<EOF | 167 | cat <<EOF |
| 163 | #define atomic_cond_read_acquire(v, c) smp_cond_load_acquire(&(v)->counter, (c)) | ||
| 164 | #define atomic_cond_read_relaxed(v, c) smp_cond_load_relaxed(&(v)->counter, (c)) | ||
| 165 | |||
| 166 | #ifdef CONFIG_GENERIC_ATOMIC64 | 168 | #ifdef CONFIG_GENERIC_ATOMIC64 |
| 167 | #include <asm-generic/atomic64.h> | 169 | #include <asm-generic/atomic64.h> |
| 168 | #endif | 170 | #endif |
| @@ -170,12 +172,9 @@ cat <<EOF · 1 unmodified line | |||
| 170 | EOF | 172 | EOF |
| 171 | 173 | ||
| 172 | grep '^[a-z]' "$1" | while read name meta args; do | 174 | grep '^[a-z]' "$1" | while read name meta args; do |
| 173 | gen_proto "${meta}" "${name}" "atomic64" "s64" ${args} | 175 | gen_proto "${meta}" "${name}" "${ARCH}" "atomic64" "s64" ${args} |
| 174 | done | 176 | done |
| 175 | 177 | ||
| 176 | cat <<EOF | 178 | cat <<EOF |
| 177 | #define atomic64_cond_read_acquire(v, c) smp_cond_load_acquire(&(v)->counter, (c)) | ||
| 178 | #define atomic64_cond_read_relaxed(v, c) smp_cond_load_relaxed(&(v)->counter, (c)) | ||
| 179 | |||
| 180 | #endif /* _LINUX_ATOMIC_FALLBACK_H */ | 179 | #endif /* _LINUX_ATOMIC_FALLBACK_H */ |
| 181 | EOF | 180 | EOF |
| @@ -10,10 +10,11 @@ LINUXDIR=${ATOMICDIR}/../.. · 9 unmodified lines | |||
| 10 | cat <<EOF | | 10 | cat <<EOF | |
| 11 | gen-atomic-instrumented.sh asm-generic/atomic-instrumented.h | 11 | gen-atomic-instrumented.sh asm-generic/atomic-instrumented.h |
| 12 | gen-atomic-long.sh asm-generic/atomic-long.h | 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-fallback.h | 14 | gen-atomic-fallback.sh linux/atomic-fallback.h |
| 14 | EOF | 15 | EOF |
| 15 | while read script header; do | 16 | while read script header args; do |
| 16 | /bin/sh ${ATOMICDIR}/${script} ${ATOMICTBL} > ${LINUXDIR}/include/${header} | 17 | /bin/sh ${ATOMICDIR}/${script} ${ATOMICTBL} ${args} > ${LINUXDIR}/include/${header} |
| 17 | HASH="$(sha1sum ${LINUXDIR}/include/${header})" | 18 | HASH="$(sha1sum ${LINUXDIR}/include/${header})" |
| 18 | HASH="${HASH%% *}" | 19 | HASH="${HASH%% *}" |
| 19 | printf "// %s\n" "${HASH}" >> ${LINUXDIR}/include/${header} | 20 | printf "// %s\n" "${HASH}" >> ${LINUXDIR}/include/${header} |