Measure real-time AMD EPYC and Ryzen power draw by reading hardware RAPL counters through turbostat for interactive per-core CorWatt and PkgWatt profiling, and the kernel amd_energy hwmon driver for continuous Prometheus scraping. Unlike wall-level IPMI telemetry, RAPL isolates exact microjoule consumption across individual cores and socket packages.
RAPL Power Telemetry Summary for AMD EPYC & Ryzen
Linux exposes AMD EPYC and Ryzen Running Average Power Limit (RAPL) energy counters through two complementary subsystems: the kernel amd_energy hwmon driver (reporting cumulative microjoules per core and per socket under sysfs) and turbostat (sampling MSRs directly for instantaneous PkgWatt and CorWatt). Pairing interactive turbostat profiling with continuous amd_energy scraping in Prometheus lets infrastructure teams compute exact joules-per-transaction, pinpoint asymmetric NUMA power draw, and catch SMU thermal or cTDP throttling before SLA degradation occurs.
Silicon & Kernel Scope: AMD EPYC 7002/7003/9004/9005 & Ryzen 7000/9000, Linux 5.13+ (amd_energy / intel_rapl_common), turbostat
Tracking datacenter power solely at the rack PDU hides which individual cores, sockets, or NUMA domains drive electricity costs. Fine-grained energy observability requires combining kernel hwmon counters with MSR sampling tools. This guide compares amd_energy and turbostat, builds a Prometheus pipeline, and resolves permission limits.
Outlet-level PDU meters cannot isolate which specific tenant workloads, cores, or NUMA quadrants spike server wattage.
Reading RAPL microjoule accumulators requires root privileges or mitigated sysfs access to prevent PLATYPUS side-channel leaks.
Combine interactive turbostat sampling with continuous amd_energy scraping to track joules per transaction and cTDP headroom.
AMD SMU Energy Accumulators and MSR Boundaries
Unlike legacy ACPI power meters that poll slowly over SMBus, AMD RAPL telemetry lives directly inside the processor’s architectural MSR space. Specifically, AMD Family 17h (Zen/Zen 2), Family 19h (Zen 3/Zen 4), and Family 1Ah (Zen 5) expose three key MSRs: MSR_RAPL_PWR_UNIT (0xC0010299), which defines the energy unit scaling factor; MSR_CORE_ENERGY_STATUS (0xC001029A), which tracks individual core energy consumption; and MSR_PKG_ENERGY_STATUS (0xC001029B), which tracks total socket package energy.
On Zen 3, Zen 4, and Zen 5 silicon, the SMU typically sets the energy unit bitfield to 16, meaning each raw counter increment equals $2^{-16}$ joules—approximately 15.26 microjoules. Because the underlying hardware registers are 32-bit unsigned counters, they wrap around periodically under heavy sustained load (roughly every few minutes at 350W–400W TDP). Both turbostat and the kernel amd_energy driver handle 32-bit-to-64-bit wrap-around accumulation transparently as long as their polling interval is shorter than the wrap window.
Understanding what is inside PkgWatt versus CorWatt is essential for accurate capacity modeling. CorWatt sums the power consumed by the execution cores, L1/L2 caches, and core clock domains. PkgWatt encompasses every core plus the shared L3 cache slices, the central I/O Die (IOD), Infinity Fabric links (including xGMI in 2P systems), PCIe 5.0 root complexes, and the DDR5/DDR4 memory controllers (UMCs). Consequently, even when all cores sit in deep CC6 sleep, an EPYC 9004 or 9005 socket will still report 45W to 85W of baseline PkgWatt because the IOD and Infinity Fabric remain powered to service memory refresh and PCIe DMA.
Before deploying fleet-wide power telemetry, confirm two prerequisites: your host must run Linux 5.13 or newer (or a backported enterprise kernel with amd_energy or intel_rapl_common), and you must have root or CAP_SYS_RAWIO access to read MSRs. After CVE-2020-12912 (the PLATYPUS power side-channel vulnerability), upstream Linux restricted /sys/class/hwmon/hwmon*/energy*_input and /sys/class/powercap/*/energy_uj to 0400 root-only permissions so unprivileged local users cannot infer cryptographic keys from sub-millisecond power traces.
Comparing amd_energy, turbostat, powercap, and IPMI DCMI
Each Linux power interface operates at a different sampling layer, privilege boundary, and hardware scope. Choosing the wrong interface leads to misleading PUE math or missed micro-burst throttling.
| Telemetry Interface | Data Source | Granularity & Cadence | Measurement Boundary | Primary Production Role |
|---|---|---|---|---|
turbostat |
Direct /dev/cpu/*/msr reads |
Per-core & per-socket, 100ms–5s | Cores (CorWatt) + Socket (PkgWatt) |
Interactive load profiling, C-state & boost debugging |
amd_energy (hwmon) |
Kernel hwmon driver (energy*_input) |
Cumulative microjoules, 1s–60s scrape | Every individual core + socket package | Continuous Prometheus node_exporter scraping |
powercap (intel-rapl) |
Unified kernel RAPL sysfs | Cumulative microjoules, socket-level | Socket package only (no per-core breakdown) | Fallback when amd_energy.ko is not compiled |
ipmitool dcmi power |
BMC PMBus / PSU telemetry | Node-wide Watts, 1s–10s polling | Total PSU AC/DC draw (CPU, RAM, NVMe, fans, VRM) | Rack breaker sizing, datacenter PUE accounting |
When auditing a dual-socket EPYC 9554 server under full compute load, you might observe PkgWatt of 360W per socket (720W combined silicon power) while ipmitool dcmi power reading reports 910W at the power supplies. That 190W delta is not measurement error—it represents 24 DDR5 RDIMMs, enterprise U.3/E3.S NVMe drives, 100GbE NICs, high-RPM chassis fans, and VRM switching losses.
Profiling Per-Core and Package Wattage with Linux CLI
Before wiring up fleet-wide monitoring, use turbostat and raw amd_energy sysfs reads on a single node to establish baseline idle and peak wattage curves. Ensure the msr and amd_energy kernel modules are loaded, and install the distro package providing turbostat (linux-tools-common plus linux-tools-$(uname -r) on Ubuntu/Debian, or kernel-tools on RHEL/Rocky).
# 1. Load the MSR and amd_energy kernel modules
sudo modprobe msr
sudo modprobe amd_energy
# 2. Confirm the hwmon sysfs path assigned to amd_energy
HWMON_DIR=$(dirname "$(grep -l amd_energy /sys/class/hwmon/hwmon*/name)")
echo "amd_energy mounted at: $HWMON_DIR"
ls -1 "$HWMON_DIR"/energy*_label | head -n 10
# 3. Profile per-core frequencies, C-states, temperatures, and wattage every 2 seconds
sudo turbostat --quiet --interval 2 \
--show Package,Core,CPU,Avg_MHz,Busy%,Bzy_MHz,CoreTmp,PkgWatt,CorWatt,C1%,C6%
# 4. Calculate instantaneous socket wattage directly from amd_energy microjoules
SOCKET_FILE=$(grep -l "Esocket0" "$HWMON_DIR"/energy*_label | sed 's/_label/_input/')
E_START=$(sudo cat "$SOCKET_FILE")
sleep 2
E_END=$(sudo cat "$SOCKET_FILE")
awk -v s="$E_START" -v e="$E_END" 'BEGIN { printf "Socket 0 Avg Power (2s): %.2f W\n", (e - s) / 2000000 }'
Pay close attention to the Bzy_MHz, C6%, CorWatt, and PkgWatt columns in turbostat. On a healthy EPYC 9004 or Ryzen 9950X node running an active single-threaded benchmark, you will see one or two cores boost above 5.0 GHz with CorWatt around 18W–28W while idle cores drop to 95%+ C6% residency and near-zero CorWatt. If idle cores show low C6% residency and elevated CorWatt, check whether a kernel boot parameter like idle=poll or an overly aggressive governor setting is blocking deep C-states.
For teams tuning frequency-versus-power curves, pair these measurements with our amd-pstate active EPP governor tuning guide and our EPYC cTDP and determinism BIOS guide to quantify exact performance-per-watt gains.
Building a Prometheus & Grafana Joules-per-Transaction Pipeline
While turbostat excels at interactive debugging, running it continuously across hundreds of servers is impractical. Instead, persist amd_energy across reboots and let Prometheus node_exporter scrape the hwmon counters natively. On a 96-core EPYC Genoa or Turin processor, amd_energy exposes 96 per-core sensors labeled Ecore000 through Ecore095 plus socket-level sensors labeled Esocket0 (and Esocket1 on 2P boards).
Because node_exporter runs unprivileged on many hardened Linux distributions, you must decide whether to run node_exporter with CAP_DAC_READ_SEARCH (recommended) or restrict scraping to root-owned collectors. Granting CAP_DAC_READ_SEARCH via a systemd drop-in avoids running the entire exporter as UID 0 while still allowing it to read 0400 root-owned hwmon energy files.
# 1. Persist amd_energy module loading across reboots
echo "amd_energy" | sudo tee /etc/modules-load.d/amd_energy.conf
# 2. Grant node_exporter read access to 0400 hwmon energy files without full root
sudo mkdir -p /etc/systemd/system/node_exporter.service.d
cat <<'EOF' | sudo tee /etc/systemd/system/node_exporter.service.d/rapl-read.conf
[Service]
AmbientCapabilities=CAP_DAC_READ_SEARCH
CapabilityBoundingSet=CAP_DAC_READ_SEARCH
EOF
sudo systemctl daemon-reload && sudo systemctl restart node_exporter
# 3. Verify node_exporter is emitting amd_energy metrics locally
curl -s http://localhost:9100/metrics | grep 'node_hwmon_energy_uj' | head -n 10
Once Prometheus ingests node_hwmon_energy_uj, you can compute instantaneous socket Watts, per-core Watts, and application efficiency KPIs directly in PromQL. Because node_hwmon_energy_uj is a monotonically increasing microjoule counter, rate() automatically handles counter resets across server reboots:
# Instantaneous Socket Package Power (Watts)
sum by (instance, label) (
rate(node_hwmon_energy_uj{chip=~".*amd_energy.*", label=~"Esocket.*"}[1m])
) / 1e6
# Total Server CPU Package Power (2P EPYC)
sum by (instance) (
rate(node_hwmon_energy_uj{chip=~".*amd_energy.*", label=~"Esocket.*"}[1m])
) / 1e6
# Joules per PostgreSQL Transaction (combining amd_energy + postgres_exporter)
(
sum by (instance) (rate(node_hwmon_energy_uj{chip=~".*amd_energy.*", label=~"Esocket.*"}[5m])) / 1e6
)
/
sum by (instance) (rate(pg_stat_database_xact_commit[5m]))
Tracking Joules per Transaction transforms power monitoring from a passive facilities metric into an engineering optimization signal. If a code deployment or kernel upgrade increases CPU Watt-hours per million API requests by 18% without increasing throughput, you catch the regression immediately in Grafana.
Verifying cTDP Headroom, Thermal Limits, and NUMA Balance
Accurate wattage telemetry also acts as an early-warning system for two silent performance killers on dense AMD servers: SMU power-limit (cTDP/PPT) throttling and asymmetric NUMA scheduling.
During a sustained AVX-512 or AI inference workload, run turbostat alongside stress-ng or your production benchmark to verify whether PkgWatt hits a flat ceiling while Bzy_MHz sags below expected all-core boost clocks. If PkgWatt pins at 280W on a 360W-capable EPYC 9554, the motherboard BIOS or BMC has likely enforced a conservative cTDP or Package Power Limit (PPT). Conversely, if CoreTmp approaches 95°C–100°C while PkgWatt drops erratically, airflow or thermal interface degradation is forcing SMU thermal throttling.
# Check for SMU thermal or power throttling while running a 30s controlled CPU stress
sudo turbostat --quiet --interval 2 \
--show Package,Core,Avg_MHz,Bzy_MHz,CoreTmp,PkgWatt,CorWatt \
-- stress-ng --cpu 16 --timeout 30s
# Compare Socket 0 vs Socket 1 power balance on a 2P EPYC host
for s in Esocket0 Esocket1; do
F=$(grep -l "$s" "$HWMON_DIR"/energy*_label | sed 's/_label/_input/')
[ -n "$F" ] && echo "$s: $(sudo cat "$F") uJ"
done
On dual-socket EPYC servers, comparing Esocket0 and Esocket1 over a 5-minute window reveals NUMA imbalance instantly. If Socket 0 draws 290W while Socket 1 idles at 75W, your application workers, KVM vCPUs, or NVMe IRQ handlers are pinned asymmetrically to NUMA node 0—leaving half your memory channels and compute cores underutilized.
Resolving PLATYPUS Permissions, Missing MSRs, and Safe Rollback
When deploying amd_energy and turbostat across heterogeneous Linux distributions (Ubuntu LTS, Debian, Rocky Linux, or custom cloud kernels), three operational issues account for nearly all setup failures.
Missing /dev/cpu/*/msr Nodes
If turbostat exits with Cannot open /dev/cpu/0/msr, load the module with sudo modprobe msr and persist it in /etc/modules-load.d/msr.conf. Under UEFI Secure Boot kernel lockdown, raw MSR writes are blocked, but read-only RAPL queries via turbostat and amd_energy continue to work.
Distro Kernel Lacks amd_energy.ko
Some RHEL-derived kernels disable CONFIG_SENSORS_AMD_ENERGY or restrict it due to PLATYPUS mitigations. When modprobe amd_energy fails, load intel_rapl_msr and scrape /sys/class/powercap/intel-rapl:0/energy_uj for socket-level package wattage.
Permission Denied in node_exporter
Because energy*_input defaults to 0400 root:root, unprivileged exporters silently skip RAPL metrics. Apply AmbientCapabilities=CAP_DAC_READ_SEARCH to the exporter’s systemd unit rather than relaxing sysfs permissions globally on multi-tenant hosts.
High Cardinality on 128+ Core Hosts
On dual-socket EPYC 9754 (256 cores), scraping every Ecore* sensor generates 256+ extra time series per host. Use Prometheus metric_relabel_configs to keep Esocket.* fleet-wide and sample per-core metrics only on profiling targets.
Safe Rollback Procedure: Energy telemetry drivers are strictly read-only observers and never alter CPU P-states, voltage, or scheduler decisions. If amd_energy causes excessive Prometheus cardinality or conflicts with a custom agent, remove /etc/modules-load.d/amd_energy.conf, delete /etc/systemd/system/node_exporter.service.d/rapl-read.conf, run sudo systemctl daemon-reload && sudo systemctl restart node_exporter, and unload the driver immediately with sudo modprobe -r amd_energy without rebooting.
Frequently Asked Questions
Why does /sys/class/powercap display intel-rapl on an AMD EPYC server?
The Linux kernel uses the unified intel_rapl_common and intel_rapl_msr subsystem names for both Intel and AMD x86 RAPL interfaces. On AMD EPYC and Ryzen hosts, /sys/class/powercap/intel-rapl:0/energy_uj reads AMD’s native SMU package energy MSR accurately.
Does polling amd_energy or turbostat introduce measurable CPU overhead?
No. Reading RAPL MSRs or hwmon sysfs counters at 1-second to 15-second intervals consumes less than 0.01% CPU time and does not wake sleeping cores from CC6 when queried via the kernel hwmon driver.
Why are amd_energy sysfs files restricted to root on modern Linux kernels?
Upstream Linux enforces 0400 permissions on RAPL energy files to mitigate CVE-2020-12912 (PLATYPUS), preventing unprivileged users from running high-frequency power side-channel attacks against co-resident workloads.
Can amd_energy report DDR5 DIMM power separately from CPU package power?
No. On AMD EPYC and Ryzen processors, memory controller (UMC) and I/O Die power are folded into the socket PkgWatt counter, while physical DDR5 DIMM wattage is only captured at the board or PSU level via IPMI DCMI.
Do RAPL energy counters work inside a KVM guest VM?
By default, hypervisors do not pass physical host RAPL MSRs to guest VMs because socket power reflects all tenants on the host. Measure wattage on the bare-metal KVM hypervisor and attribute power to VMs using CPU cycle or cgroup utilization ratios.
Profile Real-Time Silicon Wattage on Bare-Metal AMD EPYC & Ryzen
Gain full root MSR access, unobstructed amd_energy and turbostat telemetry, and deterministic cTDP thermal envelopes on dedicated AMD EPYC 9004/9005 and Ryzen 7000/9000 servers.
