jouleclaw-energy: RAPL reads each package's energy-status MSR where powercap lists none #618
Loading…
Reference in a new issue
No description provided.
Delete branch "jouleclaw-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), so
/sys/class/powercap lists no package while the counters are there, and the
RAPL counter was unavailable on hosts that can measure. Where powercap lists
no package, the counter now reads the same counters directly: each package's
MSR_PKG_ENERGY_STATUS (0x611, Intel family 6; 0xC001029B, AMD Zen and Hygon)
through /dev/cpu//msr, the 32-bit count converted at
the package's own unit (bits 12:8 of the power-unit MSR), so it wraps at 2^32
counts in microjoules and resolves one count (62 uJ at 2^-14 J). A power-unit
MSR that reads zero is no counter (KVM guests read zeros). Powercap is still
preferred, and the liveness rule is unchanged: every package readable and live,
or no figure.
On two bare-metal Supermicro servers with no powercap zone, as root: a Xeon
E-2278G live, 59.8 J over 2.0 s, 29.9 W; two Xeon Silver 4215R sockets,
summed, live, 155.0 J over 2.0 s, 77.5 W. As an unprivileged user (no
CAP_SYS_RAWIO) the counter is Unavailable and the meter falls through.
Tests: fake device files (a register's bytes at its offset) cover a two-socket
host read on each package's first CPU, the 32-bit wrap, AMD's registers, a zero
unit, an unknown CPU, a missing device, powercap preferred, and the production
probe over MSR packages. Unit tests pass on Linux and macOS; clippy is clean on
macOS (default, ioreport, rapl).
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