Skip to contentSkip to conversation

arch: barrier cleanup + barriers for virt

PATCH Superseded Michael S. Tsirkin 15 participants 257 messages Dec 31, 2015 – Jan 11, 2016 Page 1 of 2

Subsystems (15)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

v2 cover arch: barrier cleanup + barriers for virt

Changes since v1:
- replaced my asm-generic patch with an equivalent patch already in tip
- add wrappers with virt_ prefix for better code annotation, as suggested by David Miller
- dropped XXX in patch names as this makes vger choke, Cc all relevant mailing lists on all patches (not personal email, as the list becomes too long then)

I parked this in vhost tree for now, but the inclusion of patch 1 from tip creates a merge conflict (even though it's easy to resolve). Would tip maintainers prefer merging it through tip tree instead (including the virtio patches)?
Or should I just merge it all through my tree, including the duplicate patch, and assume conflict will be resolved?
If the second, acks will be appreciated.

Thanks!

This is really trying to cleanup some virt code, as suggested by Peter, who said

Quoted 2 lines

You could of course go fix that instead of mutilating things into sort-of functional state.

This work is needed for virtio, so it's probably easiest to merge it through my tree - is this fine by everyone? Arnd, if you agree, could you ack this please?

Note to arch maintainers: please don't cherry-pick patches out of this patchset as it's been structured in this order to avoid breaking bisect. Please send acks instead!

Sometimes, virtualization is weird. For example, virtio does this (conceptually):

#ifdef CONFIG_SMP
                smp_mb();
#else
                mb();

#endif

Similarly, Xen calls mb() when it's not doing any MMIO at all.

Of course it's wrong in the sense that it's suboptimal. What we would really like is to have, on UP, exactly the same barrier as on SMP. This is because a UP guest can run on an SMP host.

But Linux doesn't provide this ability: if CONFIG_SMP is not defined is optimizes most barriers out to a compiler barrier.

Consider for example x86: what we want is xchg (NOT mfence - there's no real IO going on here - just switching out of the VM - more like a function call really) but if built without CONFIG_SMP smp_store_mb does not include this.

Virt in general is probably the only use-case, because this really is an artifact of interfacing with an SMP host while running an UP kernel, but since we have (at least) two users, it seems to make sense to put these APIs in a central place.

In fact, smp_ barriers are stubs on !SMP, so they can be defined as follows:

arch/XXX/include/asm/barrier.h:

#define __smp_mb() DOSOMETHING

include/asm-generic/barrier.h:

#ifdef CONFIG_SMP
#define smp_mb() __smp_mb()
#else
#define smp_mb() barrier()
#endif

This has the benefit of cleaning out a bunch of duplicated
ifdefs on a bunch of architectures - this patchset brings
about a net reduction in LOC, even with new barriers and extra documentation :)

Then virt can use __smp_XXX when talking to an SMP host. To make those users explicit, this patchset adds virt_xxx wrappers for them.

Touching all archs is a tad tedious, but its fairly straight forward.

The rest of the patchset is structured as follows:

-. Patch 1 fixes a bug in asm-generic.
It is already in tip, included here for completeness.

-. Patches 2-12 make sure barrier.h on all remaining
architectures includes asm-generic/barrier.h:
after the change in Patch 1, code there matches asm-generic/barrier.h almost verbatim.
Minor code tweaks were required in a couple of places. Macros duplicated from asm-generic/barrier.h are dropped in the process.

After all that preparatory work, we are getting to the actual change.

-. Patches 13 adds generic smp_XXX wrappers in asm-generic
these select __smp_XXX or barrier() depending on CONFIG_SMP

-. Patches 14-27 change all architectures to
define __smp_XXX macros; the generic code in asm-generic/barrier.h then defines smp_XXX macros

I compiled the affected arches before and after the changes, dumped the .text section (using objdump -O binary) and made sure that the object code is exactly identical before and after the change.
I couldn't fully build sh,tile,xtensa but I did this test kernel/rcu/tree.o kernel/sched/wait.o and kernel/futex.o and tested these instead.

Unfortunately, I don't have a metag cross-build toolset ready. Hoping for some acks on this architecture.

Finally, the following patches put the __smp_xxx APIs to work for virt:

-. Patch 28 adds virt_ wrappers for __smp_, and documents them.
After all this work, this requires very few lines of code in the generic header.

-. Patches 29,30,33,34 convert virtio xen drivers to use the virt_xxx APIs

xen patches are untested
virtio ones have been tested on x86

-. Patches 31-32 teach virtio to use virt_store_mb
sh architecture was missing a 2-byte smp_store_mb, the fix is trivial although my code is not optimal:
if anyone cares, pls send me a patch to apply on top. I didn't build this architecture, but intel's 0-day infrastructure builds it.

tested on x86

Davidlohr Bueso (1):
lcoking/barriers, arch: Use smp barriers in smp_store_release()

Michael S. Tsirkin (33):
asm-generic: guard smp_store_release/load_acquire
ia64: rename nop->iosapic_nop
ia64: reuse asm-generic/barrier.h
powerpc: reuse asm-generic/barrier.h
s390: reuse asm-generic/barrier.h
sparc: reuse asm-generic/barrier.h
arm: reuse asm-generic/barrier.h
arm64: reuse asm-generic/barrier.h
metag: reuse asm-generic/barrier.h
mips: reuse asm-generic/barrier.h
x86/um: reuse asm-generic/barrier.h
x86: reuse asm-generic/barrier.h
asm-generic: add __smp_xxx wrappers
powerpc: define __smp_xxx
arm64: define __smp_xxx
arm: define __smp_xxx
blackfin: define __smp_xxx
ia64: define __smp_xxx
metag: define __smp_xxx
mips: define __smp_xxx
s390: define __smp_xxx
sh: define __smp_xxx, fix smp_store_mb for !SMP
sparc: define __smp_xxx
tile: define __smp_xxx
xtensa: define __smp_xxx
x86: define __smp_xxx
asm-generic: implement virt_xxx memory barriers Revert "virtio_ring: Update weak barriers to use dma_wmb/rmb"
virtio_ring: update weak barriers to use __smp_XXX
sh: support a 2-byte smp_store_mb
virtio_ring: use virt_store_mb
xenbus: use virt_xxx barriers
xen/io: use virt_xxx barriers

 arch/arm/include/asm/barrier.h      |  35 ++-----------
 arch/arm64/include/asm/barrier.h    |  19 +++----
 arch/blackfin/include/asm/barrier.h |   4 +-
 arch/ia64/include/asm/barrier.h     |  24 +++------
 arch/metag/include/asm/barrier.h    |  55 ++++++-------------
 arch/mips/include/asm/barrier.h     |  51 ++++++------------
 arch/powerpc/include/asm/barrier.h  |  33 ++++--------
 arch/s390/include/asm/barrier.h     |  25 ++++-----
 arch/sh/include/asm/barrier.h       |  11 +++-
 arch/sparc/include/asm/barrier_32.h |   1 -
 arch/sparc/include/asm/barrier_64.h |  29 +++-------
 arch/sparc/include/asm/processor.h  |   3 --
 arch/tile/include/asm/barrier.h     |   9 ++--
 arch/x86/include/asm/barrier.h      |  36 +++++--------
 arch/x86/um/asm/barrier.h           |   9 +---
 arch/xtensa/include/asm/barrier.h   |   4 +-
 include/asm-generic/barrier.h       | 102 ++++++++++++++++++++++++++++++++----
 include/linux/virtio_ring.h         |  22 +++++---
 include/xen/interface/io/ring.h     |  16 +++---
 arch/ia64/kernel/iosapic.c          |   6 +--
 drivers/virtio/virtio_ring.c        |  15 +++---
 drivers/xen/xenbus/xenbus_comms.c   |   8 +--
 Documentation/memory-barriers.txt   |  28 ++++++++--
 23 files changed, 266 insertions(+), 279 deletions(-)
Signature · 1 line
MST
author maintainer
#1 lore raw

PATCH v2 1/32 lcoking/barriers, arch: Use smp barriers in smp_store_release()

From: Davidlohr Bueso <[email protected]>

With commit b92b8b35a2e ("locking/arch: Rename set_mb() to smp_store_mb()") it was made clear that the context of this call (and thus set_mb) is strictly for CPU ordering, as opposed to IO. As such all archs should use the smp variant of mb(), respecting the semantics and saving a mandatory barrier on UP.

---
 arch/ia64/include/asm/barrier.h    | 2 +-
 arch/powerpc/include/asm/barrier.h | 2 +-
 arch/s390/include/asm/barrier.h    | 2 +-
 include/asm-generic/barrier.h      | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
arch/ia64/include/asm/barrier.h +1 -1
index df896a1..209c4b8 100644
@@ -77,7 +77,7 @@ do {									\
 	___p1;								\
 })
 
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); mb(); } while (0)
+#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
 
 /*
  * The group barrier in front of the rsm & ssm are necessary to ensure
arch/powerpc/include/asm/barrier.h +1 -1
index 0eca6ef..a7af5fb 100644
@@ -34,7 +34,7 @@
 #define rmb()  __asm__ __volatile__ ("sync" : : : "memory")
 #define wmb()  __asm__ __volatile__ ("sync" : : : "memory")
 
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); mb(); } while (0)
+#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
 
 #ifdef __SUBARCH_HAS_LWSYNC
 #    define SMPWMB      LWSYNC
arch/s390/include/asm/barrier.h +1 -1
index d68e11e..7ffd0b1 100644
@@ -36,7 +36,7 @@
 #define smp_mb__before_atomic()		smp_mb()
 #define smp_mb__after_atomic()		smp_mb()
 
-#define smp_store_mb(var, value)		do { WRITE_ONCE(var, value); mb(); } while (0)
+#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
 
 #define smp_store_release(p, v)						\
 do {									\
include/asm-generic/barrier.h +1 -1
index b42afad..0f45f93 100644
@@ -93,7 +93,7 @@
 #endif	/* CONFIG_SMP */
 
 #ifndef smp_store_mb
-#define smp_store_mb(var, value)  do { WRITE_ONCE(var, value); mb(); } while (0)
+#define smp_store_mb(var, value)  do { WRITE_ONCE(var, value); smp_mb(); } while (0)
 #endif
 
 #ifndef smp_mb__before_atomic
Signature · 1 line
MST
author maintainer
#2 lore raw

PATCH v2 1/32 lcoking/barriers, arch: Use smp barriers in smp_store_release()

In reply to Michael S. Tsirkin

From: Davidlohr Bueso <[email protected]>

With commit b92b8b35a2e ("locking/arch: Rename set_mb() to smp_store_mb()") it was made clear that the context of this call (and thus set_mb) is strictly for CPU ordering, as opposed to IO. As such all archs should use the smp variant of mb(), respecting the semantics and saving a mandatory barrier on UP.

---
 arch/ia64/include/asm/barrier.h    | 2 +-
 arch/powerpc/include/asm/barrier.h | 2 +-
 arch/s390/include/asm/barrier.h    | 2 +-
 include/asm-generic/barrier.h      | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
arch/ia64/include/asm/barrier.h +1 -1
index df896a1..209c4b8 100644
@@ -77,7 +77,7 @@ do {									\
 	___p1;								\
 })
 
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); mb(); } while (0)
+#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
 
 /*
  * The group barrier in front of the rsm & ssm are necessary to ensure
arch/powerpc/include/asm/barrier.h +1 -1
index 0eca6ef..a7af5fb 100644
@@ -34,7 +34,7 @@
 #define rmb()  __asm__ __volatile__ ("sync" : : : "memory")
 #define wmb()  __asm__ __volatile__ ("sync" : : : "memory")
 
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); mb(); } while (0)
+#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
 
 #ifdef __SUBARCH_HAS_LWSYNC
 #    define SMPWMB      LWSYNC
arch/s390/include/asm/barrier.h +1 -1
index d68e11e..7ffd0b1 100644
@@ -36,7 +36,7 @@
 #define smp_mb__before_atomic()		smp_mb()
 #define smp_mb__after_atomic()		smp_mb()
 
-#define smp_store_mb(var, value)		do { WRITE_ONCE(var, value); mb(); } while (0)
+#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
 
 #define smp_store_release(p, v)						\
 do {									\
include/asm-generic/barrier.h +1 -1
index b42afad..0f45f93 100644
@@ -93,7 +93,7 @@
 #endif	/* CONFIG_SMP */
 
 #ifndef smp_store_mb
-#define smp_store_mb(var, value)  do { WRITE_ONCE(var, value); mb(); } while (0)
+#define smp_store_mb(var, value)  do { WRITE_ONCE(var, value); smp_mb(); } while (0)
 #endif
 
 #ifndef smp_mb__before_atomic
Signature · 1 line
MST
author maintainer
#3 lore raw

PATCH v2 2/32 asm-generic: guard smp_store_release/load_acquire

In reply to Michael S. Tsirkin

Allow architectures to override smp_store_release and smp_load_acquire by guarding the defines in asm-generic/barrier.h with ifndef directives.

This is in preparation to reusing asm-generic/barrier.h on architectures which have their own definition of these macros.

---
 include/asm-generic/barrier.h | 4 ++++
 1 file changed, 4 insertions(+)
include/asm-generic/barrier.h +4 -0
index 0f45f93..987b2e0 100644
@@ -104,13 +104,16 @@
 #define smp_mb__after_atomic()	smp_mb()
 #endif
 
+#ifndef smp_store_release
 #define smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	smp_mb();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
+#endif
 
+#ifndef smp_load_acquire
 #define smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
@@ -118,6 +121,7 @@ do {									\
 	smp_mb();							\
 	___p1;								\
 })
+#endif
 
 #endif /* !__ASSEMBLY__ */
 #endif /* __ASM_GENERIC_BARRIER_H */
Signature · 1 line
MST
author maintainer
#4 lore raw

PATCH v2 2/32 asm-generic: guard smp_store_release/load_acquire

In reply to Michael S. Tsirkin

Allow architectures to override smp_store_release and smp_load_acquire by guarding the defines in asm-generic/barrier.h with ifndef directives.

This is in preparation to reusing asm-generic/barrier.h on architectures which have their own definition of these macros.

---
 include/asm-generic/barrier.h | 4 ++++
 1 file changed, 4 insertions(+)
include/asm-generic/barrier.h +4 -0
index 0f45f93..987b2e0 100644
@@ -104,13 +104,16 @@
 #define smp_mb__after_atomic()	smp_mb()
 #endif
 
+#ifndef smp_store_release
 #define smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	smp_mb();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
+#endif
 
+#ifndef smp_load_acquire
 #define smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
@@ -118,6 +121,7 @@ do {									\
 	smp_mb();							\
 	___p1;								\
 })
+#endif
 
 #endif /* !__ASSEMBLY__ */
 #endif /* __ASM_GENERIC_BARRIER_H */
Signature · 1 line
MST
author maintainer
#5 lore raw

PATCH v2 3/32 ia64: rename nop->iosapic_nop

In reply to Michael S. Tsirkin

asm-generic/barrier.h defines a nop() macro. To be able to use this header on ia64, we shouldn't call local functions/variables nop().

There's one instance where this breaks on ia64:
rename the function to iosapic_nop to avoid the conflict.

---
 arch/ia64/kernel/iosapic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/ia64/kernel/iosapic.c +3 -3
index d2fae05..90fde5b 100644
@@ -256,7 +256,7 @@ set_rte (unsigned int gsi, unsigned int irq, unsigned int dest, int mask)
 }
 
 static void
-nop (struct irq_data *data)
+iosapic_nop (struct irq_data *data)
 {
 	/* do nothing... */
 }
@@ -415,7 +415,7 @@ iosapic_unmask_level_irq (struct irq_data *data)
 #define iosapic_shutdown_level_irq	mask_irq
 #define iosapic_enable_level_irq	unmask_irq
 #define iosapic_disable_level_irq	mask_irq
-#define iosapic_ack_level_irq		nop
+#define iosapic_ack_level_irq		iosapic_nop
 
 static struct irq_chip irq_type_iosapic_level = {
 	.name =			"IO-SAPIC-level",
@@ -453,7 +453,7 @@ iosapic_ack_edge_irq (struct irq_data *data)
 }
 
 #define iosapic_enable_edge_irq		unmask_irq
-#define iosapic_disable_edge_irq	nop
+#define iosapic_disable_edge_irq	iosapic_nop
 
 static struct irq_chip irq_type_iosapic_edge = {
 	.name =			"IO-SAPIC-edge",
Signature · 1 line
MST
author maintainer
#6 lore raw

PATCH v2 3/32 ia64: rename nop->iosapic_nop

In reply to Michael S. Tsirkin

asm-generic/barrier.h defines a nop() macro. To be able to use this header on ia64, we shouldn't call local functions/variables nop().

There's one instance where this breaks on ia64:
rename the function to iosapic_nop to avoid the conflict.

---
 arch/ia64/kernel/iosapic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/ia64/kernel/iosapic.c +3 -3
index d2fae05..90fde5b 100644
@@ -256,7 +256,7 @@ set_rte (unsigned int gsi, unsigned int irq, unsigned int dest, int mask)
 }
 
 static void
-nop (struct irq_data *data)
+iosapic_nop (struct irq_data *data)
 {
 	/* do nothing... */
 }
@@ -415,7 +415,7 @@ iosapic_unmask_level_irq (struct irq_data *data)
 #define iosapic_shutdown_level_irq	mask_irq
 #define iosapic_enable_level_irq	unmask_irq
 #define iosapic_disable_level_irq	mask_irq
-#define iosapic_ack_level_irq		nop
+#define iosapic_ack_level_irq		iosapic_nop
 
 static struct irq_chip irq_type_iosapic_level = {
 	.name =			"IO-SAPIC-level",
@@ -453,7 +453,7 @@ iosapic_ack_edge_irq (struct irq_data *data)
 }
 
 #define iosapic_enable_edge_irq		unmask_irq
-#define iosapic_disable_edge_irq	nop
+#define iosapic_disable_edge_irq	iosapic_nop
 
 static struct irq_chip irq_type_iosapic_edge = {
 	.name =			"IO-SAPIC-edge",
Signature · 1 line
MST
author maintainer
#7 lore raw

PATCH v2 3/32 ia64: rename nop->iosapic_nop

In reply to Michael S. Tsirkin

asm-generic/barrier.h defines a nop() macro. To be able to use this header on ia64, we shouldn't call local functions/variables nop().

There's one instance where this breaks on ia64:
rename the function to iosapic_nop to avoid the conflict.

---
 arch/ia64/kernel/iosapic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/ia64/kernel/iosapic.c +3 -3
index d2fae05..90fde5b 100644
@@ -256,7 +256,7 @@ set_rte (unsigned int gsi, unsigned int irq, unsigned int dest, int mask)
 }
 
 static void
-nop (struct irq_data *data)
+iosapic_nop (struct irq_data *data)
 {
 	/* do nothing... */
 }
@@ -415,7 +415,7 @@ iosapic_unmask_level_irq (struct irq_data *data)
 #define iosapic_shutdown_level_irq	mask_irq
 #define iosapic_enable_level_irq	unmask_irq
 #define iosapic_disable_level_irq	mask_irq
-#define iosapic_ack_level_irq		nop
+#define iosapic_ack_level_irq		iosapic_nop
 
 static struct irq_chip irq_type_iosapic_level = {
 	.name =			"IO-SAPIC-level",
@@ -453,7 +453,7 @@ iosapic_ack_edge_irq (struct irq_data *data)
 }
 
 #define iosapic_enable_edge_irq		unmask_irq
-#define iosapic_disable_edge_irq	nop
+#define iosapic_disable_edge_irq	iosapic_nop
 
 static struct irq_chip irq_type_iosapic_edge = {
 	.name =			"IO-SAPIC-edge",
Signature · 1 line
MST
author maintainer
#8 lore raw

PATCH v2 4/32 ia64: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On ia64 smp_rmb, smp_wmb, read_barrier_depends, smp_read_barrier_depends and smp_store_mb() match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/ia64/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/ia64/include/asm/barrier.h +2 -8
index 209c4b8..2f93348 100644
@@ -48,12 +48,6 @@
 # define smp_mb()	barrier()
 #endif
 
-#define smp_rmb()	smp_mb()
-#define smp_wmb()	smp_mb()
-
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
@@ -77,12 +71,12 @@ do {									\
 	___p1;								\
 })
 
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 /*
  * The group barrier in front of the rsm & ssm are necessary to ensure
  * that none of the previous instructions in the same group are
  * affected by the rsm/ssm.
  */
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_IA64_BARRIER_H */
Signature · 1 line
MST
author maintainer
#9 lore raw

PATCH v2 4/32 ia64: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On ia64 smp_rmb, smp_wmb, read_barrier_depends, smp_read_barrier_depends and smp_store_mb() match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/ia64/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/ia64/include/asm/barrier.h +2 -8
index 209c4b8..2f93348 100644
@@ -48,12 +48,6 @@
 # define smp_mb()	barrier()
 #endif
 
-#define smp_rmb()	smp_mb()
-#define smp_wmb()	smp_mb()
-
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
@@ -77,12 +71,12 @@ do {									\
 	___p1;								\
 })
 
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 /*
  * The group barrier in front of the rsm & ssm are necessary to ensure
  * that none of the previous instructions in the same group are
  * affected by the rsm/ssm.
  */
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_IA64_BARRIER_H */
Signature · 1 line
MST
author maintainer
#10 lore raw

PATCH v2 4/32 ia64: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On ia64 smp_rmb, smp_wmb, read_barrier_depends, smp_read_barrier_depends and smp_store_mb() match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/ia64/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/ia64/include/asm/barrier.h +2 -8
index 209c4b8..2f93348 100644
@@ -48,12 +48,6 @@
 # define smp_mb()	barrier()
 #endif
 
-#define smp_rmb()	smp_mb()
-#define smp_wmb()	smp_mb()
-
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
@@ -77,12 +71,12 @@ do {									\
 	___p1;								\
 })
 
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 /*
  * The group barrier in front of the rsm & ssm are necessary to ensure
  * that none of the previous instructions in the same group are
  * affected by the rsm/ssm.
  */
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_IA64_BARRIER_H */
Signature · 1 line
MST
author maintainer
#11 lore raw

PATCH v2 5/32 powerpc: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On powerpc read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/powerpc/include/asm/barrier.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/barrier.h +2 -7
index a7af5fb..980ad0c 100644
@@ -34,8 +34,6 @@
 #define rmb()  __asm__ __volatile__ ("sync" : : : "memory")
 #define wmb()  __asm__ __volatile__ ("sync" : : : "memory")
 
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 #ifdef __SUBARCH_HAS_LWSYNC
 #    define SMPWMB      LWSYNC
 #else
@@ -60,9 +58,6 @@
 #define smp_wmb()	barrier()
 #endif /* CONFIG_SMP */
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 /*
  * This is a barrier which prevents following instructions from being
  * started until the value of the argument x is known.  For example, if
@@ -87,8 +82,8 @@ do {									\
 	___p1;								\
 })
 
-#define smp_mb__before_atomic()     smp_mb()
-#define smp_mb__after_atomic()      smp_mb()
 #define smp_mb__before_spinlock()   smp_mb()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_POWERPC_BARRIER_H */
Signature · 1 line
MST
author maintainer
#12 lore raw

PATCH v2 5/32 powerpc: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On powerpc read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/powerpc/include/asm/barrier.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/barrier.h +2 -7
index a7af5fb..980ad0c 100644
@@ -34,8 +34,6 @@
 #define rmb()  __asm__ __volatile__ ("sync" : : : "memory")
 #define wmb()  __asm__ __volatile__ ("sync" : : : "memory")
 
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 #ifdef __SUBARCH_HAS_LWSYNC
 #    define SMPWMB      LWSYNC
 #else
@@ -60,9 +58,6 @@
 #define smp_wmb()	barrier()
 #endif /* CONFIG_SMP */
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 /*
  * This is a barrier which prevents following instructions from being
  * started until the value of the argument x is known.  For example, if
@@ -87,8 +82,8 @@ do {									\
 	___p1;								\
 })
 
-#define smp_mb__before_atomic()     smp_mb()
-#define smp_mb__after_atomic()      smp_mb()
 #define smp_mb__before_spinlock()   smp_mb()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_POWERPC_BARRIER_H */
Signature · 1 line
MST
author maintainer
#13 lore raw

PATCH v2 5/32 powerpc: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On powerpc read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/powerpc/include/asm/barrier.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/barrier.h +2 -7
index a7af5fb..980ad0c 100644
@@ -34,8 +34,6 @@
 #define rmb()  __asm__ __volatile__ ("sync" : : : "memory")
 #define wmb()  __asm__ __volatile__ ("sync" : : : "memory")
 
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 #ifdef __SUBARCH_HAS_LWSYNC
 #    define SMPWMB      LWSYNC
 #else
@@ -60,9 +58,6 @@
 #define smp_wmb()	barrier()
 #endif /* CONFIG_SMP */
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 /*
  * This is a barrier which prevents following instructions from being
  * started until the value of the argument x is known.  For example, if
@@ -87,8 +82,8 @@ do {									\
 	___p1;								\
 })
 
-#define smp_mb__before_atomic()     smp_mb()
-#define smp_mb__after_atomic()      smp_mb()
 #define smp_mb__before_spinlock()   smp_mb()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_POWERPC_BARRIER_H */
