eoc-meter: RAPL reads each package's energy-status MSR where powercap lists none #627
Loading…
Reference in a new issue
No description provided.
Delete branch "eoc-meter/rapl-msr"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Some kernels ship without the powercap RAPL driver (Ubuntu without
linux-modules-extra, as on some rented bare-metal servers). On those hosts/sys/class/powercaplists no package even though the counters are there. This ports the MSR fallback from #618 (jouleclaw-energy) into this meter, with no dependency added: the standards do not depend on one another.Where powercap lists no package, each package's
MSR_PKG_ENERGY_STATUSis read on that package's first CPU through/dev/cpu/<n>/msr:eoc-meter specifics
/for MSR packages), and the counter reads them there. Zones are picked by name, so a listed but unreadable package zone stays with powercap.CounterStatus::Unavailableandrapl_statusdocs say why an unprivileged MSR host is Unavailable (noCAP_SYS_RAWIO), and read errors name the MSR when that is the source.tests/rapl_hardware.rs: its oracle read powercap only, so as root on an MSR host it would have disagreed with the meter. It now has its own MSR reader and brackets the meter's figure with MSR reads.Verified
cargo test -p eoc-meter(default andcuda) passes; clippy is clean;cargo check --workspace --all-targetsis clean.--features cudafails on 3 type-complexity lints intests/nvml_hardware.rs. CI doesn't lint that configuration.cargo test --workspacefailed oneeocbinary test,a_hit_is_charged_an_estimate_calibrated_on_this_host, under workspace load ("rapl: CounterHeld"). That host has a powercap zone, so the new code doesn't run there, and alone the test passes 3 of 3 on this branch and onmain.cargo test -p eoc-meterpasses with theioreport liveness:grep; clippy is clean.detect()picksrapl.detect()falls back.Second commit: die scope
Linux scopes Intel's RAPL MSRs per die and AMD's and Hygon's per package.
arch/x86/events/rapl.csays "AMD/HYGON platforms have a per-PKG package energy counter" and "CLX-AP is multi-die and its RAPL MSRs are die-scope". The powercap driver names a multi-die Intel package's zonespackage-<p>-die-<d>, one top-level zone per die.physical_package_id,die_id) on Intel and the package on AMD and Hygon. Each domain is read on its own first CPU and they are summed. Single-die parts are unchanged.package-<n>-die-<m>, so a multi-die host's die zones count as packages. It accepts nothing looser.New unit tests: a two-die Intel package is two domains, summed; an AMD package whose CPUs list several
die_ids is one domain; a two-die powercap tree sums both die zones; and the name rule's accepted names and near misses. Tests and clippy pass as before on Linux and macOS.🤖 Generated with Claude Code
The kernel scopes Intel's RAPL energy counters per die. Its perf PMU treats the package counter as package-scope only on AMD and Hygon ("AMD/HYGON platforms have a per-PKG package energy counter", rapl_pkg_pmu_is_pkg_scope() in arch/x86/events/rapl.c), and on a multi-die Intel package (Cascade Lake-AP) "its RAPL MSRs are die-scope"; its powercap driver then lists one zone per die, named package-<p>-die-<d> (intel_rapl_common.c). Both paths here under-counted such a package, the unsafe direction at a ceiling: - The MSR fallback grouped CPUs by physical_package_id alone, so it read one die of a multi-die Intel package. On Intel a counter domain is now (physical_package_id, die_id), die_id 0 where the file is absent; on AMD and Hygon it stays the package. Each domain is read on its lowest-numbered CPU and every domain is summed, all or nothing as before (zero unit, wrap, powercap preferred, status text unchanged). A die of a multi-die package has its own rail name, package-<p>-die-<d> (MSR), in the liveness rails and in errors. - The powercap name rule accepted only package-<n>, so such a host's die zones were no package at all. It now also accepts package-<p>-die-<d>, and nothing looser (not psys, dram, package-, package-0-die-, package-0-core-0), so every die zone is summed and watched. The hardware test's oracle follows both rules: its zone check accepts die zones, and its MSR reader groups Intel CPUs by package and die. Tests (fake files): an Intel package of two dies is two counters, each read on its own first CPU, both summed, with distinct rails, and a die whose device is missing leaves no figure; an AMD package whose CPUs report different die_ids is one counter; an Intel host with no die_id files, or all on die 0, is read per package as before; the name rule over die names and near misses; a fake two-die powercap tree sums both zones and is frozen when one die holds. Unit tests pass on Linux x86_64 (default and cuda) and on macOS (the CI step, its `ioreport liveness:` line printed); clippy is clean on macOS and on Linux in the default build. Co-Authored-By: Claude Opus 5.5 <[email protected]>