Skip to content

amdgpu: use what gpu_metrics and the driver report - #570

Merged
Syllo merged 13 commits into
masterfrom
amdgpu-metrics-activity
Nov 29, 2026
Merged

Syllo merged 13 commits into
masterfrom
amdgpu-metrics-activity

Conversation

@Syllo

@Syllo Syllo commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

nvtop's amdgpu backend now reports most of what the amdgpu driver exposes in its gpu_metrics sysfs table, preferring the driver's own interfaces when they exist and using gpu_metrics as the fallback. The AMD NPU backend reads the NPU values the firmware puts in the APU's table, and a few generic interface changes make room for the new values.

What NVTOP now shows on AMD

Information GPUs
Encode/decode usage of the whole GPU, including the processes NVTOP cannot see RDNA 3, RDNA 4, MI300, APUs from Phoenix to Strix Halo
SoC, fabric and video clocks, in the GPU information bar (-i) Radeon VII and later, Renoir and later APUs
PCIe throughput, both directions together ("Throughput") MI300, which has no pcie_bw since Linux 6.9
Power of the graphics alone, rather than of the whole chip Strix Point, Krackan, Strix Halo
Memory traffic of the whole chip, as RX and TX Strix Point, Krackan, Strix Halo and later APUs
NPU utilization with its busiest column, NPU power and frequency Strix Point, Krackan, Strix Halo
Fan percentage from the measured RPM, and the RPM when no percentage is available GPUs with a fan

Sources

  • Video engine usage: vcn_busy_percent when the driver has it (some APUs since Linux 6.10, RDNA 3, RDNA 4 and the other APUs since 6.15). Otherwise gpu_metrics: v1.1–v1.3, per engine on MI300 (v1.5, v1.7, v1.8, v1.9), and v2.1 for Phoenix. It is only used for the shared encode/decode meter (VCN 4 and later), as neither source tells encoding from decoding. The v3.0 APU value is not decoded, because its unit depends on the driver and the kernel version.
  • gpu_metrics decoding: v1.0–v1.3, v1.5, v1.7, v1.8, the v1.9 attribute stream, v2.1–v2.4 and v3.0. The offsets were checked against the kernel's kgd_pp_interface.h of the releases that use them, on 64-bit and 32-bit layouts, and the tests use the kernel's offsets independently of nvtop's structs. Unreported fields (all ones) and truncated tables are rejected.
  • NPU: read from the APU's v3.0 gpu_metrics, not through amdxdna's DRM_AMDXDNA_QUERY_SENSORS, which would need opening the NPU node. The backend deliberately never opens it, as an open creates a driver client and binds nvtop's address space. A table that cannot be read at startup (runtime-suspended GPU) is looked for again, up to 10 failed lookups.
  • Fan: the percentage source is chosen by availability rather than by pwm1_enable/fan1_enable, which give the control mode. The measured RPM over fan1_max is used first, capped at 100%, and pwm1/pwm1_max only for fans without an RPM sensor.

Interface changes

  • Combined PCIe throughput: a new pcie_throughput field, shown as "Throughput" instead of RX/TX, and printed in the snapshot only for the devices that report it.
  • Busiest engine: a new busiest-engine field for the utilization meter, shown as "50%(busiest 100%)" like the encode/decode meters, and as gpu_util_busiest_engine in the snapshot. It takes precedence over the effective load in the value.
  • Power display: power below 10 W is shown with a tenth in the TUI ("POW 1.4 W").
  • Snapshot power unit (breaking for scripts): the snapshot now gives power in milliwatts, "power_draw": "1400mW" instead of "1W".
  • APU PCIe link: APUs no longer report a maximum PCIe link: their internal bridge does not bound their RX/TX, which are memory traffic.

Known limitations

  • The v3.0 DRAM throughput is 16-bit, in MB/s: above 65.5 GB/s it saturates or wraps, depending on the driver.
  • MI300's PCIe throughput is in whole GB/s, so light traffic reads 0, and the kernel does not say whether it sums both directions.
  • RDNA 4's driver reports the first video engine's clocks as the second's (VCLK1/DCLK1, secondary clocks only).
  • On Strix, a refresh whose table cannot be read shows the socket power, with the socket cap, instead of the graphics power.
  • The RDNA 1/2 driver's decoding of the firmware video rate follows the kernel's sensor and is unverified on hardware.
  • Before Linux 6.13, reading these sysfs files wakes a runtime-suspended GPU, as nvtop's other per-refresh queries already do.

Testing

  • Each commit builds and passes the test suite on its own (94 to 107 tests), with no new build warnings. Builds without AMDGPU, AMD NPU or NVIDIA support pass, and the metrics tests also pass in a 32-bit build.
  • New tests decode synthetic tables at the kernel's offsets for every revision, including unreported, truncated and 32-bit kernel tables, and cover the NPU backend's table discovery, retry and retry limit on a fake sysfs tree.
  • The display changes were checked with fake devices through the real interface and snapshot.
  • Tested on hardware:
    • RX 6800 XT (RDNA 2, v1.3 table): SOCCLK, VCLK and DCLK, and the second video engine's VCLK1 and DCLK1, all within their expected ranges, with the idle second engine at 33 MHz. PCIe RX/TX stay N/A, as before: the driver has no PCIe usage counters for RDNA, so pcie_bw fails to read on kernels before 6.10 and is hidden from 6.10.
    • Vega 10 graphics of a Raven Ridge APU: its driver has no gpu_metrics, so nothing new is shown, as expected.
  • Still worth checking: Phoenix (video meter, clocks), Strix Point / Krackan / Strix Halo (graphics power, DRAM RX/TX, NPU values), RDNA 3 and RDNA 4 (video meter, clocks, fan RPM), and MI300 (per-engine video, Throughput, clocks).

