Repository navigation
osbench energy: the package's power on both systems, off the same registers - #1100
Conversation
93317a1 to
890f5c7
Compare
…isters The kernel's counters carry the package's energy and its unit register (Intel MSR_PKG_ENERGY_STATUS and MSR_RAPL_POWER_UNIT, SDM Vol. 3B §17.10 and Vol. 4 Table 2-20; AMD PKG_ENERGY_STAT and RAPL_PWR_UNIT, PPR 55922), the package's C2, C3, C6 and C7 residency where Table 2-20 gives them, and AMD's per-core CORE_ENERGY_STAT, all under Rights::TRACE, the energy being a side channel (CVE-2020-8694). The package's are read on the boot processor alone, for its package, as the firmware calls are. Admission follows the existing rule for model-specific counters: Intel's by the DisplayModels whose SDM sections name Table 2-20, less 06_AFH, whose Table 2-57 restates the residency in other units, and for package residency 06_66H, whose Table 2-42 gives 3F8H no rate; AMD's by Family 17h, whose PPRs in hand agree, with CPUID_Fn80000007_EDX[RAPL]. Family 19h's PPR 55901 changes the counters' widths and scope, so it is not read. No hypervisor's emulation is read for any of them. osbench's energy group becomes a group by name with its own metal row (osbench_energy, the benchcase image with that one job), since idle power is the whole machine's. On ToyOS it reads SYS_COUNTERS, on Linux the same registers through /dev/cpu/<n>/msr as root, decoded by one rule (osbench_rules::energy). It waits for the machine to go quiet, then reads the package each second across 60 s idle, 30 s of a 10 ms sleeper and 30 s each of one and of every CPU spinning: power, residency and energy per chunk, with each CPU's APERF/MPERF and core residency across each load. Linux states its panel, backlight, radios and links as setup, which compare refuses to mix. The counters metal judge holds the energy counters' presence to the bring-up line and prints the package's power. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…quiet Round 1 on both benches found two defects in the Linux half. The group pinned its main thread to CPU 0 before it counted the CPUs, and available_parallelism honours the mask, so `spin.all` ran one thread. Its workers' unpin restored the pinned mask too, and the per-CPU reads read CPU 0 alone. The package is now read on the reader's own CPU, the package's registers being the same on every CPU of it, and nothing is pinned. Linux's /proc/stat counts busy time in ticks of 10 ms, so a second with one tick in it never passed a bar of strictly under 10 ms: the AMD bench's Linux waited out the 120 s bound. A quiet second is now at most one tick. Each load also notes its per-second power in order (`<bench>.series`): the T14's ToyOS idle minute read 5.1 to 18.1 W while its later 10 ms sleeper read 2.9 W at the same PC2 residency, and the order says when. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scoreboard's T14 rows put ToyOS's idle package at 7137 mW against Linux's 1648 mW, with the package in PC2 994 permille of the minute. Phase 2's scouts (evidence pr-1100 r5) ruled out the nine driverless functions, the deepest core state, and the cores and graphics planes as the consumer; the display under the firmware's GOP, the NVMe without APST and the I219 remain. Recorded as a defect held by the power task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5e5c395 to
31be412
Compare
Review of #1100 at
|
…s filed - osbench energy reads one round a second on both systems, the package's counters and every CPU's (`power::round`): ToyOS's SYS_COUNTERS round kicks each CPU, and now Linux's reads each CPU's MSRs, an IPI to each but its own, so the two methods cost alike. A row's per-CPU notes come off its first and last rounds. - The README and the module header say that, and the quiet bar is "at most 10 ms"; the quiet gate measures CPU time alone, the core C6/C7 notes say whether the cores reached their deepest state. - Linux's power registers come from `crate::arch`, AArch64's answering none; AMD's only on Family 17h with RAPL, as the kernel admits them. - `Rights::TRACE` names the package and core energy it grants. - The `counters` judge decodes its reading by `osbench_rules::energy`. - issues/the-amd-benchs-idle-package-draws-15-percent-over-linuxs.md files the AMD bench's resolved idle deficit; the T14 issue says which statistic its figures are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Phase 3 (evidence pr-1100 r7): Linux with NVMe APST off rises from 1622 to 5127 mW idle and goes no deeper than PC3; Linux with no graphics driver stays in PC2 at 2796 mW, its 10 ms sleeper matching ToyOS's within 1 %; and on ToyOS, stopping the GOP scan-out's plane fetches releases PC2 for PC3. The I219 changed nothing on either system. APST, the larger share, comes first; the display's power programming is an owner decision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #1100 at
|
…line-judge selection defect is filed The AMD idle deficit was measured while Linux read only the package each second and ToyOS's read kicked every CPU, which inflates that row; the issue says so and gives the cores' range across the four runs (ToyOS 0-1 mW, Linux 11-20 mW). The harness's offline judge cannot take the `counters` row without `counters_silent` and so without a patch: filed as tooling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Orchestrator: r2's record blocker checked at ed35ba9. The AMD issue states that its runs predate the matched read and gives the per-run core figures, and the tooling issue is filed. Landing. |
Problem
Power is one of the subsystems that has to reach Linux parity, and nothing on either bench reads it today. The last reading, from before deep idle (#1073) and AMD's 0x415 (#1089), put ToyOS's idle package at 3.16 W on the T14 against Linux's 1.18 to 1.57 W (#866). ToyOS had no counter for the package's energy (
energy.idle_60s.packagewasunsupported), so no run could produce a figure.What this changes
The kernel's counters carry the package's power (
toyos_abi::counters,SYS_COUNTERS). They are all underRights::TRACE, since package energy is a side channel (CVE-2020-8694):package_energyMSR_PKG_ENERGY_STATUS611HPKG_ENERGY_STATC001_029BHrapl_power_unitMSR_RAPL_POWER_UNIT606HRAPL_PWR_UNITC001_0299Hpackage_c2/c3/c6/c7core_energyCORE_ENERGY_STATC001_029AHSources: SDM 325462-093 Vol. 3B §17.10 and Vol. 4 Table 2-20; PPR 55922 (Family 17h Model 60h, the AMD bench), checked against 55772 and OSRR 56255. Each counter is admitted the way
core_c6already is, inkernel/pure/cpu.rs, which has host tests:CPUID_Fn80000007_EDX[RAPL]. PPR 55901 (Family 19h Model 11h) makes the core counter 64 bits wide and the package counter an L3 complex's, so that family is not read.osbench's
energygroup runs the same code on both systems and reads the same registers. ToyOS reads them throughSYS_COUNTERS. Linux reads them as root through/dev/cpu/<n>/msr. One rule decodes both (osbench_rules::energy).Waiting for quiet. It first waits up to 120 s for three seconds in a row of at most 10 ms of machine CPU time each. The wait measures CPU time alone: whether the cores had reached their deepest idle state is each row's core C6/C7 note.
The loads:
One round a second, alike on both systems (
power::round): the package's counters and every CPU's. ToyOS'sSYS_COUNTERSround kicks each CPU, and Linux's reads each CPU's MSRs, an IPI to each but its own. Before55922d7a9, Linux read only the package each second, on whichever CPU the reader ran on, and each CPU only at a load's ends; the scoreboard below was measured that way.Each second it records:
Across each load, off its first and last rounds, it records:
cores_mw);Units have no better direction. A spin that ran faster may draw more, and work is not slowed to save power.
Linux's setup. Linux states its panel (DRM DPMS), backlight, rfkill switches and links as setup conditions.
osbench-comparerefuses to mix runs that differ on them.Its own boot.
energyleavesalland gets its own metal row,osbench_energy: the benchcase image with that one job. Idle power belongs to the whole machine, so nothing else may run beside it. The T14 and the AMD bench. The README gives the run protocol, including how Linux matches ToyOS's devices: radios blocked, panel lit.Linux's registers come from
crate::arch(AArch64 answers none). AMD's are read only on Family 17h with RAPL, as the kernel admits them; on Intel a register a model lacks reads as absent.Rights::TRACE's contract names the package and core energy it now grants, the RAPL channel (CVE-2020-8694).The
countersmetal judge now holdspackage_energyandcore_energypresence to the bring-up line. It exempts the 32-bit energy counters from the "went backwards" check, and prints the package's power across its idle second and its spin as a reading, decoded byosbench_rules::energy.Checks
The head is
ed35ba937. Review round 2 adds two issue changes: the AMD issue now says its runs predate the matched read, with the cores' range across the runs, and the offline judge's selection defect is filed as tooling (issues/no-filter-word-takes-the-counters-metal-row-without-counters-silent.md). Host CI ated35ba937: exit 0, 105 steps green (log). Below that: review round 1 (55922d7a9) and the T14 issue's phase-3 update (cf0fc945f), on the rebase onto0c7e62ca7(#1097). Evidence:r8/README.md.cargo run -- --ci hostatcf0fc945f: exit 0, 105 steps green (log).osbench_capability_groups_exit_0at55922d7a9: exit 0 (log). The head adds only an issue file.-D warnings, onx86_64-andaarch64-unknown-linux-musl: exit 0. The Linux binary builds; its sha256 is a6655896…7943a057c8cc.countersjudge over round 1's T14 readback:PASS counters, exit 0 (log). That boot ran at890f5c709, and the kernel's counters code is unchanged since then.counters_silent, whose boot has no readback. So a checked patch dropped it from the selection for this run alone, and the same command reverted it.package_energy=falsegivesFAIL counters, exit 1 (log).55922d7a9, Linux reads every CPU each second. No metal run has used that method yet; the rounds below predate it.Round 1 on metal (
r2/README.md): one ToyOS boot (890f5c709) and one Linux run per bench.osbench_energypasses on both readbacks.energy.idle.packageenergy.idle.pc2/pc6energy.wake_10ms.packageenergy.idle.packageenergy.wake_10ms.package5e5c395b9adds the per-second series, so the order of the readings shows when the power fell.5e5c395b9.spin.allran one thread and its per-CPU notes read CPU 0 alone./proc/stat's 10 ms tick, so the AMD bench's Linux never read quiet.Round 2, the scoreboard (
r4/README.md, table): four ToyOS boots and four Linux runs per bench at5e5c395b9, interleaved. Every judge passes, and every Linux run had its radios blocked. A resolved row is one where every run of one system lies beyond every run of the other (p = 0.029). Each figure is the median, over a system's four runs, of each run's per-second p50. Energy is a mean quantity and the idle series is right-skewed, so by the medians of the runs' means the T14's idle is 8272 against 2167 mW, 3.8×, and the AMD's 1688 against 1501 mW, 1.12×.energy.idle.packageenergy.idle.pc2/pc6energy.wake_10ms.packageenergy.idle.packageenergy.spin.all.packageUnresolved
issues/the-t14s-idle-package-stays-in-pc2.md. This PR adds that file. Phase 2's scouts ruled out the driverless functions, the deepest core state, and the cores and graphics as consumers (r5/README.md). Phase 3 (r7/README.md) named the two causes by putting ToyOS's state onto Linux. NVMe APST off costs Linux about 3.5 W at idle and caps it at PC3. No graphics driver holds Linux in PC2 at 2.8 W. The I219 is not a factor. "Panel lit on both" is the fair state, and the deficit is ToyOS's to fix, not by slowing work.issues/the-kernel-owns-cpu-performance-state.md.issues/the-amd-benchs-idle-package-draws-15-percent-over-linuxs.md, added here.🤖 Generated with Claude Code