Linux virtualization list
 help / color / mirror / Atom feed
* Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h
From: Peter Zijlstra @ 2016-01-04 13:20 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-mips, linux-ia64, linux-sh, Heiko Carstens, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Davidlohr Bueso, Arnd Bergmann, x86, Christian Borntraeger,
	xen-devel, Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel, Andrew Cooper
In-Reply-To: <1451572003-2440-7-git-send-email-mst@redhat.com>

On Thu, Dec 31, 2015 at 09:06:30PM +0200, Michael S. Tsirkin wrote:
> 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.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/s390/include/asm/barrier.h | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h
> index 7ffd0b1..c358c31 100644
> --- a/arch/s390/include/asm/barrier.h
> +++ b/arch/s390/include/asm/barrier.h
> @@ -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.

^ permalink raw reply

* Re: [PATCH v2 11/32] mips: reuse asm-generic/barrier.h
From: Peter Zijlstra @ 2016-01-04 13:26 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-mips, linux-ia64, linux-sh, virtualization, H. Peter Anvin,
	sparclinux, Ingo Molnar, linux-arch, linux-s390, Arnd Bergmann,
	Michael Ellerman, x86, xen-devel, Ingo Molnar, linux-xtensa,
	user-mode-linux-devel, Stefano Stabellini, Andrey Konovalov,
	adi-buildroot-devel, David Daney, Thomas Gleixner, linux-metag,
	linux-arm-kernel, Andrew Cooper, linux-kernel, Ralf Baechle
In-Reply-To: <1451572003-2440-12-git-send-email-mst@redhat.com>

On Thu, Dec 31, 2015 at 09:07:10PM +0200, Michael S. Tsirkin wrote:
> -#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;								\
> -})

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.

^ permalink raw reply

* Re: [PATCH v2 17/32] arm: define __smp_xxx
From: Peter Zijlstra @ 2016-01-04 13:36 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-mips, linux-ia64, linux-sh, Tony Lindgren, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Russell King - ARM Linux, Arnd Bergmann, x86, xen-devel,
	Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel, Andrew Cooper,
	linux-kernel, linuxppc-dev
In-Reply-To: <20160103110158-mutt-send-email-mst@redhat.com>

On Sun, Jan 03, 2016 at 11:12:44AM +0200, Michael S. Tsirkin wrote:
> On Sat, Jan 02, 2016 at 11:24:38AM +0000, Russell King - ARM Linux wrote:

> > 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.

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.

^ permalink raw reply

* Re: [PATCH v2 20/32] metag: define __smp_xxx
From: Peter Zijlstra @ 2016-01-04 13:41 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-mips, linux-ia64, linux-sh, virtualization, H. Peter Anvin,
	sparclinux, Ingo Molnar, linux-arch, linux-s390, Arnd Bergmann,
	Davidlohr Bueso, x86, xen-devel, Ingo Molnar, linux-xtensa,
	James Hogan, user-mode-linux-devel, Stefano Stabellini,
	Andrey Konovalov, adi-buildroot-devel, Thomas Gleixner,
	linux-metag, linux-arm-kernel, Andrew Cooper, linux-kernel,
	linuxppc-dev
In-Reply-To: <1451572003-2440-21-git-send-email-mst@redhat.com>

On Thu, Dec 31, 2015 at 09:08:22PM +0200, Michael S. Tsirkin wrote:
> +#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?

^ permalink raw reply

* Re: [PATCH v2 22/32] s390: define __smp_xxx
From: Peter Zijlstra @ 2016-01-04 13:45 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-mips, linux-ia64, linux-sh, Heiko Carstens, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Davidlohr Bueso, Arnd Bergmann, x86, Christian Borntraeger,
	xen-devel, Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel, Andrew Cooper
In-Reply-To: <1451572003-2440-23-git-send-email-mst@redhat.com>