Signature · 1 line
MST
author maintainer
#14 lore raw

PATCH v2 6/32 s390: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +2 -8
index 7ffd0b1..c358c31 100644
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()
-
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 #define smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
@@ -53,4 +45,6 @@ do {									\
 	___p1;								\
 })
 
+#include <asm-generic/barrier.h>
+
 #endif /* __ASM_BARRIER_H */
Signature · 1 line
MST
maintainer
#15 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

lkml.kernel.org/r/20150921112252.3c2937e1@mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

#16 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

Quoted 30 lines · On Mon, 4 Jan 2016 14:20:42 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

Quoted 4 lines

lkml.kernel.org/r/20150921112252.3c2937e1@mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

Yes, we wanted to simplify this. Thanks for the reminder, I'll queue a patch.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
author maintainer
#17 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

Quoted 33 lines · Martin Schwidefsky
Quoted 30 lines · On Mon, 4 Jan 2016 14:20:42 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

Quoted 7 lines
Quoted 4 lines

lkml.kernel.org/r/20150921112252.3c2937e1 at mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

Yes, we wanted to simplify this. Thanks for the reminder, I'll queue a patch.

Could you base on my patchset maybe, to avoid conflicts, and I'll merge it?
Or if it's just replacing these 2 with barrier() I can do this myself easily.

Quoted 5 lines
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#18 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

Quoted 39 lines · On Mon, 4 Jan 2016 22:42:44 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 38 lines · Martin Schwidefsky
Quoted 34 lines · On Mon, 4 Jan 2016 14:20:42 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

lkml.kernel.org/r/20150921112252.3c2937e1@mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

Quoted 7 lines
Quoted 2 lines

Yes, we wanted to simplify this. Thanks for the reminder, I'll queue a patch.

Could you base on my patchset maybe, to avoid conflicts, and I'll merge it?
Or if it's just replacing these 2 with barrier() I can do this myself easily.

Probably the easiest solution if you do the patch yourself and include it in your patch set.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#19 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin
Quoted 39 lines · On Mon, 4 Jan 2016 22:42:44 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 38 lines · Martin Schwidefsky
Quoted 34 lines · On Mon, 4 Jan 2016 14:20:42 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

lkml.kernel.org/r/20150921112252.3c2937e1@mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

Quoted 7 lines
Quoted 2 lines

Yes, we wanted to simplify this. Thanks for the reminder, I'll queue a patch.

Could you base on my patchset maybe, to avoid conflicts, and I'll merge it?
Or if it's just replacing these 2 with barrier() I can do this myself easily.

Probably the easiest solution if you do the patch yourself and include it in your patch set.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
author maintainer
#20 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

In reply to Martin Schwidefsky
Quoted 33 lines · Martin Schwidefsky
Quoted 30 lines · On Mon, 4 Jan 2016 14:20:42 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

Quoted 7 lines
Quoted 4 lines

lkml.kernel.org/r/20150921112252.3c2937e1@mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

Yes, we wanted to simplify this. Thanks for the reminder, I'll queue a patch.

Could you base on my patchset maybe, to avoid conflicts, and I'll merge it?
Or if it's just replacing these 2 with barrier() I can do this myself easily.

Quoted 5 lines
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
author maintainer
#21 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

In reply to Martin Schwidefsky
Quoted 33 lines · Martin Schwidefsky
Quoted 30 lines · On Mon, 4 Jan 2016 14:20:42 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

Quoted 7 lines
Quoted 4 lines

lkml.kernel.org/r/20150921112252.3c2937e1@mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

Yes, we wanted to simplify this. Thanks for the reminder, I'll queue a patch.

Could you base on my patchset maybe, to avoid conflicts, and I'll merge it?
Or if it's just replacing these 2 with barrier() I can do this myself easily.

Quoted 5 lines
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#22 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

In reply to Peter Zijlstra
Quoted 30 lines · On Mon, 4 Jan 2016 14:20:42 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

Quoted 4 lines

lkml.kernel.org/r/20150921112252.3c2937e1@mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

Yes, we wanted to simplify this. Thanks for the reminder, I'll queue a patch.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
author maintainer
#23 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

In reply to Peter Zijlstra
Quoted 30 lines · Peter Zijlstra
Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

Quoted 4 lines

lkml.kernel.org/r/20150921112252.3c2937e1@mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

Thanks Peter!

OK so I will just rename this to __smp_mb__before_atomic and __smp_mb__after_atomic but keep them around.

I'm not changing these - that's best left to s390 maintainers.

Should I add a TODO comment to change them to barrier so we don't forget?

Signature · 1 line
MST
author maintainer
#24 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

In reply to Peter Zijlstra
Quoted 30 lines · Peter Zijlstra
Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

Quoted 4 lines

lkml.kernel.org/r/20150921112252.3c2937e1@mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

Thanks Peter!

OK so I will just rename this to __smp_mb__before_atomic and __smp_mb__after_atomic but keep them around.

I'm not changing these - that's best left to s390 maintainers.

Should I add a TODO comment to change them to barrier so we don't forget?

Signature · 1 line
MST
author maintainer
#25 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

In reply to Peter Zijlstra
Quoted 30 lines · Peter Zijlstra
Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

Quoted 4 lines

lkml.kernel.org/r/20150921112252.3c2937e1@mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

Thanks Peter!

OK so I will just rename this to __smp_mb__before_atomic and __smp_mb__after_atomic but keep them around.

I'm not changing these - that's best left to s390 maintainers.

Should I add a TODO comment to change them to barrier so we don't forget?

Signature · 1 line
MST
maintainer
#26 lore raw

Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin
Quoted 18 lines · Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +0 -0
index 7ffd0b1..c358c31 100644

arch/s390/include/asm/barrier.h line 37

Quoted 8 lines
arch/s390/include/asm/barrier.h +0 -5
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()

As per:

lkml.kernel.org/r/20150921112252.3c2937e1@mschwide

s390 should change this to barrier() instead of smp_mb() and hence should not use the generic versions.

author maintainer
#27 lore raw

PATCH v2 6/32 s390: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +2 -8
index 7ffd0b1..c358c31 100644
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()
-
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 #define smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
@@ -53,4 +45,6 @@ do {									\
 	___p1;								\
 })
 
+#include <asm-generic/barrier.h>
+
 #endif /* __ASM_BARRIER_H */
Signature · 1 line
MST
author maintainer
#28 lore raw

PATCH v2 6/32 s390: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On s390 read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/s390/include/asm/barrier.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/s390/include/asm/barrier.h +2 -8
index 7ffd0b1..c358c31 100644
@@ -30,14 +30,6 @@
 #define smp_rmb()			rmb()
 #define smp_wmb()			wmb()
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_mb__before_atomic()		smp_mb()
-#define smp_mb__after_atomic()		smp_mb()
-
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 #define smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
@@ -53,4 +45,6 @@ do {									\
 	___p1;								\
 })
 
+#include <asm-generic/barrier.h>
+
 #endif /* __ASM_BARRIER_H */
Signature · 1 line
MST
author maintainer
#29 lore raw

PATCH v2 7/32 sparc: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On sparc 64 bit dma_rmb, dma_wmb, smp_store_mb, smp_mb, smp_rmb, smp_wmb, read_barrier_depends and smp_read_barrier_depends match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

nop uses __asm__ __volatile but is otherwise identical to the generic version, drop that as well.

This is in preparation to refactoring this code area.

Note: nop() was in processor.h and not in barrier.h as on other architectures. Nothing seems to depend on it being there though.

---
 arch/sparc/include/asm/barrier_32.h |  1 -
 arch/sparc/include/asm/barrier_64.h | 21 ++-------------------
 arch/sparc/include/asm/processor.h  |  3 ---
 3 files changed, 2 insertions(+), 23 deletions(-)
arch/sparc/include/asm/barrier_32.h +0 -1
index ae69eda..8059130 100644
@@ -1,7 +1,6 @@
 #ifndef __SPARC_BARRIER_H
 #define __SPARC_BARRIER_H
 
-#include <asm/processor.h> /* for nop() */
 #include <asm-generic/barrier.h>
 
 #endif /* !(__SPARC_BARRIER_H) */
arch/sparc/include/asm/barrier_64.h +2 -19
index 14a9286..26c3f72 100644
@@ -37,25 +37,6 @@ do {	__asm__ __volatile__("ba,pt	%%xcc, 1f\n\t" \
 #define rmb()	__asm__ __volatile__("":::"memory")
 #define wmb()	__asm__ __volatile__("":::"memory")
 
-#define dma_rmb()	rmb()
-#define dma_wmb()	wmb()
-
-#define smp_store_mb(__var, __value) \
-	do { WRITE_ONCE(__var, __value); membar_safe("#StoreLoad"); } while(0)
-
-#ifdef CONFIG_SMP
-#define smp_mb()	mb()
-#define smp_rmb()	rmb()
-#define smp_wmb()	wmb()
-#else
-#define smp_mb()	__asm__ __volatile__("":::"memory")
-#define smp_rmb()	__asm__ __volatile__("":::"memory")
-#define smp_wmb()	__asm__ __volatile__("":::"memory")
-#endif
-
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 #define smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
@@ -74,4 +55,6 @@ do {									\
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* !(__SPARC64_BARRIER_H) */
arch/sparc/include/asm/processor.h +0 -3
index 2fe99e6..9da9646 100644
@@ -5,7 +5,4 @@
 #else
 #include <asm/processor_32.h>
 #endif
-
-#define nop() 		__asm__ __volatile__ ("nop")
-
 #endif
Signature · 1 line
MST
maintainer Acked-by on v2 7/32
#30 lore raw

Re: [PATCH v2 07/32] sparc: reuse asm-generic/barrier.h

From: "Michael S. Tsirkin" <[email protected]>
Date: Thu, 31 Dec 2015 21:06:38 +0200

Quoted 8 lines

On sparc 64 bit dma_rmb, dma_wmb, smp_store_mb, smp_mb, smp_rmb, smp_wmb, read_barrier_depends and smp_read_barrier_depends match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

nop uses __asm__ __volatile but is otherwise identical to the generic version, drop that as well.

Quoted 7 lines

This is in preparation to refactoring this code area.

Note: nop() was in processor.h and not in barrier.h as on other architectures. Nothing seems to depend on it being there though.

maintainer Acked-by on v2 7/32
#31 lore raw

Re: [PATCH v2 07/32] sparc: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

From: "Michael S. Tsirkin" <[email protected]>
Date: Thu, 31 Dec 2015 21:06:38 +0200

Quoted 8 lines

On sparc 64 bit dma_rmb, dma_wmb, smp_store_mb, smp_mb, smp_rmb, smp_wmb, read_barrier_depends and smp_read_barrier_depends match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

nop uses __asm__ __volatile but is otherwise identical to the generic version, drop that as well.

Quoted 7 lines

This is in preparation to refactoring this code area.

Note: nop() was in processor.h and not in barrier.h as on other architectures. Nothing seems to depend on it being there though.

maintainer Acked-by on v2 7/32
#32 lore raw

Re: [PATCH v2 07/32] sparc: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

From: "Michael S. Tsirkin" <[email protected]>
Date: Thu, 31 Dec 2015 21:06:38 +0200

Quoted 8 lines

On sparc 64 bit dma_rmb, dma_wmb, smp_store_mb, smp_mb, smp_rmb, smp_wmb, read_barrier_depends and smp_read_barrier_depends match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

nop uses __asm__ __volatile but is otherwise identical to the generic version, drop that as well.

Quoted 7 lines

This is in preparation to refactoring this code area.

Note: nop() was in processor.h and not in barrier.h as on other architectures. Nothing seems to depend on it being there though.

author maintainer
#33 lore raw

PATCH v2 7/32 sparc: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On sparc 64 bit dma_rmb, dma_wmb, smp_store_mb, smp_mb, smp_rmb, smp_wmb, read_barrier_depends and smp_read_barrier_depends match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

nop uses __asm__ __volatile but is otherwise identical to the generic version, drop that as well.

This is in preparation to refactoring this code area.

Note: nop() was in processor.h and not in barrier.h as on other architectures. Nothing seems to depend on it being there though.

---
 arch/sparc/include/asm/barrier_32.h |  1 -
 arch/sparc/include/asm/barrier_64.h | 21 ++-------------------
 arch/sparc/include/asm/processor.h  |  3 ---
 3 files changed, 2 insertions(+), 23 deletions(-)
arch/sparc/include/asm/barrier_32.h +0 -1
index ae69eda..8059130 100644
@@ -1,7 +1,6 @@
 #ifndef __SPARC_BARRIER_H
 #define __SPARC_BARRIER_H
 
-#include <asm/processor.h> /* for nop() */
 #include <asm-generic/barrier.h>
 
 #endif /* !(__SPARC_BARRIER_H) */
arch/sparc/include/asm/barrier_64.h +2 -19
index 14a9286..26c3f72 100644
@@ -37,25 +37,6 @@ do {	__asm__ __volatile__("ba,pt	%%xcc, 1f\n\t" \
 #define rmb()	__asm__ __volatile__("":::"memory")
 #define wmb()	__asm__ __volatile__("":::"memory")
 
-#define dma_rmb()	rmb()
-#define dma_wmb()	wmb()
-
-#define smp_store_mb(__var, __value) \
-	do { WRITE_ONCE(__var, __value); membar_safe("#StoreLoad"); } while(0)
-
-#ifdef CONFIG_SMP
-#define smp_mb()	mb()
-#define smp_rmb()	rmb()
-#define smp_wmb()	wmb()
-#else
-#define smp_mb()	__asm__ __volatile__("":::"memory")
-#define smp_rmb()	__asm__ __volatile__("":::"memory")
-#define smp_wmb()	__asm__ __volatile__("":::"memory")
-#endif
-
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 #define smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
@@ -74,4 +55,6 @@ do {									\
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* !(__SPARC64_BARRIER_H) */
arch/sparc/include/asm/processor.h +0 -3
index 2fe99e6..9da9646 100644
@@ -5,7 +5,4 @@
 #else
 #include <asm/processor_32.h>
 #endif
-
-#define nop() 		__asm__ __volatile__ ("nop")
-
 #endif
Signature · 1 line
MST
author maintainer
#34 lore raw

PATCH v2 7/32 sparc: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On sparc 64 bit dma_rmb, dma_wmb, smp_store_mb, smp_mb, smp_rmb, smp_wmb, read_barrier_depends and smp_read_barrier_depends match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

nop uses __asm__ __volatile but is otherwise identical to the generic version, drop that as well.

This is in preparation to refactoring this code area.

Note: nop() was in processor.h and not in barrier.h as on other architectures. Nothing seems to depend on it being there though.

---
 arch/sparc/include/asm/barrier_32.h |  1 -
 arch/sparc/include/asm/barrier_64.h | 21 ++-------------------
 arch/sparc/include/asm/processor.h  |  3 ---
 3 files changed, 2 insertions(+), 23 deletions(-)
arch/sparc/include/asm/barrier_32.h +0 -1
index ae69eda..8059130 100644
@@ -1,7 +1,6 @@
 #ifndef __SPARC_BARRIER_H
 #define __SPARC_BARRIER_H
 
-#include <asm/processor.h> /* for nop() */
 #include <asm-generic/barrier.h>
 
 #endif /* !(__SPARC_BARRIER_H) */
arch/sparc/include/asm/barrier_64.h +2 -19
index 14a9286..26c3f72 100644
@@ -37,25 +37,6 @@ do {	__asm__ __volatile__("ba,pt	%%xcc, 1f\n\t" \
 #define rmb()	__asm__ __volatile__("":::"memory")
 #define wmb()	__asm__ __volatile__("":::"memory")
 
-#define dma_rmb()	rmb()
-#define dma_wmb()	wmb()
-
-#define smp_store_mb(__var, __value) \
-	do { WRITE_ONCE(__var, __value); membar_safe("#StoreLoad"); } while(0)
-
-#ifdef CONFIG_SMP
-#define smp_mb()	mb()
-#define smp_rmb()	rmb()
-#define smp_wmb()	wmb()
-#else
-#define smp_mb()	__asm__ __volatile__("":::"memory")
-#define smp_rmb()	__asm__ __volatile__("":::"memory")
-#define smp_wmb()	__asm__ __volatile__("":::"memory")
-#endif
-
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 #define smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
@@ -74,4 +55,6 @@ do {									\
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* !(__SPARC64_BARRIER_H) */
arch/sparc/include/asm/processor.h +0 -3
index 2fe99e6..9da9646 100644
@@ -5,7 +5,4 @@
 #else
 #include <asm/processor_32.h>
 #endif
-
-#define nop() 		__asm__ __volatile__ ("nop")
-
 #endif
Signature · 1 line
MST
author maintainer
#35 lore raw

PATCH v2 8/32 arm: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On arm smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release, smp_load_acquire, smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/arm/include/asm/barrier.h | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)
arch/arm/include/asm/barrier.h +1 -22
index 3ff5642..31152e8 100644
@@ -70,28 +70,7 @@ extern void arm_heavy_mb(void);
 #define smp_wmb()	dmb(ishst)
 #endif
 
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
-#define read_barrier_depends()		do { } while(0)
-#define smp_read_barrier_depends()	do { } while(0)
-
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	smp_mb()
+#include <asm-generic/barrier.h>
 
 #endif /* !__ASSEMBLY__ */
 #endif /* __ASM_BARRIER_H */
Signature · 1 line
MST
Acked-by Russell King on v2 8/32
#36 lore raw

Re: [PATCH v2 08/32] arm: reuse asm-generic/barrier.h

Quoted 9 lines · Michael S. Tsirkin

On arm smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release, smp_load_acquire, smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

Thanks, the asm-generic versions looks identical to me, so this should result in no code generation difference.

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
Acked-by Russell King on v2 8/32
#37 lore raw

Re: [PATCH v2 08/32] arm: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin
Quoted 9 lines · Michael S. Tsirkin

On arm smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release, smp_load_acquire, smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

Thanks, the asm-generic versions looks identical to me, so this should result in no code generation difference.

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#38 lore raw

PATCH v2 8/32 arm: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On arm smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release, smp_load_acquire, smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/arm/include/asm/barrier.h | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)
arch/arm/include/asm/barrier.h +1 -22
index 3ff5642..31152e8 100644
@@ -70,28 +70,7 @@ extern void arm_heavy_mb(void);
 #define smp_wmb()	dmb(ishst)
 #endif
 
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
-#define read_barrier_depends()		do { } while(0)
-#define smp_read_barrier_depends()	do { } while(0)
-
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	smp_mb()
+#include <asm-generic/barrier.h>
 
 #endif /* !__ASSEMBLY__ */
 #endif /* __ASM_BARRIER_H */
Signature · 1 line
MST
author maintainer
#39 lore raw

PATCH v2 8/32 arm: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On arm smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release, smp_load_acquire, smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/arm/include/asm/barrier.h | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)
arch/arm/include/asm/barrier.h +1 -22
index 3ff5642..31152e8 100644
@@ -70,28 +70,7 @@ extern void arm_heavy_mb(void);
 #define smp_wmb()	dmb(ishst)
 #endif
 
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
-#define read_barrier_depends()		do { } while(0)
-#define smp_read_barrier_depends()	do { } while(0)
-
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	smp_mb()
+#include <asm-generic/barrier.h>
 
 #endif /* !__ASSEMBLY__ */
 #endif /* __ASM_BARRIER_H */
Signature · 1 line
MST
author maintainer
#40 lore raw

PATCH v2 9/32 arm64: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On arm64 nop, read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/arm64/include/asm/barrier.h | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
arch/arm64/include/asm/barrier.h +1 -8
index 9622eb4..91a43f4 100644
@@ -91,14 +91,7 @@ do {									\
 	__u.__val;							\
 })
 
-#define read_barrier_depends()		do { } while(0)
-#define smp_read_barrier_depends()	do { } while(0)
-
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-#define nop()		asm volatile("nop");
-
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	smp_mb()
+#include <asm-generic/barrier.h>
 
 #endif	/* __ASSEMBLY__ */
 
Signature · 1 line
MST
author maintainer
#41 lore raw

PATCH v2 9/32 arm64: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On arm64 nop, read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/arm64/include/asm/barrier.h | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
arch/arm64/include/asm/barrier.h +1 -8
index 9622eb4..91a43f4 100644
@@ -91,14 +91,7 @@ do {									\
 	__u.__val;							\
 })
 
-#define read_barrier_depends()		do { } while(0)
-#define smp_read_barrier_depends()	do { } while(0)
-
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-#define nop()		asm volatile("nop");
-
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	smp_mb()
+#include <asm-generic/barrier.h>
 
 #endif	/* __ASSEMBLY__ */
 
Signature · 1 line
MST
author maintainer
#42 lore raw

PATCH v2 9/32 arm64: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On arm64 nop, read_barrier_depends, smp_read_barrier_depends smp_store_mb(), smp_mb__before_atomic and smp_mb__after_atomic match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/arm64/include/asm/barrier.h | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
arch/arm64/include/asm/barrier.h +1 -8
index 9622eb4..91a43f4 100644
@@ -91,14 +91,7 @@ do {									\
 	__u.__val;							\
 })
 
-#define read_barrier_depends()		do { } while(0)
-#define smp_read_barrier_depends()	do { } while(0)
-
-#define smp_store_mb(var, value)	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-#define nop()		asm volatile("nop");
-
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	smp_mb()
+#include <asm-generic/barrier.h>
 
 #endif	/* __ASSEMBLY__ */
 
Signature · 1 line
MST
author maintainer
#43 lore raw

PATCH v2 10/32 metag: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On metag dma_rmb, dma_wmb, smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release and smp_load_acquire match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/metag/include/asm/barrier.h | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
arch/metag/include/asm/barrier.h +2 -23
index 172b7e5..b5b778b 100644
@@ -44,9 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#define dma_rmb()	rmb()
-#define dma_wmb()	wmb()
-
 #ifndef CONFIG_SMP
 #define fence()		do { } while (0)
 #define smp_mb()        barrier()
@@ -81,27 +78,9 @@ static inline void fence(void)
 #endif
 #endif
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_METAG_BARRIER_H */
Signature · 1 line
MST
Acked-by on v2 10/32
#44 lore raw

Re: [PATCH v2 10/32] metag: reuse asm-generic/barrier.h

Quoted 9 lines · Michael S. Tsirkin

On metag dma_rmb, dma_wmb, smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release and smp_load_acquire match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

Looks good, and confirmed no text change (once patch 1 is applied that is).

Thanks
James

Quoted 51 lines
---
 arch/metag/include/asm/barrier.h | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
arch/metag/include/asm/barrier.h +2 -23
index 172b7e5..b5b778b 100644
@@ -44,9 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#define dma_rmb()	rmb()
-#define dma_wmb()	wmb()
-
 #ifndef CONFIG_SMP
 #define fence()		do { } while (0)
 #define smp_mb()        barrier()
@@ -81,27 +78,9 @@ static inline void fence(void)
 #endif
 #endif
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_METAG_BARRIER_H */
Signature · 1 line
MST

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160104/fd33fa53/attachment.sig>

Acked-by on v2 10/32
#45 lore raw

Re: [PATCH v2 10/32] metag: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin
Quoted 9 lines · Michael S. Tsirkin

On metag dma_rmb, dma_wmb, smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release and smp_load_acquire match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

Looks good, and confirmed no text change (once patch 1 is applied that is).

Thanks
James

Quoted 51 lines
---
 arch/metag/include/asm/barrier.h | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
arch/metag/include/asm/barrier.h +2 -23
index 172b7e5..b5b778b 100644
@@ -44,9 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#define dma_rmb()	rmb()
-#define dma_wmb()	wmb()
-
 #ifndef CONFIG_SMP
 #define fence()		do { } while (0)
 #define smp_mb()        barrier()
@@ -81,27 +78,9 @@ static inline void fence(void)
 #endif
 #endif
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_METAG_BARRIER_H */
Signature · 1 line
MST

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Acked-by on v2 10/32
#46 lore raw

Re: [PATCH v2 10/32] metag: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin
Quoted 9 lines · Michael S. Tsirkin

On metag dma_rmb, dma_wmb, smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release and smp_load_acquire match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

Looks good, and confirmed no text change (once patch 1 is applied that is).

Thanks
James

Quoted 51 lines
---
 arch/metag/include/asm/barrier.h | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
arch/metag/include/asm/barrier.h +2 -23
index 172b7e5..b5b778b 100644
@@ -44,9 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#define dma_rmb()	rmb()
-#define dma_wmb()	wmb()
-
 #ifndef CONFIG_SMP
 #define fence()		do { } while (0)
 #define smp_mb()        barrier()
@@ -81,27 +78,9 @@ static inline void fence(void)
 #endif
 #endif
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_METAG_BARRIER_H */
Signature · 1 line
MST

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author maintainer
#47 lore raw

PATCH v2 10/32 metag: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On metag dma_rmb, dma_wmb, smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release and smp_load_acquire match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/metag/include/asm/barrier.h | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
arch/metag/include/asm/barrier.h +2 -23
index 172b7e5..b5b778b 100644
@@ -44,9 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#define dma_rmb()	rmb()
-#define dma_wmb()	wmb()
-
 #ifndef CONFIG_SMP
 #define fence()		do { } while (0)
 #define smp_mb()        barrier()
@@ -81,27 +78,9 @@ static inline void fence(void)
 #endif
 #endif
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_METAG_BARRIER_H */
Signature · 1 line
MST
author maintainer
#48 lore raw

PATCH v2 10/32 metag: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On metag dma_rmb, dma_wmb, smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release and smp_load_acquire match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/metag/include/asm/barrier.h | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
arch/metag/include/asm/barrier.h +2 -23
index 172b7e5..b5b778b 100644
@@ -44,9 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#define dma_rmb()	rmb()
-#define dma_wmb()	wmb()
-
 #ifndef CONFIG_SMP
 #define fence()		do { } while (0)
 #define smp_mb()        barrier()
@@ -81,27 +78,9 @@ static inline void fence(void)
 #endif
 #endif
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_METAG_BARRIER_H */
Signature · 1 line
MST
author maintainer
#49 lore raw

PATCH v2 11/32 mips: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On mips dma_rmb, dma_wmb, smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release and smp_load_acquire match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/mips/include/asm/barrier.h | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
arch/mips/include/asm/barrier.h +2 -23
index 752e0b8..3eac4b9 100644
@@ -10,9 +10,6 @@
 
 #include <asm/addrspace.h>
 
-#define read_barrier_depends()		do { } while(0)
-#define smp_read_barrier_depends()	do { } while(0)
-
 #ifdef CONFIG_CPU_HAS_SYNC
 #define __sync()				\
 	__asm__ __volatile__(			\
@@ -87,8 +84,6 @@
 
 #define wmb()		fast_wmb()
 #define rmb()		fast_rmb()
-#define dma_wmb()	fast_wmb()
-#define dma_rmb()	fast_rmb()
 
 #if defined(CONFIG_WEAK_ORDERING) && defined(CONFIG_SMP)
 # ifdef CONFIG_CPU_CAVIUM_OCTEON
@@ -112,9 +107,6 @@
 #define __WEAK_LLSC_MB		"		\n"
 #endif
 
-#define smp_store_mb(var, value) \
-	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 #define smp_llsc_mb()	__asm__ __volatile__(__WEAK_LLSC_MB : : :"memory")
 
 #ifdef CONFIG_CPU_CAVIUM_OCTEON
@@ -129,22 +121,9 @@
 #define nudge_writes() mb()
 #endif
 
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
 #define smp_mb__before_atomic()	smp_mb__before_llsc()
 #define smp_mb__after_atomic()	smp_llsc_mb()
 
+#include <asm-generic/barrier.h>
+
 #endif /* __ASM_BARRIER_H */
Signature · 1 line
MST
maintainer
#50 lore raw

Re: [PATCH v2 11/32] mips: reuse asm-generic/barrier.h

Quoted 4 lines · Michael S. Tsirkin
arch/mips/include/asm/barrier.h +0 -4
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\

arch/mips/include/asm/barrier.h line 145

Quoted 10 lines
arch/mips/include/asm/barrier.h +0 -10
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})

David Daney wanted to use fancy new MIPS barriers to provide better implementations of this.

This patch isn't in the way of that, just a FYI.

maintainer
#51 lore raw

Re: [PATCH v2 11/32] mips: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin
Quoted 4 lines · Michael S. Tsirkin
arch/mips/include/asm/barrier.h +0 -4
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\

arch/mips/include/asm/barrier.h line 145

Quoted 10 lines
arch/mips/include/asm/barrier.h +0 -10
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})

