lkml.org 
[lkml]   [2020]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/3] asm-generic/atomic: Add try_cmpxchg64() instrumentation
    Date
    Instrument try_cmpxchg64() similar to try_cmpxchg().

    Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
    Cc: Will Deacon <will@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Boqun Feng <boqun.feng@gmail.com>
    ---
    include/asm-generic/atomic-instrumented.h | 46 ++++++++++++++++++++++-
    scripts/atomic/gen-atomic-instrumented.sh | 2 +-
    2 files changed, 46 insertions(+), 2 deletions(-)

    diff --git a/include/asm-generic/atomic-instrumented.h b/include/asm-generic/atomic-instrumented.h
    index 888b6cfeed91..396d4484963a 100644
    --- a/include/asm-generic/atomic-instrumented.h
    +++ b/include/asm-generic/atomic-instrumented.h
    @@ -1793,6 +1793,50 @@ atomic64_dec_if_positive(atomic64_t *v)
    })
    #endif

    +#if !defined(arch_try_cmpxchg64_relaxed) || defined(arch_try_cmpxchg64)
    +#define try_cmpxchg64(ptr, oldp, ...) \
    +({ \
    + typeof(ptr) __ai_ptr = (ptr); \
    + typeof(oldp) __ai_oldp = (oldp); \
    + instrument_atomic_write(__ai_ptr, sizeof(*__ai_ptr)); \
    + instrument_atomic_write(__ai_oldp, sizeof(*__ai_oldp)); \
    + arch_try_cmpxchg64(__ai_ptr, __ai_oldp, __VA_ARGS__); \
    +})
    +#endif
    +
    +#if defined(arch_try_cmpxchg64_acquire)
    +#define try_cmpxchg64_acquire(ptr, oldp, ...) \
    +({ \
    + typeof(ptr) __ai_ptr = (ptr); \
    + typeof(oldp) __ai_oldp = (oldp); \
    + instrument_atomic_write(__ai_ptr, sizeof(*__ai_ptr)); \
    + instrument_atomic_write(__ai_oldp, sizeof(*__ai_oldp)); \
    + arch_try_cmpxchg64_acquire(__ai_ptr, __ai_oldp, __VA_ARGS__); \
    +})
    +#endif
    +
    +#if defined(arch_try_cmpxchg64_release)
    +#define try_cmpxchg64_release(ptr, oldp, ...) \
    +({ \
    + typeof(ptr) __ai_ptr = (ptr); \
    + typeof(oldp) __ai_oldp = (oldp); \
    + instrument_atomic_write(__ai_ptr, sizeof(*__ai_ptr)); \
    + instrument_atomic_write(__ai_oldp, sizeof(*__ai_oldp)); \
    + arch_try_cmpxchg64_release(__ai_ptr, __ai_oldp, __VA_ARGS__); \
    +})
    +#endif
    +
    +#if defined(arch_try_cmpxchg64_relaxed)
    +#define try_cmpxchg64_relaxed(ptr, oldp, ...) \
    +({ \
    + typeof(ptr) __ai_ptr = (ptr); \
    + typeof(oldp) __ai_oldp = (oldp); \
    + instrument_atomic_write(__ai_ptr, sizeof(*__ai_ptr)); \
    + instrument_atomic_write(__ai_oldp, sizeof(*__ai_oldp)); \
    + arch_try_cmpxchg64_relaxed(__ai_ptr, __ai_oldp, __VA_ARGS__); \
    +})
    +#endif
    +
    #define cmpxchg_local(ptr, ...) \
    ({ \
    typeof(ptr) __ai_ptr = (ptr); \
    @@ -1830,4 +1874,4 @@ atomic64_dec_if_positive(atomic64_t *v)
    })

    #endif /* _ASM_GENERIC_ATOMIC_INSTRUMENTED_H */
    -// 4bec382e44520f4d8267e42620054db26a659ea3
    +// 28b0549ca119ed58a9b61da6e277ee30de18bdfc
    diff --git a/scripts/atomic/gen-atomic-instrumented.sh b/scripts/atomic/gen-atomic-instrumented.sh
    index 5766ffcec7c5..ade2e509b5eb 100755
    --- a/scripts/atomic/gen-atomic-instrumented.sh
    +++ b/scripts/atomic/gen-atomic-instrumented.sh
    @@ -186,7 +186,7 @@ grep '^[a-z]' "$1" | while read name meta args; do
    gen_proto "${meta}" "${name}" "atomic64" "s64" ${args}
    done

    -for xchg in "xchg" "cmpxchg" "cmpxchg64" "try_cmpxchg"; do
    +for xchg in "xchg" "cmpxchg" "cmpxchg64" "try_cmpxchg" "try_cmpxchg64"; do
    for order in "" "_acquire" "_release" "_relaxed"; do
    gen_optional_xchg "${xchg}" "${order}"
    done
    --
    2.26.2
    \
     
     \ /
      Last update: 2020-12-15 19:32    [W:3.412 / U:0.056 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site