On Thu, Dec 31, 2015 at 09:08:38PM +0200, Michael S. Tsirkin wrote:
> 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.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/s390/include/asm/barrier.h | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h
> index c358c31..fbd25b2 100644
> --- a/arch/s390/include/asm/barrier.h
> +++ b/arch/s390/include/asm/barrier.h
> @@ -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()

Why define the smp_*mb() primitives here? Would not the inclusion of
asm-generic/barrier.h do this?

^ permalink raw reply

* Re: [PATCH v2 17/32] arm: define __smp_xxx
From: Peter Zijlstra @ 2016-01-04 13:54 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-mips, linux-ia64, linux-sh, Tony Lindgren, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Russell King - ARM Linux, Arnd Bergmann, x86, xen-devel,
	Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel, Andrew Cooper,
	linux-kernel, linuxppc-dev
In-Reply-To: <20160104133658.GY6344@twins.programming.kicks-ass.net>

On Mon, Jan 04, 2016 at 02:36:58PM +0100, Peter Zijlstra wrote:
> On Sun, Jan 03, 2016 at 11:12:44AM +0200, Michael S. Tsirkin wrote:
> > On Sat, Jan 02, 2016 at 11:24:38AM +0000, Russell King - ARM Linux wrote:
> 
> > > 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.
> 
> 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?

^ permalink raw reply

* Re: [PATCH v2 17/32] arm: define __smp_xxx
From: Russell King - ARM Linux @ 2016-01-04 13:59 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-mips, linux-ia64, Michael S. Tsirkin, Tony Lindgren,
	virtualization, H. Peter Anvin, sparclinux, Ingo Molnar,
	linux-arch, linux-s390, Arnd Bergmann, linux-sh, x86, xen-devel,
	Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel, Andrew Cooper,
	linux-kernel, linuxppc-dev
In-Reply-To: <20160104135420.GS6373@twins.programming.kicks-ass.net>

On Mon, Jan 04, 2016 at 02:54:20PM +0100, Peter Zijlstra wrote:
> On Mon, Jan 04, 2016 at 02:36:58PM +0100, Peter Zijlstra wrote:
> > On Sun, Jan 03, 2016 at 11:12:44AM +0200, Michael S. Tsirkin wrote:
> > > On Sat, Jan 02, 2016 at 11:24:38AM +0000, Russell King - ARM Linux wrote:
> > 
> > > > 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.
> > 
> > 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.

-- 
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.

^ permalink raw reply

* Re: [PATCH v2 31/32] sh: support a 2-byte smp_store_mb
From: Peter Zijlstra @ 2016-01-04 14:05 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-mips, linux-ia64, linux-sh, virtualization, H. Peter Anvin,
	sparclinux, Ingo Molnar, linux-arch, linux-s390, Arnd Bergmann,
	x86, xen-devel, Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, adi-buildroot-devel, Thomas Gleixner,
	linux-metag, linux-arm-kernel, Andrew Cooper, linux-kernel,
	linuxppc-dev, David Miller
In-Reply-To: <1451572003-2440-32-git-send-email-mst@redhat.com>

On Thu, Dec 31, 2015 at 09:09:47PM +0200, Michael S. Tsirkin wrote:
> At the moment, xchg on sh only supports 4 and 1 byte values, so using it
> from smp_store_mb means attempts to store a 2 byte value using this
> macro fail.
> 
> And happens to be exactly what virtio drivers want to do.
> 
> Check size and fall back to a slower, but safe, WRITE_ONCE+smp_mb.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  arch/sh/include/asm/barrier.h | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/sh/include/asm/barrier.h b/arch/sh/include/asm/barrier.h
> index f887c64..0cc5735 100644
> --- a/arch/sh/include/asm/barrier.h
> +++ b/arch/sh/include/asm/barrier.h
> @@ -32,7 +32,15 @@
>  #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 { \
> +	if (sizeof(var) != 4 && sizeof(var) != 1) { \
> +		 WRITE_ONCE(var, value); \
> +		__smp_mb(); \
> +	} else { \
> +		(void)xchg(&var, value);  \
> +	} \
> +} while (0)

