roadmap PARTIAL

1161. counter_frequency_contract: the release review's findings

(The number and the slug are provisional.)

The release review of partsfoundry/counter_frequency_contract at commit 4decec9d, version 0.1.0-pre.2 and the tag v0.1.0-pre.2, under milestone 1129 (the combine review), whose block sets its form. The baseline is milestone 1073 (what an outside maintainer would fix before it leaves), its block and the cleared package notes/crate-reviews/counter-frequency-contract.md. Every 1073 finding reads Done or ruled. The crate's name, the frozen identity and the thirteen ratified names stay closed, and no later rule of design/naming.md reopens one. The package settled two behaviors as two-way while the crate has no outside caller. A 0.1.0 tag ends that, so doors D2 and D3 bring them back with evidence.

Reuse: the crate's own tests, Miri and two scratch programs.

Finding status

Open decisions

The one-way doors D1 to D9 below.

Goal

A stranger reads one page and knows whose page this is. A reader holds a rate it can divide by, or a refusal that says why. A caller that holds sixteen bytes decodes them without unsafe, and a tool built on one architecture places the page for another.

What the review read and ran

The appendix lists what the lane read and each command's result. The guidelines table marks counter_frequency_contract against the 54 API Guidelines items, and the later items hold its P1 and P2 findings in full.

Prior art

Measured from the crates.io API on 2026-11-26 at 23:13 (UTC). A stranger brings this crate one problem: how a process of one system learns its counter's rate from a page the kernel maps. Ten searches of crates.io found no crate that solves it, so no comparator ranks. Linux's perf_event_mmap_page sets the bar: a page the kernel maps read-only into a process, which carries the counter's rate. The crates below are neighbors that learn a rate another way.

crate or system role version read total 90 days reverse dependencies updated
raw-cpuid neighbor: the rate from x86 CPUID leaf 0x15 11.6.0 218,106,520 56,842,327 153 2025-09-05
quanta neighbor: calibrates the counter against the system clock in each process 0.13.0 182,175,187 41,570,076 126 2026-09-27
aarch64-cpu neighbor: the CNTFRQ_EL0 register 12.0.0 1,147,326 267,546 37 2026-11-14
tick_counter neighbor: frequency() from the register or a one-second measurement 0.4.5 173,178 80,057 1 2023-09-04
fugit integration target: typed rates, measured and not read 0.6.0 6,893,710 1,456,814 154 2026-09-07
Linux include/uapi/linux/perf_event.h, struct perf_event_mmap_page outside Rust, sets the bar v6.12
Linux arch/x86/include/asm/pvclock-abi.h and include/vdso/datapage.h outside Rust v6.12
Devicetree Specification, timebase-frequency and clock-frequency outside Rust v0.4

What counter_frequency_contract does better

perf_event_mmap_page carries its size and a compatible version and reserves its tail by name, which the crate does not; P0-4 and P0-5 follow.

The items

Effort is S (half a day), M (a day or two) or L (longer). A one-way item binds every caller from the first 0.1.0 tag, which is why the P0 items cannot wait. Line numbers are of src/lib.rs.

P0: the 0.1.0 interface

P0-1. The reader takes an integer address, and no safe function decodes sixteen bytes

Verified in source (lines 133 to 199) and by building. CounterFrequencyPage::new is the one way to read a page, it is unsafe, and it takes a u64 that it casts to a pointer. A caller that already holds the bytes writes bytes.as_ptr() as u64 inside unsafe, as every example does. Under Miri with -Zmiri-strict-provenance the crate's own tests stop at that cast, and the default Miri run warns about it. Nothing ties the 16 bytes to the value's lifetime: new(0) compiles, and the type is Copy. raw-cpuid's TscInfo and Linux's readers take a typed pointer or a value. Change: a safe const fn that decodes &[u8; PAGE_CONTENT_BYTES], which hertz calls. The unsafe constructor takes *const u8, or takes no argument and names the fixed address. Door: one-way (D1). Effort: S in the crate, one line at each caller.

P0-2. A page built for 0 reads back as Some(0), and the band binds neither half