David Daney wanted to use fancy new MIPS barriers to provide better implementations of this.

This patch isn't in the way of that, just a FYI.

maintainer
#52 lore raw

Re: [PATCH v2 11/32] mips: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin
Quoted 4 lines · Michael S. Tsirkin
arch/mips/include/asm/barrier.h +0 -4
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\

arch/mips/include/asm/barrier.h line 145

Quoted 10 lines
arch/mips/include/asm/barrier.h +0 -10
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})

David Daney wanted to use fancy new MIPS barriers to provide better implementations of this.

This patch isn't in the way of that, just a FYI.

author maintainer
#53 lore raw

PATCH v2 11/32 mips: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On mips dma_rmb, dma_wmb, smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release and smp_load_acquire match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/mips/include/asm/barrier.h | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
arch/mips/include/asm/barrier.h +2 -23
index 752e0b8..3eac4b9 100644
@@ -10,9 +10,6 @@
 
 #include <asm/addrspace.h>
 
-#define read_barrier_depends()		do { } while(0)
-#define smp_read_barrier_depends()	do { } while(0)
-
 #ifdef CONFIG_CPU_HAS_SYNC
 #define __sync()				\
 	__asm__ __volatile__(			\
@@ -87,8 +84,6 @@
 
 #define wmb()		fast_wmb()
 #define rmb()		fast_rmb()
-#define dma_wmb()	fast_wmb()
-#define dma_rmb()	fast_rmb()
 
 #if defined(CONFIG_WEAK_ORDERING) && defined(CONFIG_SMP)
 # ifdef CONFIG_CPU_CAVIUM_OCTEON
@@ -112,9 +107,6 @@
 #define __WEAK_LLSC_MB		"		\n"
 #endif
 
-#define smp_store_mb(var, value) \
-	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 #define smp_llsc_mb()	__asm__ __volatile__(__WEAK_LLSC_MB : : :"memory")
 
 #ifdef CONFIG_CPU_CAVIUM_OCTEON
@@ -129,22 +121,9 @@
 #define nudge_writes() mb()
 #endif
 
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
 #define smp_mb__before_atomic()	smp_mb__before_llsc()
 #define smp_mb__after_atomic()	smp_llsc_mb()
 
+#include <asm-generic/barrier.h>
+
 #endif /* __ASM_BARRIER_H */
Signature · 1 line
MST
author maintainer
#54 lore raw

PATCH v2 11/32 mips: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On mips dma_rmb, dma_wmb, smp_store_mb, read_barrier_depends, smp_read_barrier_depends, smp_store_release and smp_load_acquire match the asm-generic variants exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/mips/include/asm/barrier.h | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
arch/mips/include/asm/barrier.h +2 -23
index 752e0b8..3eac4b9 100644
@@ -10,9 +10,6 @@
 
 #include <asm/addrspace.h>
 
-#define read_barrier_depends()		do { } while(0)
-#define smp_read_barrier_depends()	do { } while(0)
-
 #ifdef CONFIG_CPU_HAS_SYNC
 #define __sync()				\
 	__asm__ __volatile__(			\
@@ -87,8 +84,6 @@
 
 #define wmb()		fast_wmb()
 #define rmb()		fast_rmb()
-#define dma_wmb()	fast_wmb()
-#define dma_rmb()	fast_rmb()
 
 #if defined(CONFIG_WEAK_ORDERING) && defined(CONFIG_SMP)
 # ifdef CONFIG_CPU_CAVIUM_OCTEON
@@ -112,9 +107,6 @@
 #define __WEAK_LLSC_MB		"		\n"
 #endif
 
-#define smp_store_mb(var, value) \
-	do { WRITE_ONCE(var, value); smp_mb(); } while (0)
-
 #define smp_llsc_mb()	__asm__ __volatile__(__WEAK_LLSC_MB : : :"memory")
 
 #ifdef CONFIG_CPU_CAVIUM_OCTEON
@@ -129,22 +121,9 @@
 #define nudge_writes() mb()
 #endif
 
-#define smp_store_release(p, v)						\
-do {									\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	WRITE_ONCE(*p, v);						\
-} while (0)
-
-#define smp_load_acquire(p)						\
-({									\
-	typeof(*p) ___p1 = READ_ONCE(*p);				\
-	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
-	___p1;								\
-})
-
 #define smp_mb__before_atomic()	smp_mb__before_llsc()
 #define smp_mb__after_atomic()	smp_llsc_mb()
 
+#include <asm-generic/barrier.h>
+
 #endif /* __ASM_BARRIER_H */
Signature · 1 line
MST
author maintainer
#55 lore raw

PATCH v2 12/32 x86/um: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On x86/um CONFIG_SMP is never defined. As a result, several macros match the asm-generic variant exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/x86/um/asm/barrier.h | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
arch/x86/um/asm/barrier.h +1 -8
index 755481f..174781a 100644
@@ -36,13 +36,6 @@
 #endif /* CONFIG_X86_PPRO_FENCE */
 #define dma_wmb()	barrier()
 
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); barrier(); } while (0)
-
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
+#include <asm-generic/barrier.h>
 
 #endif
Signature · 1 line
MST
maintainer Acked-by on v2 12/32
#56 lore raw

Re: [PATCH v2 12/32] x86/um: reuse asm-generic/barrier.h

Am 31.12.2015 um 20:07 schrieb Michael S. Tsirkin:

Quoted 8 lines

On x86/um CONFIG_SMP is never defined. As a result, several macros match the asm-generic variant exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

Thanks,
//richard

maintainer Acked-by on v2 12/32
#57 lore raw

Re: [PATCH v2 12/32] x86/um: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

Am 31.12.2015 um 20:07 schrieb Michael S. Tsirkin:

Quoted 8 lines

On x86/um CONFIG_SMP is never defined. As a result, several macros match the asm-generic variant exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

Thanks,
//richard

maintainer Acked-by on v2 12/32
#58 lore raw

Re: [PATCH v2 12/32] x86/um: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

Am 31.12.2015 um 20:07 schrieb Michael S. Tsirkin:

Quoted 8 lines

On x86/um CONFIG_SMP is never defined. As a result, several macros match the asm-generic variant exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

Thanks,
//richard

author maintainer
#59 lore raw

PATCH v2 12/32 x86/um: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On x86/um CONFIG_SMP is never defined. As a result, several macros match the asm-generic variant exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/x86/um/asm/barrier.h | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
arch/x86/um/asm/barrier.h +1 -8
index 755481f..174781a 100644
@@ -36,13 +36,6 @@
 #endif /* CONFIG_X86_PPRO_FENCE */
 #define dma_wmb()	barrier()
 
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); barrier(); } while (0)
-
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
+#include <asm-generic/barrier.h>
 
 #endif
Signature · 1 line
MST
author maintainer
#60 lore raw

PATCH v2 12/32 x86/um: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

On x86/um CONFIG_SMP is never defined. As a result, several macros match the asm-generic variant exactly. Drop the local definitions and pull in asm-generic/barrier.h instead.

This is in preparation to refactoring this code area.

---
 arch/x86/um/asm/barrier.h | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
arch/x86/um/asm/barrier.h +1 -8
index 755481f..174781a 100644
@@ -36,13 +36,6 @@
 #endif /* CONFIG_X86_PPRO_FENCE */
 #define dma_wmb()	barrier()
 
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); barrier(); } while (0)
-
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
+#include <asm-generic/barrier.h>
 
 #endif
Signature · 1 line
MST
author maintainer
#61 lore raw

PATCH v2 13/32 x86: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

As on most architectures, on x86 read_barrier_depends and smp_read_barrier_depends are empty. Drop the local definitions and pull the generic ones from asm-generic/barrier.h instead: they are identical.

This is in preparation to refactoring this code area.

---
 arch/x86/include/asm/barrier.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/include/asm/barrier.h +2 -3
index 0681d25..cc4c2a7 100644
@@ -43,9 +43,6 @@
 #define smp_store_mb(var, value) do { WRITE_ONCE(var, value); barrier(); } while (0)
 #endif /* SMP */
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 #if defined(CONFIG_X86_PPRO_FENCE)
 
 /*
@@ -91,4 +88,6 @@ do {									\
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_X86_BARRIER_H */
Signature · 1 line
MST
author maintainer
#62 lore raw

PATCH v2 13/32 x86: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

As on most architectures, on x86 read_barrier_depends and smp_read_barrier_depends are empty. Drop the local definitions and pull the generic ones from asm-generic/barrier.h instead: they are identical.

This is in preparation to refactoring this code area.

---
 arch/x86/include/asm/barrier.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/include/asm/barrier.h +2 -3
index 0681d25..cc4c2a7 100644
@@ -43,9 +43,6 @@
 #define smp_store_mb(var, value) do { WRITE_ONCE(var, value); barrier(); } while (0)
 #endif /* SMP */
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 #if defined(CONFIG_X86_PPRO_FENCE)
 
 /*
@@ -91,4 +88,6 @@ do {									\
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_X86_BARRIER_H */
Signature · 1 line
MST
author maintainer
#63 lore raw

PATCH v2 13/32 x86: reuse asm-generic/barrier.h

In reply to Michael S. Tsirkin

As on most architectures, on x86 read_barrier_depends and smp_read_barrier_depends are empty. Drop the local definitions and pull the generic ones from asm-generic/barrier.h instead: they are identical.

This is in preparation to refactoring this code area.

---
 arch/x86/include/asm/barrier.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/include/asm/barrier.h +2 -3
index 0681d25..cc4c2a7 100644
@@ -43,9 +43,6 @@
 #define smp_store_mb(var, value) do { WRITE_ONCE(var, value); barrier(); } while (0)
 #endif /* SMP */
 
-#define read_barrier_depends()		do { } while (0)
-#define smp_read_barrier_depends()	do { } while (0)
-
 #if defined(CONFIG_X86_PPRO_FENCE)
 
 /*
@@ -91,4 +88,6 @@ do {									\
 #define smp_mb__before_atomic()	barrier()
 #define smp_mb__after_atomic()	barrier()
 
+#include <asm-generic/barrier.h>
+
 #endif /* _ASM_X86_BARRIER_H */
Signature · 1 line
MST
author maintainer
#64 lore raw

PATCH v2 14/32 asm-generic: add __smp_xxx wrappers

In reply to Michael S. Tsirkin

On !SMP, most architectures define their
barriers as compiler barriers.
On SMP, most need an actual barrier.

Make it possible to remove the code duplication for !SMP by defining low-level __smp_xxx barriers which do not depend on the value of SMP, then use them from asm-generic conditionally.

Besides reducing code duplication, these low level APIs will also be useful for virtualization, where a barrier is sometimes needed even if !SMP since we might be talking to another kernel on the same SMP system.

Both virtio and Xen drivers will benefit.

The smp_xxx variants should use __smp_XXX ones or barrier() depending on SMP, identically for all architectures.

We keep ifndef guards around them for now - once/if all architectures are converted to use the generic code, we'll be able to remove these.

---
 include/asm-generic/barrier.h | 91 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 82 insertions(+), 9 deletions(-)
include/asm-generic/barrier.h +82 -9
index 987b2e0..8752964 100644
@@ -54,22 +54,38 @@
 #define read_barrier_depends()		do { } while (0)
 #endif
 
+#ifndef __smp_mb
+#define __smp_mb()	mb()
+#endif
+
+#ifndef __smp_rmb
+#define __smp_rmb()	rmb()
+#endif
+
+#ifndef __smp_wmb
+#define __smp_wmb()	wmb()
+#endif
+
+#ifndef __smp_read_barrier_depends
+#define __smp_read_barrier_depends()	read_barrier_depends()
+#endif
+
 #ifdef CONFIG_SMP
 
 #ifndef smp_mb
-#define smp_mb()	mb()
+#define smp_mb()	__smp_mb()
 #endif
 
 #ifndef smp_rmb
-#define smp_rmb()	rmb()
+#define smp_rmb()	__smp_rmb()
 #endif
 
 #ifndef smp_wmb
-#define smp_wmb()	wmb()
+#define smp_wmb()	__smp_wmb()
 #endif
 
 #ifndef smp_read_barrier_depends
-#define smp_read_barrier_depends()	read_barrier_depends()
+#define smp_read_barrier_depends()	__smp_read_barrier_depends()
 #endif
 
 #else	/* !CONFIG_SMP */
@@ -92,23 +108,78 @@
 
 #endif	/* CONFIG_SMP */
 
+#ifndef __smp_store_mb
+#define __smp_store_mb(var, value)  do { WRITE_ONCE(var, value); __smp_mb(); } while (0)
+#endif
+
+#ifndef __smp_mb__before_atomic
+#define __smp_mb__before_atomic()	__smp_mb()
+#endif
+
+#ifndef __smp_mb__after_atomic
+#define __smp_mb__after_atomic()	__smp_mb()
+#endif
+
+#ifndef __smp_store_release
+#define __smp_store_release(p, v)					\
+do {									\
+	compiletime_assert_atomic_type(*p);				\
+	__smp_mb();							\
+	WRITE_ONCE(*p, v);						\
+} while (0)
+#endif
+
+#ifndef __smp_load_acquire
+#define __smp_load_acquire(p)						\
+({									\
+	typeof(*p) ___p1 = READ_ONCE(*p);				\
+	compiletime_assert_atomic_type(*p);				\
+	__smp_mb();							\
+	___p1;								\
+})
+#endif
+
+#ifdef CONFIG_SMP
+
+#ifndef smp_store_mb
+#define smp_store_mb(var, value)  __smp_store_mb(var, value)
+#endif
+
+#ifndef smp_mb__before_atomic
+#define smp_mb__before_atomic()	__smp_mb__before_atomic()
+#endif
+
+#ifndef smp_mb__after_atomic
+#define smp_mb__after_atomic()	__smp_mb__after_atomic()
+#endif
+
+#ifndef smp_store_release
+#define smp_store_release(p, v) __smp_store_release(p, v)
+#endif
+
+#ifndef smp_load_acquire
+#define smp_load_acquire(p) __smp_load_acquire(p)
+#endif
+
+#else	/* !CONFIG_SMP */
+
 #ifndef smp_store_mb
-#define smp_store_mb(var, value)  do { WRITE_ONCE(var, value); smp_mb(); } while (0)
+#define smp_store_mb(var, value)  do { WRITE_ONCE(var, value); barrier(); } while (0)
 #endif
 
 #ifndef smp_mb__before_atomic
-#define smp_mb__before_atomic()	smp_mb()
+#define smp_mb__before_atomic()	barrier()
 #endif
 
 #ifndef smp_mb__after_atomic
-#define smp_mb__after_atomic()	smp_mb()
+#define smp_mb__after_atomic()	barrier()
 #endif
 
 #ifndef smp_store_release
 #define smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 #endif
@@ -118,10 +189,12 @@ do {									\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	barrier();							\
 	___p1;								\
 })
 #endif
 
+#endif
+
 #endif /* !__ASSEMBLY__ */
 #endif /* __ASM_GENERIC_BARRIER_H */
Signature · 1 line
MST
author maintainer
#65 lore raw

PATCH v2 14/32 asm-generic: add __smp_xxx wrappers

In reply to Michael S. Tsirkin

On !SMP, most architectures define their
barriers as compiler barriers.
On SMP, most need an actual barrier.

Make it possible to remove the code duplication for !SMP by defining low-level __smp_xxx barriers which do not depend on the value of SMP, then use them from asm-generic conditionally.

Besides reducing code duplication, these low level APIs will also be useful for virtualization, where a barrier is sometimes needed even if !SMP since we might be talking to another kernel on the same SMP system.

Both virtio and Xen drivers will benefit.

The smp_xxx variants should use __smp_XXX ones or barrier() depending on SMP, identically for all architectures.

We keep ifndef guards around them for now - once/if all architectures are converted to use the generic code, we'll be able to remove these.

---
 include/asm-generic/barrier.h | 91 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 82 insertions(+), 9 deletions(-)
include/asm-generic/barrier.h +82 -9
index 987b2e0..8752964 100644
@@ -54,22 +54,38 @@
 #define read_barrier_depends()		do { } while (0)
 #endif
 
+#ifndef __smp_mb
+#define __smp_mb()	mb()
+#endif
+
+#ifndef __smp_rmb
+#define __smp_rmb()	rmb()
+#endif
+
+#ifndef __smp_wmb
+#define __smp_wmb()	wmb()
+#endif
+
+#ifndef __smp_read_barrier_depends
+#define __smp_read_barrier_depends()	read_barrier_depends()
+#endif
+
 #ifdef CONFIG_SMP
 
 #ifndef smp_mb
-#define smp_mb()	mb()
+#define smp_mb()	__smp_mb()
 #endif
 
 #ifndef smp_rmb
-#define smp_rmb()	rmb()
+#define smp_rmb()	__smp_rmb()
 #endif
 
 #ifndef smp_wmb
-#define smp_wmb()	wmb()
+#define smp_wmb()	__smp_wmb()
 #endif
 
 #ifndef smp_read_barrier_depends
-#define smp_read_barrier_depends()	read_barrier_depends()
+#define smp_read_barrier_depends()	__smp_read_barrier_depends()
 #endif
 
 #else	/* !CONFIG_SMP */
@@ -92,23 +108,78 @@
 
 #endif	/* CONFIG_SMP */
 
+#ifndef __smp_store_mb
+#define __smp_store_mb(var, value)  do { WRITE_ONCE(var, value); __smp_mb(); } while (0)
+#endif
+
+#ifndef __smp_mb__before_atomic
+#define __smp_mb__before_atomic()	__smp_mb()
+#endif
+
+#ifndef __smp_mb__after_atomic
+#define __smp_mb__after_atomic()	__smp_mb()
+#endif
+
+#ifndef __smp_store_release
+#define __smp_store_release(p, v)					\
+do {									\
+	compiletime_assert_atomic_type(*p);				\
+	__smp_mb();							\
+	WRITE_ONCE(*p, v);						\
+} while (0)
+#endif
+
+#ifndef __smp_load_acquire
+#define __smp_load_acquire(p)						\
+({									\
+	typeof(*p) ___p1 = READ_ONCE(*p);				\
+	compiletime_assert_atomic_type(*p);				\
+	__smp_mb();							\
+	___p1;								\
+})
+#endif
+
+#ifdef CONFIG_SMP
+
+#ifndef smp_store_mb
+#define smp_store_mb(var, value)  __smp_store_mb(var, value)
+#endif
+
+#ifndef smp_mb__before_atomic
+#define smp_mb__before_atomic()	__smp_mb__before_atomic()
+#endif
+
+#ifndef smp_mb__after_atomic
+#define smp_mb__after_atomic()	__smp_mb__after_atomic()
+#endif
+
+#ifndef smp_store_release
+#define smp_store_release(p, v) __smp_store_release(p, v)
+#endif
+
+#ifndef smp_load_acquire
+#define smp_load_acquire(p) __smp_load_acquire(p)
+#endif
+
+#else	/* !CONFIG_SMP */
+
 #ifndef smp_store_mb
-#define smp_store_mb(var, value)  do { WRITE_ONCE(var, value); smp_mb(); } while (0)
+#define smp_store_mb(var, value)  do { WRITE_ONCE(var, value); barrier(); } while (0)
 #endif
 
 #ifndef smp_mb__before_atomic
-#define smp_mb__before_atomic()	smp_mb()
+#define smp_mb__before_atomic()	barrier()
 #endif
 
 #ifndef smp_mb__after_atomic
-#define smp_mb__after_atomic()	smp_mb()
+#define smp_mb__after_atomic()	barrier()
 #endif
 
 #ifndef smp_store_release
 #define smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 #endif
@@ -118,10 +189,12 @@ do {									\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	barrier();							\
 	___p1;								\
 })
 #endif
 
+#endif
+
 #endif /* !__ASSEMBLY__ */
 #endif /* __ASM_GENERIC_BARRIER_H */
Signature · 1 line
MST
author maintainer
#66 lore raw

PATCH v2 14/32 asm-generic: add __smp_xxx wrappers

In reply to Michael S. Tsirkin

On !SMP, most architectures define their
barriers as compiler barriers.
On SMP, most need an actual barrier.

Make it possible to remove the code duplication for !SMP by defining low-level __smp_xxx barriers which do not depend on the value of SMP, then use them from asm-generic conditionally.

Besides reducing code duplication, these low level APIs will also be useful for virtualization, where a barrier is sometimes needed even if !SMP since we might be talking to another kernel on the same SMP system.

Both virtio and Xen drivers will benefit.

The smp_xxx variants should use __smp_XXX ones or barrier() depending on SMP, identically for all architectures.

We keep ifndef guards around them for now - once/if all architectures are converted to use the generic code, we'll be able to remove these.

---
 include/asm-generic/barrier.h | 91 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 82 insertions(+), 9 deletions(-)
include/asm-generic/barrier.h +82 -9
index 987b2e0..8752964 100644
@@ -54,22 +54,38 @@
 #define read_barrier_depends()		do { } while (0)
 #endif
 
+#ifndef __smp_mb
+#define __smp_mb()	mb()
+#endif
+
+#ifndef __smp_rmb
+#define __smp_rmb()	rmb()
+#endif
+
+#ifndef __smp_wmb
+#define __smp_wmb()	wmb()
+#endif
+
+#ifndef __smp_read_barrier_depends
+#define __smp_read_barrier_depends()	read_barrier_depends()
+#endif
+
 #ifdef CONFIG_SMP
 
 #ifndef smp_mb
-#define smp_mb()	mb()
+#define smp_mb()	__smp_mb()
 #endif
 
 #ifndef smp_rmb
-#define smp_rmb()	rmb()
+#define smp_rmb()	__smp_rmb()
 #endif
 
 #ifndef smp_wmb
-#define smp_wmb()	wmb()
+#define smp_wmb()	__smp_wmb()
 #endif
 
 #ifndef smp_read_barrier_depends
-#define smp_read_barrier_depends()	read_barrier_depends()
+#define smp_read_barrier_depends()	__smp_read_barrier_depends()
 #endif
 
 #else	/* !CONFIG_SMP */
