Netdev List
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@kernel.org>
To: David Woodhouse <dwmw2@infradead.org>,
	Harshitha Ramamurthy <hramamurthy@google.com>,
	netdev@vger.kernel.org, Arthur Kiyanovski <akiyano@amazon.com>
Cc: joshwash@google.com, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	richardcochran@gmail.com, jstultz@google.com, sboyd@kernel.org,
	willemb@google.com, nktgrg@google.com, jfraker@google.com,
	ziweixiao@google.com, maolson@google.com, jordanrhee@google.com,
	thostet@google.com, alok.a.tiwari@oracle.com,
	pkaligineedi@google.com, horms@kernel.org,
	jacob.e.keller@intel.com, yyd@google.com, jefrogers@google.com,
	linux-kernel@vger.kernel.org,
	"Naman Gulati" <namangulati@google.com>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Subject: Re: [PATCH net-next v8 3/3] gve: implement PTP gettimex64
Date: Fri, 22 May 2026 16:46:36 +0200	[thread overview]
Message-ID: <87y0hbtsc3.ffs@tglx> (raw)
In-Reply-To: <aee6f77138e5f173d36f3f4ce65cc2acc4e4ae69.camel@infradead.org>

On Fri, May 22 2026 at 11:34, David Woodhouse wrote:
> On Fri, 2026-05-22 at 00:43 +0200, Thomas Gleixner wrote:
>>      1) Guest TSC value at freeze
>>      2) Guest nominal TSC frequency
>>      3) Old host REALTIME at freeze - Ideally you use TAI
>>      4) New host TSC frequency
>>      5) New host TSC/REALTIME/TAI snapshot
>> 
>>   #1 is a KVM problem, but see #3
>>   
>>   #2 ideally communicated from the guest to the host after early
>>      initialization at boot.
>> 
>>      You really want this information because the guest won't change the
>>      mult/shift pair for it ever.
>
> If *tell* the guest the frequency in CPUID, then it shouldn't be trying
> to manually calibrate it against an emulated PIT while suffering steal
> time, and its mult/shift should have a little bit less entropy.

They are identical on every boot evaluation.

> Even a system which *has* to do that crappy calibration still does it
> with a lot more *precision* than accuracy, so I suspect we ought to be
> rounding the result to the nearest 1MHz as long as that's within 10PPM
> or something like that. But that really *is* a digression :)

:)

> The model I'm enabling and documenting for KVM migration is basically
> within the noise of what you describe above, yes.
>
> But if we want to give the illusion of the TSC just ticking away while
> the guest happens to experience a little steal time, when in fact it's
> been completely migrated to a new host, we actually want to work with
> the *true* running frequency of the TSC at the moment of migration.
>
> So... 
>
>  1) Use clock_get_time_reference() to get a { host tsc, time, rate }
>     from the source host at 'freeze' time. 
>
>  2) Use clock_get_time_reference() to get a { host tsc, time, rate }
>     from the destination host, when resuming.
>
>  3) (Optionally) scale the guest's TSC frequency, not by the *nominal* 
>     rates, but by the *actual* ratio of the rates from (1) and (2)
>     above (plus any original nominal scaling of the guest's TSC from
>     the original host).
>
>  4) Calculate the guest TSC *offset* in order to convey the effect
>     that the guest's TSC continued to tick at the rate from (1),
>     during the time period between (1) and (2).
>
>  5) (Optionally) Once the guest is running, slowly undo the scaling
>     in (1) in order to get the guest back to a nice simple unscaled
>     TSC (or scaled only by nominal frequencies as it was when launched)
>
>
> Obviously, a dedicated environment which disciplines its TSC directly
> can do all of that right now already because it *has* all the
> information it would get from clock_get_time_reference().
>
> But as you know perfectly well, Thomas, I'm never happy to keep the
> blinkers on and focus only on my specific use case at hand; I want this
> to work for the *general* case, including people running QEMU in a
> fairly standard environment. And I think clock_get_time_reference()
> might be a reasonable way of doing that, and a fairly clean counterpart
> to the clock_set_time_reference() you suggested?

Agreed.

  reply	other threads:[~2026-05-22 14:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 22:58 [PATCH net-next v8 0/3] gve: add support for PTP gettimex64 Harshitha Ramamurthy
2026-05-14 22:58 ` [PATCH net-next v8 1/3] gve: skip error logging for retryable AdminQ commands Harshitha Ramamurthy
2026-05-14 22:58 ` [PATCH net-next v8 2/3] gve: make nic clock reads thread safe Harshitha Ramamurthy
2026-05-14 22:58 ` [PATCH net-next v8 3/3] gve: implement PTP gettimex64 Harshitha Ramamurthy
2026-05-20 21:08   ` Thomas Gleixner
2026-05-20 22:16     ` Jakub Kicinski
2026-05-21  4:35     ` Jordan Rhee
2026-05-21 10:08     ` David Laight
2026-05-21 11:43   ` David Woodhouse
2026-05-21 18:06     ` Thomas Gleixner
2026-05-21 19:59       ` David Woodhouse
2026-05-21 22:43         ` Thomas Gleixner
2026-05-22  0:12           ` David Woodhouse
2026-05-22  7:49             ` Thomas Gleixner
2026-05-22  8:56               ` David Woodhouse
2026-05-22 14:41                 ` Thomas Gleixner
2026-05-22 10:34           ` David Woodhouse
2026-05-22 14:46             ` Thomas Gleixner [this message]
2026-05-20  1:30 ` [PATCH net-next v8 0/3] gve: add support for " patchwork-bot+netdevbpf

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=87y0hbtsc3.ffs@tglx \
    --to=tglx@kernel.org \
    --cc=akiyano@amazon.com \
    --cc=alok.a.tiwari@oracle.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dwmw2@infradead.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=hramamurthy@google.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jefrogers@google.com \
    --cc=jfraker@google.com \
    --cc=jordanrhee@google.com \
    --cc=joshwash@google.com \
    --cc=jstultz@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maolson@google.com \
    --cc=namangulati@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=nktgrg@google.com \
    --cc=pabeni@redhat.com \
    --cc=pkaligineedi@google.com \
    --cc=richardcochran@gmail.com \
    --cc=sboyd@kernel.org \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=thostet@google.com \
    --cc=willemb@google.com \
    --cc=yyd@google.com \
    --cc=ziweixiao@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