[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 13/13] virtio-scsi: only expose cmd vqs via iothread-vq-mappin
From: |
Stefan Hajnoczi |
Subject: |
[PATCH v2 13/13] virtio-scsi: only expose cmd vqs via iothread-vq-mapping |
Date: |
Tue, 11 Mar 2025 18:11:45 +0800 |
Peter Krempa and Kevin Wolf observed that iothread-vq-mapping is
confusing to use because the control and event virtqueues have a fixed
location before the command virtqueues but need to be treated
differently.
Only expose the command virtqueues via iothread-vq-mapping so that the
command-line parameter is intuitive: it controls where SCSI requests are
processed.
The control virtqueue needs to be hardcoded to the main loop thread for
technical reasons anyway. Kevin also pointed out that it's better to
place the event virtqueue in the main loop thread since its no poll
behavior would prevent polling if assigned to an IOThread.
This change is its own commit to avoid squashing the previous commit.
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/scsi/virtio-scsi-dataplane.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index 2d37fa6712..95f13fb7c2 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -28,7 +28,6 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp)
VirtIODevice *vdev = VIRTIO_DEVICE(s);
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
- uint16_t num_vqs = vs->conf.num_queues + VIRTIO_SCSI_VQ_NUM_FIXED;
if (vs->conf.iothread && vs->conf.iothread_vq_mapping_list) {
error_setg(errp,
@@ -50,35 +49,43 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error
**errp)
}
}
- s->vq_aio_context = g_new(AioContext *, num_vqs);
+ s->vq_aio_context = g_new(AioContext *, vs->conf.num_queues +
+ VIRTIO_SCSI_VQ_NUM_FIXED);
+
+ /*
+ * Handle the ctrl virtqueue in the main loop thread where device resets
+ * can be performed.
+ */
+ s->vq_aio_context[0] = qemu_get_aio_context();
+
+ /*
+ * Handle the event virtqueue in the main loop thread where its no_poll
+ * behavior won't stop IOThread polling.
+ */
+ s->vq_aio_context[1] = qemu_get_aio_context();
if (vs->conf.iothread_vq_mapping_list) {
if (!iothread_vq_mapping_apply(vs->conf.iothread_vq_mapping_list,
- s->vq_aio_context, num_vqs, errp)) {
+ &s->vq_aio_context[VIRTIO_SCSI_VQ_NUM_FIXED],
+ vs->conf.num_queues, errp)) {
g_free(s->vq_aio_context);
s->vq_aio_context = NULL;
return;
}
} else if (vs->conf.iothread) {
AioContext *ctx = iothread_get_aio_context(vs->conf.iothread);
- for (uint16_t i = 0; i < num_vqs; i++) {
- s->vq_aio_context[i] = ctx;
+ for (uint16_t i = 0; i < vs->conf.num_queues; i++) {
+ s->vq_aio_context[VIRTIO_SCSI_VQ_NUM_FIXED + i] = ctx;
}
/* Released in virtio_scsi_dataplane_cleanup() */
object_ref(OBJECT(vs->conf.iothread));
} else {
AioContext *ctx = qemu_get_aio_context();
- for (unsigned i = 0; i < num_vqs; i++) {
- s->vq_aio_context[i] = ctx;
+ for (unsigned i = 0; i < vs->conf.num_queues; i++) {
+ s->vq_aio_context[VIRTIO_SCSI_VQ_NUM_FIXED + i] = ctx;
}
}
-
- /*
- * Always handle the ctrl virtqueue in the main loop thread where device
- * resets can be performed.
- */
- s->vq_aio_context[0] = qemu_get_aio_context();
}
/* Context: BQL held */
--
2.48.1
- [PATCH v2 04/13] scsi: introduce requests_lock, (continued)
- [PATCH v2 04/13] scsi: introduce requests_lock, Stefan Hajnoczi, 2025/03/11
- [PATCH v2 05/13] virtio-scsi: introduce event and ctrl virtqueue locks, Stefan Hajnoczi, 2025/03/11
- [PATCH v2 06/13] virtio-scsi: protect events_dropped field, Stefan Hajnoczi, 2025/03/11
- [PATCH v2 07/13] virtio-scsi: perform TMFs in appropriate AioContexts, Stefan Hajnoczi, 2025/03/11
- [PATCH v2 08/13] virtio-blk: extract cleanup_iothread_vq_mapping() function, Stefan Hajnoczi, 2025/03/11
- [PATCH v2 10/13] virtio: extract iothread-vq-mapping.h API, Stefan Hajnoczi, 2025/03/11
- [PATCH v2 11/13] virtio-scsi: add iothread-vq-mapping parameter, Stefan Hajnoczi, 2025/03/11
- [PATCH v2 09/13] virtio-blk: tidy up iothread_vq_mapping functions, Stefan Hajnoczi, 2025/03/11
- [PATCH v2 12/13] virtio-scsi: handle ctrl virtqueue in main loop, Stefan Hajnoczi, 2025/03/11
- [PATCH v2 13/13] virtio-scsi: only expose cmd vqs via iothread-vq-mapping,
Stefan Hajnoczi <=