diff options
author | Greg Kurz <groug@kaod.org> | 2021-04-07 16:35:01 +0200 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2021-05-14 10:26:18 -0400 |
commit | c4f5dcc4360a02085a633fd7a90b7ac395ca1ba4 (patch) | |
tree | 1f124f46fc3f24a77b27a39205297a64af47f6ec /hw/scsi/virtio-scsi-dataplane.c | |
parent | 61fc57bfc464c3584bd7ab810c86833661f0188c (diff) | |
download | qemu-c4f5dcc4360a02085a633fd7a90b7ac395ca1ba4.zip qemu-c4f5dcc4360a02085a633fd7a90b7ac395ca1ba4.tar.gz qemu-c4f5dcc4360a02085a633fd7a90b7ac395ca1ba4.tar.bz2 |
virtio-scsi: Configure all host notifiers in a single MR transaction
This allows the virtio-scsi-pci device to batch the setup of all its
host notifiers. This significantly improves boot time of VMs with a
high number of vCPUs, e.g. from 6m5.563s down to 1m2.884s for a
pseries machine with 384 vCPUs.
Note that memory_region_transaction_commit() must be called before
virtio_bus_cleanup_host_notifier() because the latter might close
ioeventfds that the transaction still assumes to be around when it
commits.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <20210407143501.244343-5-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>
Diffstat (limited to 'hw/scsi/virtio-scsi-dataplane.c')
-rw-r--r-- | hw/scsi/virtio-scsi-dataplane.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c index b2cb3d9..28e0032 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -152,6 +152,8 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) goto fail_guest_notifiers; } + memory_region_transaction_begin(); + rc = virtio_scsi_set_host_notifier(s, vs->ctrl_vq, 0); if (rc != 0) { goto fail_host_notifiers; @@ -173,6 +175,8 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) vq_init_count++; } + memory_region_transaction_commit(); + aio_context_acquire(s->ctx); virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx, virtio_scsi_data_plane_handle_ctrl); @@ -192,6 +196,11 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) fail_host_notifiers: for (i = 0; i < vq_init_count; i++) { virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false); + } + + memory_region_transaction_commit(); + + for (i = 0; i < vq_init_count; i++) { virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i); } k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false); @@ -229,8 +238,15 @@ void virtio_scsi_dataplane_stop(VirtIODevice *vdev) blk_drain_all(); /* ensure there are no in-flight requests */ + memory_region_transaction_begin(); + for (i = 0; i < vs->conf.num_queues + 2; i++) { virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false); + } + + memory_region_transaction_commit(); + + for (i = 0; i < vs->conf.num_queues + 2; i++) { virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i); } |