Expand description
AMD Linux backend — hand-rolled std::fs readers over sysfs/hwmon/fdinfo. No library
linkage at all: librocm_smi64 is explicitly off the table (soname churn broke btop
twice — btop #774) and libdrm ioctls are unnecessary for everything v1 needs.
Per the domain rules in CLAUDE.md:
- Every path derives from a root-dir parameter (
with_root), so the whole backend runs against committed fixture trees;init()is justwith_root("/"). - A missing file or unparsable value is
None, never a failure — an APU without hwmon orpp_dpm_*tables is a normal device, not a broken one (Intel-iGPU-style absence). - Throttle bits live in the
gpu_metricsbinary struct, which is versioned (v1.0–v3.0) with per-version field offsets AND units, and therefore needs per-version decoders backed by fixtures.decode_gpu_metrics_throttleparses it directly off the sysfs blob (offsets derived from the in-tree kernel header — see that function). A blob that is absent, truncated, of an unknown revision, or whose self-declaredstructure_sizeis inconsistent decodes toNone: that source is unobservable, and an asserted all-false would fabricate an “observed: not throttling” fact (§5.4) from bytes we never understood. - Only SMU-backed sysfs is polled (
gpu_busy_percent, hwmon) — never GRBM registers, whose polling breaks GFXOFF (the monitor must not change what it measures). - Per-process attribution is DRM fdinfo (kernel 5.14+, standardized 5.19+): cumulative
per-engine busy-ns → delta over wall time = util%;
drm-pdevties a client to a device; keys missing on older kernels degrade toNonefields, never lost processes. Other users’ fdinfo needs root/CAP_SYS_PTRACE, so unprivileged runs carry an honest “your processes only”process_hintinstead of pretending the list is complete.
Structs§
Functions§
- decode_
gpu_ metrics_ throttle - Decode AMD throttle status from a raw
gpu_metricssysfs blob.