qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>,
	Peter Maydell <peter.maydell@linaro.org>,
	Greg Kurz <groug@kaod.org>, Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [PULL 11/16] virtio-scsi: Configure all host notifiers in a single MR transaction
Date: Fri, 14 May 2021 12:04:33 -0400	[thread overview]
Message-ID: <20210514160245.91918-12-mst@redhat.com> (raw)
In-Reply-To: <20210514160245.91918-1-mst@redhat.com>

From: Greg Kurz <groug@kaod.org>

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>
---
 hw/scsi/virtio-scsi-dataplane.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index b2cb3d9dcc..28e003250a 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);
     }
 
-- 
MST



  parent reply	other threads:[~2021-05-14 16:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14 16:04 [PULL 00/16] pc,pci,virtio: bugfixes, improvements Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 01/16] amd_iommu: Fix pte_override_page_mask() Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 02/16] x86: acpi: use offset instead of pointer when using build_header() Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 03/16] hw/virtio: Pass virtio_feature_get_config_size() a const argument Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 04/16] virtio-blk: Constify VirtIOFeature feature_sizes[] Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 05/16] virtio-net: " Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 06/16] amd_iommu: fix wrong MMIO operations Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 07/16] pc-dimm: remove unnecessary get_vmstate_memory_region() method Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 08/16] virtio-blk: Fix rollback path in virtio_blk_data_plane_start() Michael S. Tsirkin
2021-07-07 15:02   ` Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 09/16] virtio-blk: Configure all host notifiers in a single MR transaction Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 10/16] virtio-scsi: Set host notifiers and callbacks separately Michael S. Tsirkin
2021-05-14 16:04 ` Michael S. Tsirkin [this message]
2021-05-14 16:04 ` [PULL 12/16] checkpatch: Fix use of uninitialized value Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 13/16] hw/smbios: support for type 41 (onboard devices extended information) Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 14/16] hw/virtio: enable ioeventfd configuring for mmio Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 15/16] vhost-vdpa: Make vhost_vdpa_get_device_id() static Michael S. Tsirkin
2021-05-14 16:04 ` [PULL 16/16] Fix build with 64 bits time_t Michael S. Tsirkin
2021-05-16 18:49 ` [PULL 00/16] pc,pci,virtio: bugfixes, improvements Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210514160245.91918-12-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=fam@euphon.net \
    --cc=groug@kaod.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).