All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Peter Xu <peterx@redhat.com>, qemu-devel@nongnu.org
Cc: Juraj Marcin <jmarcin@redhat.com>,
	peterx@redhat.com, "Dr . David Alan Gilbert" <dave@treblig.org>
Subject: Re: [PATCH v2 10/11] migration: Rewrite the migration complete detect logic
Date: Tue, 01 Jul 2025 14:35:38 -0300	[thread overview]
Message-ID: <87a55n6cgl.fsf@suse.de> (raw)
In-Reply-To: <20250609161855.6603-11-peterx@redhat.com>

Peter Xu <peterx@redhat.com> writes:

> There're a few things off here in that logic, rewrite it.  When at it, add
> rich comment to explain each of the decisions.
>
> Since this is very sensitive path for migration, below are the list of
> things changed with their reasonings.
>
>   (1) Exact pending size is only needed for precopy not postcopy
>
>       Fundamentally it's because "exact" version only does one more deep
>       sync to fetch the pending results, while in postcopy's case it's
>       never going to sync anything more than estimate as the VM on source
>       is stopped.
>
>   (2) Do _not_ rely on threshold_size anymore to decide whether postcopy
>       should complete
>
>       threshold_size was calculated from the expected downtime and
>       bandwidth only during precopy as an efficient way to decide when to
>       switchover.  It's not sensible to rely on threshold_size in postcopy.
>
>       For precopy, if switchover is decided, the migration will complete
>       soon.  It's not true for postcopy.  Logically speaking, postcopy
>       should only complete the migration if all pending data is flushed.
>
>       Here it used to work because save_complete() used to implicitly
>       contain save_live_iterate() when there's pending size.
>
>       Even if that looks benign, having RAMs to be migrated in postcopy's
>       save_complete() has other bad side effects:
>
>       (a) Since save_complete() needs to be run once at a time, it means
>       when moving RAM there's no way moving other things (rather than
>       round-robin iterating the vmstate handlers like what we do with
>       ITERABLE phase).  Not an immediate concern, but it may stop working
>       in the future when there're more than one iterables (e.g. vfio
>       postcopy).
>
>       (b) postcopy recovery, unfortunately, only works during ITERABLE
>       phase. IOW, if src QEMU moves RAM during postcopy's save_complete()
>       and network failed, then it'll crash both QEMUs... OTOH if it failed
>       during iteration it'll still be recoverable.  IOW, this change should
>       further reduce the window QEMU split brain and crash in extreme cases.
>
>       If we enable the ram_save_complete() tracepoints, we'll see this
>       before this patch:
>
>       1267959@1748381938.294066:ram_save_complete dirty=9627, done=0
>       1267959@1748381938.308884:ram_save_complete dirty=0, done=1
>
>       It means in this migration there're 9627 pages migrated at complete()
>       of postcopy phase.
>
>       After this change, all the postcopy RAM should be migrated in iterable
>       phase, rather than save_complete():
>
>       1267959@1748381938.294066:ram_save_complete dirty=0, done=0
>       1267959@1748381938.308884:ram_save_complete dirty=0, done=1
>
>   (3) Adjust when to decide to switch to postcopy
>
>       This shouldn't be super important, the movement makes sure there's
>       only one in_postcopy check, then we are clear on what we do with the
>       two completely differnt use cases (precopy v.s. postcopy).
>
>   (4) Trivial touch up on threshold_size comparision
>
>       Which changes:
>
>       "(!pending_size || pending_size < s->threshold_size)"
>
>       into:
>
>       "(pending_size <= s->threshold_size)"
>
> Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>

Reviewed-by: Fabiano Rosas <farosas@suse.de>


  reply	other threads:[~2025-07-01 17:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-09 16:18 [PATCH v2 00/11] migration: Some enhancements and cleanups for 10.1 Peter Xu
2025-06-09 16:18 ` [PATCH v2 01/11] migration/hmp: Reorg "info migrate" once more Peter Xu
2025-06-09 16:18 ` [PATCH v2 02/11] migration/hmp: Fix postcopy-blocktime per-vCPU results Peter Xu
2025-07-01 14:38   ` Fabiano Rosas
2025-06-09 16:18 ` [PATCH v2 03/11] migration/docs: Move docs for postcopy blocktime feature Peter Xu
2025-06-09 16:18 ` [PATCH v2 04/11] migration/bg-snapshot: Do not check for SKIP in iterator Peter Xu
2025-06-09 16:18 ` [PATCH v2 05/11] migration: Drop save_live_complete_postcopy hook Peter Xu
2025-07-01 14:40   ` Fabiano Rosas
2025-06-09 16:18 ` [PATCH v2 06/11] migration: Rename save_live_complete_precopy to save_complete Peter Xu
2025-07-01 14:41   ` Fabiano Rosas
2025-06-09 16:18 ` [PATCH v2 07/11] migration: qemu_savevm_complete*() helpers Peter Xu
2025-07-01 14:53   ` Fabiano Rosas
2025-06-09 16:18 ` [PATCH v2 08/11] migration/ram: One less indent for ram_find_and_save_block() Peter Xu
2025-06-09 16:18 ` [PATCH v2 09/11] migration/ram: Add tracepoints for ram_save_complete() Peter Xu
2025-06-09 16:18 ` [PATCH v2 10/11] migration: Rewrite the migration complete detect logic Peter Xu
2025-07-01 17:35   ` Fabiano Rosas [this message]
2025-06-09 16:18 ` [PATCH v2 11/11] migration/postcopy: Avoid clearing dirty bitmap for postcopy too Peter Xu
2025-06-11  6:15 ` [PATCH v2 00/11] migration: Some enhancements and cleanups for 10.1 Mario Casquero
2025-06-11 13:06   ` Peter Xu
2025-06-12 10:35     ` Mario Casquero
2025-06-12 11:43       ` Peter Xu
2025-06-11 21:35 ` 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=87a55n6cgl.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=dave@treblig.org \
    --cc=jmarcin@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.