@@ -92,23 +108,78 @@
 
 #endif	/* CONFIG_SMP */
 
+#ifndef __smp_store_mb
+#define __smp_store_mb(var, value)  do { WRITE_ONCE(var, value); __smp_mb(); } while (0)
+#endif
+
+#ifndef __smp_mb__before_atomic
+#define __smp_mb__before_atomic()	__smp_mb()
+#endif
+
+#ifndef __smp_mb__after_atomic
+#define __smp_mb__after_atomic()	__smp_mb()
+#endif
+
+#ifndef __smp_store_release
+#define __smp_store_release(p, v)					\
+do {									\
+	compiletime_assert_atomic_type(*p);				\
+	__smp_mb();							\
+	WRITE_ONCE(*p, v);						\
+} while (0)
+#endif
+
+#ifndef __smp_load_acquire
+#define __smp_load_acquire(p)						\
+({									\
+	typeof(*p) ___p1 = READ_ONCE(*p);				\
+	compiletime_assert_atomic_type(*p);				\
+	__smp_mb();							\
+	___p1;								\
+})
+#endif
+
+#ifdef CONFIG_SMP
+
+#ifndef smp_store_mb
+#define smp_store_mb(var, value)  __smp_store_mb(var, value)
+#endif
+
+#ifndef smp_mb__before_atomic
+#define smp_mb__before_atomic()	__smp_mb__before_atomic()
+#endif
+
+#ifndef smp_mb__after_atomic
+#define smp_mb__after_atomic()	__smp_mb__after_atomic()
+#endif
+
+#ifndef smp_store_release
+#define smp_store_release(p, v) __smp_store_release(p, v)
+#endif
+
+#ifndef smp_load_acquire
+#define smp_load_acquire(p) __smp_load_acquire(p)
+#endif
+
+#else	/* !CONFIG_SMP */
+
 #ifndef smp_store_mb
-#define smp_store_mb(var, value)  do { WRITE_ONCE(var, value); smp_mb(); } while (0)
+#define smp_store_mb(var, value)  do { WRITE_ONCE(var, value); barrier(); } while (0)
 #endif
 
 #ifndef smp_mb__before_atomic
-#define smp_mb__before_atomic()	smp_mb()
+#define smp_mb__before_atomic()	barrier()
 #endif
 
 #ifndef smp_mb__after_atomic
-#define smp_mb__after_atomic()	smp_mb()
+#define smp_mb__after_atomic()	barrier()
 #endif
 
 #ifndef smp_store_release
 #define smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 #endif
@@ -118,10 +189,12 @@ do {									\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	barrier();							\
 	___p1;								\
 })
 #endif
 
+#endif
+
 #endif /* !__ASSEMBLY__ */
 #endif /* __ASM_GENERIC_BARRIER_H */
Signature · 1 line
MST
author maintainer
#67 lore raw

PATCH v2 15/32 powerpc: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +8 -16
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 1 line
MST
#68 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

Hi Michael,

Quoted 19 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644

arch/powerpc/include/asm/barrier.h line 48

Quoted 7 lines
arch/powerpc/include/asm/barrier.h +1 -2
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Quoted 17 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being

arch/powerpc/include/asm/barrier.h line 65

Quoted 9 lines
arch/powerpc/include/asm/barrier.h +2 -2
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Regards,
Boqun

Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author maintainer
#69 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

Quoted 8 lines · Boqun Feng

Hi Michael,

Quoted 5 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

I think this is the part that was missed in review.

Quoted 16 lines
Quoted 16 lines

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
Quoted 6 lines

arch/powerpc/include/asm/barrier.h line 48

Quoted 4 lines
arch/powerpc/include/asm/barrier.h +1 -2
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Yes.

Quoted 20 lines
Quoted 20 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
Quoted 8 lines

arch/powerpc/include/asm/barrier.h line 65

Quoted 6 lines
arch/powerpc/include/asm/barrier.h +2 -2
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Absolutely. But smp_store_release (without __) will not.

Please note I did test this: for ppc code before and after this patch generates exactly the same binary on SMP and UP.

Quoted 5 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

Quoted 7 lines

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Regards,
Boqun

I think you missed the leading ___ :)

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync but why do this? Still, if you prefer it this way,
please let me know.

Quoted 21 lines
Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#70 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

Quoted 12 lines · Michael S. Tsirkin
Quoted 8 lines · Boqun Feng

Hi Michael,

Quoted 5 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

I think this is the part that was missed in review.

Yes, I realized my mistake after reread the series. But smp_lwsync() is not defined in asm-generic/barriers.h, right?

Quoted 54 lines
Quoted 16 lines
Quoted 16 lines

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
Quoted 6 lines

arch/powerpc/include/asm/barrier.h line 48

Quoted 4 lines
arch/powerpc/include/asm/barrier.h +1 -2
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Yes.

Quoted 20 lines
Quoted 20 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
Quoted 8 lines

arch/powerpc/include/asm/barrier.h line 65

Quoted 6 lines
arch/powerpc/include/asm/barrier.h +2 -2
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Quoted 5 lines

Absolutely. But smp_store_release (without __) will not.

Please note I did test this: for ppc code before and after this patch generates exactly the same binary on SMP and UP.

Yes, you're right, sorry for my mistake...

Quoted 11 lines
Quoted 11 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author maintainer
#71 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

Quoted 8 lines · Boqun Feng
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Boqun Feng

Hi Michael,

Quoted 3 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

I think this is the part that was missed in review.

Yes, I realized my mistake after reread the series. But smp_lwsync() is not defined in asm-generic/barriers.h, right?

It isn't because as far as I could tell it is not used outside arch/powerpc/include/asm/barrier.h smp_store_release and smp_load_acquire.

And these are now gone.

Instead there are __smp_store_release and __smp_load_acquire which call __smp_lwsync.
These are only used for virt and on SMP.
UP variants are generic - they just call barrier().

Quoted 95 lines
Quoted 54 lines
Quoted 16 lines
Quoted 16 lines

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
Quoted 6 lines

arch/powerpc/include/asm/barrier.h line 48

Quoted 4 lines
arch/powerpc/include/asm/barrier.h +1 -2
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Yes.

Quoted 20 lines
Quoted 20 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
Quoted 8 lines

arch/powerpc/include/asm/barrier.h line 65

Quoted 6 lines
arch/powerpc/include/asm/barrier.h +2 -2
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Quoted 5 lines

Absolutely. But smp_store_release (without __) will not.

Please note I did test this: for ppc code before and after this patch generates exactly the same binary on SMP and UP.

Yes, you're right, sorry for my mistake...

Quoted 11 lines
Quoted 11 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

Quoted 5 lines

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#72 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

On Tue, Jan 05, 2016 at 06:16:48PM +0200, Michael S. Tsirkin wrote:
[snip]

Quoted 38 lines
Quoted 32 lines
Quoted 10 lines
Quoted 10 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

Quoted 5 lines

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Quoted 9 lines

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Because in a patchset which implements atomic relaxed/acquire/release variants on PPC I use smp_lwsync(), this makes it have another user, please see this mail:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

in definition of PPC's __atomic_op_release().

But I think removing smp_lwsync() is a good idea and actually I think we can go further to remove __smp_lwsync() and let __smp_load_acquire and __smp_store_release call __lwsync() directly, but that is another thing.

Anyway, I will modify my patch.

Regards,
Boqun

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
Signature · 8 lines
-- 
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author maintainer
#73 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

Quoted 59 lines · Boqun Feng

On Tue, Jan 05, 2016 at 06:16:48PM +0200, Michael S. Tsirkin wrote:
[snip]

Quoted 38 lines
Quoted 32 lines
Quoted 10 lines
Quoted 10 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

Quoted 5 lines

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Quoted 9 lines

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Because in a patchset which implements atomic relaxed/acquire/release variants on PPC I use smp_lwsync(), this makes it have another user, please see this mail:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

in definition of PPC's __atomic_op_release().

Quoted 8 lines

But I think removing smp_lwsync() is a good idea and actually I think we can go further to remove __smp_lwsync() and let __smp_load_acquire and __smp_store_release call __lwsync() directly, but that is another thing.

Anyway, I will modify my patch.

Regards,
Boqun

Thanks!
Could you send an ack then please?

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
Signature · 8 lines
-- 
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Acked-by
#74 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

On Wed, Jan 06, 2016 at 10:23:51PM +0200, Michael S. Tsirkin wrote:
[...]

Quoted 24 lines
Quoted 24 lines
Quoted 10 lines

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Because in a patchset which implements atomic relaxed/acquire/release variants on PPC I use smp_lwsync(), this makes it have another user, please see this mail:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

in definition of PPC's __atomic_op_release().

But I think removing smp_lwsync() is a good idea and actually I think we can go further to remove __smp_lwsync() and let __smp_load_acquire and __smp_store_release call __lwsync() directly, but that is another thing.

Quoted 9 lines
Quoted 4 lines

Anyway, I will modify my patch.

Regards,
Boqun

Thanks!
Could you send an ack then please?

Sure, if you need one from me, feel free to add my ack for this patch:

Regards,
Boqun

Acked-by
#75 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Michael S. Tsirkin

On Wed, Jan 06, 2016 at 10:23:51PM +0200, Michael S. Tsirkin wrote:
[...]

Quoted 24 lines
Quoted 24 lines
Quoted 10 lines

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Because in a patchset which implements atomic relaxed/acquire/release variants on PPC I use smp_lwsync(), this makes it have another user, please see this mail:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

in definition of PPC's __atomic_op_release().

But I think removing smp_lwsync() is a good idea and actually I think we can go further to remove __smp_lwsync() and let __smp_load_acquire and __smp_store_release call __lwsync() directly, but that is another thing.

Quoted 9 lines
Quoted 4 lines

Anyway, I will modify my patch.

Regards,
Boqun

Thanks!
Could you send an ack then please?

Sure, if you need one from me, feel free to add my ack for this patch:

Regards,
Boqun

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Acked-by
#76 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Michael S. Tsirkin

On Wed, Jan 06, 2016 at 10:23:51PM +0200, Michael S. Tsirkin wrote:
[...]

Quoted 24 lines
Quoted 24 lines
Quoted 10 lines

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Because in a patchset which implements atomic relaxed/acquire/release variants on PPC I use smp_lwsync(), this makes it have another user, please see this mail:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

in definition of PPC's __atomic_op_release().

But I think removing smp_lwsync() is a good idea and actually I think we can go further to remove __smp_lwsync() and let __smp_load_acquire and __smp_store_release call __lwsync() directly, but that is another thing.

Quoted 9 lines
Quoted 4 lines

Anyway, I will modify my patch.

Regards,
Boqun

Thanks!
Could you send an ack then please?

Sure, if you need one from me, feel free to add my ack for this patch:

Regards,
Boqun

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author maintainer
#77 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Boqun Feng
Quoted 59 lines · Boqun Feng

On Tue, Jan 05, 2016 at 06:16:48PM +0200, Michael S. Tsirkin wrote:
[snip]

Quoted 38 lines
Quoted 32 lines
Quoted 10 lines
Quoted 10 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

Quoted 5 lines

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Quoted 9 lines

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Because in a patchset which implements atomic relaxed/acquire/release variants on PPC I use smp_lwsync(), this makes it have another user, please see this mail:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

in definition of PPC's __atomic_op_release().

Quoted 8 lines

But I think removing smp_lwsync() is a good idea and actually I think we can go further to remove __smp_lwsync() and let __smp_load_acquire and __smp_store_release call __lwsync() directly, but that is another thing.

Anyway, I will modify my patch.

Regards,
Boqun

Thanks!
Could you send an ack then please?

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
Signature · 8 lines
-- 
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author maintainer
#78 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Boqun Feng
Quoted 59 lines · Boqun Feng

On Tue, Jan 05, 2016 at 06:16:48PM +0200, Michael S. Tsirkin wrote:
[snip]

Quoted 38 lines
Quoted 32 lines
Quoted 10 lines
Quoted 10 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

Quoted 5 lines

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Quoted 9 lines

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Because in a patchset which implements atomic relaxed/acquire/release variants on PPC I use smp_lwsync(), this makes it have another user, please see this mail:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

in definition of PPC's __atomic_op_release().

Quoted 8 lines

But I think removing smp_lwsync() is a good idea and actually I think we can go further to remove __smp_lwsync() and let __smp_load_acquire and __smp_store_release call __lwsync() directly, but that is another thing.

Anyway, I will modify my patch.

Regards,
Boqun

Thanks!
Could you send an ack then please?

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
Signature · 8 lines
-- 
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#79 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Michael S. Tsirkin

On Tue, Jan 05, 2016 at 06:16:48PM +0200, Michael S. Tsirkin wrote:
[snip]

Quoted 38 lines
Quoted 32 lines
Quoted 10 lines
Quoted 10 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

Quoted 5 lines

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Quoted 9 lines

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Because in a patchset which implements atomic relaxed/acquire/release variants on PPC I use smp_lwsync(), this makes it have another user, please see this mail:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

in definition of PPC's __atomic_op_release().

But I think removing smp_lwsync() is a good idea and actually I think we can go further to remove __smp_lwsync() and let __smp_load_acquire and __smp_store_release call __lwsync() directly, but that is another thing.

Anyway, I will modify my patch.

Regards,
Boqun

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
Signature · 8 lines
-- 
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#80 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Michael S. Tsirkin

On Tue, Jan 05, 2016 at 06:16:48PM +0200, Michael S. Tsirkin wrote:
[snip]

Quoted 38 lines
Quoted 32 lines
Quoted 10 lines
Quoted 10 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

Quoted 5 lines

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Quoted 9 lines

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Because in a patchset which implements atomic relaxed/acquire/release variants on PPC I use smp_lwsync(), this makes it have another user, please see this mail:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

in definition of PPC's __atomic_op_release().

But I think removing smp_lwsync() is a good idea and actually I think we can go further to remove __smp_lwsync() and let __smp_load_acquire and __smp_store_release call __lwsync() directly, but that is another thing.

Anyway, I will modify my patch.

Regards,
Boqun

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
Signature · 8 lines
-- 
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author maintainer
#81 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Boqun Feng
Quoted 8 lines · Boqun Feng
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Boqun Feng

Hi Michael,

Quoted 3 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

I think this is the part that was missed in review.

Yes, I realized my mistake after reread the series. But smp_lwsync() is not defined in asm-generic/barriers.h, right?

It isn't because as far as I could tell it is not used outside arch/powerpc/include/asm/barrier.h smp_store_release and smp_load_acquire.

And these are now gone.

Instead there are __smp_store_release and __smp_load_acquire which call __smp_lwsync.
These are only used for virt and on SMP.
UP variants are generic - they just call barrier().

Quoted 95 lines
Quoted 54 lines
Quoted 16 lines
Quoted 16 lines

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
Quoted 6 lines

arch/powerpc/include/asm/barrier.h line 48

Quoted 4 lines
arch/powerpc/include/asm/barrier.h +1 -2
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Yes.

Quoted 20 lines
Quoted 20 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
Quoted 8 lines

arch/powerpc/include/asm/barrier.h line 65

Quoted 6 lines
arch/powerpc/include/asm/barrier.h +2 -2
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Quoted 5 lines

Absolutely. But smp_store_release (without __) will not.

Please note I did test this: for ppc code before and after this patch generates exactly the same binary on SMP and UP.

Yes, you're right, sorry for my mistake...

Quoted 11 lines
Quoted 11 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

Quoted 5 lines

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author maintainer
#82 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Boqun Feng
Quoted 8 lines · Boqun Feng
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Boqun Feng

Hi Michael,

Quoted 3 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

I think this is the part that was missed in review.

Yes, I realized my mistake after reread the series. But smp_lwsync() is not defined in asm-generic/barriers.h, right?

It isn't because as far as I could tell it is not used outside arch/powerpc/include/asm/barrier.h smp_store_release and smp_load_acquire.

And these are now gone.

Instead there are __smp_store_release and __smp_load_acquire which call __smp_lwsync.
These are only used for virt and on SMP.
UP variants are generic - they just call barrier().

Quoted 95 lines
Quoted 54 lines
Quoted 16 lines
Quoted 16 lines

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
Quoted 6 lines

arch/powerpc/include/asm/barrier.h line 48

Quoted 4 lines
arch/powerpc/include/asm/barrier.h +1 -2
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Yes.

Quoted 20 lines
Quoted 20 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
Quoted 8 lines

arch/powerpc/include/asm/barrier.h line 65

Quoted 6 lines
arch/powerpc/include/asm/barrier.h +2 -2
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Quoted 5 lines

Absolutely. But smp_store_release (without __) will not.

Please note I did test this: for ppc code before and after this patch generates exactly the same binary on SMP and UP.

Yes, you're right, sorry for my mistake...

Quoted 11 lines
Quoted 11 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

Quoted 5 lines

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Sorry, I don't understand - why do you have to do anything? I changed all users of smp_lwsync so they
use __smp_lwsync on SMP and barrier() on !SMP.

This is exactly the current behaviour, I also tested that generated code does not change at all.

Is there a patch in your tree that conflicts with this?

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#83 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 12 lines · Michael S. Tsirkin
Quoted 8 lines · Boqun Feng

Hi Michael,

Quoted 5 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

I think this is the part that was missed in review.

Yes, I realized my mistake after reread the series. But smp_lwsync() is not defined in asm-generic/barriers.h, right?

Quoted 54 lines
Quoted 16 lines
Quoted 16 lines

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
Quoted 6 lines

arch/powerpc/include/asm/barrier.h line 48

Quoted 4 lines
arch/powerpc/include/asm/barrier.h +1 -2
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Yes.

Quoted 20 lines
Quoted 20 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
Quoted 8 lines

arch/powerpc/include/asm/barrier.h line 65

Quoted 6 lines
arch/powerpc/include/asm/barrier.h +2 -2
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Quoted 5 lines

Absolutely. But smp_store_release (without __) will not.

Please note I did test this: for ppc code before and after this patch generates exactly the same binary on SMP and UP.

Yes, you're right, sorry for my mistake...

Quoted 11 lines
Quoted 11 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#84 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 12 lines · Michael S. Tsirkin
Quoted 8 lines · Boqun Feng

Hi Michael,

Quoted 5 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

I think this is the part that was missed in review.

Yes, I realized my mistake after reread the series. But smp_lwsync() is not defined in asm-generic/barriers.h, right?

Quoted 54 lines
Quoted 16 lines
Quoted 16 lines

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
Quoted 6 lines

arch/powerpc/include/asm/barrier.h line 48

Quoted 4 lines
arch/powerpc/include/asm/barrier.h +1 -2
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Yes.

Quoted 20 lines
Quoted 20 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
Quoted 8 lines

arch/powerpc/include/asm/barrier.h line 65

Quoted 6 lines
arch/powerpc/include/asm/barrier.h +2 -2
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Quoted 5 lines

Absolutely. But smp_store_release (without __) will not.

Please note I did test this: for ppc code before and after this patch generates exactly the same binary on SMP and UP.

Yes, you're right, sorry for my mistake...

Quoted 11 lines
Quoted 11 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Quoted 5 lines
Quoted 2 lines

Regards,
Boqun

I think you missed the leading ___ :)

What I mean here was smp_lwsync() was originally internal to PPC, but never mind ;-)

Quoted 4 lines

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync

You mean bringing smp_lwsync() back? because I haven't seen you defining in asm-generic/barriers.h in previous patches and you just delete it in this patch.

Quoted 3 lines

but why do this? Still, if you prefer it this way, please let me know.

I think deleting smp_lwsync() is fine, though I need to change atomic variants patches on PPC because of it ;-/

Regards,
Boqun

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author maintainer
#85 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Boqun Feng
Quoted 8 lines · Boqun Feng

Hi Michael,

Quoted 5 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

I think this is the part that was missed in review.

Quoted 16 lines
Quoted 16 lines

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
Quoted 6 lines

arch/powerpc/include/asm/barrier.h line 48

Quoted 4 lines
arch/powerpc/include/asm/barrier.h +1 -2
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Yes.

Quoted 20 lines
Quoted 20 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
Quoted 8 lines

arch/powerpc/include/asm/barrier.h line 65

Quoted 6 lines
arch/powerpc/include/asm/barrier.h +2 -2
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Absolutely. But smp_store_release (without __) will not.

Please note I did test this: for ppc code before and after this patch generates exactly the same binary on SMP and UP.

Quoted 5 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

Quoted 7 lines

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Regards,
Boqun

I think you missed the leading ___ :)

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync but why do this? Still, if you prefer it this way,
please let me know.

Quoted 21 lines
Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author maintainer
#86 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Boqun Feng
Quoted 8 lines · Boqun Feng

Hi Michael,

Quoted 5 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

I think this is the part that was missed in review.

Quoted 16 lines
Quoted 16 lines

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
Quoted 6 lines

arch/powerpc/include/asm/barrier.h line 48

Quoted 4 lines
arch/powerpc/include/asm/barrier.h +1 -2
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Yes.

Quoted 20 lines
Quoted 20 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
Quoted 8 lines

arch/powerpc/include/asm/barrier.h line 65

Quoted 6 lines
arch/powerpc/include/asm/barrier.h +2 -2
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Absolutely. But smp_store_release (without __) will not.

Please note I did test this: for ppc code before and after this patch generates exactly the same binary on SMP and UP.

Quoted 5 lines

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

Quoted 7 lines

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Regards,
Boqun

I think you missed the leading ___ :)

smp_store_release is external and it needs __smp_lwsync as defined here.

I can duplicate some code and have smp_lwsync *not* call __smp_lwsync but why do this? Still, if you prefer it this way,
please let me know.

Quoted 21 lines
Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#87 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Michael S. Tsirkin

Hi Michael,

Quoted 19 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644

arch/powerpc/include/asm/barrier.h line 48

Quoted 7 lines
arch/powerpc/include/asm/barrier.h +1 -2
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Quoted 17 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being

arch/powerpc/include/asm/barrier.h line 65

Quoted 9 lines
arch/powerpc/include/asm/barrier.h +2 -2
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Regards,
Boqun

Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#88 lore raw

Re: [PATCH v2 15/32] powerpc: define __smp_xxx

In reply to Michael S. Tsirkin

Hi Michael,

Quoted 19 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +0 -0
index 980ad0c..c0deafc 100644

arch/powerpc/include/asm/barrier.h line 48

Quoted 7 lines
arch/powerpc/include/asm/barrier.h +1 -2
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 

so __smp_lwsync() is always mapped to lwsync, right?

Quoted 17 lines
arch/powerpc/include/asm/barrier.h +3 -10
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being

arch/powerpc/include/asm/barrier.h line 65

Quoted 9 lines
arch/powerpc/include/asm/barrier.h +2 -2
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\

, therefore this will emit an lwsync no matter SMP or UP.

Another thing is that smp_lwsync() may have a third user(other than smp_load_acquire() and smp_store_release()):

http://article.gmane.org/gmane.linux.ports.ppc.embedded/89877

I'm OK to change my patch accordingly, but do we really want smp_lwsync() get involved in this cleanup? If I understand you correctly, this cleanup focuses on external API like smp_{r,w,}mb(), while smp_lwsync() is internal to PPC.

Regards,
Boqun

Quoted 21 lines
arch/powerpc/include/asm/barrier.h +2 -2
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 7 lines
MST

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author maintainer
#89 lore raw

PATCH v2 15/32 powerpc: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +8 -16
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 1 line
MST
author maintainer
#90 lore raw

PATCH v2 15/32 powerpc: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for powerpc for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/powerpc/include/asm/barrier.h | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/barrier.h +8 -16
index 980ad0c..c0deafc 100644
@@ -44,19 +44,11 @@
 #define dma_rmb()	__lwsync()
 #define dma_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
-#ifdef CONFIG_SMP
-#define smp_lwsync()	__lwsync()
+#define __smp_lwsync()	__lwsync()
 
