]> git.ipfire.org Git - thirdparty/linux.git/commit
x86/kvmclock: Implement read_snapshot() for kvmclock clocksource
authorDavid Woodhouse <dwmw@amazon.co.uk>
Thu, 4 Jun 2026 09:35:17 +0000 (10:35 +0100)
committerThomas Gleixner <tglx@kernel.org>
Fri, 5 Jun 2026 12:25:03 +0000 (14:25 +0200)
commit19fa3e50644d2d47fca713b0df640f67dcd26634
treeba00271d2fff0673940c4363270e1185e0378fdf
parentc51100f9e26857f2b2376d5cd657a15f52b9e05c
x86/kvmclock: Implement read_snapshot() for kvmclock clocksource

Implement the read_snapshot() callback for the kvmclock clocksource.  This
returns the kvmclock nanosecond value (for timekeeping) while also
providing the raw TSC value that was used to compute it.

The TSC is read inside the pvclock seqlock-protected region, ensuring the
raw TSC and derived kvmclock value are atomically paired.

This enables ktime_get_snapshot_id() to provide the raw TSC to consumers
like the vmclock PTP driver, which currently has to do a separate call to
get_cycles() to obtain a value at *approximately* the same time, to feed
through the vmclock calculation.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Assisted-by: Kiro:claude-opus-4.6-1m
Link: https://patch.msgid.link/20260604095755.64849-3-dwmw2@infradead.org
arch/x86/kernel/kvmclock.c