Skip to content

Commit 2050327

Browse files
dwmw2davem330
authored andcommitted
ptp: Add support for the AMZNC10C 'vmclock' device
The vmclock device addresses the problem of live migration with precision clocks. The tolerances of a hardware counter (e.g. TSC) are typically around ±50PPM. A guest will use NTP/PTP/PPS to discipline that counter against an external source of 'real' time, and track the precise frequency of the counter as it changes with environmental conditions. When a guest is live migrated, anything it knows about the frequency of the underlying counter becomes invalid. It may move from a host where the counter running at -50PPM of its nominal frequency, to a host where it runs at +50PPM. There will also be a step change in the value of the counter, as the correctness of its absolute value at migration is limited by the accuracy of the source and destination host's time synchronization. In its simplest form, the device merely advertises a 'disruption_marker' which indicates that the guest should throw away any NTP synchronization it thinks it has, and start again. Because the shared memory region can be exposed all the way to userspace through the /dev/vmclock0 node, applications can still use time from a fast vDSO 'system call', and check the disruption marker to be sure that their timestamp is indeed truthful. The structure also allows for the precise time, as known by the host, to be exposed directly to guests so that they don't have to wait for NTP to resync from scratch. The PTP driver consumes this information if present. Like the KVM PTP clock, this PTP driver can convert TSC-based cross timestamps into KVM clock values. Unlike the KVM PTP clock, it does so only when such is actually helpful. The values and fields are based on the nascent virtio-rtc specification, and the intent is that a version (hopefully precisely this version) of this structure will be included as an optional part of that spec. In the meantime, this driver supports the simple ACPI form of the device which is being shipped in certain commercial hypervisors (and submitted for inclusion in QEMU). Signed-off-by: David Woodhouse <[email protected]> Acked-by: Richard Cochran <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f31fd0b commit 2050327

File tree

5 files changed

+818
-0
lines changed

5 files changed

+818
-0
lines changed

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18683,6 +18683,13 @@ S: Maintained
1868318683
F: drivers/ptp/ptp_vclock.c
1868418684
F: net/ethtool/phc_vclocks.c
1868518685

18686+
PTP VMCLOCK SUPPORT
18687+
M: David Woodhouse <[email protected]>
18688+
18689+
S: Maintained
18690+
F: drivers/ptp/ptp_vmclock.c
18691+
F: include/uapi/linux/vmclock-abi.h
18692+
1868618693
PTRACE SUPPORT
1868718694
M: Oleg Nesterov <[email protected]>
1868818695
S: Maintained

drivers/ptp/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,19 @@ config PTP_1588_CLOCK_KVM
131131
To compile this driver as a module, choose M here: the module
132132
will be called ptp_kvm.
133133

134+
config PTP_1588_CLOCK_VMCLOCK
135+
tristate "Virtual machine PTP clock"
136+
depends on X86_TSC || ARM_ARCH_TIMER
137+
depends on PTP_1588_CLOCK && ACPI && ARCH_SUPPORTS_INT128
138+
default y
139+
help
140+
This driver adds support for using a virtual precision clock
141+
advertised by the hypervisor. This clock is only useful in virtual
142+
machines where such a device is present.
143+
144+
To compile this driver as a module, choose M here: the module
145+
will be called ptp_vmclock.
146+
134147
config PTP_1588_CLOCK_IDT82P33
135148
tristate "IDT 82P33xxx PTP clock"
136149
depends on PTP_1588_CLOCK && I2C

drivers/ptp/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ obj-$(CONFIG_PTP_1588_CLOCK_DTE) += ptp_dte.o
1111
obj-$(CONFIG_PTP_1588_CLOCK_INES) += ptp_ines.o
1212
obj-$(CONFIG_PTP_1588_CLOCK_PCH) += ptp_pch.o
1313
obj-$(CONFIG_PTP_1588_CLOCK_KVM) += ptp_kvm.o
14+
obj-$(CONFIG_PTP_1588_CLOCK_VMCLOCK) += ptp_vmclock.o
1415
obj-$(CONFIG_PTP_1588_CLOCK_QORIQ) += ptp-qoriq.o
1516
ptp-qoriq-y += ptp_qoriq.o
1617
ptp-qoriq-$(CONFIG_DEBUG_FS) += ptp_qoriq_debugfs.o

0 commit comments

Comments
 (0)