Repository navigation
Conversation
…MONOTONIC (#644) The trace and the journal are on CLOCK_MONOTONIC, which runs on jiffies from timekeeping_init until the switch to kvm-clock and loses the ticks it misses: 18-21 ms nested, 11-14 on metal. The ledger took its 0 for the kernel's, so kernel_zero and qemu_start read that much late. The kernel prints both clocks at one tick ("sched_clock: Marking stable"); the ledger moves the trace and the journal forward by their difference, and refuses a journal without the line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The goal is a cold boot to the first SSH login in under 100 ms. The ledger is the instrument that says where the time before the kernel's clock goes. Its
kernel_zerolanded 19.5 ms (bench) and 12.6 ms (metal) after a marker the kernel writes at its clock's zero (#611). Soqemu_startread that much long, and #611 first put ~23 ms in QEMU and the firmware that were not there.What
The ledger took CLOCK_MONOTONIC's 0, which is the trace's and the journal's clock, for the kernel's 0. CLOCK_MONOTONIC runs on jiffies from timekeeping_init until the switch to kvm-clock at fs_initcall. It loses every tick it misses. At late_initcall the kernel prints both clocks as one tick read them (
sched_clock: Marking stable (MONO, …)->(SCHED, …)). Their difference accounted for the whole error in all 24 boots of #611's runs, to within 0.15 ms.internal/lab/ledger.go. The ledger reads that lag (monotonic_lag) and moves the trace and the journal forward by it. Every window is then on the kernel's sched clock, andkernel_zerois the sched clock's 0. A journal without the line refuses the ledger. The lag lands in the first window, the kernel's.ledgerprobe.gorecordsmonotonic_lag.Proof: an instrument must see the phase it claims
The marker kernel (
kernel/patches/0099onexp/firmware-split-611) ran with this fix cherry-picked onto the lab-only branchlab/644-proof. Both runs use spin's shape, v20261123.04, QEMU traced and 10 boots. QEMU's trace stamps the 0xdf port write 0.03 to 0.14 ms after the ledger'skernel_zero(measured):kernel_zero, msmonotonic_lag, msBefore the fix the same check read −19.5 and −12.6 (labs 45177818419, 45177817516).
Numbers that moved
All of these are recomputed from the runs' kept journals (measured):
kernel_zero97-114 → 77-95, andqemu_start49.4 → 29.3.before_qemuandguest_to_zerodo not move.No cold-budget row used the ledger's anchor. Two rows sit on clocks with errors of their own, now noted beside them with issues:
runningand firmware-stages' anchor are kvm-clock's 0, which is 2.8 ms (bench) and 4.7 ms (metal) before QEMU's KVM_SET_CLOCK.Closes #644.
🤖 Generated with Claude Code