-#define smp_mb()	mb()
-#define smp_rmb()	__lwsync()
-#define smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
-#else
-#define smp_lwsync()	barrier()
-
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#endif /* CONFIG_SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	__lwsync()
+#define __smp_wmb()	__asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
 
 /*
  * This is a barrier which prevents following instructions from being
@@ -67,18 +59,18 @@
 #define data_barrier(x)	\
 	asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_lwsync();							\
+	__smp_lwsync();							\
 	___p1;								\
 })
 
Signature · 1 line
MST
author maintainer
#91 lore raw

PATCH v2 16/32 arm64: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for arm64, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

Note: arm64 does not support !SMP config, so smp_xxx and __smp_xxx are always equivalent.

---
 arch/arm64/include/asm/barrier.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm64/include/asm/barrier.h +5 -5
index 91a43f4..dae5c49 100644
@@ -35,11 +35,11 @@
 #define dma_rmb()	dmb(oshld)
 #define dma_wmb()	dmb(oshst)
 
-#define smp_mb()	dmb(ish)
-#define smp_rmb()	dmb(ishld)
-#define smp_wmb()	dmb(ishst)
+#define __smp_mb()	dmb(ish)
+#define __smp_rmb()	dmb(ishld)
+#define __smp_wmb()	dmb(ishst)
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	switch (sizeof(*p)) {						\
@@ -62,7 +62,7 @@ do {									\
 	}								\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	union { typeof(*p) __val; char __c[1]; } __u;			\
 	compiletime_assert_atomic_type(*p);				\
Signature · 1 line
MST
author maintainer
#92 lore raw

PATCH v2 16/32 arm64: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for arm64, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

Note: arm64 does not support !SMP config, so smp_xxx and __smp_xxx are always equivalent.

---
 arch/arm64/include/asm/barrier.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm64/include/asm/barrier.h +5 -5
index 91a43f4..dae5c49 100644
@@ -35,11 +35,11 @@
 #define dma_rmb()	dmb(oshld)
 #define dma_wmb()	dmb(oshst)
 
-#define smp_mb()	dmb(ish)
-#define smp_rmb()	dmb(ishld)
-#define smp_wmb()	dmb(ishst)
+#define __smp_mb()	dmb(ish)
+#define __smp_rmb()	dmb(ishld)
+#define __smp_wmb()	dmb(ishst)
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	switch (sizeof(*p)) {						\
@@ -62,7 +62,7 @@ do {									\
 	}								\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	union { typeof(*p) __val; char __c[1]; } __u;			\
 	compiletime_assert_atomic_type(*p);				\
Signature · 1 line
MST
author maintainer
#93 lore raw

PATCH v2 16/32 arm64: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for arm64, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

Note: arm64 does not support !SMP config, so smp_xxx and __smp_xxx are always equivalent.

---
 arch/arm64/include/asm/barrier.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm64/include/asm/barrier.h +5 -5
index 91a43f4..dae5c49 100644
@@ -35,11 +35,11 @@
 #define dma_rmb()	dmb(oshld)
 #define dma_wmb()	dmb(oshst)
 
-#define smp_mb()	dmb(ish)
-#define smp_rmb()	dmb(ishld)
-#define smp_wmb()	dmb(ishst)
+#define __smp_mb()	dmb(ish)
+#define __smp_rmb()	dmb(ishld)
+#define __smp_wmb()	dmb(ishst)
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	switch (sizeof(*p)) {						\
@@ -62,7 +62,7 @@ do {									\
 	}								\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	union { typeof(*p) __val; char __c[1]; } __u;			\
 	compiletime_assert_atomic_type(*p);				\
Signature · 1 line
MST
author maintainer
#94 lore raw

PATCH v2 17/32 arm: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for arm, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/arm/include/asm/barrier.h | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
arch/arm/include/asm/barrier.h +3 -9
index 31152e8..112cc1a 100644
@@ -60,15 +60,9 @@ extern void arm_heavy_mb(void);
 #define dma_wmb()	barrier()
 #endif
 
-#ifndef CONFIG_SMP
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#else
-#define smp_mb()	dmb(ish)
-#define smp_rmb()	smp_mb()
-#define smp_wmb()	dmb(ishst)
-#endif
+#define __smp_mb()	dmb(ish)
+#define __smp_rmb()	__smp_mb()
+#define __smp_wmb()	dmb(ishst)
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
Acked-by Russell King on v2 17/32
#95 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

Quoted 10 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for arm, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

In combination with patch 14, this looks like it should result in no change to the resulting code.

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#96 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

Quoted 22 lines · Russell King - ARM Linux
Quoted 10 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for arm, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

In combination with patch 14, this looks like it should result in no change to the resulting code.

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

Quoted 4 lines

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Quoted 4 lines
Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
maintainer
#97 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

Quoted 4 lines

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

And I suppose most of virtio would actually be modules, so you cannot do what I did with preempt_enable_no_resched() either.

But yes, it would be good to limit the use of these things.

maintainer
#98 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

Quoted 7 lines
Quoted 4 lines

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

Ah, I see, you add virt_*mb() stuff later on for that use case.

So, assuming everybody does include asm-generic/barrier.h, you could simply #undef the __smp version at the end of that, once we've generated all the regular primitives from it, no?

#99 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

Quoted 19 lines · Peter Zijlstra
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Quoted 8 lines
Quoted 2 lines

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

Ah, I see, you add virt_*mb() stuff later on for that use case.

So, assuming everybody does include asm-generic/barrier.h, you could simply #undef the __smp version at the end of that, once we've generated all the regular primitives from it, no?

Not so simple - that's why I mentioned using inline functions.

The new smp_* _macros_ are:

+#define smp_mb() __smp_mb()

which means if we simply #undef __smp_mb(), smp_mb() then points at something which is no longer available, and we'll end up with errors saying that __smp_mb() doesn't exist.

My suggestion was to change:

#ifndef smp_mb
#define smp_mb() __smp_mb()
#endif

to:

#ifndef smp_mb
static inline void smp_mb(void)

{
	__smp_mb();
}

#endif

which then means __smp_mb() and friends can be #undef'd afterwards.

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#100 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

Quoted 47 lines · Russell King - ARM Linux
Quoted 19 lines · Peter Zijlstra
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Quoted 8 lines
Quoted 2 lines

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

Ah, I see, you add virt_*mb() stuff later on for that use case.

So, assuming everybody does include asm-generic/barrier.h, you could simply #undef the __smp version at the end of that, once we've generated all the regular primitives from it, no?

Not so simple - that's why I mentioned using inline functions.

The new smp_* _macros_ are:

+#define smp_mb() __smp_mb()

which means if we simply #undef __smp_mb(), smp_mb() then points at something which is no longer available, and we'll end up with errors saying that __smp_mb() doesn't exist.

My suggestion was to change:

#ifndef smp_mb
#define smp_mb() __smp_mb()
#endif

to:

Quoted 8 lines

#ifndef smp_mb
static inline void smp_mb(void)

{
	__smp_mb();
}

#endif

which then means __smp_mb() and friends can be #undef'd afterwards.

Absolutely, I got it.
The issue is that e.g. tile has:
#define __smp_mb__after_atomic() do { } while (0)

and this is cheaper than barrier().

For this reason I left
#define smp_mb__after_atomic() __smp_mb__after_atomic() in place there.

Now, of course I can do (in asm-generic):

#ifndef smp_mb__after_atomic
static inline void smp_mb__after_atomic(void)
{
...
}
#endif

but this seems ugly: architectures do defines, generic version does inline.

And that is not all: APIs like smp_store_mb can take a variety of types as arguments so they pretty much must be implemented as macros.

Teaching checkpatch.pl to complain about it seems like the cleanest approach.

Quoted 4 lines
Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#101 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Russell King - ARM Linux
Quoted 47 lines · Russell King - ARM Linux
Quoted 19 lines · Peter Zijlstra
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Quoted 8 lines
Quoted 2 lines

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

Ah, I see, you add virt_*mb() stuff later on for that use case.

So, assuming everybody does include asm-generic/barrier.h, you could simply #undef the __smp version at the end of that, once we've generated all the regular primitives from it, no?

Not so simple - that's why I mentioned using inline functions.

The new smp_* _macros_ are:

+#define smp_mb() __smp_mb()

which means if we simply #undef __smp_mb(), smp_mb() then points at something which is no longer available, and we'll end up with errors saying that __smp_mb() doesn't exist.

My suggestion was to change:

#ifndef smp_mb
#define smp_mb() __smp_mb()
#endif

to:

Quoted 8 lines

#ifndef smp_mb
static inline void smp_mb(void)

{
	__smp_mb();
}

#endif

which then means __smp_mb() and friends can be #undef'd afterwards.

Absolutely, I got it.
The issue is that e.g. tile has:
#define __smp_mb__after_atomic() do { } while (0)

and this is cheaper than barrier().

For this reason I left
#define smp_mb__after_atomic() __smp_mb__after_atomic() in place there.

Now, of course I can do (in asm-generic):

#ifndef smp_mb__after_atomic
static inline void smp_mb__after_atomic(void)
{
...
}
#endif

but this seems ugly: architectures do defines, generic version does inline.

And that is not all: APIs like smp_store_mb can take a variety of types as arguments so they pretty much must be implemented as macros.

Teaching checkpatch.pl to complain about it seems like the cleanest approach.

Quoted 4 lines
Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#102 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Peter Zijlstra
Quoted 19 lines · Peter Zijlstra
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Quoted 8 lines
Quoted 2 lines

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

Ah, I see, you add virt_*mb() stuff later on for that use case.

So, assuming everybody does include asm-generic/barrier.h, you could simply #undef the __smp version at the end of that, once we've generated all the regular primitives from it, no?

Not so simple - that's why I mentioned using inline functions.

The new smp_* _macros_ are:

+#define smp_mb() __smp_mb()

which means if we simply #undef __smp_mb(), smp_mb() then points at something which is no longer available, and we'll end up with errors saying that __smp_mb() doesn't exist.

My suggestion was to change:

#ifndef smp_mb
#define smp_mb() __smp_mb()
#endif

to:

#ifndef smp_mb
static inline void smp_mb(void)

{
	__smp_mb();
}

#endif

which then means __smp_mb() and friends can be #undef'd afterwards.

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#103 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Peter Zijlstra
Quoted 19 lines · Peter Zijlstra
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Quoted 8 lines
Quoted 2 lines

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

Ah, I see, you add virt_*mb() stuff later on for that use case.

So, assuming everybody does include asm-generic/barrier.h, you could simply #undef the __smp version at the end of that, once we've generated all the regular primitives from it, no?

Not so simple - that's why I mentioned using inline functions.

The new smp_* _macros_ are:

+#define smp_mb() __smp_mb()

which means if we simply #undef __smp_mb(), smp_mb() then points at something which is no longer available, and we'll end up with errors saying that __smp_mb() doesn't exist.

My suggestion was to change:

#ifndef smp_mb
#define smp_mb() __smp_mb()
#endif

to:

#ifndef smp_mb
static inline void smp_mb(void)

{
	__smp_mb();
}

#endif

which then means __smp_mb() and friends can be #undef'd afterwards.

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#104 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Peter Zijlstra
Quoted 19 lines · Peter Zijlstra
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Quoted 8 lines
Quoted 2 lines

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

Ah, I see, you add virt_*mb() stuff later on for that use case.

So, assuming everybody does include asm-generic/barrier.h, you could simply #undef the __smp version at the end of that, once we've generated all the regular primitives from it, no?

Maybe I misunderstand, but I don't think so:

------>
#define __smp_xxx FOO
#define smp_xxx __smp_xxx
#undef __smp_xxx

smp_xxx
<------

resolves to __smp_xxx, not FOO.

That's why I went the checkpatch way.

Signature · 1 line
MST
author maintainer
#105 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Peter Zijlstra
Quoted 19 lines · Peter Zijlstra
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Quoted 8 lines
Quoted 2 lines

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

Ah, I see, you add virt_*mb() stuff later on for that use case.

So, assuming everybody does include asm-generic/barrier.h, you could simply #undef the __smp version at the end of that, once we've generated all the regular primitives from it, no?

Maybe I misunderstand, but I don't think so:

------>
#define __smp_xxx FOO
#define smp_xxx __smp_xxx
#undef __smp_xxx

smp_xxx
<------

resolves to __smp_xxx, not FOO.

That's why I went the checkpatch way.

Signature · 1 line
MST
author maintainer
#106 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Peter Zijlstra
Quoted 19 lines · Peter Zijlstra
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Quoted 8 lines
Quoted 2 lines

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

Ah, I see, you add virt_*mb() stuff later on for that use case.

So, assuming everybody does include asm-generic/barrier.h, you could simply #undef the __smp version at the end of that, once we've generated all the regular primitives from it, no?

Maybe I misunderstand, but I don't think so:

------>
#define __smp_xxx FOO
#define smp_xxx __smp_xxx
#undef __smp_xxx

smp_xxx
<------

resolves to __smp_xxx, not FOO.

That's why I went the checkpatch way.

Signature · 1 line
MST
maintainer
#107 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Peter Zijlstra
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

Quoted 7 lines
Quoted 4 lines

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

Ah, I see, you add virt_*mb() stuff later on for that use case.

So, assuming everybody does include asm-generic/barrier.h, you could simply #undef the __smp version at the end of that, once we've generated all the regular primitives from it, no?

author maintainer
#108 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Peter Zijlstra
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

Quoted 7 lines
Quoted 4 lines

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

My take out from discussion with you was that virtualization is probably the only valid use-case. So at David Miller's suggestion there's a patch later in the series that adds virt_xxxx wrappers and these are then used by virtio xen and later maybe others.

Quoted 4 lines

And I suppose most of virtio would actually be modules, so you cannot do what I did with preempt_enable_no_resched() either.

But yes, it would be good to limit the use of these things.

Right so the trick is checkpatch warns about use of __smp_xxx and hopefully people are not crazy enough to use virt_xxx variants for non-virtual drivers.

Signature · 1 line
MST
author maintainer
#109 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Peter Zijlstra
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

Quoted 7 lines
Quoted 4 lines

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

My take out from discussion with you was that virtualization is probably the only valid use-case. So at David Miller's suggestion there's a patch later in the series that adds virt_xxxx wrappers and these are then used by virtio xen and later maybe others.

Quoted 4 lines

And I suppose most of virtio would actually be modules, so you cannot do what I did with preempt_enable_no_resched() either.

But yes, it would be good to limit the use of these things.

Right so the trick is checkpatch warns about use of __smp_xxx and hopefully people are not crazy enough to use virt_xxx variants for non-virtual drivers.

Signature · 1 line
MST
maintainer
#110 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

Quoted 4 lines

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

And I suppose most of virtio would actually be modules, so you cannot do what I did with preempt_enable_no_resched() either.

But yes, it would be good to limit the use of these things.

maintainer
#111 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Russell King - ARM Linux

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

Quoted 4 lines

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Wasn't the whole purpose of these things for 'drivers' (namely virtio/xen hypervisor interaction) to use these?

And I suppose most of virtio would actually be modules, so you cannot do what I did with preempt_enable_no_resched() either.

But yes, it would be good to limit the use of these things.

author maintainer
#112 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Russell King - ARM Linux
Quoted 22 lines · Russell King - ARM Linux
Quoted 10 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for arm, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

In combination with patch 14, this looks like it should result in no change to the resulting code.

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

Quoted 4 lines

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

That'd be tricky to do cleanly since asm-generic depends on ifndef to add generic variants where needed.

But it would be possible to add a checkpatch test for this.

Quoted 4 lines
Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
Acked-by Russell King on v2 17/32
#113 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 10 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for arm, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

In combination with patch 14, this looks like it should result in no change to the resulting code.

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
Acked-by Russell King on v2 17/32
#114 lore raw

Re: [PATCH v2 17/32] arm: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 10 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for arm, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

In combination with patch 14, this looks like it should result in no change to the resulting code.

My only concern is that it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (been there with other arch stuff before.)

I wonder whether we should consider making the smp memory barriers inline functions, so these __smp_xxx() variants can be undef'd afterwards, thereby preventing drivers getting their hands on these new macros?

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#115 lore raw

PATCH v2 17/32 arm: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for arm, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/arm/include/asm/barrier.h | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
arch/arm/include/asm/barrier.h +3 -9
index 31152e8..112cc1a 100644
@@ -60,15 +60,9 @@ extern void arm_heavy_mb(void);
 #define dma_wmb()	barrier()
 #endif
 
-#ifndef CONFIG_SMP
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#else
-#define smp_mb()	dmb(ish)
-#define smp_rmb()	smp_mb()
-#define smp_wmb()	dmb(ishst)
-#endif
+#define __smp_mb()	dmb(ish)
+#define __smp_rmb()	__smp_mb()
+#define __smp_wmb()	dmb(ishst)
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#116 lore raw

PATCH v2 17/32 arm: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for arm, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/arm/include/asm/barrier.h | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
arch/arm/include/asm/barrier.h +3 -9
index 31152e8..112cc1a 100644
@@ -60,15 +60,9 @@ extern void arm_heavy_mb(void);
 #define dma_wmb()	barrier()
 #endif
 
-#ifndef CONFIG_SMP
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#else
-#define smp_mb()	dmb(ish)
-#define smp_rmb()	smp_mb()
-#define smp_wmb()	dmb(ishst)
-#endif
+#define __smp_mb()	dmb(ish)
+#define __smp_rmb()	__smp_mb()
+#define __smp_wmb()	dmb(ishst)
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#117 lore raw

PATCH v2 18/32 blackfin: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for blackfin, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

---
 arch/blackfin/include/asm/barrier.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/blackfin/include/asm/barrier.h +2 -2
index dfb66fe..7cca51c 100644
@@ -78,8 +78,8 @@
 
 #endif /* !CONFIG_SMP */
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#118 lore raw

PATCH v2 18/32 blackfin: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for blackfin, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

---
 arch/blackfin/include/asm/barrier.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/blackfin/include/asm/barrier.h +2 -2
index dfb66fe..7cca51c 100644
@@ -78,8 +78,8 @@
 
 #endif /* !CONFIG_SMP */
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#119 lore raw

PATCH v2 18/32 blackfin: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for blackfin, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

---
 arch/blackfin/include/asm/barrier.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/blackfin/include/asm/barrier.h +2 -2
index dfb66fe..7cca51c 100644
@@ -78,8 +78,8 @@
 
 #endif /* !CONFIG_SMP */
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#120 lore raw

PATCH v2 19/32 ia64: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for ia64, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/ia64/include/asm/barrier.h | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
arch/ia64/include/asm/barrier.h +5 -9
index 2f93348..588f161 100644
@@ -42,28 +42,24 @@
 #define dma_rmb()	mb()
 #define dma_wmb()	mb()
 
-#ifdef CONFIG_SMP
-# define smp_mb()	mb()
-#else
-# define smp_mb()	barrier()
-#endif
+# define __smp_mb()	mb()
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 /*
  * IA64 GCC turns volatile stores into st.rel and volatile loads into ld.acq no
  * need for asm trickery!
  */
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
Signature · 1 line
MST
author maintainer
#121 lore raw

PATCH v2 19/32 ia64: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for ia64, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/ia64/include/asm/barrier.h | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
arch/ia64/include/asm/barrier.h +5 -9
index 2f93348..588f161 100644
@@ -42,28 +42,24 @@
 #define dma_rmb()	mb()
 #define dma_wmb()	mb()
 
-#ifdef CONFIG_SMP
-# define smp_mb()	mb()
-#else
-# define smp_mb()	barrier()
-#endif
+# define __smp_mb()	mb()
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 /*
  * IA64 GCC turns volatile stores into st.rel and volatile loads into ld.acq no
  * need for asm trickery!
  */
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
Signature · 1 line
MST
author maintainer
#122 lore raw

PATCH v2 19/32 ia64: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for ia64, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

This reduces the amount of arch-specific boiler-plate code.

---
 arch/ia64/include/asm/barrier.h | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
arch/ia64/include/asm/barrier.h +5 -9
index 2f93348..588f161 100644
@@ -42,28 +42,24 @@
 #define dma_rmb()	mb()
 #define dma_wmb()	mb()
 
-#ifdef CONFIG_SMP
-# define smp_mb()	mb()
-#else
-# define smp_mb()	barrier()
-#endif
+# define __smp_mb()	mb()
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 /*
  * IA64 GCC turns volatile stores into st.rel and volatile loads into ld.acq no
  * need for asm trickery!
  */
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
Signature · 1 line
MST
author maintainer
#123 lore raw

PATCH v2 20/32 metag: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for metag,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: as __smp_XX macros should not depend on CONFIG_SMP, they can not use the existing fence() macro since that is defined differently between SMP and !SMP. For this reason, this patch introduces a wrapper metag_fence() that doesn't depend on CONFIG_SMP.
fence() is then defined using that, depending on CONFIG_SMP.

---
 arch/metag/include/asm/barrier.h | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
arch/metag/include/asm/barrier.h +15 -17
index b5b778b..84880c9 100644
@@ -44,13 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#ifndef CONFIG_SMP
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
-#else
-
 #ifdef CONFIG_METAG_SMP_WRITE_REORDERING
 /*
  * Write to the atomic memory unlock system event register (command 0). This is
@@ -60,26 +53,31 @@ static inline void wr_fence(void)
  * incoherence). It is therefore ineffective if used after and on the same
  * thread as a write.
  */
-static inline void fence(void)
+static inline void metag_fence(void)
 {
 	volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
 	barrier();
 	*flushptr = 0;
 	barrier();
 }
-#define smp_mb()        fence()
-#define smp_rmb()       fence()
-#define smp_wmb()       barrier()
+#define __smp_mb()        metag_fence()
+#define __smp_rmb()       metag_fence()
+#define __smp_wmb()       barrier()
 #else
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
+#define metag_fence()		do { } while (0)
+#define __smp_mb()        barrier()
+#define __smp_rmb()       barrier()
+#define __smp_wmb()       barrier()
 #endif
+
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
maintainer
#124 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 77

Quoted 5 lines · Michael S. Tsirkin
arch/metag/include/asm/barrier.h +4 -0
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif

James, it strikes me as odd that fence() is a no-op instead of a barrier() for UP, can you verify/explain?

#125 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

Hi Peter,

Quoted 9 lines · Peter Zijlstra

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 77

Quoted 5 lines · Michael S. Tsirkin
arch/metag/include/asm/barrier.h +4 -0
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif

James, it strikes me as odd that fence() is a no-op instead of a barrier() for UP, can you verify/explain?

fence() is an unfortunate workaround for a specific issue on a certain SoC, where writes from different hw threads get reordered outside of the core, resulting in incoherency between RAM and cache. It has slightly different semantics to the normal SMP barriers, since I was assured it is required before a write rather than after it.

Here's the comment:

Quoted 5 lines

This is needed before a write to shared memory in a critical section, to prevent external reordering of writes before the fence on other threads with writes after the fence on this thread (and to prevent the ensuing cache-memory incoherence). It is therefore ineffective if used after and on the same thread as a write.

It is used along with the metag specific __global_lock1() (global voluntary lock between hw threads) whenever a write is performed, and by smp_mb/smp_rmb to try to catch other cases, but I've never been confident this fixes every single corner case, since there could be other places where multiple CPUs perform unsynchronised writes to the same memory location, and expect cache not to become incoherent at that location.

It seemed to be sufficient to achieve stability however, and SMP on Meta Linux never made it into a product anyway, since the other hw thread tended to be used for RTOS stuff, so it didn't seem worth extending the generic barrier API for it.

Cheers
James

maintainer
#126 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

Quoted 7 lines · James Hogan

It is used along with the metag specific __global_lock1() (global voluntary lock between hw threads) whenever a write is performed, and by smp_mb/smp_rmb to try to catch other cases, but I've never been confident this fixes every single corner case, since there could be other places where multiple CPUs perform unsynchronised writes to the same memory location, and expect cache not to become incoherent at that location.

Ah, yuck, I thought blackfin was the only one attempting !coherent SMP. And yes, this is bound to break in lots of places in subtle ways. We very much assume cache coherency for SMP in generic code.

Quoted 4 lines

It seemed to be sufficient to achieve stability however, and SMP on Meta Linux never made it into a product anyway, since the other hw thread tended to be used for RTOS stuff, so it didn't seem worth extending the generic barrier API for it.

*phew*, should we take it out then, just to be sure nobody accidentally tries to use it then?

#127 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

Quoted 9 lines · Peter Zijlstra
Quoted 7 lines · James Hogan

It is used along with the metag specific __global_lock1() (global voluntary lock between hw threads) whenever a write is performed, and by smp_mb/smp_rmb to try to catch other cases, but I've never been confident this fixes every single corner case, since there could be other places where multiple CPUs perform unsynchronised writes to the same memory location, and expect cache not to become incoherent at that location.

Quoted 3 lines

Ah, yuck, I thought blackfin was the only one attempting !coherent SMP. And yes, this is bound to break in lots of places in subtle ways. We very much assume cache coherency for SMP in generic code.

Well, its usually completely coherent, its just a bit dodgy in a particular hardware corner case, which was pretty hard to hit, even without these workarounds.

Quoted 8 lines
Quoted 5 lines

It seemed to be sufficient to achieve stability however, and SMP on Meta Linux never made it into a product anyway, since the other hw thread tended to be used for RTOS stuff, so it didn't seem worth extending the generic barrier API for it.

*phew*, should we take it out then, just to be sure nobody accidentally tries to use it then?

SMP support on this SoC you mean? I doubt it'll be a problem tbh, and it'd work fine in QEMU when emulating this SoC, so I'd prefer to keep it in.

Cheers
James

#128 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

In reply to Peter Zijlstra
Quoted 9 lines · Peter Zijlstra
Quoted 7 lines · James Hogan

It is used along with the metag specific __global_lock1() (global voluntary lock between hw threads) whenever a write is performed, and by smp_mb/smp_rmb to try to catch other cases, but I've never been confident this fixes every single corner case, since there could be other places where multiple CPUs perform unsynchronised writes to the same memory location, and expect cache not to become incoherent at that location.

Quoted 3 lines

Ah, yuck, I thought blackfin was the only one attempting !coherent SMP. And yes, this is bound to break in lots of places in subtle ways. We very much assume cache coherency for SMP in generic code.

Well, its usually completely coherent, its just a bit dodgy in a particular hardware corner case, which was pretty hard to hit, even without these workarounds.

Quoted 8 lines
Quoted 5 lines

It seemed to be sufficient to achieve stability however, and SMP on Meta Linux never made it into a product anyway, since the other hw thread tended to be used for RTOS stuff, so it didn't seem worth extending the generic barrier API for it.

*phew*, should we take it out then, just to be sure nobody accidentally tries to use it then?

SMP support on this SoC you mean? I doubt it'll be a problem tbh, and it'd work fine in QEMU when emulating this SoC, so I'd prefer to keep it in.

