[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/14] virtio-blk: always set ioeventfd during startup
|
From: |
Kevin Wolf |
|
Subject: |
[PULL 13/14] virtio-blk: always set ioeventfd during startup |
|
Date: |
Fri, 19 Jan 2024 19:13:26 +0100 |
From: Stefan Hajnoczi <stefanha@redhat.com>
When starting ioeventfd it is common practice to set the event notifier
so that the ioeventfd handler is triggered to run immediately. There may
be no requests waiting to be processed, but the idea is that if a
request snuck in then we guarantee that it will be detected.
One scenario where self-triggering the ioeventfd is necessary is when
virtio_blk_handle_output() is called from a vCPU thread before the
VIRTIO Device Status transitions to DRIVER_OK. In that case we need to
self-trigger the ioeventfd so that the kick handled by the vCPU thread
causes the vq AioContext thread to take over handling the request(s).
Fixes: b6948ab01df0 ("virtio-blk: add iothread-vq-mapping parameter")
Reported-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20240119135748.270944-7-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/block/virtio-blk.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 73248d15c8..227d83569f 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1809,14 +1809,14 @@ static int virtio_blk_start_ioeventfd(VirtIODevice
*vdev)
smp_wmb(); /* paired with aio_notify_accept() on the read side */
/* Get this show started by hooking up our callbacks */
- if (!blk_in_drain(s->conf.conf.blk)) {
- for (i = 0; i < nvqs; i++) {
- VirtQueue *vq = virtio_get_queue(vdev, i);
- AioContext *ctx = s->vq_aio_context[i];
+ for (i = 0; i < nvqs; i++) {
+ VirtQueue *vq = virtio_get_queue(vdev, i);
+ AioContext *ctx = s->vq_aio_context[i];
- /* Kick right away to begin processing requests already in vring */
- event_notifier_set(virtio_queue_get_host_notifier(vq));
+ /* Kick right away to begin processing requests already in vring */
+ event_notifier_set(virtio_queue_get_host_notifier(vq));
+ if (!blk_in_drain(s->conf.conf.blk)) {
virtio_queue_aio_attach_host_notifier(vq, ctx);
}
}
--
2.43.0
- [PULL 08/14] virtio-blk: move dataplane code into virtio-blk.c, (continued)
- [PULL 08/14] virtio-blk: move dataplane code into virtio-blk.c, Kevin Wolf, 2024/01/19
- [PULL 10/14] virtio-blk: rename dataplane to ioeventfd, Kevin Wolf, 2024/01/19
- [PULL 05/14] iotests: add filter_qmp_generated_node_ids(), Kevin Wolf, 2024/01/19
- [PULL 02/14] string-output-visitor: Fix (pseudo) struct handling, Kevin Wolf, 2024/01/19
- [PULL 06/14] iotests: port 141 to Python for reliable QMP testing, Kevin Wolf, 2024/01/19
- [PULL 09/14] virtio-blk: rename dataplane create/destroy functions, Kevin Wolf, 2024/01/19
- [PULL 07/14] monitor: only run coroutine commands in qemu_aio_context, Kevin Wolf, 2024/01/19
- [PULL 04/14] stream: Allow users to request only format driver names in backing file format, Kevin Wolf, 2024/01/19
- [PULL 14/14] block/blklogwrites: Protect mutable driver state with a mutex., Kevin Wolf, 2024/01/19
- [PULL 12/14] virtio-blk: tolerate failure to set BlockBackend AioContext, Kevin Wolf, 2024/01/19
- [PULL 13/14] virtio-blk: always set ioeventfd during startup,
Kevin Wolf <=
- [PULL 11/14] virtio-blk: restart s->rq reqs in vq AioContexts, Kevin Wolf, 2024/01/19
- Re: [PULL 00/14] Block layer patches, Peter Maydell, 2024/01/20