thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-virtio-scsi-Configure-all-host-notifiers-in-a-single.patch

a83cc2
From 5e7855d3c9d5a59d2c0ac05444428b058ca9abb8 Mon Sep 17 00:00:00 2001
a83cc2
From: Greg Kurz <groug@kaod.org>
a83cc2
Date: Wed, 26 May 2021 09:03:54 -0400
a83cc2
Subject: [PATCH 14/15] virtio-scsi: Configure all host notifiers in a single
a83cc2
 MR 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: [11/12] f3c785c4b63aeb3a7b153f2fc17e86c983f98c23 (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-scsi-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 6m5.563s down to 1m2.884s 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-5-groug@kaod.org>
a83cc2
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
a83cc2
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
a83cc2
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
a83cc2
(cherry picked from commit c4f5dcc4360a02085a633fd7a90b7ac395ca1ba4)
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/scsi/virtio-scsi-dataplane.c | 16 ++++++++++++++++
a83cc2
 1 file changed, 16 insertions(+)
a83cc2
a83cc2
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
a83cc2
index b2cb3d9dcc..28e003250a 100644
a83cc2
--- a/hw/scsi/virtio-scsi-dataplane.c
a83cc2
+++ b/hw/scsi/virtio-scsi-dataplane.c
a83cc2
@@ -152,6 +152,8 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
a83cc2
         goto fail_guest_notifiers;
a83cc2
     }
a83cc2
 
a83cc2
+    memory_region_transaction_begin();
a83cc2
+
a83cc2
     rc = virtio_scsi_set_host_notifier(s, vs->ctrl_vq, 0);
a83cc2
     if (rc != 0) {
a83cc2
         goto fail_host_notifiers;
a83cc2
@@ -173,6 +175,8 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
a83cc2
         vq_init_count++;
a83cc2
     }
a83cc2
 
a83cc2
+    memory_region_transaction_commit();
a83cc2
+
a83cc2
     aio_context_acquire(s->ctx);
a83cc2
     virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx,
a83cc2
                                             virtio_scsi_data_plane_handle_ctrl);
a83cc2
@@ -192,6 +196,11 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
a83cc2
 fail_host_notifiers:
a83cc2
     for (i = 0; i < vq_init_count; 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 < vq_init_count; i++) {
a83cc2
         virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
a83cc2
     }
a83cc2
     k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
a83cc2
@@ -229,8 +238,15 @@ void virtio_scsi_dataplane_stop(VirtIODevice *vdev)
a83cc2
 
a83cc2
     blk_drain_all(); /* ensure there are no in-flight requests */
a83cc2
 
a83cc2
+    memory_region_transaction_begin();
a83cc2
+
a83cc2
     for (i = 0; i < vs->conf.num_queues + 2; 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 < vs->conf.num_queues + 2; i++) {
a83cc2
         virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
a83cc2
     }
a83cc2
 
a83cc2
-- 
a83cc2
2.27.0
a83cc2