mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Ming Lin <minggr@gmail.com>
Cc: Sean Christopherson <seanjc@google.com>,
	kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: pvclock time drifting backward
Date: Sat, 29 Mar 2025 08:20:32 +0000	[thread overview]
Message-ID: <eaa33f756bc2e66ca193180a9847ee43fbdaa8ad.camel@infradead.org> (raw)
In-Reply-To: <CAF1ivSaEz0brSGfpv08oKnTjT=h99hs_G0ju0UGPwzoLvOSV8A@mail.gmail.com>

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

On Fri, 2025-03-28 at 11:30 -0700, Ming Lin wrote:
> 
> > 
> > Is this live migration from one VMM to another on the same host, so we
> > don't have to worry about the accuracy of the TSC itself? The guest TSC
> > remains consistent? And presumably your host does *have* a stable TSC,
> > and the guest's test case really ought to be checking the
> > PVCLOCK_TSC_STABLE_BIT to make sure of that?
> 
> The live migration is from one VMM to another on a remote host, and we
> have also observed the same issue during live upgrades on the same host.

Moving to a remote host also requires that you get the guest TSC to be
reasonably synchronised on the destination. Which is another litany of
sadness, especially if you have TSC scaling in the mix. Or even if your
two "identical" hosts calculated a slightly different TSC frequency
when they measured it at first boot.

In that latter case, the mul/scale factors advertised to the guest in
the pvclock will be *slightly* different on the new host. Your test in
the guest would then fail if it requires that the pvclock be
*identical*. The actual criterion is that the result should be
identical at the time of the live migration (when the TSC frequency
effectively changes).

The code currently requires that the old and new TSC frequencies are
within ±1kHz of each other.

> > 
> > If all the above assumptions/interpretations of mine are true, I still
> > think it's expected that your clock will jump on live migration
> > *unless* you also taught your VMM to use the new KVM_[GS]ET_CLOCK_GUEST
> > ioctls which were added in my patch series, specifically to preserve
> > the mathematical relationship between guest TSC and kvmclock across a
> > migration.
> > 
> 
> We are planning to test the patches on a 6.9 kernel (where they can be
> applied cleanly) and modify the live upgrade/migration code to use the new
> KVM_[GS]ET_CLOCK_GUEST ioctls.
> 
> BTW, what is the plan for upstreaming these patches?

I need to find the time to rebase, rework and retest them. You're doing
some of the testing and increasing the motivation... I'll see if I can
get it done in the next week or three.

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]

  reply	other threads:[~2025-03-29  8:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-20  5:38 Ming Lin
2025-03-24 22:54 ` Sean Christopherson
2025-03-25 11:07   ` David Woodhouse
2025-03-26 15:54     ` Ming Lin
2025-03-27  8:10       ` David Woodhouse
2025-03-28 18:30         ` Ming Lin
2025-03-29  8:20           ` David Woodhouse [this message]
2026-04-20 17:26             ` David Woodhouse

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=eaa33f756bc2e66ca193180a9847ee43fbdaa8ad.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minggr@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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

all inboxes | Powered by JetHome®