From: Peter Xu <peterx@redhat.com>
To: Chuang Xu <xuchuangxclwt@bytedance.com>
Cc: qemu-devel@nongnu.org, mst@redhat.com, sgarzare@redhat.com,
richard.henderson@linaro.org, pbonzini@redhat.com,
david@kernel.org, philmd@linaro.org, farosas@suse.de,
Jason Wang <jasowang@redhat.com>
Subject: Re: [RFC v1 1/2] vhost: eliminate duplicate dirty_bitmap sync when log shared by multiple devices
Date: Tue, 9 Dec 2025 15:47:34 -0500 [thread overview]
Message-ID: <aTiK5opcOOrsFem9@x1.local> (raw)
In-Reply-To: <20251208120952.37563-2-xuchuangxclwt@bytedance.com>
On Mon, Dec 08, 2025 at 08:09:51PM +0800, Chuang Xu wrote:
> From: xuchuangxclwt <xuchuangxclwt@bytedance.com>
>
> Although logs can now be shared among multiple vhost devices,
> live migration still performs repeated vhost_log_sync for each
> vhost device during bitmap_sync, which increases the time required
> for bitmap_sync and makes it more difficult for dirty pages to converge.
>
> Attempt to eliminate these duplicate sync.
>
> Signed-off-by: Chuang Xu <xuchuangxclwt@bytedance.com>
It looks reasonable from migration POV, but I don't know the details.
Please remember to copy Jason (I added for this email) when repost.
Thanks,
> ---
> hw/virtio/vhost.c | 30 ++++++++++++++++++++++--------
> include/hw/virtio/vhost.h | 1 +
> 2 files changed, 23 insertions(+), 8 deletions(-)
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 266a11514a..d397ca327f 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -268,14 +268,6 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
> return 0;
> }
>
> -static void vhost_log_sync(MemoryListener *listener,
> - MemoryRegionSection *section)
> -{
> - struct vhost_dev *dev = container_of(listener, struct vhost_dev,
> - memory_listener);
> - vhost_sync_dirty_bitmap(dev, section, 0x0, ~0x0ULL);
> -}
> -
> static void vhost_log_sync_range(struct vhost_dev *dev,
> hwaddr first, hwaddr last)
> {
> @@ -287,6 +279,27 @@ static void vhost_log_sync_range(struct vhost_dev *dev,
> }
> }
>
> +static void vhost_log_sync(MemoryListener *listener,
> + MemoryRegionSection *section)
> +{
> + struct vhost_dev *dev = container_of(listener, struct vhost_dev,
> + memory_listener);
> + struct vhost_log *log = dev->log;
> +
> + if (log && log->refcnt > 1) {
> + /*
> + * When multiple devices use same log, we implement the logic of
> + * vhost_log_sync just like what we do in vhost_log_put.
> + */
> + log->sync_cnt = (log->sync_cnt + 1) % log->refcnt;
> + if (!log->sync_cnt) {
> + vhost_log_sync_range(dev, 0, dev->log_size * VHOST_LOG_CHUNK - 1);
> + }
> + } else {
> + vhost_sync_dirty_bitmap(dev, section, 0x0, ~0x0ULL);
> + }
> +}
> +
> static uint64_t vhost_get_log_size(struct vhost_dev *dev)
> {
> uint64_t log_size = 0;
> @@ -383,6 +396,7 @@ static struct vhost_log *vhost_log_get(VhostBackendType backend_type,
> ++log->refcnt;
> }
>
> + log->sync_cnt = 0;
> return log;
> }
>
> diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
> index 08bbb4dfe9..43bf1c2150 100644
> --- a/include/hw/virtio/vhost.h
> +++ b/include/hw/virtio/vhost.h
> @@ -50,6 +50,7 @@ typedef unsigned long vhost_log_chunk_t;
> struct vhost_log {
> unsigned long long size;
> int refcnt;
> + int sync_cnt;
> int fd;
> vhost_log_chunk_t *log;
> };
> --
> 2.20.1
>
--
Peter Xu
next prev parent reply other threads:[~2025-12-09 20:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 12:09 [RFC v1 0/2] migration: reduce bitmap sync time and make dirty pages converge much more easily Chuang Xu
2025-12-08 12:09 ` [RFC v1 1/2] vhost: eliminate duplicate dirty_bitmap sync when log shared by multiple devices Chuang Xu
2025-12-09 20:47 ` Peter Xu [this message]
2025-12-10 6:51 ` Jason Wang
2025-12-10 13:52 ` Chuang Xu
2025-12-08 12:09 ` [RFC v1 2/2] migration: merge fragmented clear_dirty ioctls Chuang Xu
2025-12-09 21:10 ` Peter Xu
2025-12-10 14:18 ` Chuang Xu
2025-12-10 19:45 ` Peter Xu
2025-12-09 21:06 ` [RFC v1 0/2] migration: reduce bitmap sync time and make dirty pages converge much more easily Peter Xu
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=aTiK5opcOOrsFem9@x1.local \
--to=peterx@redhat.com \
--cc=david@kernel.org \
--cc=farosas@suse.de \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sgarzare@redhat.com \
--cc=xuchuangxclwt@bytedance.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).