From: Peter Xu <peterx@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
qemu-devel@nongnu.org,
"Alexander Duyck" <alexander.duyck@gmail.com>,
qemu-stable@nongnu.org, "Wei Wang" <wei.w.wang@intel.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [PATCH v2 1/2] virtio-balloon: don't start free page hinting if postcopy is possible
Date: Thu, 8 Jul 2021 14:51:55 -0400 [thread overview]
Message-ID: <YOdJS8kJBqRdbdmE@t490s> (raw)
In-Reply-To: <20210708095339.20274-2-david@redhat.com>
On Thu, Jul 08, 2021 at 11:53:38AM +0200, David Hildenbrand wrote:
> Postcopy never worked properly with 'free-page-hint=on', as there are
> at least two issues:
>
> 1) With postcopy, the guest will never receive a VIRTIO_BALLOON_CMD_ID_DONE
> and consequently won't release free pages back to the OS once
> migration finishes.
>
> The issue is that for postcopy, we won't do a final bitmap sync while
> the guest is stopped on the source and
> virtio_balloon_free_page_hint_notify() will only call
> virtio_balloon_free_page_done() on the source during
> PRECOPY_NOTIFY_CLEANUP, after the VM state was already migrated to
> the destination.
>
> 2) Once the VM touches a page on the destination that has been excluded
> from migration on the source via qemu_guest_free_page_hint() while
> postcopy is active, that thread will stall until postcopy finishes
> and all threads are woken up. (with older Linux kernels that won't
> retry faults when woken up via userfaultfd, we might actually get a
> SEGFAULT)
>
> The issue is that the source will refuse to migrate any pages that
> are not marked as dirty in the dirty bmap -- for example, because the
> page might just have been sent. Consequently, the faulting thread will
> stall, waiting for the page to be migrated -- which could take quite
> a while and result in guest OS issues.
>
> While we could fix 1) comparatively easily, 2) is harder to get right and
> might require more involved RAM migration changes on source and destination
> [1].
>
> As it never worked properly, let's not start free page hinting in the
> precopy notifier if the postcopy migration capability was enabled to fix
> it easily. Capabilities cannot be enabled once migration is already
> running.
>
> Note 1: in the future we might either adjust migration code on the source
> to track pages that have actually been sent or adjust
> migration code on source and destination to eventually send
> pages multiple times from the source and and deal with pages
> that are sent multiple times on the destination.
>
> Note 2: virtio-mem has similar issues, however, access to "unplugged"
> memory by the guest is very rare and we would have to be very
> lucky for it to happen during migration. The spec states
> "The driver SHOULD NOT read from unplugged memory blocks ..."
> and "The driver MUST NOT write to unplugged memory blocks".
> virtio-mem will move away from virtio_balloon_free_page_done()
> soon and handle this case explicitly on the destination.
>
> [1] https://lkml.kernel.org/r/e79fd18c-aa62-c1d8-c7f3-ba3fc2c25fc8@redhat.com
>
> Fixes: c13c4153f76d ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT")
> Cc: qemu-stable@nongnu.org
> Cc: Wei Wang <wei.w.wang@intel.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Cc: Alexander Duyck <alexander.duyck@gmail.com>
> Cc: Juan Quintela <quintela@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Cc: Peter Xu <peterx@redhat.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Thanks, David.
--
Peter Xu
next prev parent reply other threads:[~2021-07-08 19:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-08 9:53 [PATCH v2 0/2] virtio-balloon: don't start free page hinting if postcopy is possible David Hildenbrand
2021-07-08 9:53 ` [PATCH v2 1/2] " David Hildenbrand
2021-07-08 18:51 ` Peter Xu [this message]
2021-07-08 9:53 ` [PATCH v2 2/2] virtio-balloon: free page hinting cleanups David Hildenbrand
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=YOdJS8kJBqRdbdmE@t490s \
--to=peterx@redhat.com \
--cc=alexander.duyck@gmail.com \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=mst@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=quintela@redhat.com \
--cc=wei.w.wang@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.