Message ID | 20221226074908.8154-3-jasowang@redhat.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | virtio-net: don't busy poll for cvq command | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 2 this patch: 2 |
netdev/cc_maintainers | success | CCed 3 of 3 maintainers |
netdev/build_clang | success | Errors and warnings before: 1 this patch: 1 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 2 this patch: 2 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 26 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Mon, Dec 26, 2022 at 03:49:06PM +0800, Jason Wang wrote: > Switch to reuse BAD_RING() to allow common logic to be implemented in > BAD_RING(). > > Signed-off-by: Jason Wang <jasowang@redhat.com> > --- > Changes since V1: > - switch to use BAD_RING in virtio_break_device() > --- > drivers/virtio/virtio_ring.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > index 2e7689bb933b..5cfb2fa8abee 100644 > --- a/drivers/virtio/virtio_ring.c > +++ b/drivers/virtio/virtio_ring.c > @@ -58,7 +58,8 @@ > do { \ > dev_err(&_vq->vq.vdev->dev, \ > "%s:"fmt, (_vq)->vq.name, ##args); \ > - (_vq)->broken = true; \ > + /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ \ I don't think WRITE_ONCE/READ_ONCE pair as such. Can you point me at documentation of such pairing? > + WRITE_ONCE((_vq)->broken, true); \ > } while (0) > #define START_USE(vq) > #define END_USE(vq) > @@ -2237,7 +2238,7 @@ bool virtqueue_notify(struct virtqueue *_vq) > > /* Prod other side to tell it about changes. */ > if (!vq->notify(_vq)) { > - vq->broken = true; > + BAD_RING(vq, "vq %d is broken\n", vq->vq.index); > return false; > } > return true; > @@ -2786,8 +2787,7 @@ void virtio_break_device(struct virtio_device *dev) > list_for_each_entry(_vq, &dev->vqs, list) { > struct vring_virtqueue *vq = to_vvq(_vq); > > - /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ > - WRITE_ONCE(vq->broken, true); > + BAD_RING(vq, "Device break vq %d", _vq->index); > } > spin_unlock(&dev->vqs_list_lock); > } > -- > 2.25.1
On Tue, Dec 27, 2022 at 7:36 AM Michael S. Tsirkin <mst@redhat.com> wrote: > > On Mon, Dec 26, 2022 at 03:49:06PM +0800, Jason Wang wrote: > > Switch to reuse BAD_RING() to allow common logic to be implemented in > > BAD_RING(). > > > > Signed-off-by: Jason Wang <jasowang@redhat.com> > > --- > > Changes since V1: > > - switch to use BAD_RING in virtio_break_device() > > --- > > drivers/virtio/virtio_ring.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > > index 2e7689bb933b..5cfb2fa8abee 100644 > > --- a/drivers/virtio/virtio_ring.c > > +++ b/drivers/virtio/virtio_ring.c > > @@ -58,7 +58,8 @@ > > do { \ > > dev_err(&_vq->vq.vdev->dev, \ > > "%s:"fmt, (_vq)->vq.name, ##args); \ > > - (_vq)->broken = true; \ > > + /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ \ > > I don't think WRITE_ONCE/READ_ONCE pair as such. Can you point > me at documentation of such pairing? Introduced by: commit 60f0779862e4ab943810187752c462e85f5fa371 Author: Parav Pandit <parav@nvidia.com> Date: Wed Jul 21 17:26:45 2021 +0300 virtio: Improve vq->broken access to avoid any compiler optimization I think it might still apply here since virtqueue_is_broken() is still put into a loop inside wait_event(). Thanks > > > + WRITE_ONCE((_vq)->broken, true); \ > > } while (0) > > #define START_USE(vq) > > #define END_USE(vq) > > @@ -2237,7 +2238,7 @@ bool virtqueue_notify(struct virtqueue *_vq) > > > > /* Prod other side to tell it about changes. */ > > if (!vq->notify(_vq)) { > > - vq->broken = true; > > + BAD_RING(vq, "vq %d is broken\n", vq->vq.index); > > return false; > > } > > return true; > > @@ -2786,8 +2787,7 @@ void virtio_break_device(struct virtio_device *dev) > > list_for_each_entry(_vq, &dev->vqs, list) { > > struct vring_virtqueue *vq = to_vvq(_vq); > > > > - /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ > > - WRITE_ONCE(vq->broken, true); > > + BAD_RING(vq, "Device break vq %d", _vq->index); > > } > > spin_unlock(&dev->vqs_list_lock); > > } > > -- > > 2.25.1 >
On Tue, Dec 27, 2022 at 11:51:02AM +0800, Jason Wang wrote: > On Tue, Dec 27, 2022 at 7:36 AM Michael S. Tsirkin <mst@redhat.com> wrote: > > > > On Mon, Dec 26, 2022 at 03:49:06PM +0800, Jason Wang wrote: > > > Switch to reuse BAD_RING() to allow common logic to be implemented in > > > BAD_RING(). > > > > > > Signed-off-by: Jason Wang <jasowang@redhat.com> > > > --- > > > Changes since V1: > > > - switch to use BAD_RING in virtio_break_device() > > > --- > > > drivers/virtio/virtio_ring.c | 8 ++++---- > > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > > > index 2e7689bb933b..5cfb2fa8abee 100644 > > > --- a/drivers/virtio/virtio_ring.c > > > +++ b/drivers/virtio/virtio_ring.c > > > @@ -58,7 +58,8 @@ > > > do { \ > > > dev_err(&_vq->vq.vdev->dev, \ > > > "%s:"fmt, (_vq)->vq.name, ##args); \ > > > - (_vq)->broken = true; \ > > > + /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ \ > > > > I don't think WRITE_ONCE/READ_ONCE pair as such. Can you point > > me at documentation of such pairing? > > Introduced by: > > commit 60f0779862e4ab943810187752c462e85f5fa371 > Author: Parav Pandit <parav@nvidia.com> > Date: Wed Jul 21 17:26:45 2021 +0300 > > virtio: Improve vq->broken access to avoid any compiler optimization > > I think it might still apply here since virtqueue_is_broken() is still > put into a loop inside wait_event(). > > Thanks Oh I see. Maybe it's a response to some discussion we had at the time, at this point I can no longer say what it meant. But you are doing right not changing it here of course. > > > > > + WRITE_ONCE((_vq)->broken, true); \ > > > } while (0) > > > #define START_USE(vq) > > > #define END_USE(vq) > > > @@ -2237,7 +2238,7 @@ bool virtqueue_notify(struct virtqueue *_vq) > > > > > > /* Prod other side to tell it about changes. */ > > > if (!vq->notify(_vq)) { > > > - vq->broken = true; > > > + BAD_RING(vq, "vq %d is broken\n", vq->vq.index); > > > return false; > > > } > > > return true; > > > @@ -2786,8 +2787,7 @@ void virtio_break_device(struct virtio_device *dev) > > > list_for_each_entry(_vq, &dev->vqs, list) { > > > struct vring_virtqueue *vq = to_vvq(_vq); > > > > > > - /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ > > > - WRITE_ONCE(vq->broken, true); > > > + BAD_RING(vq, "Device break vq %d", _vq->index); > > > } > > > spin_unlock(&dev->vqs_list_lock); > > > } > > > -- > > > 2.25.1 > >
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 2e7689bb933b..5cfb2fa8abee 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -58,7 +58,8 @@ do { \ dev_err(&_vq->vq.vdev->dev, \ "%s:"fmt, (_vq)->vq.name, ##args); \ - (_vq)->broken = true; \ + /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ \ + WRITE_ONCE((_vq)->broken, true); \ } while (0) #define START_USE(vq) #define END_USE(vq) @@ -2237,7 +2238,7 @@ bool virtqueue_notify(struct virtqueue *_vq) /* Prod other side to tell it about changes. */ if (!vq->notify(_vq)) { - vq->broken = true; + BAD_RING(vq, "vq %d is broken\n", vq->vq.index); return false; } return true; @@ -2786,8 +2787,7 @@ void virtio_break_device(struct virtio_device *dev) list_for_each_entry(_vq, &dev->vqs, list) { struct vring_virtqueue *vq = to_vvq(_vq); - /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ - WRITE_ONCE(vq->broken, true); + BAD_RING(vq, "Device break vq %d", _vq->index); } spin_unlock(&dev->vqs_list_lock); }
Switch to reuse BAD_RING() to allow common logic to be implemented in BAD_RING(). Signed-off-by: Jason Wang <jasowang@redhat.com> --- Changes since V1: - switch to use BAD_RING in virtio_break_device() --- drivers/virtio/virtio_ring.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)