Re: [PATCHv2 04/16] atomics/treewide: make atomic_fetch_add_unless() optional

From: Palmer Dabbelt
Date: Mon Jun 04 2018 - 19:25:02 EST


On Tue, 29 May 2018 08:43:34 PDT (-0700), mark.rutland@xxxxxxx wrote:
Several architectures these have a near-identical implementation based
on atomic_read() and atomic_cmpxchg() that we can instead define in
<linux/atomic.h>, so let's do so, using something close to the existing
x86 implementation with try_cmpxchg().

Where an architecture provides its own atomic_fetch_add_unless(), it
must define a preprocessor symbol for it. The instrumented atomics are
updated accordingly.

Note that arch/arc's existing atomic_fetch_add_unless() had redundant
barriers, as these are already present in its atomic_cmpxchg()
implementation.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@xxxxxxx>
Reviewed-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Acked-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Cc: Boqun Feng <boqun.feng@xxxxxxxxx>
Cc: Will Deacon <will.deacon@xxxxxxx>
Cc: Vineet Gupta <vgupta@xxxxxxxxxxxx>
---
arch/alpha/include/asm/atomic.h | 2 +-
arch/arc/include/asm/atomic.h | 28 ----------------------------
arch/arm/include/asm/atomic.h | 11 +----------
arch/arm64/include/asm/atomic.h | 1 -
arch/h8300/include/asm/atomic.h | 1 +
arch/hexagon/include/asm/atomic.h | 1 +
arch/ia64/include/asm/atomic.h | 16 ----------------
arch/m68k/include/asm/atomic.h | 15 ---------------
arch/mips/include/asm/atomic.h | 24 ------------------------
arch/parisc/include/asm/atomic.h | 24 ------------------------
arch/powerpc/include/asm/atomic.h | 1 +
arch/riscv/include/asm/atomic.h | 1 +
arch/s390/include/asm/atomic.h | 15 ---------------
arch/sh/include/asm/atomic.h | 25 -------------------------
arch/sparc/include/asm/atomic_32.h | 2 ++
arch/sparc/include/asm/atomic_64.h | 15 ---------------
arch/x86/include/asm/atomic.h | 21 ---------------------
arch/xtensa/include/asm/atomic.h | 24 ------------------------
include/asm-generic/atomic-instrumented.h | 4 +++-
include/asm-generic/atomic.h | 11 -----------
include/linux/atomic.h | 23 +++++++++++++++++++++++
21 files changed, 34 insertions(+), 231 deletions(-)
[...]
diff --git a/arch/riscv/include/asm/atomic.h b/arch/riscv/include/asm/atomic.h
index 18259e90f57e..5f161daefcd2 100644
--- a/arch/riscv/include/asm/atomic.h
+++ b/arch/riscv/include/asm/atomic.h
@@ -349,6 +349,7 @@ static __always_inline int atomic_fetch_add_unless(atomic_t *v, int a, int u)
: "memory");
return prev;
}
+#define atomic_fetch_add_unless atomic_fetch_add_unless

#ifndef CONFIG_GENERIC_ATOMIC64
static __always_inline long __atomic64_add_unless(atomic64_t *v, long a, long u)

Acked-by: Palmer Dabbelt <palmer@xxxxxxxxxx>

Thanks!