Syllo added 13 commits November 29, 2026 09:20
The encode and decode meter summed the usage of the processes nvtop can
see, missing those of other users, containers and virtual machines. The
driver reports the usage of the video engines of the whole device in
vcn_busy_percent: for some APUs since Linux 6.10, and for RDNA 3, RDNA 4
and the other APUs since 6.15. Otherwise, as on MI300, the firmware reports
it in gpu_metrics: from v1.1 to v1.3 for the whole video block, which RDNA 3
and 4 fill with their busier engine, and per engine in v1.5, v1.7, v1.8 and
v1.9.

Use it for the shared encode and decode meter, from VCN 4 on, with the
busiest engine when there are several. Older VCNs keep their separate meters,
as neither tells encoding from decoding.
Some devices report their PCIe throughput for both directions together,
not apart. Add a field for it, shown as Throughput instead of the RX and TX
values, and as pcie_throughput in the snapshot.
Since Linux 6.9, MI300 has no pcie_bw file, so nvtop showed no PCIe
throughput for it. Its firmware reports the instantaneous PCIe bandwidth in
gpu_metrics from v1.5 on, as a single value in whole GB/s, without saying
whether it sums both directions. Show it as the
throughput of both directions when pcie_bw is missing.
Without vcn_busy_percent, the video engine usage of the APUs from Renoir to
Phoenix is in their own gpu_metrics formats, v2.1 to v2.4, as a single value
for the whole video block. Phoenix is the only one of them with a shared
encode and decode meter, which is all this value is used for: decode it from
its v2.1 table, in hundredths of a percent as its firmware headers say and as
its driver divides it for its own sensor. v2.2 to v2.4 are not needed, and
Van Gogh reports them in percent with its newer firmware.

The v3.0 table of the later APUs is not decoded for it: its unit depends on
the driver and the kernel version, hundredths for Strix Point, Krackan and
Strix Halo, and percent for the latest APUs on recent kernels.
gpu_metrics reports the clocks of the SoC, of the data fabric on the APUs,
and of the video engines, which nvtop did not show. Report them as extra
clocks: SOCCLK, FCLK, VCLK and DCLK, and VCLK1, DCLK1 and VPECLK as
secondary domains. When a clock is reported per die or engine, as on MI300,
show the highest one. RDNA 4 reports the clocks of its first video engine
for the second one as well.

Most APUs only report time averaged clocks, and Strix Point, Krackan and
Strix Halo time filtered ones: use them there. The fabric clock of the APUs
before Strix Point is the memory clock on all but Renoir, so it is left out.
The power sensor of an APU measures the whole socket, the CPU included. The
v3.0 gpu_metrics of Strix Point, Krackan and Strix Halo reports the power of
the graphics block alone: use it when reported. The graphics power of the
older APU tables is the one of a rail the CPU cores share, so it is not used.

A refresh whose table cannot be read keeps the socket power, as a value is
better than none. There is no power cap of the graphics block alone: the
socket one is only shown with the socket power.
An APU has no PCIe link of its own, so its RX and TX showed N/A. The v3.0
gpu_metrics of Strix Point, Krackan, Strix Halo and later APUs reports the
DRAM read and write throughput, in MB/s: show them as RX and TX. It is the
one of the whole SoC, the CPU included, which is still the memory traffic of
the APU. The values are 16-bit, so a throughput beyond 65535 MB/s does not
fit.

The internal PCIe bridge of an APU does not bound that throughput: report no
maximum PCIe link for APUs, so that their RX and TX are not plotted as a
share of it.
The NPU utilization was the sum of the processes nvtop can see, from Linux
7.4 on, and the NPU had no power or clock. On Strix Point, Krackan and Strix
Halo, the firmware reports the utilization of each NPU column, the NPU power
and its clock in the v3.0 gpu_metrics table of the graphics block of the
APU. Read them from there: a system has a single APU, and the dGPU tables
have another format.

When a table cannot be read, as while its GPU is runtime suspended, the
table is looked for again at the next refreshes, up to 10 failed lookups: it
may be the table of a dGPU, on a system whose APU has no table with its NPU.
The fan percentage was the PWM duty cycle when pwm1_enable was not 0, else
the RPM over the maximum one when fan1_enable was not 0. These give the fan
control mode, not whether the sensors are reported: fan1_enable is 0 in the
default automatic mode, so the RPM was never used then. And the duty cycle
is what the fan is driven with, not how fast it spins.

Use the RPM over the maximum one when the driver reports it, capped at 100%
as the maximum of the fan table is not always the top speed of the fan, and
the duty cycle only for fans without one. Since Linux 6.13, the driver
refuses to read them while the GPU is runtime suspended or reset: choose
again at a later refresh rather than settle on the duty cycle.

Also report the RPM, which the interface shows when the percentage is
unknown.
The utilization of a device with several engines averages them, which
hides a single busy one. Add the busiest engine to the utilization, shown
in its meter as the encode and decode ones do, and in the snapshot, for the
backends that measure each engine. It replaces the effective load in the
value, as the more telling of the two.
The NPU utilization the firmware measures is the average over the NPU
columns, which hides a single busy one: also report the busiest column.
…apshot

The power was shown in whole watts, so the small ones said little: an NPU
drawing 1.4 W showed 1 W. In the interface, show the power and the power cap
with a tenth below 10 W, as they fit the same width; they are still
truncated to whole watts from 10 W on. In the snapshot, which scripts read,
give them in milliwatts, the resolution the backends report them in, rather
than in truncated watts: "power_draw": "1400mW" instead of "1W".
@Syllo
Syllo merged commit a174eb9 into master Nov 29, 2026
8 checks passed
@Syllo
Syllo deleted the amdgpu-metrics-activity branch November 29, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant