Re: [RFC] virtio-net: help live migrate SR-IOV devices

2017-12-05 Thread achiad shochat
On 4 December 2017 at 18:30, Alexander Duyck wrote: > On Mon, Dec 4, 2017 at 1:51 AM, achiad shochat > wrote: >> On 3 December 2017 at 19:35, Stephen Hemminger >> wrote: >>> On Sun, 3 Dec 2017 11:14:37 +0200 >>>

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Peter Zijlstra
On Tue, Dec 05, 2017 at 09:51:48PM +0200, Michael S. Tsirkin wrote: > > > WRITE_ONCE(obj->val, 1); > > > smp_wmb(); > > > WRITE_ONCE(*foo, obj); > > > > I believe Peter was instead suggesting: > > > > WRITE_ONCE(obj->val, 1); > > smp_store_release(foo, obj); > > Isn't that more expensive

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Michael S. Tsirkin
On Tue, Dec 05, 2017 at 08:57:52PM +0100, Peter Zijlstra wrote: > On Tue, Dec 05, 2017 at 09:51:48PM +0200, Michael S. Tsirkin wrote: > > > > WRITE_ONCE(obj->val, 1); > > > > smp_wmb(); > > > > WRITE_ONCE(*foo, obj); > > > > > > I believe Peter was instead suggesting: > > > > > >

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Paul E. McKenney
On Tue, Dec 05, 2017 at 11:24:49PM +0200, Michael S. Tsirkin wrote: > On Tue, Dec 05, 2017 at 12:08:01PM -0800, Paul E. McKenney wrote: > > On Tue, Dec 05, 2017 at 09:51:48PM +0200, Michael S. Tsirkin wrote: > > > On Tue, Dec 05, 2017 at 11:33:39AM -0800, Paul E. McKenney wrote: > > > > On Tue,

Re: [RFC] virtio-net: help live migrate SR-IOV devices

2017-12-05 Thread Jesse Brandeburg
On Tue, 5 Dec 2017 21:20:07 +0200 "Michael S. Tsirkin" wrote: > On Tue, Dec 05, 2017 at 11:59:17AM +0200, achiad shochat wrote: > > Then we'll have a single solution for both netvsc and virtio (and any > > other PV device). > > And we could handle the VF DMA dirt issue

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Peter Zijlstra
On Tue, Dec 05, 2017 at 11:24:49PM +0200, Michael S. Tsirkin wrote: > READ_ONCE is really all over the place (some code literally replaced all > memory accesses with READ/WRITE ONCE). Yeah, so? Complain to the compiler people for forcing us into that. > Would an API like

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Paul E. McKenney
On Tue, Dec 05, 2017 at 11:43:41PM +0200, Michael S. Tsirkin wrote: > On Tue, Dec 05, 2017 at 01:36:44PM -0800, Paul E. McKenney wrote: > > On Tue, Dec 05, 2017 at 11:24:49PM +0200, Michael S. Tsirkin wrote: > > > On Tue, Dec 05, 2017 at 12:08:01PM -0800, Paul E. McKenney wrote: > > > > On Tue,

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Peter Zijlstra
On Tue, Dec 05, 2017 at 01:36:44PM -0800, Paul E. McKenney wrote: > What we do in some code is to comment the pairings, allowing the other > side of the pairing to be easily located. Would that work for you? I would say that that is mandatory for any memory ordering code ;-)

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Michael S. Tsirkin
On Tue, Dec 05, 2017 at 10:57:00PM +0100, Peter Zijlstra wrote: > On Tue, Dec 05, 2017 at 11:24:49PM +0200, Michael S. Tsirkin wrote: > > READ_ONCE is really all over the place (some code literally replaced all > > memory accesses with READ/WRITE ONCE). > > Yeah, so? Oh my point was I can't just

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Paul E. McKenney
On Tue, Dec 05, 2017 at 09:24:21PM +0200, Michael S. Tsirkin wrote: > On Tue, Dec 05, 2017 at 08:17:33PM +0100, Peter Zijlstra wrote: > > On Tue, Dec 05, 2017 at 08:57:46PM +0200, Michael S. Tsirkin wrote: > > > > > I don't see WRITE_ONCE inserting any barriers, release or > > > write. > > > >

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Peter Zijlstra
On Tue, Dec 05, 2017 at 09:24:21PM +0200, Michael S. Tsirkin wrote: > On Tue, Dec 05, 2017 at 08:17:33PM +0100, Peter Zijlstra wrote: > > On Tue, Dec 05, 2017 at 08:57:46PM +0200, Michael S. Tsirkin wrote: > > > > > I don't see WRITE_ONCE inserting any barriers, release or > > > write. > > > >

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Michael S. Tsirkin
On Tue, Dec 05, 2017 at 11:33:39AM -0800, Paul E. McKenney wrote: > On Tue, Dec 05, 2017 at 09:24:21PM +0200, Michael S. Tsirkin wrote: > > On Tue, Dec 05, 2017 at 08:17:33PM +0100, Peter Zijlstra wrote: > > > On Tue, Dec 05, 2017 at 08:57:46PM +0200, Michael S. Tsirkin wrote: > > > > > > > I

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Paul E. McKenney
On Tue, Dec 05, 2017 at 09:51:48PM +0200, Michael S. Tsirkin wrote: > On Tue, Dec 05, 2017 at 11:33:39AM -0800, Paul E. McKenney wrote: > > On Tue, Dec 05, 2017 at 09:24:21PM +0200, Michael S. Tsirkin wrote: [ . . . ] > > > and this barrier is no longer paired with anything until > > > you