So SH is an orphaned arch, which is also why I did not comment on using
xchg() for the UP smp_store_mb() thing.

But I really think we should try fixing the xchg() implementation
instead of this duct-tape.

^ permalink raw reply

* Re: [PATCH v2 33/34] xenbus: use virt_xxx barriers
From: Peter Zijlstra @ 2016-01-04 14:09 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-mips, linux-ia64, linux-sh, virtualization, H. Peter Anvin,
	sparclinux, Boris Ostrovsky, linux-arch, linux-s390,
	Arnd Bergmann, x86, xen-devel, Ingo Molnar, linux-xtensa,
	user-mode-linux-devel, Stefano Stabellini, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel,
	Konrad Rzeszutek Wilk, Andrew Cooper, linux-kernel, David Vrabel,
	linuxppc-dev
In-Reply-To: <1451572003-2440-34-git-send-email-mst@redhat.com>

On Thu, Dec 31, 2015 at 09:10:01PM +0200, Michael S. Tsirkin wrote:
> drivers/xen/xenbus/xenbus_comms.c uses
> full memory barriers to communicate with the other side.
> 
> For guests compiled with CONFIG_SMP, smp_wmb and smp_mb
> would be sufficient, so mb() and wmb() here are only needed if
> a non-SMP guest runs on an SMP host.
> 
> Switch to virt_xxx barriers which serve this exact purpose.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/xen/xenbus/xenbus_comms.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/xen/xenbus/xenbus_comms.c b/drivers/xen/xenbus/xenbus_comms.c
> index fdb0f33..ecdecce 100644
> --- a/drivers/xen/xenbus/xenbus_comms.c
> +++ b/drivers/xen/xenbus/xenbus_comms.c
> @@ -123,14 +123,14 @@ int xb_write(const void *data, unsigned len)
>  			avail = len;
>  
>  		/* Must write data /after/ reading the consumer index. */
> -		mb();
> +		virt_mb();
>  

So its possible to remove this barrier entirely, see the "CONTROL
DEPENDNCIES" chunk of memory-barrier.txt.

But do that in a separate patch series and only if you really really
need the performance.

^ permalink raw reply

* Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h
From: Martin Schwidefsky @ 2016-01-04 15:03 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-mips, linux-ia64, Michael S. Tsirkin, Heiko Carstens,
	virtualization, H. Peter Anvin, sparclinux, Ingo Molnar,
	linux-arch, linux-s390, Davidlohr Bueso, Arnd Bergmann, linux-sh,
	x86, Christian Borntraeger, xen-devel, Ingo Molnar, linux-xtensa,
	user-mode-linux-devel, Stefano Stabellini, Andrey Konovalov,
	adi-buildroot-devel, Thomas Gleixner, linux-metag,
	linux-arm-kernel, Andrew
In-Reply-To: <20160104132042.GW6344@twins.programming.kicks-ass.net>

On Mon, 4 Jan 2016 14:20:42 +0100
Peter Zijlstra <peterz@infradead.org> wrote:

> On Thu, Dec 31, 2015 at 09:06:30PM +0200, Michael S. Tsirkin wrote:
> > 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.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > Acked-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  arch/s390/include/asm/barrier.h | 10 ++--------
> >  1 file changed, 2 insertions(+), 8 deletions(-)
> > 
> > diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h
> > index 7ffd0b1..c358c31 100644
> > --- a/arch/s390/include/asm/barrier.h
> > +++ b/arch/s390/include/asm/barrier.h
> > @@ -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.
 
Yes, we wanted to simplify this. Thanks for the reminder, I'll queue
a patch.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

^ permalink raw reply

* Re: [PATCH v2 20/32] metag: define __smp_xxx
From: James Hogan @ 2016-01-04 15:25 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-mips, linux-ia64, Michael S. Tsirkin, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Arnd Bergmann, Davidlohr Bueso, linux-sh, x86, xen-devel,
	Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel, Andrew Cooper,
	linux-kernel, linuxppc-dev
In-Reply-To: <20160104134128.GZ6344@twins.programming.kicks-ass.net>


[-- Attachment #1.1: Type: text/plain, Size: 1789 bytes --]

Hi Peter,

On Mon, Jan 04, 2016 at 02:41:28PM +0100, Peter Zijlstra wrote:
> On Thu, Dec 31, 2015 at 09:08:22PM +0200, Michael S. Tsirkin wrote:
> > +#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:

> 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

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* Re: [PATCH v2 20/32] metag: define __smp_xxx
From: Peter Zijlstra @ 2016-01-04 15:30 UTC (permalink / raw)
  To: James Hogan
  Cc: linux-mips, linux-ia64, Michael S. Tsirkin, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Arnd Bergmann, Davidlohr Bueso, linux-sh, x86, xen-devel,
	Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel, Andrew Cooper,
	linux-kernel, linuxppc-dev
In-Reply-To: <20160104152558.GD17861@jhogan-linux.le.imgtec.org>

On Mon, Jan 04, 2016 at 03:25:58PM +0000, James Hogan wrote:
> 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.

> 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?

^ permalink raw reply

* Re: [PATCH v2 20/32] metag: define __smp_xxx
From: James Hogan @ 2016-01-04 16:04 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-mips, linux-ia64, Michael S. Tsirkin, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Arnd Bergmann, Davidlohr Bueso, linux-sh, x86, xen-devel,
	Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel, Andrew Cooper,
	linux-kernel, linuxppc-dev
In-Reply-To: <20160104153036.GG6344@twins.programming.kicks-ass.net>


[-- Attachment #1.1: Type: text/plain, Size: 1505 bytes --]

On Mon, Jan 04, 2016 at 04:30:36PM +0100, Peter Zijlstra wrote:
> On Mon, Jan 04, 2016 at 03:25:58PM +0000, James Hogan wrote:
> > 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.

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.

> 
> > 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

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* Re: [PATCH 1/3] checkpatch.pl: add missing memory barriers
From: Joe Perches @ 2016-01-04 16:07 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel
  Cc: linux-mips, linux-ia64, linux-sh, Peter Zijlstra, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Russell King - ARM Linux, Arnd Bergmann, x86, Tony Lindgren,
	xen-devel, Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Cc : Andy Whitcroft, Thomas Gleixner, linux-metag,
	linux-arm-kernel, Andrew
In-Reply-To: <1451907395-15978-2-git-send-email-mst@redhat.com>

On Mon, 2016-01-04 at 13:36 +0200, Michael S. Tsirkin wrote:
> SMP-only barriers were missing in checkpatch.pl
> 
> Refactor code slightly to make adding more variants easier.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  scripts/checkpatch.pl | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 2b3c228..0245bbe 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5116,7 +5116,14 @@ sub process {
>  			}
>  		}
>  # check for memory barriers without a comment.
> -		if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) {
> +
> +		my @barriers = ('mb', 'rmb', 'wmb', 'read_barrier_depends');
> +		my @smp_barriers = ('smp_store_release', 'smp_load_acquire', 'smp_store_mb');
> +
> +		@smp_barriers = (@smp_barriers, map {"smp_" . $_} @barriers);

I think using map, which so far checkpatch doesn't use,
makes smp_barriers harder to understand and it'd be
better to enumerate them.

> +		my $all_barriers = join('|', (@barriers, @smp_barriers));
> +
> +		if ($line =~ /\b($all_barriers)\(/) {

It would be better to use /\b$all_barriers\s*\(/
as there's no reason for the capture and there
could be a space between the function and the
open parenthesis.


>  			if (!ctx_has_comment($first_line, $linenr)) {
>  				WARN("MEMORY_BARRIER",
>  				     "memory barrier without comment\n" . $herecurr);

^ permalink raw reply

* Re: [PATCH 1/3] checkpatch.pl: add missing memory barriers
From: Russell King - ARM Linux @ 2016-01-04 16:11 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-mips, linux-ia64, Michael S. Tsirkin, Peter Zijlstra,
	virtualization, H. Peter Anvin, sparclinux, Ingo Molnar,
	linux-arch, linux-s390, Arnd Bergmann, linux-sh, x86,
	Tony Lindgren, xen-devel, Ingo Molnar, linux-xtensa,
	user-mode-linux-devel, Stefano Stabellini, Andrey Konovalov,
	adi-buildroot-devel, Cc : Andy Whitcroft, Thomas Gleixner,
	linux-metag, linux-arm-kernel, Andrew Cooper <andrew>
In-Reply-To: <1451923660.4334.83.camel@perches.com>

On Mon, Jan 04, 2016 at 08:07:40AM -0800, Joe Perches wrote:
> On Mon, 2016-01-04 at 13:36 +0200, Michael S. Tsirkin wrote:
> > +		my $all_barriers = join('|', (@barriers, @smp_barriers));
> > +
> > +		if ($line =~ /\b($all_barriers)\(/) {
> 
> It would be better to use /\b$all_barriers\s*\(/
> as there's no reason for the capture and there
> could be a space between the function and the
> open parenthesis.

I think you mean

	/\b(?:$all_barriers)\s*\(/

as 'all_barriers' will be:

	mb|wmb|rmb|smp_mb|smp_wmb|smp_rmb

and putting that into your suggestion results in:

	/\bmb|wmb|rmb|smp_mb|smp_wmb|smp_rmb\s*\(/

which is clearly wrong - the \b only applies to 'mb' and the \s*\( only
applies to smp_rmb.

-- 
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.

^ permalink raw reply

* Re: [PATCH 1/3] checkpatch.pl: add missing memory barriers
From: Joe Perches @ 2016-01-04 16:15 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-mips, linux-ia64, Michael S. Tsirkin, Peter Zijlstra,
	virtualization, H. Peter Anvin, sparclinux, Ingo Molnar,
	linux-arch, linux-s390, Arnd Bergmann, linux-sh, x86,
	Tony Lindgren, xen-devel, Ingo Molnar, linux-xtensa,
	user-mode-linux-devel, Stefano Stabellini, Andrey Konovalov,
	adi-buildroot-devel, Cc : Andy Whitcroft, Thomas Gleixner,
	linux-metag, linux-arm-kernel, Andrew Cooper <andrew>
In-Reply-To: <20160104161123.GJ19062@n2100.arm.linux.org.uk>

On Mon, 2016-01-04 at 16:11 +0000, Russell King - ARM Linux wrote:
> On Mon, Jan 04, 2016 at 08:07:40AM -0800, Joe Perches wrote:
> > On Mon, 2016-01-04 at 13:36 +0200, Michael S. Tsirkin wrote:
> > > +		my $all_barriers = join('|', (@barriers, @smp_barriers));
> > > +
> > > +		if ($line =~ /\b($all_barriers)\(/) {
> > 
> > It would be better to use /\b$all_barriers\s*\(/
> > as there's no reason for the capture and there
> > could be a space between the function and the
> > open parenthesis.
> 
> I think you mean
> 
> 	/\b(?:$all_barriers)\s*\(/
> 
> as 'all_barriers' will be:
> 
> 	mb|wmb|rmb|smp_mb|smp_wmb|smp_rmb
> 
> and putting that into your suggestion results in:
> 
> 	/\bmb|wmb|rmb|smp_mb|smp_wmb|smp_rmb\s*\(/
> 
> which is clearly wrong - the \b only applies to 'mb' and the \s*\( only
> applies to smp_rmb.

right, thanks.

^ permalink raw reply

* Re: [PATCH 3/3] checkpatch: add virt barriers
From: Joe Perches @ 2016-01-04 16:47 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel
  Cc: linux-mips, linux-ia64, linux-sh, Peter Zijlstra, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Russell King - ARM Linux, Arnd Bergmann, x86, Tony Lindgren,
	xen-devel, Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Cc : Andy Whitcroft, Thomas Gleixner, linux-metag,
	linux-arm-kernel, Andrew
In-Reply-To: <1451907395-15978-4-git-send-email-mst@redhat.com>

On Mon, 2016-01-04 at 13:37 +0200, Michael S. Tsirkin wrote:
> Add virt_ barriers to list of barriers to check for
> presence of a comment.

Are these virt_ barriers used anywhere?

I see some virtio_ barrier like uses.

^ permalink raw reply

* Re: [PATCH v2 17/32] arm: define __smp_xxx
From: Michael S. Tsirkin @ 2016-01-04 20:12 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-mips, linux-ia64, linux-sh, Tony Lindgren, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Russell King - ARM Linux, Arnd Bergmann, x86, xen-devel,
	Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel, Andrew Cooper,
	linux-kernel, linuxppc-dev
In-Reply-To: <20160104133658.GY6344@twins.programming.kicks-ass.net>

On Mon, Jan 04, 2016 at 02:36:58PM +0100, Peter Zijlstra wrote:
> On Sun, Jan 03, 2016 at 11:12:44AM +0200, Michael S. Tsirkin wrote:
> > On Sat, Jan 02, 2016 at 11:24:38AM +0000, Russell King - ARM Linux wrote:
> 
> > > 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.
> 
> 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.

> 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.

-- 
MST

^ permalink raw reply

* Re: [PATCH v2 22/32] s390: define __smp_xxx
From: Michael S. Tsirkin @ 2016-01-04 20:18 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-mips, linux-ia64, linux-sh, Heiko Carstens, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Davidlohr Bueso, Arnd Bergmann, x86, Christian Borntraeger,
	xen-devel, Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel, Andrew Cooper
In-Reply-To: <20160104134525.GA6344@twins.programming.kicks-ass.net>

On Mon, Jan 04, 2016 at 02:45:25PM +0100, Peter Zijlstra wrote:
> On Thu, Dec 31, 2015 at 09:08:38PM +0200, Michael S. Tsirkin wrote:
> > 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.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > Acked-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  arch/s390/include/asm/barrier.h | 15 +++++++++------
> >  1 file changed, 9 insertions(+), 6 deletions(-)
> > 
> > diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h
> > index c358c31..fbd25b2 100644
> > --- a/arch/s390/include/asm/barrier.h
> > +++ b/arch/s390/include/asm/barrier.h
> > @@ -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()
> 
> 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.

-- 
MST

^ permalink raw reply

* Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h
From: Michael S. Tsirkin @ 2016-01-04 20:34 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-mips, linux-ia64, linux-sh, Heiko Carstens, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Davidlohr Bueso, Arnd Bergmann, x86, Christian Borntraeger,
	xen-devel, Ingo Molnar, Paul E. McKenney, linux-xtensa,
	user-mode-linux-devel, Stefano Stabellini, Andrey Konovalov,
	adi-buildroot-devel, Thomas Gleixner, linux-metag,
	linux-arm-kernel
In-Reply-To: <20160104132042.GW6344@twins.programming.kicks-ass.net>

On Mon, Jan 04, 2016 at 02:20:42PM +0100, Peter Zijlstra wrote:
> On Thu, Dec 31, 2015 at 09:06:30PM +0200, Michael S. Tsirkin wrote:
> > 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.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > Acked-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  arch/s390/include/asm/barrier.h | 10 ++--------
> >  1 file changed, 2 insertions(+), 8 deletions(-)
> > 
> > diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h
> > index 7ffd0b1..c358c31 100644
> > --- a/arch/s390/include/asm/barrier.h
> > +++ b/arch/s390/include/asm/barrier.h
> > @@ -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.

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?

-- 
MST

^ permalink raw reply

* Re: [PATCH v2 17/32] arm: define __smp_xxx
From: Michael S. Tsirkin @ 2016-01-04 20:39 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-mips, linux-ia64, linux-sh, Tony Lindgren, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Russell King - ARM Linux, Arnd Bergmann, x86, xen-devel,
	Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Thomas Gleixner, linux-metag, linux-arm-kernel, Andrew Cooper,
	linux-kernel, linuxppc-dev
In-Reply-To: <20160104135420.GS6373@twins.programming.kicks-ass.net>

On Mon, Jan 04, 2016 at 02:54:20PM +0100, Peter Zijlstra wrote:
> On Mon, Jan 04, 2016 at 02:36:58PM +0100, Peter Zijlstra wrote:
> > On Sun, Jan 03, 2016 at 11:12:44AM +0200, Michael S. Tsirkin wrote:
> > > On Sat, Jan 02, 2016 at 11:24:38AM +0000, Russell King - ARM Linux wrote:
> > 
> > > > 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.
> > 
> > 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.


-- 
MST

^ permalink raw reply

* Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h
From: Michael S. Tsirkin @ 2016-01-04 20:42 UTC (permalink / raw)
  To: Martin Schwidefsky
  Cc: linux-mips, linux-ia64, linux-sh, Peter Zijlstra, Heiko Carstens,
	virtualization, H. Peter Anvin, sparclinux, Ingo Molnar,
	linux-arch, linux-s390, Davidlohr Bueso, Arnd Bergmann, x86,
	Christian Borntraeger, xen-devel, Ingo Molnar, linux-xtensa,
	user-mode-linux-devel, Stefano Stabellini, Andrey Konovalov,
	adi-buildroot-devel, Thomas Gleixner, linux-metag,
	linux-arm-kernel, Andrew
In-Reply-To: <20160104160339.25101b5d@mschwide>

On Mon, Jan 04, 2016 at 04:03:39PM +0100, Martin Schwidefsky wrote:
> On Mon, 4 Jan 2016 14:20:42 +0100
> Peter Zijlstra <peterz@infradead.org> wrote:
> 
> > On Thu, Dec 31, 2015 at 09:06:30PM +0200, Michael S. Tsirkin wrote:
> > > 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.
> > > 
> > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > > Acked-by: Arnd Bergmann <arnd@arndb.de>
> > > ---
> > >  arch/s390/include/asm/barrier.h | 10 ++--------
> > >  1 file changed, 2 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h
> > > index 7ffd0b1..c358c31 100644
> > > --- a/arch/s390/include/asm/barrier.h
> > > +++ b/arch/s390/include/asm/barrier.h
> > > @@ -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.
>  
> 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.

> -- 
> blue skies,
>    Martin.
> 
> "Reality continues to ruin my life." - Calvin.

^ permalink raw reply

* Re: [PATCH 1/3] checkpatch.pl: add missing memory barriers
From: Michael S. Tsirkin @ 2016-01-04 20:45 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-mips, linux-ia64, linux-sh, Peter Zijlstra, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Russell King - ARM Linux, Arnd Bergmann, x86, Tony Lindgren,
	xen-devel, Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Cc : Andy Whitcroft, Thomas Gleixner, linux-metag,
	linux-arm-kernel, Andrew
In-Reply-To: <1451923660.4334.83.camel@perches.com>

On Mon, Jan 04, 2016 at 08:07:40AM -0800, Joe Perches wrote:
> On Mon, 2016-01-04 at 13:36 +0200, Michael S. Tsirkin wrote:
> > SMP-only barriers were missing in checkpatch.pl
> > 
> > Refactor code slightly to make adding more variants easier.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  scripts/checkpatch.pl | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 2b3c228..0245bbe 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -5116,7 +5116,14 @@ sub process {
> >  			}
> >  		}
> >  # check for memory barriers without a comment.
> > -		if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) {
> > +
> > +		my @barriers = ('mb', 'rmb', 'wmb', 'read_barrier_depends');
> > +		my @smp_barriers = ('smp_store_release', 'smp_load_acquire', 'smp_store_mb');
> > +
> > +		@smp_barriers = (@smp_barriers, map {"smp_" . $_} @barriers);
> 
> I think using map, which so far checkpatch doesn't use,
> makes smp_barriers harder to understand and it'd be
> better to enumerate them.

Okay - I'll rewrite using foreach.

> > +		my $all_barriers = join('|', (@barriers, @smp_barriers));
> > +
> > +		if ($line =~ /\b($all_barriers)\(/) {
> 
> It would be better to use /\b$all_barriers\s*\(/
> as there's no reason for the capture and there
> could be a space between the function and the
> open parenthesis.

That's the way it was - space before ( will trigger other
warnings. But sure, ok.

> 
> >  			if (!ctx_has_comment($first_line, $linenr)) {
> >  				WARN("MEMORY_BARRIER",
> >  				     "memory barrier without comment\n" . $herecurr);

^ permalink raw reply

* Re: [PATCH 3/3] checkpatch: add virt barriers
From: Michael S. Tsirkin @ 2016-01-04 21:07 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-mips, linux-ia64, linux-sh, Peter Zijlstra, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Russell King - ARM Linux, Arnd Bergmann, x86, Tony Lindgren,
	xen-devel, Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Cc : Andy Whitcroft, Thomas Gleixner, linux-metag,
	linux-arm-kernel, Andrew
In-Reply-To: <1451926073.4334.90.camel@perches.com>

On Mon, Jan 04, 2016 at 08:47:53AM -0800, Joe Perches wrote:
> On Mon, 2016-01-04 at 13:37 +0200, Michael S. Tsirkin wrote:
> > Add virt_ barriers to list of barriers to check for
> > presence of a comment.
> 
> Are these virt_ barriers used anywhere?
> 
> I see some virtio_ barrier like uses.

They will be :) They are added and used by patchset
	        arch: barrier cleanup + barriers for virt

See
http://article.gmane.org/gmane.linux.kernel.virtualization/26555


-- 
MST

^ permalink raw reply

* Re: [PATCH 3/3] checkpatch: add virt barriers
From: Joe Perches @ 2016-01-04 22:11 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-mips, linux-ia64, linux-sh, Peter Zijlstra, virtualization,
	H. Peter Anvin, sparclinux, Ingo Molnar, linux-arch, linux-s390,
	Russell King - ARM Linux, Arnd Bergmann, x86, Tony Lindgren,
	xen-devel, Ingo Molnar, linux-xtensa, user-mode-linux-devel,
	Stefano Stabellini, Andrey Konovalov, adi-buildroot-devel,
	Cc : Andy Whitcroft, Thomas Gleixner, linux-metag,
	linux-arm-kernel, Andrew
In-Reply-To: <20160104230528-mutt-send-email-mst@redhat.com>

On Mon, 2016-01-04 at 23:07 +0200, Michael S. Tsirkin wrote:
> On Mon, Jan 04, 2016 at 08:47:53AM -0800, Joe Perches wrote:
> > On Mon, 2016-01-04 at 13:37 +0200, Michael S. Tsirkin wrote:
> > > Add virt_ barriers to list of barriers to check for
> > > presence of a comment.
> > 
> > Are these virt_ barriers used anywhere?
> > 
> > I see some virtio_ barrier like uses.
> 
> They will be :) They are added and used by patchset
> 	        arch: barrier cleanup + barriers for virt
> 
> See
> http://article.gmane.org/gmane.linux.kernel.virtualization/26555

Ah, OK, thanks.

Are the virtio_ barriers going away?
If not, maybe those should be added too.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox