qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: "Maxiwell S. Garcia" <maxiwell@linux.ibm.com>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/1] spapr: Do not re-read the clock on pre_save handler on migration
Date: Wed, 12 Jun 2019 15:14:46 +1000	[thread overview]
Message-ID: <20190612051446.GH3998@umbus.fritz.box> (raw)
In-Reply-To: <20190605193927.3lek4voay5stxtqt@maxibm>

[-- Attachment #1: Type: text/plain, Size: 4484 bytes --]

On Wed, Jun 05, 2019 at 04:39:27PM -0300, Maxiwell S. Garcia wrote:
> On Thu, May 30, 2019 at 11:13:41AM +1000, David Gibson wrote:
> > On Thu, May 23, 2019 at 05:18:51PM -0300, Maxiwell S. Garcia wrote:
> > > On Thu, May 23, 2019 at 09:29:52AM +1000, David Gibson wrote:
> > > > On Mon, May 20, 2019 at 05:43:40PM -0300, Maxiwell S. Garcia wrote:
> > > > > This handler was added in the commit:
> > > > >   42043e4f1241: spapr: clock should count only if vm is running
> > > > > 
> > > > > In a scenario without migration, this pre_save handler is not
> > > > > triggered, so the 'stop/cont' commands save and restore the clock
> > > > > in the function 'cpu_ppc_clock_vm_state_change.' The SW clock
> > > > > in the guest doesn't know about this pause.
> > > > > 
> > > > > If the command 'migrate' is called between 'stop' and 'cont',
> > > > > the pre_save handler re-read the clock, and the SW clock in the
> > > > > guest will know about the pause between 'stop' and 'migrate.'
> > > > > If the guest is running a workload like HTC, a side-effect of
> > > > > this is a lot of process stall messages (with call traces) in
> > > > > the kernel guest.
> > > > > 
> > > > > Signed-off-by: Maxiwell S. Garcia <maxiwell@linux.ibm.com>
> > > > 
> > > > What affect will this have on the clock for the case of migrations
> > > > without a stop/cont around?
> > > 
> > > The guest timebase is saved when the VM stop running and restored when
> > > the VM starts running again (cpu_ppc_clock_vm_state_change handler).
> > > Migrations without stop/cont save the clock when the VM go to the
> > > FINISH_MIGRATE state.
> > 
> > Right... which means the clock is effectively stopped for the
> > migration downtime window while we transfer the final state.  That
> > means the guest clock will drift from wall clock by a couple of
> > hundred ms across the migration which is not correct.
> > 
> > > > The complicated thing here is that for
> > > > *explicit* stops/continues we want to freeze the clock, however for
> > > > the implicit stop/continue during migration downtime, we want to keep
> > > > the clock running (logically), so that the guest time of day doesn't
> > > > get out of sync on migration.
> > > > 
> > > 
> > > Not sure if the *implicit* word here is about commands from the libvirt
> > > or any other orchestrator.
> > 
> > By implicit I mean the stopping of the VM which qemu does to transfer
> > the final part of the state, rather than because of an explicit
> > stop/cont command.
> > 
> > > QEMU itself doesn't know the intent behind the
> > > command stop/cont. So, If we are using a guest to process a workload and
> > > the manager tool decide to migrate our VM transparently, it's unpleasant
> > > to see a lot of process stalls with call traces in the kernel log.
> > 
> > If you have a lot of process stalls across a migration, that suggests
> > your permitted downtime window is *way* too long.
> 
> I see a difference between live migration and 'cold' migration. In
> a cold migration scenario (where a user 'stop' the machine, wait an
> arbitrary time, move it to another server, and run it), the behavior
> should be the same as executing 'stop/cont' in a guest without migration.

Agreed.  The difficulty is distinguishing those two cases and handling
them both correctly.

> This problem also emerges when the 'timeout' flag is used with 'virsh'
> tool to live-migrate a guest. After the 'timeout', the libvirt sends a
> 'stop' command to QEMU to suspend the guest before migrate. If the NFS
> is slow, for example, this guest will wait many minutes to run again.

Hm, in this case it's pretty unclear what the right action is.
Failing the migration outright is bad, but shifting the guest's real
time clock by minutes is pretty bad too.

> Maybe a solution is to modify the timebase_pre_save handler to know the
> current vm_state and only save the timebase again when vm_state is not
> in 'stop' state. What do you think?

Sounds reasonable, but the problem is I'm not sure there's a clear way
to tell that the guest has been explicitly stopped - that is with a
"stop" monitor instruction - rather that just the automatic stop due
to the vm_stop() in the migration path.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2019-06-12  5:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20 20:43 [Qemu-devel] [PATCH 0/1] spapr: Do not re-read the clock on pre_save handler on migration Maxiwell S. Garcia
2019-05-20 20:43 ` [Qemu-devel] [PATCH 1/1] " Maxiwell S. Garcia
2019-05-22 23:29   ` David Gibson
2019-05-23 20:18     ` [Qemu-devel] [Qemu-ppc] " Maxiwell S. Garcia
2019-05-30  1:13       ` David Gibson
2019-06-05 19:39         ` Maxiwell S. Garcia
2019-06-12  5:14           ` David Gibson [this message]

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=20190612051446.GH3998@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=maxiwell@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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 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).