Re: [RFC] virtio-net: help live migrate SR-IOV devices

2017-12-05 Thread Michael S. Tsirkin
On Tue, Dec 05, 2017 at 01:52:26PM -0800, Jesse Brandeburg wrote: > On Tue, 5 Dec 2017 21:20:07 +0200 > "Michael S. Tsirkin" wrote: > > > On Tue, Dec 05, 2017 at 11:59:17AM +0200, achiad shochat wrote: > > > Then we'll have a single solution for both netvsc and virtio (and any >

[PATCH] ptr_ring: add barriers

2017-12-05 Thread Michael S. Tsirkin
Users of ptr_ring expect that it's safe to give the data structure a pointer and have it be available to consumers, but that actually requires an smb_wmb or a stronger barrier. In absence of such barriers and on architectures that reorder writes, consumer might read an un=initialized value from

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Peter Zijlstra
On Tue, Dec 05, 2017 at 10:28:38PM +0200, Michael S. Tsirkin wrote: > On Tue, Dec 05, 2017 at 08:57:52PM +0100, Peter Zijlstra wrote: > > On Tue, Dec 05, 2017 at 09:51:48PM +0200, Michael S. Tsirkin wrote: > > > > > WRITE_ONCE(obj->val, 1); > > > > > smp_wmb(); > > > > > WRITE_ONCE(*foo, obj); > >

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Michael S. Tsirkin
On Tue, Dec 05, 2017 at 12:08:01PM -0800, Paul E. McKenney wrote: > On Tue, Dec 05, 2017 at 09:51:48PM +0200, Michael S. Tsirkin wrote: > > On Tue, Dec 05, 2017 at 11:33:39AM -0800, Paul E. McKenney wrote: > > > On Tue, Dec 05, 2017 at 09:24:21PM +0200, Michael S. Tsirkin wrote: > > [ . . . ] >

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Michael S. Tsirkin
On Tue, Dec 05, 2017 at 10:17:35PM +0100, Peter Zijlstra wrote: > On Tue, Dec 05, 2017 at 10:28:38PM +0200, Michael S. Tsirkin wrote: > > On Tue, Dec 05, 2017 at 08:57:52PM +0100, Peter Zijlstra wrote: > > > On Tue, Dec 05, 2017 at 09:51:48PM +0200, Michael S. Tsirkin wrote: > > > > > >

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Michael S. Tsirkin
On Tue, Dec 05, 2017 at 01:36:44PM -0800, Paul E. McKenney wrote: > On Tue, Dec 05, 2017 at 11:24:49PM +0200, Michael S. Tsirkin wrote: > > On Tue, Dec 05, 2017 at 12:08:01PM -0800, Paul E. McKenney wrote: > > > On Tue, Dec 05, 2017 at 09:51:48PM +0200, Michael S. Tsirkin wrote: > > > > On Tue,

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Peter Zijlstra
On Tue, Dec 05, 2017 at 08:57:46PM +0200, Michael S. Tsirkin wrote: > I don't see WRITE_ONCE inserting any barriers, release or > write. Correct, never claimed there was. Just saying that: obj = READ_ONCE(*foo); val = READ_ONCE(obj->val); Never needs a barrier (except on Alpha

Re: [RFC] virtio-net: help live migrate SR-IOV devices

