diff mbox

virtio-scsi-pci iothread spins at 100%

Message ID 20170209053917.GH22807@lemon.lan
State New
Headers show

Commit Message

Fam Zheng Feb. 9, 2017, 5:39 a.m. UTC
On Wed, 02/08 19:44, Ed Swierk wrote:
> On Wed, Feb 8, 2017 at 6:52 PM, Fam Zheng <famz@redhat.com> wrote:
> > This means virtio-scsi event vq handler is returning true but actually no
> > progress is made. Can you try the following patch to see if it's because a
> > stalled cache of VQ index?
> >
> > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> > index 6365706..7f7ab57 100644
> > --- a/hw/virtio/virtio.c
> > +++ b/hw/virtio/virtio.c
> > @@ -2126,7 +2126,7 @@ static bool virtio_queue_host_notifier_aio_poll(void *opaque)
> >      EventNotifier *n = opaque;
> >      VirtQueue *vq = container_of(n, VirtQueue, host_notifier);
> >
> > -    if (virtio_queue_empty(vq)) {
> > +    if (vring_avail_idx(vq) == vq->last_avail_idx) {
> >          return false;
> >      }
> 
> I tried this change but the behavior is the same, unfortunately.

Hmm, maybe I'm missing something. How about this:

Comments

Fam Zheng Feb. 9, 2017, 6:43 a.m. UTC | #1
On Thu, 02/09 13:39, Fam Zheng wrote:
> On Wed, 02/08 19:44, Ed Swierk wrote:
> > On Wed, Feb 8, 2017 at 6:52 PM, Fam Zheng <famz@redhat.com> wrote:
> > > This means virtio-scsi event vq handler is returning true but actually no
> > > progress is made. Can you try the following patch to see if it's because a
> > > stalled cache of VQ index?
> > >
> > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> > > index 6365706..7f7ab57 100644
> > > --- a/hw/virtio/virtio.c
> > > +++ b/hw/virtio/virtio.c
> > > @@ -2126,7 +2126,7 @@ static bool virtio_queue_host_notifier_aio_poll(void *opaque)
> > >      EventNotifier *n = opaque;
> > >      VirtQueue *vq = container_of(n, VirtQueue, host_notifier);
> > >
> > > -    if (virtio_queue_empty(vq)) {
> > > +    if (vring_avail_idx(vq) == vq->last_avail_idx) {
> > >          return false;
> > >      }
> > 
> > I tried this change but the behavior is the same, unfortunately.
> 
> Hmm, maybe I'm missing something. How about this:
> 
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index ce19eff..8b23e80 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -754,9 +754,7 @@ out:
>  
>  void virtio_scsi_handle_event_vq(VirtIOSCSI *s, VirtQueue *vq)
>  {
> -    if (s->events_dropped) {
> -        virtio_scsi_push_event(s, NULL, VIRTIO_SCSI_T_NO_EVENT, 0);
> -    }
> +    virtio_scsi_push_event(s, NULL, VIRTIO_SCSI_T_NO_EVENT, 0);
>  }
>  
>  static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq)
> 

Ignore this. It will break the "assert(event == VIRTIO_SCSI_T_EVENTS_MISSED)" in
the called function. 

Anyway I think the cause is virtio_queue_host_notifier_aio_poll() only checks if
there is an available req in the virtqueue, but in virtio-scsi, eventq actually
contain buffers that are only useful when an event needs to be pushed.

It is reproducible with ubuntu LTS 14.04.5. I'll see if I can sort out a proper
fix.

Fam
diff mbox

Patch

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index ce19eff..8b23e80 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -754,9 +754,7 @@  out:
 
 void virtio_scsi_handle_event_vq(VirtIOSCSI *s, VirtQueue *vq)
 {
-    if (s->events_dropped) {
-        virtio_scsi_push_event(s, NULL, VIRTIO_SCSI_T_NO_EVENT, 0);
-    }
+    virtio_scsi_push_event(s, NULL, VIRTIO_SCSI_T_NO_EVENT, 0);
 }
 
 static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq)