On Tue, 2026-05-26 at 14:57 +0100, David Woodhouse wrote:
> 
> One simple option that occurs to me would be to add a 'cycles_raw'
> value to the system_time_snapshot, for PV clocksources like hyperv and
> kvmclock to populate with the original TSC reading.
> 
> That might actually let us clean up some of the PTP code that currently
> has to deal with TSC vs. kvmclock in counter snapshots too. I think I
> could kill the use of get_cycles() in vmclock for the kvmclock case,
> which might make Thomas happy...

I hacked that up to see what it looks like, and it kind of seems to work...

Based on merging my kvmclock branch and Thomas's ktime_get_snapshot_id():
 • 
https://git.infradead.org/?p=users/dwmw2/linux.git;a=shortlog;h=refs/heads/kvmclock5https://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git/log/?h=timers/ptp/timekeeping

I'll probably not post this for real until the above two are merged;
there's no rush but I think it's a worthwhile cleanup. For now it's at
 • 
https://git.infradead.org/?p=users/dwmw2/linux.git;a=shortlog;h=refs/heads/kvm-ktime-snapshot

David Woodhouse (8):
      timekeeping: Add clocksource read_raw() method and raw_cycles to snapshot
      clocksource/hyperv: Implement read_raw() for TSC page clocksource
      x86/kvmclock: Implement read_raw() for kvmclock clocksource
      KVM: x86: Use ktime_get_snapshot_id() for master clock
      KVM: x86: Compute kvmclock base without pvclock_gtod_data
      KVM: x86: Replace pvclock_gtod_data vclock_mode with boolean
      KVM: x86: Remove pvclock_gtod_data and private timekeeping code
      ptp: vmclock: Use raw_cycles from snapshot for precise TSC pairing

 arch/x86/kernel/kvmclock.c         |  21 ++++
 arch/x86/kvm/x86.c                 | 239 ++++++++-----------------------------
 drivers/clocksource/hyperv_timer.c |  14 +++
 drivers/ptp/ptp_vmclock.c          |   4 +
 include/linux/clocksource.h        |   8 ++
 include/linux/timekeeping.h        |   6 +
 kernel/time/timekeeping.c          |  30 ++++-
 7 files changed, 130 insertions(+), 192 deletions(-)

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to