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 Vrabel David -- 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 33/34] xenbus: use virt_xxx barriers
On 31/12/15 19:10, 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. Acked-by: David Vrabel If you're feeling particularly keen there's a rmb() consume_one_event() in drivers/xen/events/events_fifo.c that can be converted to virt_rmb() as well. David -- 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
[PATCH 3/3] checkpatch: add virt barriers
Add virt_ barriers to list of barriers to check for presence of a comment. Signed-off-by: Michael S. Tsirkin --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e3f9ad9..5fb6ef7 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5121,7 +5121,8 @@ sub process { 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)); + my @virt_barriers = map {my $l = $_; $l =~ s/smp_/virt_/; $l} @smp_barriers; + my $all_barriers = join('|', (@barriers, @smp_barriers, @virt_barriers)); if ($line =~ /\b($all_barriers)\(/) { if (!ctx_has_comment($first_line, $linenr)) { -- 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 2/3] checkpatch: check for __smp outside barrier.h
Introduction of __smp barriers cleans up a bunch of duplicate code, but 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 (as happened with other arch stuff before.) Add a checkpatch test so it will trigger a warning. Reported-by: Russell King Signed-off-by: Michael S. Tsirkin --- scripts/checkpatch.pl | 11 +++ 1 file changed, 11 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0245bbe..e3f9ad9 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5130,6 +5130,17 @@ sub process { } } + my @underscore_smp_barriers = map {"__" . $_} @smp_barriers; + my $underscore_all_barriers = join('|', @underscore_smp_barriers); + + if ($realfile !~ m@^include/asm-generic/@ && + $realfile !~ m@/barrier\.h$@ && + $line =~ m/\b($underscore_all_barriers)\(/ && + $line !~ m/^.\s*\#\s*define\s+($underscore_all_barriers)\(/) { + WARN("MEMORY_BARRIER", +"__smp memory barriers shouldn't be used outside barrier.h and asm-generic\n" . $herecurr); + } + # check for waitqueue_active without a comment. if ($line =~ /\bwaitqueue_active\s*\(/) { if (!ctx_has_comment($first_line, $linenr)) { -- 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 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 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. Tsirkin Reviewed-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: [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. Tsirkin Reviewed-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 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 11/32] mips: reuse asm-generic/barrier.h
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. -- 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 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 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 22/32] s390: define __smp_xxx
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? -- 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? 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? -- 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: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 +, 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. -- 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(&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. -- 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 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. 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
Re: [PATCH 1/3] checkpatch.pl: add missing memory barriers
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 > --- > 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); -- 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 3/3] checkpatch: add virt barriers
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. -- 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
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: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 +, 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 -- 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 04:03:39PM +0100, Martin Schwidefsky wrote: > On Mon, 4 Jan 2016 14:20:42 +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. > > 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. -- 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, 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 > > --- > > 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); -- 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 3/3] checkpatch: add virt barriers
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 -- 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 3/3] checkpatch: add virt barriers
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. -- 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 22:45 +0200, Michael S. Tsirkin 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: > > > 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); > > > > 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. > I think using the qr form (like 'our $Attribute' and a bunch of others) is the general style that should be used for checkpatch. -- 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] metag: ftrace: remove the misleading comment for ftrace_dyn_arch_init
On Mon, Dec 28, 2015 at 04:34:07PM +0800, Li Bin wrote: > ftrace_dyn_arch_init no longer in kstop_machine, so remove the > corresponding comment. > > Signed-off-by: Li Bin Applied, thanks, Cheers James > --- > arch/metag/kernel/ftrace.c |1 - > 1 files changed, 0 insertions(+), 1 deletions(-) > > diff --git a/arch/metag/kernel/ftrace.c b/arch/metag/kernel/ftrace.c > index ed1d685..4abcae4 100644 > --- a/arch/metag/kernel/ftrace.c > +++ b/arch/metag/kernel/ftrace.c > @@ -116,7 +116,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned > long addr) > return ftrace_modify_code(ip, old, new); > } > > -/* run from kstop_machine */ > int __init ftrace_dyn_arch_init(void) > { > return 0; > -- > 1.7.1 > > -- > 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 signature.asc Description: Digital signature
Re: [PATCH v2 10/32] metag: reuse asm-generic/barrier.h
On Thu, Dec 31, 2015 at 09:07:02PM +0200, Michael S. Tsirkin wrote: > 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. > > Signed-off-by: Michael S. Tsirkin > Acked-by: Arnd Bergmann Looks good, and confirmed no text change (once patch 1 is applied that is). Acked-by: James Hogan Thanks James > --- > arch/metag/include/asm/barrier.h | 25 ++--- > 1 file changed, 2 insertions(+), 23 deletions(-) > > diff --git a/arch/metag/include/asm/barrier.h > b/arch/metag/include/asm/barrier.h > index 172b7e5..b5b778b 100644 > --- a/arch/metag/include/asm/barrier.h > +++ b/arch/metag/include/asm/barrier.h > @@ -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 > + > #endif /* _ASM_METAG_BARRIER_H */ > -- > MST > signature.asc Description: Digital signature
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 15/32] powerpc: define __smp_xxx
Hi Michael, On Thu, Dec 31, 2015 at 09:07:42PM +0200, Michael S. Tsirkin wrote: > 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. > > Signed-off-by: Michael S. Tsirkin > Acked-by: Arnd Bergmann > --- > arch/powerpc/include/asm/barrier.h | 24 > 1 file changed, 8 insertions(+), 16 deletions(-) > > diff --git a/arch/powerpc/include/asm/barrier.h > b/arch/powerpc/include/asm/barrier.h > index 980ad0c..c0deafc 100644 > --- a/arch/powerpc/include/asm/barrier.h > +++ b/arch/powerpc/include/asm/barrier.h > @@ -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? > -#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(); \ , 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 > 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; \ > }) > > -- > MST > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- 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