Message ID | 20240206153105.81868-2-stefanha@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [PULL,1/1] virtio-blk: avoid using ioeventfd state in irqfd conditional | expand |
06.02.2024 18:31, Stefan Hajnoczi : > Requests that complete in an IOThread use irqfd to notify the guest > while requests that complete in the main loop thread use the traditional > qdev irq code path. The reason for this conditional is that the irq code > path requires the BQL: > > if (s->ioeventfd_started && !s->ioeventfd_disabled) { > virtio_notify_irqfd(vdev, req->vq); > } else { > virtio_notify(vdev, req->vq); > } > > There is a corner case where the conditional invokes the irq code path > instead of the irqfd code path: > > static void virtio_blk_stop_ioeventfd(VirtIODevice *vdev) > { > ... > /* > * Set ->ioeventfd_started to false before draining so that host notifiers > * are not detached/attached anymore. > */ > s->ioeventfd_started = false; > > /* Wait for virtio_blk_dma_restart_bh() and in flight I/O to complete */ > blk_drain(s->conf.conf.blk); > > During blk_drain() the conditional produces the wrong result because > ioeventfd_started is false. > > Use qemu_in_iothread() instead of checking the ioeventfd state. > > Buglink: https://issues.redhat.com/browse/RHEL-15394 > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> > Message-id: 20240122172625.415386-1-stefanha@redhat.com > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Cc qemu-stable? This smells like a stable material, please let me know if it is not. (And yes I've seen it also included in another pullreq) Thanks, /mjt
Am 08.02.2024 um 06:37 hat Michael Tokarev geschrieben: > 06.02.2024 18:31, Stefan Hajnoczi : > > Requests that complete in an IOThread use irqfd to notify the guest > > while requests that complete in the main loop thread use the traditional > > qdev irq code path. The reason for this conditional is that the irq code > > path requires the BQL: > > > > if (s->ioeventfd_started && !s->ioeventfd_disabled) { > > virtio_notify_irqfd(vdev, req->vq); > > } else { > > virtio_notify(vdev, req->vq); > > } > > > > There is a corner case where the conditional invokes the irq code path > > instead of the irqfd code path: > > > > static void virtio_blk_stop_ioeventfd(VirtIODevice *vdev) > > { > > ... > > /* > > * Set ->ioeventfd_started to false before draining so that host notifiers > > * are not detached/attached anymore. > > */ > > s->ioeventfd_started = false; > > > > /* Wait for virtio_blk_dma_restart_bh() and in flight I/O to complete */ > > blk_drain(s->conf.conf.blk); > > > > During blk_drain() the conditional produces the wrong result because > > ioeventfd_started is false. > > > > Use qemu_in_iothread() instead of checking the ioeventfd state. > > > > Buglink: https://issues.redhat.com/browse/RHEL-15394 > > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> > > Message-id: 20240122172625.415386-1-stefanha@redhat.com > > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> > > Cc qemu-stable? This smells like a stable material, please let me know > if it is not. The patch email itself was CCed to qemu-stable and even contained a note for backporting to stable: https://lists.gnu.org/archive/html/qemu-block/2024-01/msg00278.html It's only missing in the commit message. I'll add the Cc: line to my pull request (for Stefan's pull request it seems too late because Peter is already processing it, so we'll probably end up having both versions in the git history). Kevin
08.02.2024 11:42, Kevin Wolf wrote: > The patch email itself was CCed to qemu-stable and even contained a note > for backporting to stable: > > https://lists.gnu.org/archive/html/qemu-block/2024-01/msg00278.html Ahh. Yes. I'm having a large(ish) queue in stable and missed the fact I already has this one in there. Was a -ENOCOFFEE issue this morning. Sorry for the noise. > It's only missing in the commit message. I'll add the Cc: line to > my pull request (for Stefan's pull request it seems too late because > Peter is already processing it, so we'll probably end up having both > versions in the git history). That's ok I guess :) Thanks, /mjt
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 227d83569f..287c31ee3c 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -64,7 +64,7 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status) iov_discard_undo(&req->inhdr_undo); iov_discard_undo(&req->outhdr_undo); virtqueue_push(req->vq, &req->elem, req->in_len); - if (s->ioeventfd_started && !s->ioeventfd_disabled) { + if (qemu_in_iothread()) { virtio_notify_irqfd(vdev, req->vq); } else { virtio_notify(vdev, req->vq);