Re: [PATCH v2 22/32] s390: define __smp_xxx
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> > Acked-by: Arnd Bergmann > > --- > > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h
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> > Acked-by: Arnd Bergmann > > --- > > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 17/32] arm: define __smp_xxx
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 +, 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_ 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 -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] checkpatch: handling of memory barriers
As part of memory barrier cleanup, this patchset extends checkpatch to make it easier to stop incorrect memory barrier usage. This applies on top of my series arch: barrier cleanup + barriers for virt and will be included in the next version of the series. Michael S. Tsirkin (3): checkpatch.pl: add missing memory barriers checkpatch: check for __smp outside barrier.h checkpatch: add virt barriers scripts/checkpatch.pl | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) -- MST -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 34/34] xen/io: use virt_xxx barriers
On Thu, 31 Dec 2015, Michael S. Tsirkin wrote: > include/xen/interface/io/ring.h 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. TsirkinReviewed-by: Stefano Stabellini > include/xen/interface/io/ring.h | 16 > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/ring.h > index 7dc685b..21f4fbd 100644 > --- a/include/xen/interface/io/ring.h > +++ b/include/xen/interface/io/ring.h > @@ -208,12 +208,12 @@ struct __name##_back_ring { > \ > > > #define RING_PUSH_REQUESTS(_r) do { \ > -wmb(); /* back sees requests /before/ updated producer index */ \ > +virt_wmb(); /* back sees requests /before/ updated producer index */ > \ > (_r)->sring->req_prod = (_r)->req_prod_pvt; > \ > } while (0) > > #define RING_PUSH_RESPONSES(_r) do { \ > -wmb(); /* front sees responses /before/ updated producer index */ > \ > +virt_wmb(); /* front sees responses /before/ updated producer index */ > \ > (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt; > \ > } while (0) > > @@ -250,9 +250,9 @@ struct __name##_back_ring { > \ > #define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do { > \ > RING_IDX __old = (_r)->sring->req_prod; \ > RING_IDX __new = (_r)->req_prod_pvt; \ > -wmb(); /* back sees requests /before/ updated producer index */ \ > +virt_wmb(); /* back sees requests /before/ updated producer index */ > \ > (_r)->sring->req_prod = __new; \ > -mb(); /* back sees new requests /before/ we check req_event */ \ > +virt_mb(); /* back sees new requests /before/ we check req_event */ > \ > (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) < > \ >(RING_IDX)(__new - __old));\ > } while (0) > @@ -260,9 +260,9 @@ struct __name##_back_ring { > \ > #define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do { > \ > RING_IDX __old = (_r)->sring->rsp_prod; \ > RING_IDX __new = (_r)->rsp_prod_pvt; \ > -wmb(); /* front sees responses /before/ updated producer index */ > \ > +virt_wmb(); /* front sees responses /before/ updated producer index */ > \ > (_r)->sring->rsp_prod = __new; \ > -mb(); /* front sees new responses /before/ we check rsp_event */ \ > +virt_mb(); /* front sees new responses /before/ we check rsp_event */ > \ > (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) < > \ >(RING_IDX)(__new - __old));\ > } while (0) > @@ -271,7 +271,7 @@ struct __name##_back_ring { > \ > (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); > \ > if (_work_to_do) break; \ > (_r)->sring->req_event = (_r)->req_cons + 1; \ > -mb();\ > +virt_mb(); > \ > (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); > \ > } while (0) > > @@ -279,7 +279,7 @@ struct __name##_back_ring { > \ > (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); > \ > if (_work_to_do) break; \ > (_r)->sring->rsp_event = (_r)->rsp_cons + 1; \ > -mb();\ > +virt_mb(); > \ > (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); > \ > } while (0) > > -- > MST > -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 33/34] xenbus: use virt_xxx barriers
On Thu, 31 Dec 2015, 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. TsirkinReviewed-by: Stefano Stabellini Are you also going to take care of drivers/xen/grant-table.c drivers/xen/evtchn.c drivers/xen/events/events_fifo.c drivers/xen/xen-scsiback.c drivers/xen/tmem.c drivers/xen/xen-pciback/pci_stub.c drivers/xen/xen-pciback/pciback_ops.c ? > 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(); > > memcpy(dst, data, avail); > data += avail; > len -= avail; > > /* Other side must not see new producer until data is there. */ > - wmb(); > + virt_wmb(); > intf->req_prod += avail; > > /* Implies mb(): other side will see the updated producer. */ > @@ -180,14 +180,14 @@ int xb_read(void *data, unsigned len) > avail = len; > > /* Must read data /after/ reading the producer index. */ > - rmb(); > + virt_rmb(); > > memcpy(data, src, avail); > data += avail; > len -= avail; > > /* Other side must not see free space until we've copied out */ > - mb(); > + virt_mb(); > intf->rsp_cons += avail; > > pr_debug("Finished read of %i bytes (%i to go)\n", avail, len); > -- > MST > -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Xen-devel] [PATCH v2 34/34] xen/io: use virt_xxx barriers
On 31/12/15 19:10, Michael S. Tsirkin wrote: > include/xen/interface/io/ring.h 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. Acked-by: David VrabelDavid -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] checkpatch.pl: add missing memory barriers
SMP-only barriers were missing in checkpatch.pl Refactor code slightly to make adding more variants easier. Signed-off-by: Michael S. Tsirkin--- 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); + my $all_barriers = join('|', (@barriers, @smp_barriers)); + + if ($line =~ /\b($all_barriers)\(/) { if (!ctx_has_comment($first_line, $linenr)) { WARN("MEMORY_BARRIER", "memory barrier without comment\n" . $herecurr); -- MST -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 20/32] metag: define __smp_xxx
Hi Michael, On Thu, Dec 31, 2015 at 09:08:22PM +0200, Michael S. Tsirkin wrote: > 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...). > > Signed-off-by: Michael S. Tsirkin> Acked-by: Arnd Bergmann > --- > arch/metag/include/asm/barrier.h | 32 +++- > 1 file changed, 15 insertions(+), 17 deletions(-) > > diff --git a/arch/metag/include/asm/barrier.h > b/arch/metag/include/asm/barrier.h > index b5b778b..84880c9 100644 > --- a/arch/metag/include/asm/barrier.h > +++ b/arch/metag/include/asm/barrier.h > @@ -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. > - > #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() 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: Acked-by: James Hogan Cheers James > #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 > > -- > MST > signature.asc Description: Digital signature
Re: [PATCH v2 17/32] arm: define __smp_xxx
On Sun, Jan 03, 2016 at 11:12:44AM +0200, Michael S. Tsirkin wrote: > On Sat, Jan 02, 2016 at 11:24:38AM +, 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. -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h
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> Acked-by: Arnd Bergmann > --- > 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. -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 20/32] metag: define __smp_xxx
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? -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 31/32] sh: support a 2-byte smp_store_mb
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> --- > 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(, 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(, 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. -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 33/34] xenbus: use virt_xxx barriers
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> --- > 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. -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 06/32] s390: reuse asm-generic/barrier.h
On Mon, 4 Jan 2016 14:20:42 +0100 Peter Zijlstrawrote: > 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 > > Acked-by: Arnd Bergmann > > --- > > 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. -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 20/32] metag: define __smp_xxx
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 signature.asc Description: Digital signature
Re: [PATCH v2 20/32] metag: define __smp_xxx
On Mon, Jan 04, 2016 at 03:25:58PM +, 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? -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 20/32] metag: define __smp_xxx
On Mon, Jan 04, 2016 at 04:30:36PM +0100, Peter Zijlstra wrote: > On Mon, Jan 04, 2016 at 03:25:58PM +, 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 signature.asc Description: Digital signature
Re: [PATCH 1/3] checkpatch.pl: add missing memory barriers
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. -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] checkpatch.pl: add missing memory barriers
On Mon, 2016-01-04 at 16:11 +, 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. -- To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html