|
|
a83cc2 |
From f02134f067150d02d1a74ff5aea151096679492e Mon Sep 17 00:00:00 2001
|
|
|
a83cc2 |
From: Greg Kurz <groug@kaod.org>
|
|
|
a83cc2 |
Date: Wed, 26 May 2021 09:03:52 -0400
|
|
|
a83cc2 |
Subject: [PATCH 12/15] virtio-blk: Configure all host notifiers in a single MR
|
|
|
a83cc2 |
transaction
|
|
|
a83cc2 |
|
|
|
a83cc2 |
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
RH-MergeRequest: 5: Synchronize RHEL-AV 8.5 release 18 to RHEL 9 Beta
|
|
|
a83cc2 |
RH-Commit: [9/12] 609631835874ea62dad1ffbd469e83744299ee07 (mrezanin/centos-src-qemu-kvm)
|
|
|
a83cc2 |
RH-Bugzilla: 1957194
|
|
|
a83cc2 |
RH-Acked-by: Danilo Cesar Lemes de Paula <ddepaula@redhat.com>
|
|
|
a83cc2 |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
a83cc2 |
RH-Acked-by: Greg Kurz <gkurz@redhat.com>
|
|
|
a83cc2 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
a83cc2 |
|
|
|
a83cc2 |
This allows the virtio-blk-pci device to batch the setup of all its
|
|
|
a83cc2 |
host notifiers. This significantly improves boot time of VMs with a
|
|
|
a83cc2 |
high number of vCPUs, e.g. from 3m26.186s down to 0m58.023s for a
|
|
|
a83cc2 |
pseries machine with 384 vCPUs.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Note that memory_region_transaction_commit() must be called before
|
|
|
a83cc2 |
virtio_bus_cleanup_host_notifier() because the latter might close
|
|
|
a83cc2 |
ioeventfds that the transaction still assumes to be around when it
|
|
|
a83cc2 |
commits.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Signed-off-by: Greg Kurz <groug@kaod.org>
|
|
|
a83cc2 |
Message-Id: <20210407143501.244343-3-groug@kaod.org>
|
|
|
a83cc2 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
a83cc2 |
(cherry picked from commit d0267da614890b8f817364ae25850cdbb580a569)
|
|
|
a83cc2 |
Signed-off-by: Greg Kurz <gkurz@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
---
|
|
|
a83cc2 |
hw/block/dataplane/virtio-blk.c | 25 +++++++++++++++++++++++++
|
|
|
a83cc2 |
1 file changed, 25 insertions(+)
|
|
|
a83cc2 |
|
|
|
a83cc2 |
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
|
|
|
a83cc2 |
index d7b5c95d26..cd81893d1d 100644
|
|
|
a83cc2 |
--- a/hw/block/dataplane/virtio-blk.c
|
|
|
a83cc2 |
+++ b/hw/block/dataplane/virtio-blk.c
|
|
|
a83cc2 |
@@ -198,19 +198,30 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
|
|
|
a83cc2 |
goto fail_guest_notifiers;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
+ memory_region_transaction_begin();
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
/* Set up virtqueue notify */
|
|
|
a83cc2 |
for (i = 0; i < nvqs; i++) {
|
|
|
a83cc2 |
r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, true);
|
|
|
a83cc2 |
if (r != 0) {
|
|
|
a83cc2 |
+ int j = i;
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
fprintf(stderr, "virtio-blk failed to set host notifier (%d)\n", r);
|
|
|
a83cc2 |
while (i--) {
|
|
|
a83cc2 |
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
|
|
|
a83cc2 |
+ }
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
+ memory_region_transaction_commit();
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
+ while (j--) {
|
|
|
a83cc2 |
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
goto fail_host_notifiers;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
+ memory_region_transaction_commit();
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
s->starting = false;
|
|
|
a83cc2 |
vblk->dataplane_started = true;
|
|
|
a83cc2 |
trace_virtio_blk_data_plane_start(s);
|
|
|
a83cc2 |
@@ -246,8 +257,15 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
|
|
|
a83cc2 |
return 0;
|
|
|
a83cc2 |
|
|
|
a83cc2 |
fail_aio_context:
|
|
|
a83cc2 |
+ memory_region_transaction_begin();
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
for (i = 0; i < nvqs; i++) {
|
|
|
a83cc2 |
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
|
|
|
a83cc2 |
+ }
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
+ memory_region_transaction_commit();
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
+ for (i = 0; i < nvqs; i++) {
|
|
|
a83cc2 |
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
fail_host_notifiers:
|
|
|
a83cc2 |
@@ -312,8 +330,15 @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev)
|
|
|
a83cc2 |
|
|
|
a83cc2 |
aio_context_release(s->ctx);
|
|
|
a83cc2 |
|
|
|
a83cc2 |
+ memory_region_transaction_begin();
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
for (i = 0; i < nvqs; i++) {
|
|
|
a83cc2 |
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
|
|
|
a83cc2 |
+ }
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
+ memory_region_transaction_commit();
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
+ for (i = 0; i < nvqs; i++) {
|
|
|
a83cc2 |
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
--
|
|
|
a83cc2 |
2.27.0
|
|
|
a83cc2 |
|