Skip to main content

Module amd

Module amd 

Source
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 just with_root("/").
  • A missing file or unparsable value is None, never a failure — an APU without hwmon or pp_dpm_* tables is a normal device, not a broken one (Intel-iGPU-style absence).
  • Throttle bits live in the gpu_metrics binary 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_throttle parses 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-declared structure_size is inconsistent decodes to None: 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-pdev ties a client to a device; keys missing on older kernels degrade to None fields, never lost processes. Other users’ fdinfo needs root/CAP_SYS_PTRACE, so unprivileged runs carry an honest “your processes only” process_hint instead of pretending the list is complete.

Structs§

AmdBackend

Functions§

decode_gpu_metrics_throttle
Decode AMD throttle status from a raw gpu_metrics sysfs blob.