Skip to contentSkip to conversation

locking/arch changes for v3.18

GIT PULL Ingo Molnar 1 participant 1 message Oct 13, 2014

Subsystems (16)
Arm (32-bit) x86 PowerPC Library code +12 more subsystems
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest locking-arch-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking-arch-for-linus

# HEAD: 2291059c852706c6f5ffb400366042b7625066cd locking,arch: Use ACCESS_ONCE() instead of cast to volatile in atomic_read()

This is a series kept separate from the main locking tree, which cleans up and improves various details in the atomics type handling:

- Remove the unused atomic_or_long() method

- Consolidate and compress atomic ops implementations between architectures, to reduce linecount and to make it easier to add new ops.

- Rewrite generic atomic support to only require cmpxchg() from an architecture - generate all other methods from that.

Thanks,

Ingo

------------------>
Peter Zijlstra (22):
locking,x86: Kill atomic_or_long() locking,arch,alpha: Fold atomic_ops locking,arch,arc: Fold atomic_ops locking,arch,arm: Fold atomic_ops locking,arch,arm64: Fold atomic_ops locking,arch,avr32: Fold atomic_ops locking,arch,cris: Fold atomic_ops locking,arch,hexagon: Fold atomic_ops locking,arch,ia64: Fold atomic_ops locking,arch,m32r: Fold atomic_ops locking,arch,m68k: Fold atomic_ops locking,arch,metag: Fold atomic_ops locking,arch,mips: Fold atomic_ops locking,arch,mn10300: Fold atomic_ops locking,arch,parisc: Fold atomic_ops locking,arch,powerpc: Fold atomic_ops locking,arch,sh: Fold atomic_ops locking,arch,sparc: Fold atomic_ops locking,arch,xtensa: Fold atomic_ops locking,arch: Rewrite generic atomic support locking, sparc64: Fix atomics locking, mips: Fix atomics

Pranith Kumar (1):
locking,arch: Use ACCESS_ONCE() instead of cast to volatile in atomic_read()

 arch/alpha/include/asm/atomic.h        | 217 +++++--------
 arch/arc/include/asm/atomic.h          | 184 ++++-------
 arch/arm/include/asm/atomic.h          | 307 ++++++++----------
 arch/arm64/include/asm/atomic.h        | 201 +++++-------
 arch/avr32/include/asm/atomic.h        | 125 ++++----
 arch/cris/include/asm/atomic.h         |  59 ++--
 arch/frv/include/asm/atomic.h          |   2 +-
 arch/hexagon/include/asm/atomic.h      |  68 ++--
 arch/ia64/include/asm/atomic.h         | 192 ++++++-----
 arch/m32r/include/asm/atomic.h         | 145 ++++-----
 arch/m68k/include/asm/atomic.h         | 111 +++----
 arch/metag/include/asm/atomic_lnkget.h | 121 +++----
 arch/metag/include/asm/atomic_lock1.h  |  76 ++---
 arch/mips/include/asm/atomic.h         | 561 +++++++++++----------------------
 arch/mn10300/include/asm/atomic.h      | 125 +++-----
 arch/parisc/include/asm/atomic.h       | 117 ++++---
 arch/powerpc/include/asm/atomic.h      | 198 +++++-------
 arch/sh/include/asm/atomic-grb.h       | 119 +++----
 arch/sh/include/asm/atomic-irq.h       |  62 ++--
 arch/sh/include/asm/atomic-llsc.h      | 101 +++---
 arch/sh/include/asm/atomic.h           |   2 +-
 arch/sparc/include/asm/atomic_32.h     |  19 +-
 arch/sparc/include/asm/atomic_64.h     |  49 +--
 arch/sparc/kernel/smp_64.c             |   2 +-
 arch/sparc/lib/atomic32.c              |  29 +-
 arch/sparc/lib/atomic_64.S             | 163 ++++------
 arch/sparc/lib/ksyms.c                 |  25 +-
 arch/x86/include/asm/atomic.h          |  17 +-
 arch/x86/include/asm/atomic64_64.h     |   2 +-
 arch/xtensa/include/asm/atomic.h       | 235 +++++---------
 include/asm-generic/atomic.h           | 194 ++++++------
 include/asm-generic/atomic64.h         |  20 +-
 lib/atomic64.c                         |  83 +++--
 33 files changed, 1611 insertions(+), 2320 deletions(-)
