Repository navigation
kernel: portable code calls the CPU's counter the counter, not the TSC - #944
Conversation
On AArch64 `cpu::counter` reads the generic timer's CNTVCT_EL0, yet the portable kernel named it the TSC. Renamed, no behaviour change: - clock: TSC_BOOT -> COUNTER_AT_BOOT (the clock page's own field name), TSC_PERIOD_FS -> COUNTER_PERIOD_FS, tsc_deadline -> counter_deadline, beside the existing set_counter and counter_ticks. - deadline: AT_TSC -> AT_COUNTER. - hardlockup: BOUND_TSC -> BOUND_TICKS, AT_TSC -> AT_COUNTER. PERIOD's doc no longer restates that x86 reference cycles are TSC ticks; that fact stays where it is true, at arch/x86_64/pmu.rs's `arm`. - Comments in clock, deadline, hardlockup, panic_reboot, main, xhci and pure/sched say the counter (or `cpu::counter`) where they said TSC or `rdtsc`. pure/sched/hw.rs's kernel-side summary names each architecture's timer, IPI and counter rather than x86's LAPIC/ICR/TSC, and its TSC-deadline remark is marked as the x86 timer mode it is. - arch/x86_64/smp.rs follows the rename of the static it cites. Closes issues/portable-kernel-code-names-the-tsc.md: no item or comment outside kernel/src/arch/x86_64/ names the TSC for the counter `cpu::counter` reads (`rg -i tsc` outside that directory, PORTSC aside, leaves only hw.rs's x86 TSC-deadline timer mode). The rule itself is reviewer.md's "generic kernel code does not name architecture implementations", so nothing is folded.
Review of #944 at 79a162c (base origin/main 979d4c5)Assessment. The rename is the right size and stays inside the kernel crate. I checked the diff hunk by hunk. Every change is an identifier rename ( Exit check. I ran
Issue citations left alone. This is correct. Root's rule edits an existing issue only when it is taken up or a rule requires it. No conflict with #946: that branch does not touch Findings
SEND BACK |
Review of #944: the trait's doc said only x86's LAPIC one-shot converts and predicted a TSC-deadline mode that does not exist. Both architectures' `irqchip::arm_one_shot` take a span (x86_64 apic.rs, aarch64 irqchip.rs), and `KernelHw::set_timer` (kernel/src/hw.rs) turns the absolute deadline into one; the doc now says that, leaving no x86 name in kernel/pure. Also drops the x86 names left in comments this branch already touched: deadline.rs's "local APIC read and two writes" and "LAPIC timer's arm", and clock.rs's NMI sample `rip`.
|
Round 1 addressed at
Checks: |
Review round 2: #944 at
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What this changes
Portable kernel code stops calling the CPU's free-running counter the TSC. On AArch64
cpu::counterreads the generic timer'sCNTVCT_EL0; the names now follow the vocabulary the arch layer andclockalready used (cpu::counter,clock::set_counter,clock::counter_ticks,ClockPage::counter_at_boot). No behaviour change.clock:TSC_BOOT→COUNTER_AT_BOOT,TSC_PERIOD_FS→COUNTER_PERIOD_FS,tsc_deadline→counter_deadline(callers indeadline,hardlockup/probe,panic_reboot,xhcifollow).deadline:AT_TSC→AT_COUNTER.hardlockup:BOUND_TSC→BOUND_TICKS,AT_TSC→AT_COUNTER.hardlockup::PERIOD's doc said x86 reference cycles are TSC ticks; it now states only the unit (cpu::counterticks, whatpmu::armtakes). The x86 fact already lives where it is true,arch/x86_64/pmu.rs'sarm.clock,deadline,hardlockup,panic_reboot,main,xhci/{mod,stop}andkernel/pure/sched/{cpu,hw}.rssay the counter where they said TSC orrdtsc.pure/sched/hw.rs's kernel-side summary names each architecture's timer, IPI and counter instead of x86's LAPIC/ICR/TSC, andMachine::set_timer's doc states the conversion both kernels make (irqchip::arm_one_shottakes a span on both, soKernelHw::set_timerconverts) instead of an x86-only LAPIC/TSC-deadline remark. The x86 names left in comments this branch touched (deadline's LAPIC read and arm,clock's NMIrip) now say timer and PC.arch/x86_64/smp.rsfollows the rename of the static it cites.Why
Closes
issues/portable-kernel-code-names-the-tsc.md. Its exit — no item or comment outsidekernel/src/arch/x86_64/names the TSC for the countercpu::counterreads — holds:rg -i tsc kernel/src kernel/pure --glob '!kernel/src/arch/x86_64/**' | rg -vi portscreturns nothing. The rule the issue enforced is alreadyreviewer.md's "generic kernel code does not name architecture implementations", so nothing is folded into a module header.Evidence
Head
23a96debeon base979d4c539, on an Apple-silicon macOS host.23a96debe:cargo run -- --ci host→ exit 0, "Host: 86 step(s), all green". Log: https://github.com/ToyOSOrg/evidence/blob/00f694c9ff56e91a0cf7e1745a87f3c6c7c891c5/944/ci-host-23a96debe.log79a162cda:cargo run -- --ci host→ exit 0, "Host: 86 step(s), all green"; includes clippy-D warningsforkernelonx86_64-unknown-noneandaarch64-unknown-none-softfloatwith every feature setbuild/clippy.rscovers. Log: https://github.com/ToyOSOrg/evidence/blob/9a891c123e41553e5d255e05c6584ed58fd168a8/944/ci-host.log79a162cda:cargo run -- --build-only --arch x86_64→ exit 0. Log: https://github.com/ToyOSOrg/evidence/blob/9a891c123e41553e5d255e05c6584ed58fd168a8/944/build-x86_64.log79a162cda:cargo run -- --build-only --arch aarch64→ exit 0. Log: https://github.com/ToyOSOrg/evidence/blob/9a891c123e41553e5d255e05c6584ed58fd168a8/944/build-aarch64.logThe image builds above are from
79a162cda;23a96debechanges only comments, which cannot change what compiles, and its host CI run re-checks clippy on both kernel targets.No guest run: the diff renames five private statics and one
pub fnwithin the kernel crate and rewrites comments. A rename the compiler accepts on both targets cannot change what any path computes, so no guest test could observe it.What is unsure
issues/a-120000-ms-boot-deadline-fired-132859-ms-late-on-the-t14.mdcitesAT_TSC;issues/ap-tsc-trail-is-assumed-and-never-checked.mdcitesTSC_BOOT). Left untouched perissues/README.md(existing issues are edited only when taken up); a reader following them now findsAT_COUNTER/COUNTER_AT_BOOT.hardlockup's header still describes the x86 mechanism (local APIC LVT, SDM citations) in a portable module; AArch64 refuses to arm it (arch/aarch64/pmu.rs). That is outside this issue's TSC-naming exit and unchanged here.gh pr diffprints nothing), so there is no conflict withclock.rsordeadline.rs. Design: idle CPUs enter the deep idle states the firmware declares #870's design text mentions TSC-deadline mode and invariant TSC as x86 hardware facts, which this rename does not touch. Another agent is changingkernel/src/drivers/serial.rs/serial_lock.rs; this branch does not touch them.Anything a reader of
mainmust not missDeletes
issues/portable-kernel-code-names-the-tsc.md(closed).clock::tsc_deadlineis nowclock::counter_deadline; a branch still calling the old name fails to compile rather than misbehaving.