Cheers
James

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#129 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

In reply to Peter Zijlstra
Quoted 9 lines · Peter Zijlstra
Quoted 7 lines · James Hogan

It is used along with the metag specific __global_lock1() (global voluntary lock between hw threads) whenever a write is performed, and by smp_mb/smp_rmb to try to catch other cases, but I've never been confident this fixes every single corner case, since there could be other places where multiple CPUs perform unsynchronised writes to the same memory location, and expect cache not to become incoherent at that location.

Quoted 3 lines

Ah, yuck, I thought blackfin was the only one attempting !coherent SMP. And yes, this is bound to break in lots of places in subtle ways. We very much assume cache coherency for SMP in generic code.

Well, its usually completely coherent, its just a bit dodgy in a particular hardware corner case, which was pretty hard to hit, even without these workarounds.

Quoted 8 lines
Quoted 5 lines

It seemed to be sufficient to achieve stability however, and SMP on Meta Linux never made it into a product anyway, since the other hw thread tended to be used for RTOS stuff, so it didn't seem worth extending the generic barrier API for it.

*phew*, should we take it out then, just to be sure nobody accidentally tries to use it then?

SMP support on this SoC you mean? I doubt it'll be a problem tbh, and it'd work fine in QEMU when emulating this SoC, so I'd prefer to keep it in.

Cheers
James

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

maintainer
#130 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

In reply to James Hogan
Quoted 7 lines · James Hogan

It is used along with the metag specific __global_lock1() (global voluntary lock between hw threads) whenever a write is performed, and by smp_mb/smp_rmb to try to catch other cases, but I've never been confident this fixes every single corner case, since there could be other places where multiple CPUs perform unsynchronised writes to the same memory location, and expect cache not to become incoherent at that location.

Ah, yuck, I thought blackfin was the only one attempting !coherent SMP. And yes, this is bound to break in lots of places in subtle ways. We very much assume cache coherency for SMP in generic code.

Quoted 4 lines

It seemed to be sufficient to achieve stability however, and SMP on Meta Linux never made it into a product anyway, since the other hw thread tended to be used for RTOS stuff, so it didn't seem worth extending the generic barrier API for it.

*phew*, should we take it out then, just to be sure nobody accidentally tries to use it then?

#131 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

In reply to Peter Zijlstra

Hi Peter,

Quoted 9 lines · Peter Zijlstra

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 77

Quoted 5 lines · Michael S. Tsirkin
arch/metag/include/asm/barrier.h +4 -0
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif

James, it strikes me as odd that fence() is a no-op instead of a barrier() for UP, can you verify/explain?

fence() is an unfortunate workaround for a specific issue on a certain SoC, where writes from different hw threads get reordered outside of the core, resulting in incoherency between RAM and cache. It has slightly different semantics to the normal SMP barriers, since I was assured it is required before a write rather than after it.

Here's the comment:

Quoted 5 lines

This is needed before a write to shared memory in a critical section, to prevent external reordering of writes before the fence on other threads with writes after the fence on this thread (and to prevent the ensuing cache-memory incoherence). It is therefore ineffective if used after and on the same thread as a write.

It is used along with the metag specific __global_lock1() (global voluntary lock between hw threads) whenever a write is performed, and by smp_mb/smp_rmb to try to catch other cases, but I've never been confident this fixes every single corner case, since there could be other places where multiple CPUs perform unsynchronised writes to the same memory location, and expect cache not to become incoherent at that location.

It seemed to be sufficient to achieve stability however, and SMP on Meta Linux never made it into a product anyway, since the other hw thread tended to be used for RTOS stuff, so it didn't seem worth extending the generic barrier API for it.

Cheers
James

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#132 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

In reply to Peter Zijlstra

Hi Peter,

Quoted 9 lines · Peter Zijlstra

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 77

Quoted 5 lines · Michael S. Tsirkin
arch/metag/include/asm/barrier.h +4 -0
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif

James, it strikes me as odd that fence() is a no-op instead of a barrier() for UP, can you verify/explain?

fence() is an unfortunate workaround for a specific issue on a certain SoC, where writes from different hw threads get reordered outside of the core, resulting in incoherency between RAM and cache. It has slightly different semantics to the normal SMP barriers, since I was assured it is required before a write rather than after it.

Here's the comment:

Quoted 5 lines

This is needed before a write to shared memory in a critical section, to prevent external reordering of writes before the fence on other threads with writes after the fence on this thread (and to prevent the ensuing cache-memory incoherence). It is therefore ineffective if used after and on the same thread as a write.

It is used along with the metag specific __global_lock1() (global voluntary lock between hw threads) whenever a write is performed, and by smp_mb/smp_rmb to try to catch other cases, but I've never been confident this fixes every single corner case, since there could be other places where multiple CPUs perform unsynchronised writes to the same memory location, and expect cache not to become incoherent at that location.

It seemed to be sufficient to achieve stability however, and SMP on Meta Linux never made it into a product anyway, since the other hw thread tended to be used for RTOS stuff, so it didn't seem worth extending the generic barrier API for it.

Cheers
James

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

maintainer
#133 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

In reply to Michael S. Tsirkin

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 77

Quoted 5 lines · Michael S. Tsirkin
arch/metag/include/asm/barrier.h +4 -0
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif

James, it strikes me as odd that fence() is a no-op instead of a barrier() for UP, can you verify/explain?

Acked-by on v2 20/32
#134 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

In reply to Michael S. Tsirkin

Hi Michael,

Quoted 11 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for metag,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: as __smp_XX macros should not depend on CONFIG_SMP, they can not use the existing fence() macro since that is defined differently between SMP and !SMP. For this reason, this patch introduces a wrapper metag_fence() that doesn't depend on CONFIG_SMP.
fence() is then defined using that, depending on CONFIG_SMP.

I'm not a fan of the inconsistent commit message wrapping. I wrap to 72 columns (although I now notice SubmittingPatches says to use 75...).

Quoted 12 lines
---
 arch/metag/include/asm/barrier.h | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
arch/metag/include/asm/barrier.h +0 -0
index b5b778b..84880c9 100644

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 52

Quoted 9 lines
arch/metag/include/asm/barrier.h +0 -6
@@ -44,13 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#ifndef CONFIG_SMP
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
-#else

!SMP kernel text differs, but only because of new presence of unused metag_fence() inline function. If I #if 0 that out, then it matches, so thats fine.

Quoted 21 lines
arch/metag/include/asm/barrier.h +3 -5
-
 #ifdef CONFIG_METAG_SMP_WRITE_REORDERING
 /*
  * Write to the atomic memory unlock system event register (command 0). This is
@@ -60,26 +53,31 @@ static inline void wr_fence(void)
  * incoherence). It is therefore ineffective if used after and on the same
  * thread as a write.
  */
-static inline void fence(void)
+static inline void metag_fence(void)
 {
 	volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
 	barrier();
 	*flushptr = 0;
 	barrier();
 }
-#define smp_mb()        fence()
-#define smp_rmb()       fence()
-#define smp_wmb()       barrier()
+#define __smp_mb()        metag_fence()
+#define __smp_rmb()       metag_fence()

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 70

Quoted 10 lines
arch/metag/include/asm/barrier.h +5 -4
+#define __smp_wmb()       barrier()
 #else
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
+#define metag_fence()		do { } while (0)
+#define __smp_mb()        barrier()
+#define __smp_rmb()       barrier()
+#define __smp_wmb()       barrier()

Whitespace is now messed up. Admitedly its already inconsistent tabs/spaces, but it'd be nice if the definitions at least still all lined up. You're touching all the definitions which use spaces anyway, so feel free to convert them to tabs while you're at it.

Other than those niggles, it looks sensible to me:

Cheers
James

Quoted 18 lines
arch/metag/include/asm/barrier.h +7 -2
 #endif
+
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#135 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

Quoted 81 lines · James Hogan

Hi Michael,

Quoted 11 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for metag,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: as __smp_XX macros should not depend on CONFIG_SMP, they can not use the existing fence() macro since that is defined differently between SMP and !SMP. For this reason, this patch introduces a wrapper metag_fence() that doesn't depend on CONFIG_SMP.
fence() is then defined using that, depending on CONFIG_SMP.

I'm not a fan of the inconsistent commit message wrapping. I wrap to 72 columns (although I now notice SubmittingPatches says to use 75...).

Quoted 12 lines
---
 arch/metag/include/asm/barrier.h | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
arch/metag/include/asm/barrier.h +0 -0
index b5b778b..84880c9 100644

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 52

Quoted 9 lines
arch/metag/include/asm/barrier.h +0 -6
@@ -44,13 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#ifndef CONFIG_SMP
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
-#else

!SMP kernel text differs, but only because of new presence of unused metag_fence() inline function. If I #if 0 that out, then it matches, so thats fine.

Quoted 21 lines
arch/metag/include/asm/barrier.h +3 -5
-
 #ifdef CONFIG_METAG_SMP_WRITE_REORDERING
 /*
  * Write to the atomic memory unlock system event register (command 0). This is
@@ -60,26 +53,31 @@ static inline void wr_fence(void)
  * incoherence). It is therefore ineffective if used after and on the same
  * thread as a write.
  */
-static inline void fence(void)
+static inline void metag_fence(void)
 {
 	volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
 	barrier();
 	*flushptr = 0;
 	barrier();
 }
-#define smp_mb()        fence()
-#define smp_rmb()       fence()
-#define smp_wmb()       barrier()
+#define __smp_mb()        metag_fence()
+#define __smp_rmb()       metag_fence()

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 70

Quoted 10 lines
arch/metag/include/asm/barrier.h +5 -4
+#define __smp_wmb()       barrier()
 #else
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
+#define metag_fence()		do { } while (0)
+#define __smp_mb()        barrier()
+#define __smp_rmb()       barrier()
+#define __smp_wmb()       barrier()

Whitespace is now messed up. Admitedly its already inconsistent tabs/spaces, but it'd be nice if the definitions at least still all lined up. You're touching all the definitions which use spaces anyway, so feel free to convert them to tabs while you're at it.

Quoted 5 lines

Other than those niggles, it looks sensible to me:

Cheers
James

Thanks!

I did this in my tree (replaced spaces with tabs in the new definitions); not reposting just because of this change.

Quoted 18 lines
Quoted 18 lines
arch/metag/include/asm/barrier.h +7 -2
 #endif
+
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#136 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

In reply to James Hogan
Quoted 81 lines · James Hogan

Hi Michael,

Quoted 11 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for metag,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: as __smp_XX macros should not depend on CONFIG_SMP, they can not use the existing fence() macro since that is defined differently between SMP and !SMP. For this reason, this patch introduces a wrapper metag_fence() that doesn't depend on CONFIG_SMP.
fence() is then defined using that, depending on CONFIG_SMP.

I'm not a fan of the inconsistent commit message wrapping. I wrap to 72 columns (although I now notice SubmittingPatches says to use 75...).

Quoted 12 lines
---
 arch/metag/include/asm/barrier.h | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
arch/metag/include/asm/barrier.h +0 -0
index b5b778b..84880c9 100644

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 52

Quoted 9 lines
arch/metag/include/asm/barrier.h +0 -6
@@ -44,13 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#ifndef CONFIG_SMP
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
-#else

!SMP kernel text differs, but only because of new presence of unused metag_fence() inline function. If I #if 0 that out, then it matches, so thats fine.

Quoted 21 lines
arch/metag/include/asm/barrier.h +3 -5
-
 #ifdef CONFIG_METAG_SMP_WRITE_REORDERING
 /*
  * Write to the atomic memory unlock system event register (command 0). This is
@@ -60,26 +53,31 @@ static inline void wr_fence(void)
  * incoherence). It is therefore ineffective if used after and on the same
  * thread as a write.
  */
-static inline void fence(void)
+static inline void metag_fence(void)
 {
 	volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
 	barrier();
 	*flushptr = 0;
 	barrier();
 }
-#define smp_mb()        fence()
-#define smp_rmb()       fence()
-#define smp_wmb()       barrier()
+#define __smp_mb()        metag_fence()
+#define __smp_rmb()       metag_fence()

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 70

Quoted 10 lines
arch/metag/include/asm/barrier.h +5 -4
+#define __smp_wmb()       barrier()
 #else
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
+#define metag_fence()		do { } while (0)
+#define __smp_mb()        barrier()
+#define __smp_rmb()       barrier()
+#define __smp_wmb()       barrier()

Whitespace is now messed up. Admitedly its already inconsistent tabs/spaces, but it'd be nice if the definitions at least still all lined up. You're touching all the definitions which use spaces anyway, so feel free to convert them to tabs while you're at it.

Quoted 5 lines

Other than those niggles, it looks sensible to me:

Cheers
James

Thanks!

I did this in my tree (replaced spaces with tabs in the new definitions); not reposting just because of this change.

Quoted 18 lines
Quoted 18 lines
arch/metag/include/asm/barrier.h +7 -2
 #endif
+
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#137 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

In reply to James Hogan
Quoted 81 lines · James Hogan

Hi Michael,

Quoted 11 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for metag,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: as __smp_XX macros should not depend on CONFIG_SMP, they can not use the existing fence() macro since that is defined differently between SMP and !SMP. For this reason, this patch introduces a wrapper metag_fence() that doesn't depend on CONFIG_SMP.
fence() is then defined using that, depending on CONFIG_SMP.

I'm not a fan of the inconsistent commit message wrapping. I wrap to 72 columns (although I now notice SubmittingPatches says to use 75...).

Quoted 12 lines
---
 arch/metag/include/asm/barrier.h | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
arch/metag/include/asm/barrier.h +0 -0
index b5b778b..84880c9 100644

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 52

Quoted 9 lines
arch/metag/include/asm/barrier.h +0 -6
@@ -44,13 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#ifndef CONFIG_SMP
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
-#else

!SMP kernel text differs, but only because of new presence of unused metag_fence() inline function. If I #if 0 that out, then it matches, so thats fine.

Quoted 21 lines
arch/metag/include/asm/barrier.h +3 -5
-
 #ifdef CONFIG_METAG_SMP_WRITE_REORDERING
 /*
  * Write to the atomic memory unlock system event register (command 0). This is
@@ -60,26 +53,31 @@ static inline void wr_fence(void)
  * incoherence). It is therefore ineffective if used after and on the same
  * thread as a write.
  */
-static inline void fence(void)
+static inline void metag_fence(void)
 {
 	volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
 	barrier();
 	*flushptr = 0;
 	barrier();
 }
-#define smp_mb()        fence()
-#define smp_rmb()       fence()
-#define smp_wmb()       barrier()
+#define __smp_mb()        metag_fence()
+#define __smp_rmb()       metag_fence()

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 70

Quoted 10 lines
arch/metag/include/asm/barrier.h +5 -4
+#define __smp_wmb()       barrier()
 #else
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
+#define metag_fence()		do { } while (0)
+#define __smp_mb()        barrier()
+#define __smp_rmb()       barrier()
+#define __smp_wmb()       barrier()

Whitespace is now messed up. Admitedly its already inconsistent tabs/spaces, but it'd be nice if the definitions at least still all lined up. You're touching all the definitions which use spaces anyway, so feel free to convert them to tabs while you're at it.

Quoted 5 lines

Other than those niggles, it looks sensible to me:

Cheers
James

Thanks!

I did this in my tree (replaced spaces with tabs in the new definitions); not reposting just because of this change.

Quoted 18 lines
Quoted 18 lines
arch/metag/include/asm/barrier.h +7 -2
 #endif
+
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
Acked-by on v2 20/32
#138 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

In reply to Michael S. Tsirkin

Hi Michael,

Quoted 11 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for metag,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: as __smp_XX macros should not depend on CONFIG_SMP, they can not use the existing fence() macro since that is defined differently between SMP and !SMP. For this reason, this patch introduces a wrapper metag_fence() that doesn't depend on CONFIG_SMP.
fence() is then defined using that, depending on CONFIG_SMP.

I'm not a fan of the inconsistent commit message wrapping. I wrap to 72 columns (although I now notice SubmittingPatches says to use 75...).

Quoted 12 lines
---
 arch/metag/include/asm/barrier.h | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
arch/metag/include/asm/barrier.h +0 -0
index b5b778b..84880c9 100644

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 52

Quoted 9 lines
arch/metag/include/asm/barrier.h +0 -6
@@ -44,13 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#ifndef CONFIG_SMP
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
-#else

!SMP kernel text differs, but only because of new presence of unused metag_fence() inline function. If I #if 0 that out, then it matches, so thats fine.

Quoted 21 lines
arch/metag/include/asm/barrier.h +3 -5
-
 #ifdef CONFIG_METAG_SMP_WRITE_REORDERING
 /*
  * Write to the atomic memory unlock system event register (command 0). This is
@@ -60,26 +53,31 @@ static inline void wr_fence(void)
  * incoherence). It is therefore ineffective if used after and on the same
  * thread as a write.
  */
-static inline void fence(void)
+static inline void metag_fence(void)
 {
 	volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
 	barrier();
 	*flushptr = 0;
 	barrier();
 }
-#define smp_mb()        fence()
-#define smp_rmb()       fence()
-#define smp_wmb()       barrier()
+#define __smp_mb()        metag_fence()
+#define __smp_rmb()       metag_fence()

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 70

Quoted 10 lines
arch/metag/include/asm/barrier.h +5 -4
+#define __smp_wmb()       barrier()
 #else
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
+#define metag_fence()		do { } while (0)
+#define __smp_mb()        barrier()
+#define __smp_rmb()       barrier()
+#define __smp_wmb()       barrier()

Whitespace is now messed up. Admitedly its already inconsistent tabs/spaces, but it'd be nice if the definitions at least still all lined up. You're touching all the definitions which use spaces anyway, so feel free to convert them to tabs while you're at it.

Other than those niggles, it looks sensible to me:

Cheers
James

Quoted 18 lines
arch/metag/include/asm/barrier.h +7 -2
 #endif
+
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Acked-by on v2 20/32
#139 lore raw

Re: [PATCH v2 20/32] metag: define __smp_xxx

In reply to Michael S. Tsirkin

Hi Michael,

Quoted 11 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for metag,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: as __smp_XX macros should not depend on CONFIG_SMP, they can not use the existing fence() macro since that is defined differently between SMP and !SMP. For this reason, this patch introduces a wrapper metag_fence() that doesn't depend on CONFIG_SMP.
fence() is then defined using that, depending on CONFIG_SMP.

I'm not a fan of the inconsistent commit message wrapping. I wrap to 72 columns (although I now notice SubmittingPatches says to use 75...).

Quoted 12 lines
---
 arch/metag/include/asm/barrier.h | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
arch/metag/include/asm/barrier.h +0 -0
index b5b778b..84880c9 100644

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 52

Quoted 9 lines
arch/metag/include/asm/barrier.h +0 -6
@@ -44,13 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#ifndef CONFIG_SMP
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
-#else

!SMP kernel text differs, but only because of new presence of unused metag_fence() inline function. If I #if 0 that out, then it matches, so thats fine.

Quoted 21 lines
arch/metag/include/asm/barrier.h +3 -5
-
 #ifdef CONFIG_METAG_SMP_WRITE_REORDERING
 /*
  * Write to the atomic memory unlock system event register (command 0). This is
@@ -60,26 +53,31 @@ static inline void wr_fence(void)
  * incoherence). It is therefore ineffective if used after and on the same
  * thread as a write.
  */
-static inline void fence(void)
+static inline void metag_fence(void)
 {
 	volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
 	barrier();
 	*flushptr = 0;
 	barrier();
 }
-#define smp_mb()        fence()
-#define smp_rmb()       fence()
-#define smp_wmb()       barrier()
+#define __smp_mb()        metag_fence()
+#define __smp_rmb()       metag_fence()

arch/metag/include/asm/barrier.h static inline void wr_fence(void) · line 70

Quoted 10 lines
arch/metag/include/asm/barrier.h +5 -4
+#define __smp_wmb()       barrier()
 #else
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
+#define metag_fence()		do { } while (0)
+#define __smp_mb()        barrier()
+#define __smp_rmb()       barrier()
+#define __smp_wmb()       barrier()

Whitespace is now messed up. Admitedly its already inconsistent tabs/spaces, but it'd be nice if the definitions at least still all lined up. You're touching all the definitions which use spaces anyway, so feel free to convert them to tabs while you're at it.

Other than those niggles, it looks sensible to me:

Cheers
James

Quoted 18 lines
arch/metag/include/asm/barrier.h +7 -2
 #endif
+
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author maintainer
#140 lore raw

PATCH v2 20/32 metag: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for metag,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: as __smp_XX macros should not depend on CONFIG_SMP, they can not use the existing fence() macro since that is defined differently between SMP and !SMP. For this reason, this patch introduces a wrapper metag_fence() that doesn't depend on CONFIG_SMP.
fence() is then defined using that, depending on CONFIG_SMP.

---
 arch/metag/include/asm/barrier.h | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
arch/metag/include/asm/barrier.h +15 -17
index b5b778b..84880c9 100644
@@ -44,13 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#ifndef CONFIG_SMP
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
-#else
-
 #ifdef CONFIG_METAG_SMP_WRITE_REORDERING
 /*
  * Write to the atomic memory unlock system event register (command 0). This is
@@ -60,26 +53,31 @@ static inline void wr_fence(void)
  * incoherence). It is therefore ineffective if used after and on the same
  * thread as a write.
  */
-static inline void fence(void)
+static inline void metag_fence(void)
 {
 	volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
 	barrier();
 	*flushptr = 0;
 	barrier();
 }
-#define smp_mb()        fence()
-#define smp_rmb()       fence()
-#define smp_wmb()       barrier()
+#define __smp_mb()        metag_fence()
+#define __smp_rmb()       metag_fence()
+#define __smp_wmb()       barrier()
 #else
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
+#define metag_fence()		do { } while (0)
+#define __smp_mb()        barrier()
+#define __smp_rmb()       barrier()
+#define __smp_wmb()       barrier()
 #endif
+
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#141 lore raw

PATCH v2 20/32 metag: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for metag,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: as __smp_XX macros should not depend on CONFIG_SMP, they can not use the existing fence() macro since that is defined differently between SMP and !SMP. For this reason, this patch introduces a wrapper metag_fence() that doesn't depend on CONFIG_SMP.
fence() is then defined using that, depending on CONFIG_SMP.

---
 arch/metag/include/asm/barrier.h | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
arch/metag/include/asm/barrier.h +15 -17
index b5b778b..84880c9 100644
@@ -44,13 +44,6 @@ static inline void wr_fence(void)
 #define rmb()		barrier()
 #define wmb()		mb()
 
-#ifndef CONFIG_SMP
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
-#else
-
 #ifdef CONFIG_METAG_SMP_WRITE_REORDERING
 /*
  * Write to the atomic memory unlock system event register (command 0). This is
@@ -60,26 +53,31 @@ static inline void wr_fence(void)
  * incoherence). It is therefore ineffective if used after and on the same
  * thread as a write.
  */
-static inline void fence(void)
+static inline void metag_fence(void)
 {
 	volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
 	barrier();
 	*flushptr = 0;
 	barrier();
 }
-#define smp_mb()        fence()
-#define smp_rmb()       fence()
-#define smp_wmb()       barrier()
+#define __smp_mb()        metag_fence()
+#define __smp_rmb()       metag_fence()
+#define __smp_wmb()       barrier()
 #else
-#define fence()		do { } while (0)
-#define smp_mb()        barrier()
-#define smp_rmb()       barrier()
-#define smp_wmb()       barrier()
+#define metag_fence()		do { } while (0)
+#define __smp_mb()        barrier()
+#define __smp_rmb()       barrier()
+#define __smp_wmb()       barrier()
 #endif
+
+#ifdef CONFIG_SMP
+#define fence() metag_fence()
+#else
+#define fence()		do { } while (0)
 #endif
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#142 lore raw

PATCH v2 21/32 mips: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for mips,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: the only exception is smp_mb__before_llsc which is mips-specific. We define both the __smp_mb__before_llsc variant (for use in asm/barriers.h) and smp_mb__before_llsc (for use elsewhere on this architecture).

---
 arch/mips/include/asm/barrier.h | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
arch/mips/include/asm/barrier.h +14 -12
index 3eac4b9..d296633 100644
@@ -85,20 +85,20 @@
 #define wmb()		fast_wmb()
 #define rmb()		fast_rmb()
 
-#if defined(CONFIG_WEAK_ORDERING) && defined(CONFIG_SMP)
+#if defined(CONFIG_WEAK_ORDERING)
 # ifdef CONFIG_CPU_CAVIUM_OCTEON
-#  define smp_mb()	__sync()
-#  define smp_rmb()	barrier()
-#  define smp_wmb()	__syncw()
+#  define __smp_mb()	__sync()
+#  define __smp_rmb()	barrier()
+#  define __smp_wmb()	__syncw()
 # else
-#  define smp_mb()	__asm__ __volatile__("sync" : : :"memory")
-#  define smp_rmb()	__asm__ __volatile__("sync" : : :"memory")
-#  define smp_wmb()	__asm__ __volatile__("sync" : : :"memory")
+#  define __smp_mb()	__asm__ __volatile__("sync" : : :"memory")
+#  define __smp_rmb()	__asm__ __volatile__("sync" : : :"memory")
+#  define __smp_wmb()	__asm__ __volatile__("sync" : : :"memory")
 # endif
 #else
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
+#define __smp_mb()	barrier()
+#define __smp_rmb()	barrier()
+#define __smp_wmb()	barrier()
 #endif
 
 #if defined(CONFIG_WEAK_REORDERING_BEYOND_LLSC) && defined(CONFIG_SMP)
