From 37f8173dd84936ea78000ed1cad24f8b18d48ebb Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Fri, 24 Jan 2020 22:13:03 +0100 Subject: locking/atomics: Flip fallbacks and instrumentation Currently instrumentation of atomic primitives is done at the architecture level, while composites or fallbacks are provided at the generic level. The result is that there are no uninstrumented variants of the fallbacks. Since there is now need of such variants to isolate text poke from any form of instrumentation invert this ordering. Doing this means moving the instrumentation into the generic code as well as having (for now) two variants of the fallbacks. Notes: - the various *cond_read* primitives are not proper fallbacks and got moved into linux/atomic.c. No arch_ variants are generated because the base primitives smp_cond_load*() are instrumented. - once all architectures are moved over to arch_atomic_ one of the fallback variants can be removed and some 2300 lines reclaimed. - atomic_{read,set}*() are no longer double-instrumented Reported-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Acked-by: Mark Rutland Link: https://lkml.kernel.org/r/20200505134058.769149955@linutronix.de --- scripts/atomic/fallbacks/acquire | 4 ++-- scripts/atomic/fallbacks/add_negative | 6 +++--- scripts/atomic/fallbacks/add_unless | 6 +++--- scripts/atomic/fallbacks/andnot | 4 ++-- scripts/atomic/fallbacks/dec | 4 ++-- scripts/atomic/fallbacks/dec_and_test | 6 +++--- scripts/atomic/fallbacks/dec_if_positive | 6 +++--- scripts/atomic/fallbacks/dec_unless_positive | 6 +++--- scripts/atomic/fallbacks/fence | 4 ++-- scripts/atomic/fallbacks/fetch_add_unless | 8 ++++---- scripts/atomic/fallbacks/inc | 4 ++-- scripts/atomic/fallbacks/inc_and_test | 6 +++--- scripts/atomic/fallbacks/inc_not_zero | 6 +++--- scripts/atomic/fallbacks/inc_unless_negative | 6 +++--- scripts/atomic/fallbacks/read_acquire | 2 +- scripts/atomic/fallbacks/release | 4 ++-- scripts/atomic/fallbacks/set_release | 2 +- scripts/atomic/fallbacks/sub_and_test | 6 +++--- scripts/atomic/fallbacks/try_cmpxchg | 4 ++-- scripts/atomic/gen-atomic-fallback.sh | 29 +++++++++++++--------------- scripts/atomic/gen-atomics.sh | 5 +++-- 21 files changed, 63 insertions(+), 65 deletions(-) (limited to 'scripts') diff --git a/scripts/atomic/fallbacks/acquire b/scripts/atomic/fallbacks/acquire index ea489acc285e..59c00529dc7c 100755 --- a/scripts/atomic/fallbacks/acquire +++ b/scripts/atomic/fallbacks/acquire @@ -1,8 +1,8 @@ cat < 0)) return false; - } while (!${atomic}_try_cmpxchg(v, &c, c - 1)); + } while (!${arch}${atomic}_try_cmpxchg(v, &c, c - 1)); return true; } diff --git a/scripts/atomic/fallbacks/fence b/scripts/atomic/fallbacks/fence index 92a3a4691bab..3764fc8ce945 100755 --- a/scripts/atomic/fallbacks/fence +++ b/scripts/atomic/fallbacks/fence @@ -1,10 +1,10 @@ cat <counter); } diff --git a/scripts/atomic/fallbacks/release b/scripts/atomic/fallbacks/release index 730d2a6d3e07..f8906d537c0f 100755 --- a/scripts/atomic/fallbacks/release +++ b/scripts/atomic/fallbacks/release @@ -1,8 +1,8 @@ cat <counter, i); } diff --git a/scripts/atomic/fallbacks/sub_and_test b/scripts/atomic/fallbacks/sub_and_test index 6cfe4ed49746..c580f4c2136e 100755 --- a/scripts/atomic/fallbacks/sub_and_test +++ b/scripts/atomic/fallbacks/sub_and_test @@ -1,6 +1,6 @@ cat <counter, (c)) -#define atomic_cond_read_relaxed(v, c) smp_cond_load_relaxed(&(v)->counter, (c)) - #ifdef CONFIG_GENERIC_ATOMIC64 #include #endif @@ -172,12 +172,9 @@ cat <counter, (c)) -#define atomic64_cond_read_relaxed(v, c) smp_cond_load_relaxed(&(v)->counter, (c)) - #endif /* _LINUX_ATOMIC_FALLBACK_H */ EOF diff --git a/scripts/atomic/gen-atomics.sh b/scripts/atomic/gen-atomics.sh index 000dc6437893..d29e159ef489 100644 --- a/scripts/atomic/gen-atomics.sh +++ b/scripts/atomic/gen-atomics.sh @@ -10,10 +10,11 @@ LINUXDIR=${ATOMICDIR}/../.. cat < ${LINUXDIR}/include/${header} +while read script header args; do + /bin/sh ${ATOMICDIR}/${script} ${ATOMICTBL} ${args} > ${LINUXDIR}/include/${header} HASH="$(sha1sum ${LINUXDIR}/include/${header})" HASH="${HASH%% *}" printf "// %s\n" "${HASH}" >> ${LINUXDIR}/include/${header} -- cgit