Repository navigation
doc: state the host clock source requirement for clock_realtime and KVM PTP - #6244
yuchen-plori wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Thanks for the contribution, and for the thorough investigation behind it!
You are right that both clock_realtime and KVM PTP depend on the host using a TSC-based clock source, and documenting this precondition, especially the silent PTP failure, would save users a lot of debugging. I agree with the overall direction.
I left a few minor comments, mostly about wording precision.
Thanks!
69f5621 to
e88d560
Compare
zulinx86
left a comment
There was a problem hiding this comment.
Thanks for the quick update!
I left one more small nit, which is not blocking. Feel free to take it or leave
it as is.
LGTM, thanks again for documenting this.
|
Thanks for applying the suggestion! Could you squash the "drop it to keep the |
2d582d8 to
409f058
Compare
|
Squashed into the first commit and force-pushed (409f058). The branch now has one commit with the original message and a — Plori AI team |
zulinx86
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the contribution again!
|
Agh... CI now fails on gitlint for the commit message
Could you shorten the title, for example to "doc: document host clock source |
Both `clock_realtime: true` on snapshot load and the KVM PTP device (/dev/ptp0) need the host kernel to use a TSC-based clock source. KVM sets KVM_CLOCK_REALTIME in KVM_GET_CLOCK, and answers the KVM_HC_CLOCK_PAIRING hypercall, only when the host clock is TSC-based. On a host that uses kvm-clock, for example a KVM guest without an invariant TSC, the snapshot load fails with "clock_realtime requested but not present in the snapshot state" and the guest has no /dev/ptp0, with no message from the driver. Document the requirement in the snapshot guide and in the wall-clock FAQ answer, with a way to check the host. Signed-off-by: Plori AI Team <agent@plori.ai>
1eabfab to
5716930
Compare
|
Reworded and force-pushed (5716930): the title is now "doc: document host clock source requirement for clock_realtime and PTP" (70 characters) and the body is wrapped at 72 columns. — Plori AI team |
Changes
Documentation only:
docs/snapshotting/snapshot-support.md: the host that creates the snapshot mustuse a TSC-based clock source for
clock_realtime: true, and the error you getwhen it does not.
FAQ.md(wall-clock answer):/dev/ptp0appears only when the host kernel usesa TSC-based clock source, and how to check the host.
Reason
On a host that is itself a KVM guest without an invariant TSC, both
clock_realtimeand the KVM PTP time source fail. The docs do not name thisprecondition, and the PTP failure is silent. We observed it with Firecracker
v1.17.0 on such a host:
current_clocksource=kvm-clock(available:kvm-clock acpi_pm);tsc: Marking TSC unstable due to TSCs unsynchronizedandkvm: SMP vm created on host with unstable TSC; guest TSC will not be reliable;constant_tsc/nonstop_tscin/proc/cpuinfo.Results:
LoadSnapshotwithclock_realtime: truefails withclock_realtime requested but not present in the snapshot state(snapshotcreated and loaded on the same host and Firecracker build).
CONFIG_PTP_1588_CLOCK_KVM=y) has no/dev/ptp0, andthe kernel logs nothing about it. The same guest kernel on a host with a
TSC clock source gets
/dev/ptp0, and chrony uses it as a PHC refclock.Both come from one condition in KVM (Linux v6.8):
__get_kvmclock()setsKVM_CLOCK_REALTIMEonly when the VM uses the masterclock and
kvm_get_walltime_and_clockread()succeeds(x86.c#L3056).
The master clock needs a TSC-based host clock
(
gtod_is_based_on_tsc()).Firecracker then returns
ClockRealtimeNotInState(vm.rs).
kvm_pv_clock_pairing()returns-KVM_EOPNOTSUPPunder the same check(x86.c#L9875),
so the guest's
ptp_kvmdriver does not register/dev/ptp0.A nested host is the common case, not the only one: a nested host that gets an
invariant TSC can use
tsc, so the docs describe the clock source condition andgive a way to check it. NTP in the guest, which the FAQ already names as the
canonical solution, works on these hosts; we serve NTP from the host to the
guests.
Related: the TSC-stability question in the review of #5809
(#5809 (comment))
and the test fixes for non-metal hosts in #5946.
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.PR Checklist
tools/devtool checkbuild --allto verify that the PR passesbuild checks on all supported architectures. (Documentation only; no code
changes.)
tools/devtool checkstyle --no-clippyto verify that the PRpasses the automated style checks. (Ran the same
mdformat0.7.22 with thegfm, frontmatter and footnote plugins on both files;
mdformat --checkpasses.)
how they are solving the problem in a clear and encompassing way.
in the PR.
CHANGELOG.md. (Not needed:documentation only.)
Runbook for Firecracker API changes. (No API change.)
integration tests. (Documentation only.)
TODO. (No TODOs.)rust-vmm. (Not applicable.)— Plori AI team (plori.ai)