@@ -111,6 +111,7 @@
 
 #ifdef CONFIG_CPU_CAVIUM_OCTEON
 #define smp_mb__before_llsc() smp_wmb()
+#define __smp_mb__before_llsc() __smp_wmb()
 /* Cause previous writes to become visible on all CPUs as soon as possible */
 #define nudge_writes() __asm__ __volatile__(".set push\n\t"		\
 					    ".set arch=octeon\n\t"	\
@@ -118,11 +119,12 @@
 					    ".set pop" : : : "memory")
 #else
 #define smp_mb__before_llsc() smp_llsc_mb()
+#define __smp_mb__before_llsc() smp_llsc_mb()
 #define nudge_writes() mb()
 #endif
 
-#define smp_mb__before_atomic()	smp_mb__before_llsc()
-#define smp_mb__after_atomic()	smp_llsc_mb()
+#define __smp_mb__before_atomic()	__smp_mb__before_llsc()
+#define __smp_mb__after_atomic()	smp_llsc_mb()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#143 lore raw

PATCH v2 21/32 mips: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for mips,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: the only exception is smp_mb__before_llsc which is mips-specific. We define both the __smp_mb__before_llsc variant (for use in asm/barriers.h) and smp_mb__before_llsc (for use elsewhere on this architecture).

---
 arch/mips/include/asm/barrier.h | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
arch/mips/include/asm/barrier.h +14 -12
index 3eac4b9..d296633 100644
@@ -85,20 +85,20 @@
 #define wmb()		fast_wmb()
 #define rmb()		fast_rmb()
 
-#if defined(CONFIG_WEAK_ORDERING) && defined(CONFIG_SMP)
+#if defined(CONFIG_WEAK_ORDERING)
 # ifdef CONFIG_CPU_CAVIUM_OCTEON
-#  define smp_mb()	__sync()
-#  define smp_rmb()	barrier()
-#  define smp_wmb()	__syncw()
+#  define __smp_mb()	__sync()
+#  define __smp_rmb()	barrier()
+#  define __smp_wmb()	__syncw()
 # else
-#  define smp_mb()	__asm__ __volatile__("sync" : : :"memory")
-#  define smp_rmb()	__asm__ __volatile__("sync" : : :"memory")
-#  define smp_wmb()	__asm__ __volatile__("sync" : : :"memory")
+#  define __smp_mb()	__asm__ __volatile__("sync" : : :"memory")
+#  define __smp_rmb()	__asm__ __volatile__("sync" : : :"memory")
+#  define __smp_wmb()	__asm__ __volatile__("sync" : : :"memory")
 # endif
 #else
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
+#define __smp_mb()	barrier()
+#define __smp_rmb()	barrier()
+#define __smp_wmb()	barrier()
 #endif
 
 #if defined(CONFIG_WEAK_REORDERING_BEYOND_LLSC) && defined(CONFIG_SMP)
@@ -111,6 +111,7 @@
 
 #ifdef CONFIG_CPU_CAVIUM_OCTEON
 #define smp_mb__before_llsc() smp_wmb()
+#define __smp_mb__before_llsc() __smp_wmb()
 /* Cause previous writes to become visible on all CPUs as soon as possible */
 #define nudge_writes() __asm__ __volatile__(".set push\n\t"		\
 					    ".set arch=octeon\n\t"	\
@@ -118,11 +119,12 @@
 					    ".set pop" : : : "memory")
 #else
 #define smp_mb__before_llsc() smp_llsc_mb()
+#define __smp_mb__before_llsc() smp_llsc_mb()
 #define nudge_writes() mb()
 #endif
 
-#define smp_mb__before_atomic()	smp_mb__before_llsc()
-#define smp_mb__after_atomic()	smp_llsc_mb()
+#define __smp_mb__before_atomic()	__smp_mb__before_llsc()
+#define __smp_mb__after_atomic()	smp_llsc_mb()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#144 lore raw

PATCH v2 22/32 s390: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +9 -6
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()
+
+#define __smp_store_release(p, v)					\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
Signature · 1 line
MST
maintainer
#145 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

Quoted 24 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +0 -1
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()

arch/s390/include/asm/barrier.h line 34

Quoted 10 lines
arch/s390/include/asm/barrier.h +6 -4
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

author maintainer
#146 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

If in fact this turns out to be wrong, I can pick up a patch to change this, but I'd rather make this a patch on top so that my patches are testable just by compiling and comparing the binary.

Signature · 1 line
MST
#147 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

Quoted 40 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

Quoted 5 lines

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not. Is there really an architecture where you need special virt_xxx barriers?!?

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
author maintainer
#148 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

Quoted 45 lines · Martin Schwidefsky
Quoted 42 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Quoted 8 lines
Quoted 3 lines

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

OK, so I'll queue a patch to do this then?

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

But I also see a lot of weirdness on this architecture.

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Not used in arch specific code so this is likely OK.

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

I could not figure out the above commit.

arch/s390/kvm/kvm-s390.c: smp_mb();

Does not appear to be paired with anything.

arch/s390/lib/spinlock.c:               smp_mb();
arch/s390/lib/spinlock.c:                       smp_mb();

Seems ok, and appears paired properly.
Just to make sure - spinlock is not paravirtualized on s390, is it?

rch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();

It's all around vdso, so I'm guessing userspace is using this, this is why there's no pairing.

Quoted 10 lines
Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not.
Is there really
an architecture where you need special virt_xxx barriers?!?

It is whenever host and guest or two guests access memory at the same time.

The optimization where smp_xxx barriers are compiled out when CONFIG_SMP is cleared means that two UP guests running on an SMP host can not use smp_xxx barriers for communication.

See explanation here:
http://thread.gmane.org/gmane.linux.kernel.virtualization/26555

Quoted 5 lines
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#149 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

Quoted 50 lines · On Tue, 5 Jan 2016 11:30:19 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 49 lines · Martin Schwidefsky
Quoted 45 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

Quoted 6 lines
Quoted 4 lines

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

OK, so I'll queue a patch to do this then?

Yes please.

Quoted 6 lines

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

Correct. Guest to host communication either uses instructions which imply a memory barrier or QDIO which uses atomics.

Quoted 1 line

But I also see a lot of weirdness on this architecture.

Mostly historical, s390 actually is one of the easiest architectures in regard to memory barriers.

Quoted 6 lines

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Not used in arch specific code so this is likely OK.

This has been introduced with git commit 5402ea6af11dc5a9, the smp_mb and smp_mb__before_atomic are used in clear_bit_unlock and __clear_bit_unlock which are 1:1 copies from the code in include/asm-generic/bitops/lock.h. Only test_and_set_bit_lock differs from the generic implementation.

Quoted 23 lines

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

That smp_mb can be removed. The initial s390 vdso code is heavily influenced by the powerpc version which does have a smp_wmb in vdso_init right before the vdso_ready=1 assignment. s390 has no need for that.

Quoted 4 lines

arch/s390/kvm/kvm-s390.c: smp_mb();

Does not appear to be paired with anything.

This one does not make sense to me. Imho can be removed as well.

Quoted 5 lines
arch/s390/lib/spinlock.c:               smp_mb();
arch/s390/lib/spinlock.c:                       smp_mb();

Seems ok, and appears paired properly.
Just to make sure - spinlock is not paravirtualized on s390, is it?

s390 just uses the compare-and-swap instruction for the basic lock/unlock operation, this implies the memory barrier. We do call the hypervisor for contended locks if the lock can not be acquired after a number of retries.

A while ago we did play with ticket spinlocks but they behaved badly in out usual virtualized environments. If we find the time we might take a closer look at the para-virtualized queued spinlocks.

Quoted 7 lines
rch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();

It's all around vdso, so I'm guessing userspace is using this, this is why there's no pairing.

Correct, this is the update count mechanics with the vdso user space code.

Quoted 14 lines
Quoted 10 lines
Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not.
Is there really
an architecture where you need special virt_xxx barriers?!?

It is whenever host and guest or two guests access memory at the same time.

Quoted 6 lines

The optimization where smp_xxx barriers are compiled out when CONFIG_SMP is cleared means that two UP guests running on an SMP host can not use smp_xxx barriers for communication.

See explanation here:
http://thread.gmane.org/gmane.linux.kernel.virtualization/26555

Got it, makes sense.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
author maintainer
#150 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

Quoted 53 lines · Martin Schwidefsky
Quoted 50 lines · On Tue, 5 Jan 2016 11:30:19 +0200 "Michael S. Tsirkin"…
Quoted 49 lines · Martin Schwidefsky
Quoted 45 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin"…
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

OK, so I'll queue a patch to do this then?

Yes please.

OK, I'll add a patch on top in v3.

Quoted 9 lines
Quoted 6 lines

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

Correct. Guest to host communication either uses instructions which imply a memory barrier or QDIO which uses atomics.

And atomics imply a barrier on s390, right?

Quoted 10 lines
Quoted 1 line

But I also see a lot of weirdness on this architecture.

Mostly historical, s390 actually is one of the easiest architectures in regard to memory barriers.

Quoted 5 lines

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Quoted 7 lines
Quoted 1 line

Not used in arch specific code so this is likely OK.

This has been introduced with git commit 5402ea6af11dc5a9, the smp_mb and smp_mb__before_atomic are used in clear_bit_unlock and __clear_bit_unlock which are 1:1 copies from the code in include/asm-generic/bitops/lock.h. Only test_and_set_bit_lock differs from the generic implementation.

something to keep in mind, but
I'd rather not touch bitops at the moment - this patchset is already too big.

Quoted 74 lines
Quoted 23 lines

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

That smp_mb can be removed. The initial s390 vdso code is heavily influenced by the powerpc version which does have a smp_wmb in vdso_init right before the vdso_ready=1 assignment. s390 has no need for that.

Quoted 4 lines

arch/s390/kvm/kvm-s390.c: smp_mb();

Does not appear to be paired with anything.

This one does not make sense to me. Imho can be removed as well.

Quoted 5 lines
arch/s390/lib/spinlock.c:               smp_mb();
arch/s390/lib/spinlock.c:                       smp_mb();

Seems ok, and appears paired properly.
Just to make sure - spinlock is not paravirtualized on s390, is it?

s390 just uses the compare-and-swap instruction for the basic lock/unlock operation, this implies the memory barrier. We do call the hypervisor for contended locks if the lock can not be acquired after a number of retries.

A while ago we did play with ticket spinlocks but they behaved badly in out usual virtualized environments. If we find the time we might take a closer look at the para-virtualized queued spinlocks.

Quoted 7 lines
rch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();

It's all around vdso, so I'm guessing userspace is using this, this is why there's no pairing.

Correct, this is the update count mechanics with the vdso user space code.

Quoted 14 lines
Quoted 10 lines
Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not.
Is there really
an architecture where you need special virt_xxx barriers?!?

It is whenever host and guest or two guests access memory at the same time.

Quoted 8 lines
Quoted 6 lines

The optimization where smp_xxx barriers are compiled out when CONFIG_SMP is cleared means that two UP guests running on an SMP host can not use smp_xxx barriers for communication.

See explanation here:
http://thread.gmane.org/gmane.linux.kernel.virtualization/26555

Got it, makes sense.

An ack would be appreciated.

Quoted 5 lines
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#151 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

Quoted 59 lines · On Tue, 5 Jan 2016 15:04:43 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 58 lines · Martin Schwidefsky
Quoted 55 lines · On Tue, 5 Jan 2016 11:30:19 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 53 lines · Martin Schwidefsky
Quoted 40 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

Quoted 5 lines

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

OK, so I'll queue a patch to do this then?

Yes please.

OK, I'll add a patch on top in v3.

Good, with this addition:

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

Correct. Guest to host communication either uses instructions which imply a memory barrier or QDIO which uses atomics.

And atomics imply a barrier on s390, right?

Yes they do.

Quoted 12 lines
Quoted 12 lines
Quoted 1 line

But I also see a lot of weirdness on this architecture.

Mostly historical, s390 actually is one of the easiest architectures in regard to memory barriers.

Quoted 6 lines

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Not used in arch specific code so this is likely OK.

Quoted 8 lines
Quoted 5 lines

This has been introduced with git commit 5402ea6af11dc5a9, the smp_mb and smp_mb__before_atomic are used in clear_bit_unlock and __clear_bit_unlock which are 1:1 copies from the code in include/asm-generic/bitops/lock.h. Only test_and_set_bit_lock differs from the generic implementation.

something to keep in mind, but
I'd rather not touch bitops at the moment - this patchset is already too big.

With the conversion smp_mb__before_atomic to a barrier() it does the correct thing. I don't think that any chance is necessary.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#152 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 59 lines · On Tue, 5 Jan 2016 15:04:43 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 58 lines · Martin Schwidefsky
Quoted 55 lines · On Tue, 5 Jan 2016 11:30:19 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 53 lines · Martin Schwidefsky
Quoted 40 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

Quoted 5 lines

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

OK, so I'll queue a patch to do this then?

Yes please.

OK, I'll add a patch on top in v3.

Good, with this addition:

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

Correct. Guest to host communication either uses instructions which imply a memory barrier or QDIO which uses atomics.

And atomics imply a barrier on s390, right?

Yes they do.

Quoted 12 lines
Quoted 12 lines
Quoted 1 line

But I also see a lot of weirdness on this architecture.

Mostly historical, s390 actually is one of the easiest architectures in regard to memory barriers.

Quoted 6 lines

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Not used in arch specific code so this is likely OK.

Quoted 8 lines
Quoted 5 lines

This has been introduced with git commit 5402ea6af11dc5a9, the smp_mb and smp_mb__before_atomic are used in clear_bit_unlock and __clear_bit_unlock which are 1:1 copies from the code in include/asm-generic/bitops/lock.h. Only test_and_set_bit_lock differs from the generic implementation.

something to keep in mind, but
I'd rather not touch bitops at the moment - this patchset is already too big.

With the conversion smp_mb__before_atomic to a barrier() it does the correct thing. I don't think that any chance is necessary.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#153 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 59 lines · On Tue, 5 Jan 2016 15:04:43 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 58 lines · Martin Schwidefsky
Quoted 55 lines · On Tue, 5 Jan 2016 11:30:19 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 53 lines · Martin Schwidefsky
Quoted 40 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

Quoted 5 lines

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

OK, so I'll queue a patch to do this then?

Yes please.

OK, I'll add a patch on top in v3.

Good, with this addition:

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

Correct. Guest to host communication either uses instructions which imply a memory barrier or QDIO which uses atomics.

And atomics imply a barrier on s390, right?

Yes they do.

Quoted 12 lines
Quoted 12 lines
Quoted 1 line

But I also see a lot of weirdness on this architecture.

Mostly historical, s390 actually is one of the easiest architectures in regard to memory barriers.

Quoted 6 lines

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Not used in arch specific code so this is likely OK.

Quoted 8 lines
Quoted 5 lines

This has been introduced with git commit 5402ea6af11dc5a9, the smp_mb and smp_mb__before_atomic are used in clear_bit_unlock and __clear_bit_unlock which are 1:1 copies from the code in include/asm-generic/bitops/lock.h. Only test_and_set_bit_lock differs from the generic implementation.

something to keep in mind, but
I'd rather not touch bitops at the moment - this patchset is already too big.

With the conversion smp_mb__before_atomic to a barrier() it does the correct thing. I don't think that any chance is necessary.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
author maintainer
#154 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Martin Schwidefsky
Quoted 53 lines · Martin Schwidefsky
Quoted 50 lines · On Tue, 5 Jan 2016 11:30:19 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 49 lines · Martin Schwidefsky
Quoted 45 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

OK, so I'll queue a patch to do this then?

Yes please.

OK, I'll add a patch on top in v3.

Quoted 9 lines
Quoted 6 lines

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

Correct. Guest to host communication either uses instructions which imply a memory barrier or QDIO which uses atomics.

And atomics imply a barrier on s390, right?

Quoted 10 lines
Quoted 1 line

But I also see a lot of weirdness on this architecture.

Mostly historical, s390 actually is one of the easiest architectures in regard to memory barriers.

Quoted 5 lines

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Quoted 7 lines
Quoted 1 line

Not used in arch specific code so this is likely OK.

This has been introduced with git commit 5402ea6af11dc5a9, the smp_mb and smp_mb__before_atomic are used in clear_bit_unlock and __clear_bit_unlock which are 1:1 copies from the code in include/asm-generic/bitops/lock.h. Only test_and_set_bit_lock differs from the generic implementation.

something to keep in mind, but
I'd rather not touch bitops at the moment - this patchset is already too big.

Quoted 74 lines
Quoted 23 lines

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

That smp_mb can be removed. The initial s390 vdso code is heavily influenced by the powerpc version which does have a smp_wmb in vdso_init right before the vdso_ready=1 assignment. s390 has no need for that.

Quoted 4 lines

arch/s390/kvm/kvm-s390.c: smp_mb();

Does not appear to be paired with anything.

This one does not make sense to me. Imho can be removed as well.

Quoted 5 lines
arch/s390/lib/spinlock.c:               smp_mb();
arch/s390/lib/spinlock.c:                       smp_mb();

Seems ok, and appears paired properly.
Just to make sure - spinlock is not paravirtualized on s390, is it?

s390 just uses the compare-and-swap instruction for the basic lock/unlock operation, this implies the memory barrier. We do call the hypervisor for contended locks if the lock can not be acquired after a number of retries.

A while ago we did play with ticket spinlocks but they behaved badly in out usual virtualized environments. If we find the time we might take a closer look at the para-virtualized queued spinlocks.

Quoted 7 lines
rch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();

It's all around vdso, so I'm guessing userspace is using this, this is why there's no pairing.

Correct, this is the update count mechanics with the vdso user space code.

Quoted 14 lines
Quoted 10 lines
Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not.
Is there really
an architecture where you need special virt_xxx barriers?!?

It is whenever host and guest or two guests access memory at the same time.

Quoted 8 lines
Quoted 6 lines

The optimization where smp_xxx barriers are compiled out when CONFIG_SMP is cleared means that two UP guests running on an SMP host can not use smp_xxx barriers for communication.

See explanation here:
http://thread.gmane.org/gmane.linux.kernel.virtualization/26555

Got it, makes sense.

An ack would be appreciated.

Quoted 5 lines
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
author maintainer
#155 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Martin Schwidefsky
Quoted 53 lines · Martin Schwidefsky
Quoted 50 lines · On Tue, 5 Jan 2016 11:30:19 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 49 lines · Martin Schwidefsky
Quoted 45 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

OK, so I'll queue a patch to do this then?

Yes please.

OK, I'll add a patch on top in v3.

Quoted 9 lines
Quoted 6 lines

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

Correct. Guest to host communication either uses instructions which imply a memory barrier or QDIO which uses atomics.

And atomics imply a barrier on s390, right?

Quoted 10 lines
Quoted 1 line

But I also see a lot of weirdness on this architecture.

Mostly historical, s390 actually is one of the easiest architectures in regard to memory barriers.

Quoted 5 lines

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Quoted 7 lines
Quoted 1 line

Not used in arch specific code so this is likely OK.

This has been introduced with git commit 5402ea6af11dc5a9, the smp_mb and smp_mb__before_atomic are used in clear_bit_unlock and __clear_bit_unlock which are 1:1 copies from the code in include/asm-generic/bitops/lock.h. Only test_and_set_bit_lock differs from the generic implementation.

something to keep in mind, but
I'd rather not touch bitops at the moment - this patchset is already too big.

Quoted 74 lines
Quoted 23 lines

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

That smp_mb can be removed. The initial s390 vdso code is heavily influenced by the powerpc version which does have a smp_wmb in vdso_init right before the vdso_ready=1 assignment. s390 has no need for that.

Quoted 4 lines

arch/s390/kvm/kvm-s390.c: smp_mb();

Does not appear to be paired with anything.

This one does not make sense to me. Imho can be removed as well.

Quoted 5 lines
arch/s390/lib/spinlock.c:               smp_mb();
arch/s390/lib/spinlock.c:                       smp_mb();

Seems ok, and appears paired properly.
Just to make sure - spinlock is not paravirtualized on s390, is it?

s390 just uses the compare-and-swap instruction for the basic lock/unlock operation, this implies the memory barrier. We do call the hypervisor for contended locks if the lock can not be acquired after a number of retries.

A while ago we did play with ticket spinlocks but they behaved badly in out usual virtualized environments. If we find the time we might take a closer look at the para-virtualized queued spinlocks.

Quoted 7 lines
rch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();

It's all around vdso, so I'm guessing userspace is using this, this is why there's no pairing.

Correct, this is the update count mechanics with the vdso user space code.

Quoted 14 lines
Quoted 10 lines
Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not.
Is there really
an architecture where you need special virt_xxx barriers?!?

It is whenever host and guest or two guests access memory at the same time.

Quoted 8 lines
Quoted 6 lines

The optimization where smp_xxx barriers are compiled out when CONFIG_SMP is cleared means that two UP guests running on an SMP host can not use smp_xxx barriers for communication.

See explanation here:
http://thread.gmane.org/gmane.linux.kernel.virtualization/26555

Got it, makes sense.

An ack would be appreciated.

Quoted 5 lines
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#156 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 50 lines · On Tue, 5 Jan 2016 11:30:19 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 49 lines · Martin Schwidefsky
Quoted 45 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

Quoted 6 lines
Quoted 4 lines

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

OK, so I'll queue a patch to do this then?

Yes please.

Quoted 6 lines

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

Correct. Guest to host communication either uses instructions which imply a memory barrier or QDIO which uses atomics.

Quoted 1 line

But I also see a lot of weirdness on this architecture.

Mostly historical, s390 actually is one of the easiest architectures in regard to memory barriers.

Quoted 6 lines

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Not used in arch specific code so this is likely OK.

This has been introduced with git commit 5402ea6af11dc5a9, the smp_mb and smp_mb__before_atomic are used in clear_bit_unlock and __clear_bit_unlock which are 1:1 copies from the code in include/asm-generic/bitops/lock.h. Only test_and_set_bit_lock differs from the generic implementation.

Quoted 23 lines

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

That smp_mb can be removed. The initial s390 vdso code is heavily influenced by the powerpc version which does have a smp_wmb in vdso_init right before the vdso_ready=1 assignment. s390 has no need for that.

Quoted 4 lines

arch/s390/kvm/kvm-s390.c: smp_mb();

Does not appear to be paired with anything.

This one does not make sense to me. Imho can be removed as well.

Quoted 5 lines
arch/s390/lib/spinlock.c:               smp_mb();
arch/s390/lib/spinlock.c:                       smp_mb();

Seems ok, and appears paired properly.
Just to make sure - spinlock is not paravirtualized on s390, is it?

s390 just uses the compare-and-swap instruction for the basic lock/unlock operation, this implies the memory barrier. We do call the hypervisor for contended locks if the lock can not be acquired after a number of retries.

A while ago we did play with ticket spinlocks but they behaved badly in out usual virtualized environments. If we find the time we might take a closer look at the para-virtualized queued spinlocks.

Quoted 7 lines
rch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();

It's all around vdso, so I'm guessing userspace is using this, this is why there's no pairing.

Correct, this is the update count mechanics with the vdso user space code.

Quoted 14 lines
Quoted 10 lines
Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not.
Is there really
an architecture where you need special virt_xxx barriers?!?

It is whenever host and guest or two guests access memory at the same time.

Quoted 6 lines

The optimization where smp_xxx barriers are compiled out when CONFIG_SMP is cleared means that two UP guests running on an SMP host can not use smp_xxx barriers for communication.

See explanation here:
http://thread.gmane.org/gmane.linux.kernel.virtualization/26555

Got it, makes sense.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#157 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 50 lines · On Tue, 5 Jan 2016 11:30:19 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 49 lines · Martin Schwidefsky
Quoted 45 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

Quoted 6 lines
Quoted 4 lines

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

OK, so I'll queue a patch to do this then?

Yes please.

Quoted 6 lines

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

Correct. Guest to host communication either uses instructions which imply a memory barrier or QDIO which uses atomics.

Quoted 1 line

But I also see a lot of weirdness on this architecture.

Mostly historical, s390 actually is one of the easiest architectures in regard to memory barriers.

Quoted 6 lines

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Not used in arch specific code so this is likely OK.

This has been introduced with git commit 5402ea6af11dc5a9, the smp_mb and smp_mb__before_atomic are used in clear_bit_unlock and __clear_bit_unlock which are 1:1 copies from the code in include/asm-generic/bitops/lock.h. Only test_and_set_bit_lock differs from the generic implementation.

Quoted 23 lines

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

That smp_mb can be removed. The initial s390 vdso code is heavily influenced by the powerpc version which does have a smp_wmb in vdso_init right before the vdso_ready=1 assignment. s390 has no need for that.

Quoted 4 lines

arch/s390/kvm/kvm-s390.c: smp_mb();

Does not appear to be paired with anything.

This one does not make sense to me. Imho can be removed as well.

Quoted 5 lines
arch/s390/lib/spinlock.c:               smp_mb();
arch/s390/lib/spinlock.c:                       smp_mb();