Verified by building. build_page(0) returns a page with the magic, hertz() on it returns Some(0), and a scratch program that divided by the result panicked. No function makes the page of an unknown rate. Both doc comments hand the band to the caller. raw-cpuid's tsc_frequency returns None when a term is zero. The cleared package records the stricter reader as a choice for a later release. Change: hertz returns None outside the band, as Option<core::num::NonZeroU64>, and build_page refuses a rate outside it. A constant or a function gives the page of an unknown rate. Door: one-way (D2). Effort: S, with one host test, one harness and its patch.

P0-3. PAGE_VIRTUAL_ADDRESS follows the build target and exists on every target

Verified by building. The constant is 0x0000_0038_0000_0000 under cfg(target_arch = "riscv64") and 0x0000_7000_0000_0000 on every other target (lines 91 and 103). A const assertion in a scratch crate showed the x86_64 value on aarch64-unknown-none-softfloat, where the crate says no page exists. A tool built for one architecture that places the page for another reads its own target's address. Milestone 1153 (the release review of address_space_layout) found the same question answered with one table for all architectures. Change: one constant for each architecture under its own name, visible on every target, and PAGE_VIRTUAL_ADDRESS defined on x86_64 and riscv64 alone as an alias of its own. Door: one-way (D3). Effort: S in the crate, S at an aarch64 caller if one exists.

P0-4. No rule says what the bytes after the sixteenth hold

Verified in source (line 81) and the README. The doc comment says the rest of the frame is zeroes and not whether a reader relies on that. So nobody can tell whether version 1 may gain a field at offset 16. Linux's perf_event_mmap_page carries size and compat_version, and names its tail __reserved. Change: one sentence in the contract. A writer zeroes the bytes after the sixteenth, a reader ignores them, and a field added there keeps the magic. Door: one-way (D4). Effort: S.

P0-5. hertz answers None for an unknown rate and for a page it cannot read alike

Verified by building. A zeroed frame, a frame with a foreign magic and a frame with the magic TIMEBAS2 all read as None. A reader cannot tell a kernel that does not know the rate from a kernel with a newer layout. The crate has no error type. Linux's page gives a reader version and compat_version to tell the two apart. Change: the shape the errors decision picks for a contract's decoder, with at least two refusals: no page written, and a page of another layout. Door: one-way (D5). Effort: S.

P0-6. MAGIC, VERSION and INTERFACE_ID have no shared spelling or type

Verified in source (lines 32, 36 and 42) and in the census of milestone 1129. MAGIC is a [u8; 8] here and a u64 in two sibling contract crates. VERSION is a u32 and INTERFACE_ID a u64. The three names are ratified, and the values are frozen. Change: the types and entry points the contract-layout decision picks. The values do not move. Door: one-way (D6). Effort: S.

P1: before the first release

The evidence for each is in the later items. Each is verified in source or by building.

P2: may follow

The same appendix holds each in full.

Measured performance

Measured on a Linux x86_64 host with a page of 2,100,000,000 hertz; the appendix gives the method and what each row includes.

operation nanoseconds per call
build_page 1.98
CounterFrequencyPage::hertz 1.54
ticks to nanoseconds by ticks * 1e9 / hertz 30.02
ticks to nanoseconds by a multiplier and a shift derived once 0.71
quanta 0.13.0 Clock::delta_as_nanos 0.69

A process reads the page once. The division costs 42 times the multiply, and the page's unit leads a reader to it; P2-1 removes that without changing the page.

One-way doors

Evidence for the shared decisions

Follow-on

Done when

Doors D1 to D9 each carry a ruling, the six P0 and six P1 lines of the finding status read Done, and script/review-status counts 1161 as BUILT.

BUGS

Index row

The release review of counter_frequency_contract against the pages Linux maps for the same job, the Devicetree Specification's property and four neighbor crates; no crate ranks as a comparator. Six findings touch the 0.1.0 interface. Four are open: a reader built from an integer address, a band neither half enforces, an address constant that follows the build target, and an unstated rule for the page's tail. Two wait on shared decisions. Six land before the release, five may follow, and nine doors wait for the architect.