2017-12-05 Thread Michael S. Tsirkin
On Tue, Dec 05, 2017 at 11:59:17AM +0200, achiad shochat wrote: > Then we'll have a single solution for both netvsc and virtio (and any > other PV device). > And we could handle the VF DMA dirt issue agnostically. For the record, I won't block patches adding this kist to virtio on the basis that

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Michael S. Tsirkin
On Tue, Dec 05, 2017 at 07:39:46PM +0100, Peter Zijlstra wrote: > On Tue, Dec 05, 2017 at 08:31:20PM +0200, Michael S. Tsirkin wrote: > > > Apropos, READ_ONCE is now asymmetrical with WRITE_ONCE. > > > > I can read a pointer with READ_ONCE and be sure the value > > is sane, but only if I also

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Michael S. Tsirkin
On Tue, Dec 05, 2017 at 08:17:33PM +0100, Peter Zijlstra wrote: > On Tue, Dec 05, 2017 at 08:57:46PM +0200, Michael S. Tsirkin wrote: > > > I don't see WRITE_ONCE inserting any barriers, release or > > write. > > Correct, never claimed there was. > > Just saying that: > > obj =

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Peter Zijlstra
On Tue, Dec 05, 2017 at 08:31:20PM +0200, Michael S. Tsirkin wrote: > Apropos, READ_ONCE is now asymmetrical with WRITE_ONCE. > > I can read a pointer with READ_ONCE and be sure the value > is sane, but only if I also remember to put in smp_wmb before > WRITE_ONCE. Otherwise the pointer is ok

Re: [RFC] virtio-net: help live migrate SR-IOV devices

2017-12-05 Thread Stephen Hemminger
On Tue, 5 Dec 2017 14:29:28 -0800 Jakub Kicinski wrote: > On Tue, 5 Dec 2017 11:59:17 +0200, achiad shochat wrote: > > I second Jacob - having a netdev of one device driver enslave a netdev > > of another device driver is an awkward a-symmetric model. > >

Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()

2017-12-05 Thread Paul E. McKenney
On Wed, Dec 06, 2017 at 12:09:36AM +0200, Michael S. Tsirkin wrote: > On Tue, Dec 05, 2017 at 10:57:00PM +0100, Peter Zijlstra wrote: > > On Tue, Dec 05, 2017 at 11:24:49PM +0200, Michael S. Tsirkin wrote: > > > READ_ONCE is really all over the place (some code literally replaced all > > > memory

Re: [PATCH] ptr_ring: add barriers

2017-12-05 Thread Jason Wang
On 2017年12月06日 10:53, Michael S. Tsirkin wrote: On Wed, Dec 06, 2017 at 10:31:39AM +0800, Jason Wang wrote: On 2017年12月06日 03:29, Michael S. Tsirkin wrote: Users of ptr_ring expect that it's safe to give the data structure a pointer and have it be available to consumers, but that actually

Re: [PATCH] ptr_ring: add barriers

2017-12-05 Thread Jason Wang
On 2017年12月06日 03:29, Michael S. Tsirkin wrote: Users of ptr_ring expect that it's safe to give the data structure a pointer and have it be available to consumers, but that actually requires an smb_wmb or a stronger barrier. In absence of such barriers and on architectures that reorder

Re: [PATCH] ptr_ring: add barriers

2017-12-05 Thread Michael S. Tsirkin
On Wed, Dec 06, 2017 at 10:31:39AM +0800, Jason Wang wrote: > > > On 2017年12月06日 03:29, Michael S. Tsirkin wrote: > > Users of ptr_ring expect that it's safe to give the > > data structure a pointer and have it be available > > to consumers, but that actually requires an smb_wmb > > or a

[PATCH v2 2/2] virtio_mmio: add cleanup for virtio_mmio_remove

2017-12-05 Thread weiping zhang
cleanup all resource allocated by virtio_mmio_probe. Signed-off-by: weiping zhang --- drivers/virtio/virtio_mmio.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index f984510..5e2ca34 100644

[PATCH v2 0/2] Add cleanup for virtio_mmio driver

2017-12-05 Thread weiping zhang
this patchset try to add cleanup for virtio_mmio driver, include virtio_mmio_probe and virtio_mmio_remove weiping zhang (2): virtio_mmio: add cleanup for virtio_mmio_probe virtio_mmio: add cleanup for virtio_mmio_remove drivers/virtio/virtio_mmio.c | 43

[PATCH v2 1/2] virtio_mmio: add cleanup for virtio_mmio_probe

2017-12-05 Thread weiping zhang
As mentioned at drivers/base/core.c: /* * NOTE: _Never_ directly free @dev after calling this function, even * if it returned an error! Always use put_device() to give up the * reference initialized in this function instead. */ Normal we do cleanup for @vm_dev by contianer_of(@dev), but in