Seems ok, and appears paired properly.
Just to make sure - spinlock is not paravirtualized on s390, is it?

s390 just uses the compare-and-swap instruction for the basic lock/unlock operation, this implies the memory barrier. We do call the hypervisor for contended locks if the lock can not be acquired after a number of retries.

A while ago we did play with ticket spinlocks but they behaved badly in out usual virtualized environments. If we find the time we might take a closer look at the para-virtualized queued spinlocks.

Quoted 7 lines
rch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();

It's all around vdso, so I'm guessing userspace is using this, this is why there's no pairing.

Correct, this is the update count mechanics with the vdso user space code.

Quoted 14 lines
Quoted 10 lines
Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not.
Is there really
an architecture where you need special virt_xxx barriers?!?

It is whenever host and guest or two guests access memory at the same time.

Quoted 6 lines

The optimization where smp_xxx barriers are compiled out when CONFIG_SMP is cleared means that two UP guests running on an SMP host can not use smp_xxx barriers for communication.

See explanation here:
http://thread.gmane.org/gmane.linux.kernel.virtualization/26555

Got it, makes sense.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#158 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 24 lines · Michael S. Tsirkin

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

It was probably me misreading the code. I change a wmb into a full mb here since I was changing the defintion of wmb to a compiler barrier. I tried to fixup all users of wmb that really pair with other code. I assumed that there must be some reader (as there was a wmb before) but I could not figure out which. So I just played safe here.

But it probably can be removed.

Quoted 1 line

arch/s390/kvm/kvm-s390.c: smp_mb();

This can go. If you have a patch, I can carry that via the kvms390 tree, or I will spin a new patch with you as suggested-by.

Christian

author maintainer
#159 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

Quoted 34 lines · Christian Borntraeger
Quoted 24 lines · Michael S. Tsirkin

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

It was probably me misreading the code. I change a wmb into a full mb here since I was changing the defintion of wmb to a compiler barrier. I tried to fixup all users of wmb that really pair with other code. I assumed that there must be some reader (as there was a wmb before) but I could not figure out which. So I just played safe here.

Quoted 8 lines

But it probably can be removed.

Quoted 1 line

arch/s390/kvm/kvm-s390.c: smp_mb();

This can go. If you have a patch, I can carry that via the kvms390 tree, or I will spin a new patch with you as suggested-by.

Christian

I have both, will post shortly.

Signature · 1 line
MST
author maintainer
#160 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Christian Borntraeger
Quoted 34 lines · Christian Borntraeger
Quoted 24 lines · Michael S. Tsirkin

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

It was probably me misreading the code. I change a wmb into a full mb here since I was changing the defintion of wmb to a compiler barrier. I tried to fixup all users of wmb that really pair with other code. I assumed that there must be some reader (as there was a wmb before) but I could not figure out which. So I just played safe here.

Quoted 8 lines

But it probably can be removed.

Quoted 1 line

arch/s390/kvm/kvm-s390.c: smp_mb();

This can go. If you have a patch, I can carry that via the kvms390 tree, or I will spin a new patch with you as suggested-by.

Christian

I have both, will post shortly.

Signature · 1 line
MST
author maintainer
#161 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Christian Borntraeger
Quoted 34 lines · Christian Borntraeger
Quoted 24 lines · Michael S. Tsirkin

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

It was probably me misreading the code. I change a wmb into a full mb here since I was changing the defintion of wmb to a compiler barrier. I tried to fixup all users of wmb that really pair with other code. I assumed that there must be some reader (as there was a wmb before) but I could not figure out which. So I just played safe here.

Quoted 8 lines

But it probably can be removed.

Quoted 1 line

arch/s390/kvm/kvm-s390.c: smp_mb();

This can go. If you have a patch, I can carry that via the kvms390 tree, or I will spin a new patch with you as suggested-by.

Christian

I have both, will post shortly.

Signature · 1 line
MST
#162 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 24 lines · Michael S. Tsirkin

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

It was probably me misreading the code. I change a wmb into a full mb here since I was changing the defintion of wmb to a compiler barrier. I tried to fixup all users of wmb that really pair with other code. I assumed that there must be some reader (as there was a wmb before) but I could not figure out which. So I just played safe here.

But it probably can be removed.

Quoted 1 line

arch/s390/kvm/kvm-s390.c: smp_mb();

This can go. If you have a patch, I can carry that via the kvms390 tree, or I will spin a new patch with you as suggested-by.

Christian

#163 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 24 lines · Michael S. Tsirkin

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

Quoted 1 line

I could not figure out the above commit.

It was probably me misreading the code. I change a wmb into a full mb here since I was changing the defintion of wmb to a compiler barrier. I tried to fixup all users of wmb that really pair with other code. I assumed that there must be some reader (as there was a wmb before) but I could not figure out which. So I just played safe here.

But it probably can be removed.

Quoted 1 line

arch/s390/kvm/kvm-s390.c: smp_mb();

This can go. If you have a patch, I can carry that via the kvms390 tree, or I will spin a new patch with you as suggested-by.

Christian

author maintainer
#164 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Martin Schwidefsky
Quoted 45 lines · Martin Schwidefsky
Quoted 42 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Quoted 8 lines
Quoted 3 lines

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

OK, so I'll queue a patch to do this then?

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

But I also see a lot of weirdness on this architecture.

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Not used in arch specific code so this is likely OK.

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

I could not figure out the above commit.

arch/s390/kvm/kvm-s390.c: smp_mb();

Does not appear to be paired with anything.

arch/s390/lib/spinlock.c:               smp_mb();
arch/s390/lib/spinlock.c:                       smp_mb();

Seems ok, and appears paired properly.
Just to make sure - spinlock is not paravirtualized on s390, is it?

rch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();

It's all around vdso, so I'm guessing userspace is using this, this is why there's no pairing.

Quoted 10 lines
Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not.
Is there really
an architecture where you need special virt_xxx barriers?!?

It is whenever host and guest or two guests access memory at the same time.

The optimization where smp_xxx barriers are compiled out when CONFIG_SMP is cleared means that two UP guests running on an SMP host can not use smp_xxx barriers for communication.

See explanation here:
http://thread.gmane.org/gmane.linux.kernel.virtualization/26555

Quoted 5 lines
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
author maintainer
#165 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Martin Schwidefsky
Quoted 45 lines · Martin Schwidefsky
Quoted 42 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Quoted 8 lines
Quoted 3 lines

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

OK, so I'll queue a patch to do this then?

Just to make sure: the question would be, are smp_xxx barriers ever used in s390 arch specific code to flush in/out memory accesses for synchronization with the hypervisor?

I went over s390 arch code and it seems to me the answer is no (except of course for virtio).

But I also see a lot of weirdness on this architecture.

I found these calls:

arch/s390/include/asm/bitops.h: smp_mb__before_atomic(); arch/s390/include/asm/bitops.h: smp_mb();

Not used in arch specific code so this is likely OK.

arch/s390/kernel/vdso.c: smp_mb();

Looking at
Author: Christian Borntraeger <[email protected]>
Date: Fri Sep 11 16:23:06 2015 +0200

s390/vdso: use correct memory barrier

By definition smp_wmb only orders writes against writes. (Finish all previous writes, and do not start any future write). To protect the vdso init code against early reads on other CPUs, let's use a full smp_mb at the end of vdso init. As right now smp_wmb is implemented as full serialization, this needs no stable backport, but this change will be necessary if we reimplement smp_wmb.

ok from hypervisor point of view, but it's also strange:
1. why isn't this paired with another mb somewhere?
this seems to violate barrier pairing rules.
2. how does smp_mb protect against early reads on other CPUs? It normally does not: it orders reads from this CPU versus writes from same CPU. But init code does not appear to read anything. Maybe this is some s390 specific trick?

I could not figure out the above commit.

arch/s390/kvm/kvm-s390.c: smp_mb();

Does not appear to be paired with anything.

arch/s390/lib/spinlock.c:               smp_mb();
arch/s390/lib/spinlock.c:                       smp_mb();

Seems ok, and appears paired properly.
Just to make sure - spinlock is not paravirtualized on s390, is it?

rch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();
arch/s390/kernel/time.c:        smp_wmb();

It's all around vdso, so I'm guessing userspace is using this, this is why there's no pairing.

Quoted 10 lines
Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not.
Is there really
an architecture where you need special virt_xxx barriers?!?

It is whenever host and guest or two guests access memory at the same time.

The optimization where smp_xxx barriers are compiled out when CONFIG_SMP is cleared means that two UP guests running on an SMP host can not use smp_xxx barriers for communication.

See explanation here:
http://thread.gmane.org/gmane.linux.kernel.virtualization/26555

Quoted 5 lines
Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#166 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 40 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

Quoted 5 lines

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not. Is there really an architecture where you need special virt_xxx barriers?!?

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
#167 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 40 lines · On Mon, 4 Jan 2016 22:18:58 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

Quoted 5 lines

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

The s390 kernel is SMP to 99.99%, we just didn't bother with a non-smp variant for the memory-barriers. If the generic header is used we'd get the non-smp version for free. It will save a small amount of text space for CONFIG_SMP=n.

Quoted 5 lines

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

The definition of the memory barriers is independent from the fact if the system is running on an hypervisor or not. Is there really an architecture where you need special virt_xxx barriers?!?

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.
author maintainer
#168 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Peter Zijlstra
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

If in fact this turns out to be wrong, I can pick up a patch to change this, but I'd rather make this a patch on top so that my patches are testable just by compiling and comparing the binary.

Signature · 1 line
MST
author maintainer
#169 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Peter Zijlstra
Quoted 30 lines · Peter Zijlstra
Quoted 29 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +1 -5
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
Quoted 8 lines

arch/s390/include/asm/barrier.h line 34

Quoted 5 lines
arch/s390/include/asm/barrier.h +5 -0
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

No because the generic one is a nop on !SMP, this one isn't.

Pls note this patch is just reordering code without making functional changes.
And at the moment, on s390 smp_xxx barriers are always non empty.

Some of this could be sub-optimal, but
since on s390 Linux always runs on a hypervisor,
I am not sure it's safe to use the generic version - in other words, it just might be that for s390 smp_ and virt_ barriers must be equivalent.

If in fact this turns out to be wrong, I can pick up a patch to change this, but I'd rather make this a patch on top so that my patches are testable just by compiling and comparing the binary.

Signature · 1 line
MST
maintainer
#170 lore raw

Re: [PATCH v2 22/32] s390: define __smp_xxx

In reply to Michael S. Tsirkin
Quoted 24 lines · Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +0 -1
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()

arch/s390/include/asm/barrier.h line 34

Quoted 10 lines
arch/s390/include/asm/barrier.h +6 -4
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()

Why define the smp_*mb() primitives here? Would not the inclusion of asm-generic/barrier.h do this?

author maintainer
#171 lore raw

PATCH v2 22/32 s390: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +9 -6
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()
+
+#define __smp_store_release(p, v)					\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
Signature · 1 line
MST
author maintainer
#172 lore raw

PATCH v2 22/32 s390: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for s390,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: smp_mb, smp_rmb and smp_wmb are defined as full barriers unconditionally on this architecture.

---
 arch/s390/include/asm/barrier.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/s390/include/asm/barrier.h +9 -6
index c358c31..fbd25b2 100644
@@ -26,18 +26,21 @@
 #define wmb()				barrier()
 #define dma_rmb()			mb()
 #define dma_wmb()			mb()
-#define smp_mb()			mb()
-#define smp_rmb()			rmb()
-#define smp_wmb()			wmb()
-
-#define smp_store_release(p, v)						\
+#define __smp_mb()			mb()
+#define __smp_rmb()			rmb()
+#define __smp_wmb()			wmb()
+#define smp_mb()			__smp_mb()
+#define smp_rmb()			__smp_rmb()
+#define smp_wmb()			__smp_wmb()
+
+#define __smp_store_release(p, v)					\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
Signature · 1 line
MST
author maintainer
#173 lore raw

PATCH v2 23/32 sh: define __smp_xxx, fix smp_store_mb for !SMP

In reply to Michael S. Tsirkin

sh variant of smp_store_mb() calls xchg() on !SMP which is stronger than implied by both the name and the documentation.

define __smp_store_mb instead: code in asm-generic/barrier.h will then define smp_store_mb correctly depending on CONFIG_SMP.

---
 arch/sh/include/asm/barrier.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/sh/include/asm/barrier.h +2 -1
index bf91037..f887c64 100644
@@ -32,7 +32,8 @@
 #define ctrl_barrier()	__asm__ __volatile__ ("nop;nop;nop;nop;nop;nop;nop;nop")
 #endif
 
-#define smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
+#define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
+#define smp_store_mb(var, value) __smp_store_mb(var, value)
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#174 lore raw

PATCH v2 23/32 sh: define __smp_xxx, fix smp_store_mb for !SMP

In reply to Michael S. Tsirkin

sh variant of smp_store_mb() calls xchg() on !SMP which is stronger than implied by both the name and the documentation.

define __smp_store_mb instead: code in asm-generic/barrier.h will then define smp_store_mb correctly depending on CONFIG_SMP.

---
 arch/sh/include/asm/barrier.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/sh/include/asm/barrier.h +2 -1
index bf91037..f887c64 100644
@@ -32,7 +32,8 @@
 #define ctrl_barrier()	__asm__ __volatile__ ("nop;nop;nop;nop;nop;nop;nop;nop")
 #endif
 
-#define smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
+#define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
+#define smp_store_mb(var, value) __smp_store_mb(var, value)
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#175 lore raw

PATCH v2 23/32 sh: define __smp_xxx, fix smp_store_mb for !SMP

In reply to Michael S. Tsirkin

sh variant of smp_store_mb() calls xchg() on !SMP which is stronger than implied by both the name and the documentation.

define __smp_store_mb instead: code in asm-generic/barrier.h will then define smp_store_mb correctly depending on CONFIG_SMP.

---
 arch/sh/include/asm/barrier.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/sh/include/asm/barrier.h +2 -1
index bf91037..f887c64 100644
@@ -32,7 +32,8 @@
 #define ctrl_barrier()	__asm__ __volatile__ ("nop;nop;nop;nop;nop;nop;nop;nop")
 #endif
 
-#define smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
+#define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
+#define smp_store_mb(var, value) __smp_store_mb(var, value)
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#176 lore raw

PATCH v2 24/32 sparc: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for sparc, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

---
 arch/sparc/include/asm/barrier_64.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/sparc/include/asm/barrier_64.h +4 -4
index 26c3f72..c9f6ee6 100644
@@ -37,14 +37,14 @@ do {	__asm__ __volatile__("ba,pt	%%xcc, 1f\n\t" \
 #define rmb()	__asm__ __volatile__("":::"memory")
 #define wmb()	__asm__ __volatile__("":::"memory")
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
@@ -52,8 +52,8 @@ do {									\
 	___p1;								\
 })
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
maintainer Acked-by on v2 24/32
#177 lore raw

Re: [PATCH v2 24/32] sparc: define __smp_xxx

From: "Michael S. Tsirkin" <[email protected]>
Date: Thu, 31 Dec 2015 21:08:53 +0200

Quoted 8 lines

This defines __smp_xxx barriers for sparc, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

maintainer Acked-by on v2 24/32
#178 lore raw

Re: [PATCH v2 24/32] sparc: define __smp_xxx

In reply to Michael S. Tsirkin

From: "Michael S. Tsirkin" <[email protected]>
Date: Thu, 31 Dec 2015 21:08:53 +0200

Quoted 8 lines

This defines __smp_xxx barriers for sparc, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

author maintainer
#179 lore raw

PATCH v2 24/32 sparc: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for sparc, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

---
 arch/sparc/include/asm/barrier_64.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/sparc/include/asm/barrier_64.h +4 -4
index 26c3f72..c9f6ee6 100644
@@ -37,14 +37,14 @@ do {	__asm__ __volatile__("ba,pt	%%xcc, 1f\n\t" \
 #define rmb()	__asm__ __volatile__("":::"memory")
 #define wmb()	__asm__ __volatile__("":::"memory")
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
@@ -52,8 +52,8 @@ do {									\
 	___p1;								\
 })
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#180 lore raw

PATCH v2 24/32 sparc: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for sparc, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

---
 arch/sparc/include/asm/barrier_64.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/sparc/include/asm/barrier_64.h +4 -4
index 26c3f72..c9f6ee6 100644
@@ -37,14 +37,14 @@ do {	__asm__ __volatile__("ba,pt	%%xcc, 1f\n\t" \
 #define rmb()	__asm__ __volatile__("":::"memory")
 #define wmb()	__asm__ __volatile__("":::"memory")
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)						\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
@@ -52,8 +52,8 @@ do {									\
 	___p1;								\
 })
 
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#181 lore raw

PATCH v2 25/32 tile: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for tile,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: for 32 bit, keep smp_mb__after_atomic around since it's faster than the generic implementation.

---
 arch/tile/include/asm/barrier.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
arch/tile/include/asm/barrier.h +5 -4
index 96a42ae..d552228 100644
@@ -79,11 +79,12 @@ mb_incoherent(void)
  * But after the word is updated, the routine issues an "mf" before returning,
  * and since it's a function call, we don't even need a compiler barrier.
  */
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	do { } while (0)
+#define __smp_mb__before_atomic()	__smp_mb()
+#define __smp_mb__after_atomic()	do { } while (0)
+#define smp_mb__after_atomic()	__smp_mb__after_atomic()
 #else /* 64 bit */
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	smp_mb()
+#define __smp_mb__before_atomic()	__smp_mb()
+#define __smp_mb__after_atomic()	__smp_mb()
 #endif
 
 #include <asm-generic/barrier.h>
Signature · 1 line
MST
author maintainer
#182 lore raw

PATCH v2 25/32 tile: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for tile,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: for 32 bit, keep smp_mb__after_atomic around since it's faster than the generic implementation.

---
 arch/tile/include/asm/barrier.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
arch/tile/include/asm/barrier.h +5 -4
index 96a42ae..d552228 100644
@@ -79,11 +79,12 @@ mb_incoherent(void)
  * But after the word is updated, the routine issues an "mf" before returning,
  * and since it's a function call, we don't even need a compiler barrier.
  */
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	do { } while (0)
+#define __smp_mb__before_atomic()	__smp_mb()
+#define __smp_mb__after_atomic()	do { } while (0)
+#define smp_mb__after_atomic()	__smp_mb__after_atomic()
 #else /* 64 bit */
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	smp_mb()
+#define __smp_mb__before_atomic()	__smp_mb()
+#define __smp_mb__after_atomic()	__smp_mb()
 #endif
 
 #include <asm-generic/barrier.h>
Signature · 1 line
MST
author maintainer
#183 lore raw

PATCH v2 25/32 tile: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for tile,
for use by virtualization.

Some smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

Note: for 32 bit, keep smp_mb__after_atomic around since it's faster than the generic implementation.

---
 arch/tile/include/asm/barrier.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
arch/tile/include/asm/barrier.h +5 -4
index 96a42ae..d552228 100644
@@ -79,11 +79,12 @@ mb_incoherent(void)
  * But after the word is updated, the routine issues an "mf" before returning,
  * and since it's a function call, we don't even need a compiler barrier.
  */
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	do { } while (0)
+#define __smp_mb__before_atomic()	__smp_mb()
+#define __smp_mb__after_atomic()	do { } while (0)
+#define smp_mb__after_atomic()	__smp_mb__after_atomic()
 #else /* 64 bit */
-#define smp_mb__before_atomic()	smp_mb()
-#define smp_mb__after_atomic()	smp_mb()
+#define __smp_mb__before_atomic()	__smp_mb()
+#define __smp_mb__after_atomic()	__smp_mb()
 #endif
 
 #include <asm-generic/barrier.h>
Signature · 1 line
MST
author maintainer
#184 lore raw

PATCH v2 26/32 xtensa: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for xtensa, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

---
 arch/xtensa/include/asm/barrier.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/xtensa/include/asm/barrier.h +2 -2
index 5b88774..956596e 100644
@@ -13,8 +13,8 @@
 #define rmb() barrier()
 #define wmb() mb()
 
-#define smp_mb__before_atomic()		barrier()
-#define smp_mb__after_atomic()		barrier()
+#define __smp_mb__before_atomic()		barrier()
+#define __smp_mb__after_atomic()		barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#185 lore raw

PATCH v2 26/32 xtensa: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for xtensa, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

---
 arch/xtensa/include/asm/barrier.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/xtensa/include/asm/barrier.h +2 -2
index 5b88774..956596e 100644
@@ -13,8 +13,8 @@
 #define rmb() barrier()
 #define wmb() mb()
 
-#define smp_mb__before_atomic()		barrier()
-#define smp_mb__after_atomic()		barrier()
+#define __smp_mb__before_atomic()		barrier()
+#define __smp_mb__after_atomic()		barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#186 lore raw

PATCH v2 27/32 x86: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for x86,
for use by virtualization.

smp_xxx barriers are removed as they are
defined correctly by asm-generic/barriers.h

---
 arch/x86/include/asm/barrier.h | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)
arch/x86/include/asm/barrier.h +12 -19
index cc4c2a7..a584e1c 100644
@@ -31,17 +31,10 @@
 #endif
 #define dma_wmb()	barrier()
 
-#ifdef CONFIG_SMP
-#define smp_mb()	mb()
-#define smp_rmb()	dma_rmb()
-#define smp_wmb()	barrier()
-#define smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
-#else /* !SMP */
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); barrier(); } while (0)
-#endif /* SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	dma_rmb()
+#define __smp_wmb()	barrier()
+#define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
 
 #if defined(CONFIG_X86_PPRO_FENCE)
 
@@ -50,31 +43,31 @@
  * model and we should fall back to full barriers.
  */
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)					\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	__smp_mb();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	__smp_mb();							\
 	___p1;								\
 })
 
 #else /* regular x86 TSO memory ordering */
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)					\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
@@ -85,8 +78,8 @@ do {									\
 #endif
 
 /* Atomic operations are already serializing on x86 */
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#187 lore raw

PATCH v2 27/32 x86: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for x86, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

---
 arch/x86/include/asm/barrier.h | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)
arch/x86/include/asm/barrier.h +12 -19
index cc4c2a7..a584e1c 100644
@@ -31,17 +31,10 @@
 #endif
 #define dma_wmb()	barrier()
 
-#ifdef CONFIG_SMP
-#define smp_mb()	mb()
-#define smp_rmb()	dma_rmb()
-#define smp_wmb()	barrier()
-#define smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
-#else /* !SMP */
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); barrier(); } while (0)
-#endif /* SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	dma_rmb()
+#define __smp_wmb()	barrier()
+#define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
 
 #if defined(CONFIG_X86_PPRO_FENCE)
 
@@ -50,31 +43,31 @@
  * model and we should fall back to full barriers.
  */
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)					\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	__smp_mb();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	__smp_mb();							\
 	___p1;								\
 })
 
 #else /* regular x86 TSO memory ordering */
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)					\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
@@ -85,8 +78,8 @@ do {									\
 #endif
 
 /* Atomic operations are already serializing on x86 */
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST
author maintainer
#188 lore raw

PATCH v2 27/32 x86: define __smp_xxx

In reply to Michael S. Tsirkin

This defines __smp_xxx barriers for x86, for use by virtualization.

smp_xxx barriers are removed as they are defined correctly by asm-generic/barriers.h

---
 arch/x86/include/asm/barrier.h | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)
arch/x86/include/asm/barrier.h +12 -19
index cc4c2a7..a584e1c 100644
@@ -31,17 +31,10 @@
 #endif
 #define dma_wmb()	barrier()
 
-#ifdef CONFIG_SMP
-#define smp_mb()	mb()
-#define smp_rmb()	dma_rmb()
-#define smp_wmb()	barrier()
-#define smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
-#else /* !SMP */
-#define smp_mb()	barrier()
-#define smp_rmb()	barrier()
-#define smp_wmb()	barrier()
-#define smp_store_mb(var, value) do { WRITE_ONCE(var, value); barrier(); } while (0)
-#endif /* SMP */
+#define __smp_mb()	mb()
+#define __smp_rmb()	dma_rmb()
+#define __smp_wmb()	barrier()
+#define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
 
 #if defined(CONFIG_X86_PPRO_FENCE)
 
@@ -50,31 +43,31 @@
  * model and we should fall back to full barriers.
  */
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)					\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	__smp_mb();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
-	smp_mb();							\
+	__smp_mb();							\
 	___p1;								\
 })
 
 #else /* regular x86 TSO memory ordering */
 
-#define smp_store_release(p, v)						\
+#define __smp_store_release(p, v)					\
 do {									\
 	compiletime_assert_atomic_type(*p);				\
 	barrier();							\
 	WRITE_ONCE(*p, v);						\
 } while (0)
 
-#define smp_load_acquire(p)						\
+#define __smp_load_acquire(p)						\
 ({									\
 	typeof(*p) ___p1 = READ_ONCE(*p);				\
 	compiletime_assert_atomic_type(*p);				\
@@ -85,8 +78,8 @@ do {									\
 #endif
 
 /* Atomic operations are already serializing on x86 */
-#define smp_mb__before_atomic()	barrier()
-#define smp_mb__after_atomic()	barrier()
+#define __smp_mb__before_atomic()	barrier()
+#define __smp_mb__after_atomic()	barrier()
 
 #include <asm-generic/barrier.h>
 
Signature · 1 line
MST