[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/16] virtio-scsi: Set host notifiers and callbacks separately
From: |
Michael S. Tsirkin |
Subject: |
[PULL 10/16] virtio-scsi: Set host notifiers and callbacks separately |
Date: |
Fri, 14 May 2021 12:04:31 -0400 |
From: Greg Kurz <groug@kaod.org>
Host notifiers are guaranteed to be idle until the callbacks are
hooked up with virtio_queue_aio_set_host_notifier_handler(). They
thus don't need to be set or unset with the AioContext lock held.
Do this outside the critical section, like virtio-blk already
does : basically downgrading virtio_scsi_vring_init() to only
setup the host notifier and set the callback in the caller.
This will allow to batch addition/deletion of ioeventds in
a single memory transaction, which is expected to greatly
improve initialization time.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <20210407143501.244343-4-groug@kaod.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/scsi/virtio-scsi-dataplane.c | 40 ++++++++++++++++++---------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index 4ad8793406..b2cb3d9dcc 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -94,8 +94,7 @@ static bool virtio_scsi_data_plane_handle_event(VirtIODevice
*vdev,
return progress;
}
-static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n,
- VirtIOHandleAIOOutput fn)
+static int virtio_scsi_set_host_notifier(VirtIOSCSI *s, VirtQueue *vq, int n)
{
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
int rc;
@@ -109,7 +108,6 @@ static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue
*vq, int n,
return rc;
}
- virtio_queue_aio_set_host_notifier_handler(vq, s->ctx, fn);
return 0;
}
@@ -154,38 +152,44 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
goto fail_guest_notifiers;
}
- aio_context_acquire(s->ctx);
- rc = virtio_scsi_vring_init(s, vs->ctrl_vq, 0,
- virtio_scsi_data_plane_handle_ctrl);
- if (rc) {
- goto fail_vrings;
+ rc = virtio_scsi_set_host_notifier(s, vs->ctrl_vq, 0);
+ if (rc != 0) {
+ goto fail_host_notifiers;
}
vq_init_count++;
- rc = virtio_scsi_vring_init(s, vs->event_vq, 1,
- virtio_scsi_data_plane_handle_event);
- if (rc) {
- goto fail_vrings;
+ rc = virtio_scsi_set_host_notifier(s, vs->event_vq, 1);
+ if (rc != 0) {
+ goto fail_host_notifiers;
}
vq_init_count++;
+
for (i = 0; i < vs->conf.num_queues; i++) {
- rc = virtio_scsi_vring_init(s, vs->cmd_vqs[i], i + 2,
- virtio_scsi_data_plane_handle_cmd);
+ rc = virtio_scsi_set_host_notifier(s, vs->cmd_vqs[i], i + 2);
if (rc) {
- goto fail_vrings;
+ goto fail_host_notifiers;
}
vq_init_count++;
}
+ aio_context_acquire(s->ctx);
+ virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx,
+
virtio_scsi_data_plane_handle_ctrl);
+ virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx,
+
virtio_scsi_data_plane_handle_event);
+
+ for (i = 0; i < vs->conf.num_queues; i++) {
+ virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx,
+
virtio_scsi_data_plane_handle_cmd);
+ }
+
s->dataplane_starting = false;
s->dataplane_started = true;
aio_context_release(s->ctx);
return 0;
-fail_vrings:
- aio_wait_bh_oneshot(s->ctx, virtio_scsi_dataplane_stop_bh, s);
- aio_context_release(s->ctx);
+fail_host_notifiers:
for (i = 0; i < vq_init_count; i++) {
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
--
MST
- [PULL 00/16] pc,pci,virtio: bugfixes, improvements, Michael S. Tsirkin, 2021/05/14
- [PULL 01/16] amd_iommu: Fix pte_override_page_mask(), Michael S. Tsirkin, 2021/05/14
- [PULL 03/16] hw/virtio: Pass virtio_feature_get_config_size() a const argument, Michael S. Tsirkin, 2021/05/14
- [PULL 04/16] virtio-blk: Constify VirtIOFeature feature_sizes[], Michael S. Tsirkin, 2021/05/14
- [PULL 05/16] virtio-net: Constify VirtIOFeature feature_sizes[], Michael S. Tsirkin, 2021/05/14
- [PULL 07/16] pc-dimm: remove unnecessary get_vmstate_memory_region() method, Michael S. Tsirkin, 2021/05/14
- [PULL 08/16] virtio-blk: Fix rollback path in virtio_blk_data_plane_start(), Michael S. Tsirkin, 2021/05/14
- [PULL 09/16] virtio-blk: Configure all host notifiers in a single MR transaction, Michael S. Tsirkin, 2021/05/14
- [PULL 10/16] virtio-scsi: Set host notifiers and callbacks separately,
Michael S. Tsirkin <=
- [PULL 11/16] virtio-scsi: Configure all host notifiers in a single MR transaction, Michael S. Tsirkin, 2021/05/14
- [PULL 12/16] checkpatch: Fix use of uninitialized value, Michael S. Tsirkin, 2021/05/14
- [PULL 15/16] vhost-vdpa: Make vhost_vdpa_get_device_id() static, Michael S. Tsirkin, 2021/05/14
- [PULL 06/16] amd_iommu: fix wrong MMIO operations, Michael S. Tsirkin, 2021/05/14
- [PULL 02/16] x86: acpi: use offset instead of pointer when using build_header(), Michael S. Tsirkin, 2021/05/14
- [PULL 14/16] hw/virtio: enable ioeventfd configuring for mmio, Michael S. Tsirkin, 2021/05/14
- [PULL 13/16] hw/smbios: support for type 41 (onboard devices extended information), Michael S. Tsirkin, 2021/05/14
- [PULL 16/16] Fix build with 64 bits time_t, Michael S. Tsirkin, 2021/05/14
- Re: [PULL 00/16] pc,pci,virtio: bugfixes, improvements, Peter Maydell, 2021/05/16