qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Longpeng(Mike)" via <qemu-devel@nongnu.org>
To: <stefanha@redhat.com>, <mst@redhat.com>, <jasowang@redhat.com>,
	<sgarzare@redhat.com>
Cc: <cohuck@redhat.com>, <pbonzini@redhat.com>,
	<arei.gonglei@huawei.com>, <yechuan@huawei.com>,
	<huangzhichao@huawei.com>, <qemu-devel@nongnu.org>,
	Longpeng <longpeng2@huawei.com>
Subject: [PATCH v2 2/2] vdpa: commit all host notifier MRs in a single MR transaction
Date: Tue, 6 Dec 2022 16:18:41 +0800	[thread overview]
Message-ID: <20221206081841.2458-3-longpeng2@huawei.com> (raw)
In-Reply-To: <20221206081841.2458-1-longpeng2@huawei.com>

From: Longpeng <longpeng2@huawei.com>

This allows the vhost-vdpa device to batch the setup of all its MRs of
host notifiers.

This significantly reduces the device starting time, e.g. the time spend
on setup the host notifier MRs reduce from 423ms to 32ms for a VM with
64 vCPUs and 3 vhost-vDPA generic devices[1] (64vq per device).

[1] https://www.mail-archive.com/qemu-devel@nongnu.org/msg921541.html

Signed-off-by: Longpeng <longpeng2@huawei.com>
---
 hw/virtio/vhost-vdpa.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 7468e44b87..eb233cf08a 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -547,9 +547,18 @@ static void vhost_vdpa_host_notifiers_uninit(struct vhost_dev *dev, int n)
 {
     int i;
 
+    /*
+     * Pack all the changes to the memory regions in a single
+     * transaction to avoid a few updating of the address space
+     * topology.
+     */
+    memory_region_transaction_begin();
+
     for (i = dev->vq_index; i < dev->vq_index + n; i++) {
         vhost_vdpa_host_notifier_uninit(dev, i);
     }
+
+    memory_region_transaction_commit();
 }
 
 static void vhost_vdpa_host_notifiers_init(struct vhost_dev *dev)
@@ -562,16 +571,25 @@ static void vhost_vdpa_host_notifiers_init(struct vhost_dev *dev)
         return;
     }
 
+    /*
+     * Pack all the changes to the memory regions in a single
+     * transaction to avoid a few updating of the address space
+     * topology.
+     */
+    memory_region_transaction_begin();
+
     for (i = dev->vq_index; i < dev->vq_index + dev->nvqs; i++) {
         if (vhost_vdpa_host_notifier_init(dev, i)) {
             goto err;
         }
     }
 
+    memory_region_transaction_commit();
     return;
 
 err:
     vhost_vdpa_host_notifiers_uninit(dev, i - dev->vq_index);
+    memory_region_transaction_commit();
     return;
 }
 
-- 
2.23.0



  parent reply	other threads:[~2022-12-06  8:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06  8:18 [PATCH v2 0/2] two optimizations to speed up the start time Longpeng(Mike) via
2022-12-06  8:18 ` [PATCH v2 1/2] vhost: configure all host notifiers in a single MR transaction Longpeng(Mike) via
2022-12-06  9:07   ` Philippe Mathieu-Daudé
2022-12-06 10:28     ` longpeng2--- via
2022-12-06 10:45       ` Philippe Mathieu-Daudé
2022-12-07  0:22         ` longpeng2--- via
2022-12-20 13:32           ` Michael S. Tsirkin
2022-12-06  8:18 ` Longpeng(Mike) via [this message]
2022-12-06  8:30   ` [PATCH v2 2/2] vdpa: commit all host notifier MRs " Philippe Mathieu-Daudé
2022-12-06  8:49     ` longpeng2--- via

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=20221206081841.2458-3-longpeng2@huawei.com \
    --to=qemu-devel@nongnu.org \
    --cc=arei.gonglei@huawei.com \
    --cc=cohuck@redhat.com \
    --cc=huangzhichao@huawei.com \
    --cc=jasowang@redhat.com \
    --cc=longpeng2@huawei.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=yechuan@huawei.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).