arch/alpha/include/asm/atomic.h +82 -135
index ed60a1ee1ed3..8f8eafbedd7c 100644
@@ -17,8 +17,8 @@
 #define ATOMIC_INIT(i)		{ (i) }
 #define ATOMIC64_INIT(i)	{ (i) }
 
-#define atomic_read(v)		(*(volatile int *)&(v)->counter)
-#define atomic64_read(v)	(*(volatile long *)&(v)->counter)
+#define atomic_read(v)		ACCESS_ONCE((v)->counter)
+#define atomic64_read(v)	ACCESS_ONCE((v)->counter)
 
 #define atomic_set(v,i)		((v)->counter = (i))
 #define atomic64_set(v,i)	((v)->counter = (i))
@@ -29,145 +29,92 @@
  * branch back to restart the operation.
  */
 
-static __inline__ void atomic_add(int i, atomic_t * v)
-{
-	unsigned long temp;
-	__asm__ __volatile__(
-	"1:	ldl_l %0,%1\n"
-	"	addl %0,%2,%0\n"
-	"	stl_c %0,%1\n"
-	"	beq %0,2f\n"
-	".subsection 2\n"
-	"2:	br 1b\n"
-	".previous"
-	:"=&r" (temp), "=m" (v->counter)
-	:"Ir" (i), "m" (v->counter));
-}
-
-static __inline__ void atomic64_add(long i, atomic64_t * v)
-{
-	unsigned long temp;
-	__asm__ __volatile__(
-	"1:	ldq_l %0,%1\n"
-	"	addq %0,%2,%0\n"
-	"	stq_c %0,%1\n"
-	"	beq %0,2f\n"
-	".subsection 2\n"
-	"2:	br 1b\n"
-	".previous"
-	:"=&r" (temp), "=m" (v->counter)
-	:"Ir" (i), "m" (v->counter));
-}
-
-static __inline__ void atomic_sub(int i, atomic_t * v)
-{
-	unsigned long temp;
-	__asm__ __volatile__(
-	"1:	ldl_l %0,%1\n"
-	"	subl %0,%2,%0\n"
-	"	stl_c %0,%1\n"
-	"	beq %0,2f\n"
-	".subsection 2\n"
-	"2:	br 1b\n"
-	".previous"
-	:"=&r" (temp), "=m" (v->counter)
-	:"Ir" (i), "m" (v->counter));
+#define ATOMIC_OP(op)							\
+static __inline__ void atomic_##op(int i, atomic_t * v)			\
+{									\
+	unsigned long temp;						\
+	__asm__ __volatile__(						\
+	"1:	ldl_l %0,%1\n"						\
+	"	" #op "l %0,%2,%0\n"					\
+	"	stl_c %0,%1\n"						\
+	"	beq %0,2f\n"						\
+	".subsection 2\n"						\
+	"2:	br 1b\n"						\
+	".previous"							\
+	:"=&r" (temp), "=m" (v->counter)				\
+	:"Ir" (i), "m" (v->counter));					\
+}									\
+
+#define ATOMIC_OP_RETURN(op)						\
+static inline int atomic_##op##_return(int i, atomic_t *v)		\
+{									\
+	long temp, result;						\
+	smp_mb();							\
+	__asm__ __volatile__(						\
+	"1:	ldl_l %0,%1\n"						\
+	"	" #op "l %0,%3,%2\n"					\
+	"	" #op "l %0,%3,%0\n"					\
+	"	stl_c %0,%1\n"						\
+	"	beq %0,2f\n"						\
+	".subsection 2\n"						\
+	"2:	br 1b\n"						\
+	".previous"							\
+	:"=&r" (temp), "=m" (v->counter), "=&r" (result)		\
+	:"Ir" (i), "m" (v->counter) : "memory");			\
+	smp_mb();							\
+	return result;							\
 }
 
-static __inline__ void atomic64_sub(long i, atomic64_t * v)
-{
-	unsigned long temp;
-	__asm__ __volatile__(
-	"1:	ldq_l %0,%1\n"
-	"	subq %0,%2,%0\n"
-	"	stq_c %0,%1\n"
-	"	beq %0,2f\n"
-	".subsection 2\n"
-	"2:	br 1b\n"
-	".previous"
-	:"=&r" (temp), "=m" (v->counter)
-	:"Ir" (i), "m" (v->counter));
-}
-
-
-/*
- * Same as above, but return the result value
- */
-static inline int atomic_add_return(int i, atomic_t *v)
-{
-	long temp, result;
-	smp_mb();
-	__asm__ __volatile__(
-	"1:	ldl_l %0,%1\n"
-	"	addl %0,%3,%2\n"
-	"	addl %0,%3,%0\n"
-	"	stl_c %0,%1\n"
-	"	beq %0,2f\n"
-	".subsection 2\n"
-	"2:	br 1b\n"
-	".previous"
-	:"=&r" (temp), "=m" (v->counter), "=&r" (result)
-	:"Ir" (i), "m" (v->counter) : "memory");
-	smp_mb();
-	return result;
+#define ATOMIC64_OP(op)							\
+static __inline__ void atomic64_##op(long i, atomic64_t * v)		\
+{									\
+	unsigned long temp;						\
+	__asm__ __volatile__(						\
+	"1:	ldq_l %0,%1\n"						\
+	"	" #op "q %0,%2,%0\n"					\
+	"	stq_c %0,%1\n"						\
+	"	beq %0,2f\n"						\
+	".subsection 2\n"						\
+	"2:	br 1b\n"						\
+	".previous"							\
+	:"=&r" (temp), "=m" (v->counter)				\
+	:"Ir" (i), "m" (v->counter));					\
+}									\
+
+#define ATOMIC64_OP_RETURN(op)						\
+static __inline__ long atomic64_##op##_return(long i, atomic64_t * v)	\
+{									\
+	long temp, result;						\
+	smp_mb();							\
+	__asm__ __volatile__(						\
+	"1:	ldq_l %0,%1\n"						\
+	"	" #op "q %0,%3,%2\n"					\
+	"	" #op "q %0,%3,%0\n"					\
+	"	stq_c %0,%1\n"						\
+	"	beq %0,2f\n"						\
+	".subsection 2\n"						\
+	"2:	br 1b\n"						\
+	".previous"							\
+	:"=&r" (temp), "=m" (v->counter), "=&r" (result)		\
+	:"Ir" (i), "m" (v->counter) : "memory");			\
+	smp_mb();							\
+	return result;							\
 }
 
-static __inline__ long atomic64_add_return(long i, atomic64_t * v)
-{
-	long temp, result;
-	smp_mb();
-	__asm__ __volatile__(
-	"1:	ldq_l %0,%1\n"
-	"	addq %0,%3,%2\n"
-	"	addq %0,%3,%0\n"
-	"	stq_c %0,%1\n"
-	"	beq %0,2f\n"
-	".subsection 2\n"
-	"2:	br 1b\n"
-	".previous"
-	:"=&r" (temp), "=m" (v->counter), "=&r" (result)
-	:"Ir" (i), "m" (v->counter) : "memory");
-	smp_mb();
-	return result;
-}
+#define ATOMIC_OPS(opg)							\
+	ATOMIC_OP(opg)							\
+	ATOMIC_OP_RETURN(opg)						\
+	ATOMIC64_OP(opg)						\
+	ATOMIC64_OP_RETURN(opg)
 
-static __inline__ long atomic_sub_return(int i, atomic_t * v)
-{
-	long temp, result;
-	smp_mb();
-	__asm__ __volatile__(
-	"1:	ldl_l %0,%1\n"
-	"	subl %0,%3,%2\n"
-	"	subl %0,%3,%0\n"
-	"	stl_c %0,%1\n"
-	"	beq %0,2f\n"
-	".subsection 2\n"
-	"2:	br 1b\n"
-	".previous"
-	:"=&r" (temp), "=m" (v->counter), "=&r" (result)
-	:"Ir" (i), "m" (v->counter) : "memory");
-	smp_mb();
-	return result;
-}
+ATOMIC_OPS(add)
+ATOMIC_OPS(sub)
 
-static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
-{
-	long temp, result;
-	smp_mb();
-	__asm__ __volatile__(
-	"1:	ldq_l %0,%1\n"
-	"	subq %0,%3,%2\n"
-	"	subq %0,%3,%0\n"
-	"	stq_c %0,%1\n"
-	"	beq %0,2f\n"
-	".subsection 2\n"
-	"2:	br 1b\n"
-	".previous"
-	:"=&r" (temp), "=m" (v->counter), "=&r" (result)
-	:"Ir" (i), "m" (v->counter) : "memory");
-	smp_mb();
-	return result;
-}
+#undef ATOMIC_OPS
+#undef ATOMIC64_OP_RETURN
+#undef ATOMIC64_OP
+#undef ATOMIC_OP_RETURN
+#undef ATOMIC_OP
 
 #define atomic64_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), old, new))
 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
arch/arc/include/asm/atomic.h +63 -121

210 lines not on this page · raw message

arch/arm/include/asm/atomic.h +124 -183

343 lines not on this page · raw message

arch/arm64/include/asm/atomic.h +82 -119

230 lines not on this page · raw message

arch/avr32/include/asm/atomic.h +63 -62

162 lines not on this page · raw message

arch/cris/include/asm/atomic.h +26 -33

74 lines not on this page · raw message

arch/frv/include/asm/atomic.h +1 -1
index f6c3a1690101..102190a61d65 100644
@@ -31,7 +31,7 @@
  */
 
 #define ATOMIC_INIT(i)		{ (i) }
-#define atomic_read(v)		(*(volatile int *)&(v)->counter)
+#define atomic_read(v)		ACCESS_ONCE((v)->counter)
 #define atomic_set(v, i)	(((v)->counter) = (i))
 
 #ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
arch/hexagon/include/asm/atomic.h +37 -31

78 lines not on this page · raw message

arch/ia64/include/asm/atomic.h +88 -104

229 lines not on this page · raw message

arch/m32r/include/asm/atomic.h +58 -87

186 lines not on this page · raw message

arch/m68k/include/asm/atomic.h +48 -63

138 lines not on this page · raw message

arch/metag/include/asm/atomic_lnkget.h +46 -75

131 lines not on this page · raw message

arch/metag/include/asm/atomic_lock1.h +31 -45

86 lines not on this page · raw message

arch/mips/include/asm/atomic.h +189 -372

593 lines not on this page · raw message

arch/mn10300/include/asm/atomic.h +42 -83

151 lines not on this page · raw message

arch/parisc/include/asm/atomic.h +71 -46

146 lines not on this page · raw message

arch/powerpc/include/asm/atomic.h +77 -121

198 lines not on this page · raw message

arch/sh/include/asm/atomic-grb.h +45 -74

119 lines not on this page · raw message

arch/sh/include/asm/atomic-irq.h +26 -36

62 lines not on this page · raw message

arch/sh/include/asm/atomic-llsc.h +41 -60

101 lines not on this page · raw message

arch/sh/include/asm/atomic.h +1 -1
index f57b8a6743b3..05b9f74ce2d5 100644

Lines of this file are not shown. View the raw message.

arch/sparc/include/asm/atomic_32.h +9 -10
index 7aed2be45b44..765c1776ec9f 100644

Lines of this file are not shown. View the raw message.

arch/sparc/include/asm/atomic_64.h +25 -24

49 lines not on this page · raw message

arch/sparc/kernel/smp_64.c +1 -1
index 41aa2478f3ca..32dab009915f 100644

Lines of this file are not shown. View the raw message.

arch/sparc/lib/atomic32.c +17 -12
index 1d32b54089aa..a7c418ac26af 100644

Lines of this file are not shown. View the raw message.

arch/sparc/lib/atomic_64.S +67 -96

163 lines not on this page · raw message

arch/sparc/lib/ksyms.c +17 -8
index 323335b9cd2b..1d649a95660c 100644

Lines of this file are not shown. View the raw message.

arch/x86/include/asm/atomic.h +1 -16
index 6dd1c7dd0473..5e5cd123fdfb 100644

Lines of this file are not shown. View the raw message.

arch/x86/include/asm/atomic64_64.h +1 -1
index 46e9052bbd28..f8d273e18516 100644

Lines of this file are not shown. View the raw message.

arch/xtensa/include/asm/atomic.h +83 -152

235 lines not on this page · raw message

include/asm-generic/atomic.h +97 -97

194 lines not on this page · raw message

include/asm-generic/atomic64.h +16 -4
index b18ce4f9ee3d..30ad9c86cebb 100644

Lines of this file are not shown. View the raw message.

lib/atomic64.c +36 -47

83 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.