[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/16] virtio-blk: Configure all host notifiers in a single MR tra
From: |
Michael S. Tsirkin |
Subject: |
[PULL 09/16] virtio-blk: Configure all host notifiers in a single MR transaction |
Date: |
Fri, 14 May 2021 12:04:29 -0400 |
From: Greg Kurz <groug@kaod.org>
This allows the virtio-blk-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 3m26.186s down to 0m58.023s 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-3-groug@kaod.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/block/dataplane/virtio-blk.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index d7b5c95d26..cd81893d1d 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -198,19 +198,30 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
goto fail_guest_notifiers;
}
+ memory_region_transaction_begin();
+
/* Set up virtqueue notify */
for (i = 0; i < nvqs; i++) {
r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, true);
if (r != 0) {
+ int j = i;
+
fprintf(stderr, "virtio-blk failed to set host notifier (%d)\n",
r);
while (i--) {
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
+ }
+
+ memory_region_transaction_commit();
+
+ while (j--) {
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
}
goto fail_host_notifiers;
}
}
+ memory_region_transaction_commit();
+
s->starting = false;
vblk->dataplane_started = true;
trace_virtio_blk_data_plane_start(s);
@@ -246,8 +257,15 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
return 0;
fail_aio_context:
+ memory_region_transaction_begin();
+
for (i = 0; i < nvqs; i++) {
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
+ }
+
+ memory_region_transaction_commit();
+
+ for (i = 0; i < nvqs; i++) {
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
}
fail_host_notifiers:
@@ -312,8 +330,15 @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev)
aio_context_release(s->ctx);
+ memory_region_transaction_begin();
+
for (i = 0; i < nvqs; i++) {
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
+ }
+
+ memory_region_transaction_commit();
+
+ for (i = 0; i < nvqs; i++) {
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 <=
- [PULL 10/16] virtio-scsi: Set host notifiers and callbacks separately, Michael S. Tsirkin, 2021/05/14
- [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