jcp-energy: RAPL reads each package's energy-status MSR where powercap lists none #625
Loading…
Reference in a new issue
No description provided.
Delete branch "jcp-energy/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:jcp-energy specifics
Raplnow holds powercap zones or MSR packages (RaplPackage). A package zone that is listed but can't be read never falls through to the MSRs.rapl_access(): checks the MSRs where powercap has no package zone. Permission denied on any package givesNeedsPrivilege; before, such a host was reported asAbsent. Nomsrmodule, an unknown CPU or a zero unit givesNoInterface. The survey note names the MSR path and what it needs.tests/rapl_hardware.rs: gains an MSR oracle that is independent of the crate. The existing CI grep forpackage-only innerstill holds.Verified
cargo test -p jcp-energy(default andnvml) andcargo test -p jcp-gatewaypass.jcp-energy(with theioreport liveness:grep) andjcp-gateway(with theupstream tree:grep) pass. Clippy onjcp-energyandjcp-gatewayis clean.main, in untouched survey code (lib.rs ~6266, ~6306, ~6415). CI lints this crate on macOS only.NeedsPrivilege, and the meter falls to the default-power estimate.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