Skip to content

Include AMD GPU state and memory pools in debug reports - #16130

Open
zihaomu wants to merge 2 commits into
omacom:quattrofrom
zihaomu:feat/amd-gpu-debug
Open

zihaomu wants to merge 2 commits into
omacom:quattrofrom
zihaomu:feat/amd-gpu-debug

Conversation

@zihaomu

@zihaomu zihaomu commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add an AMD GPU section to omarchy debug, reporting cached PCI identity, bound driver, runtime state, GPU activity, and separate VRAM/GTT allocation and capacity counters.

  • Detect display controllers by cached PCI vendor 1002 and class 03, including Display-class 038000 APUs and multiple GPUs. No fixed DRM card index or loaded-module predicate.
  • Read live counters only for amdgpu devices with runtime state active or unsupported. Skip suspended, transitional, or unavailable states.
  • Show unavailable fields explicitly and continue the report when metadata or counters cannot be read.
  • Collect the AMD section before inxi, so it records runtime state before that broader scan.
  • Use existing sysfs interfaces and shell/coreutils; no ROCm dependency, package installation, or GPU setting change.

Memory counts are printed in bytes. VRAM and GTT remain separate driver pools, with a note about their relationship to system RAM accounting. This is a diagnostic enhancement.

Native execution

Ran the complete bin/omarchy-debug --no-sudo --print command on an HP ZBook Ultra G1a with Ryzen AI Max+ PRO 395 / Radeon 8060S. It exited 0 in approximately 1.2 seconds with no stderr output.

PCI address: 0000:c3:00.0
  PCI ID: 1002:1586
  PCI class: 038000
  Driver: amdgpu
  Runtime state: active
  GPU busy: 4%
  Driver VRAM total: 536870912 bytes
  Driver VRAM used: 460894208 bytes
  GTT total: 67140354048 bytes
  GTT used: 868536320 bytes

The pool values matched a subsequent native sysfs read; GPU activity changed from 4% to 5% between samples, as expected for a live counter. The capacities are 512 MiB VRAM and about 62.53 GiB GTT. The DRM node on this machine is card1.

Checks and limits

  • bash -n bin/omarchy-debug: passed.
  • git diff --check: passed.
  • bin/omarchy debug --help: resolves to the existing command and flags.
  • bash test/shell.d/debug-amd-gpu-test.sh: 24/24 fixture checks passed.
  • FIFO counter files make an attempted read from a skipped device block and fail a bounded timeout. A positive control exercises the real reader against a sentinel.
  • Two deliberate regressions in temporary copies (reading in a skipped-runtime branch and in a skipped-driver branch) were both rejected by the suite with the expected blocked-read failures.
  • The native run covers one active APU. Other runtime states, drivers, multiple controllers, and fallback cases are exercised with fixtures; actual suspended discrete GPUs and other hardware combinations have not been exercised.
  • The runtime guard applies to the new collector. The complete command still runs its existing hardware tools; it is not guaranteed to leave every suspended GPU asleep.

No full system report or journal output is attached; the excerpt contains the AMD section only.

Fixture coverage follow-up

Test-only commit e73b47dd adds test/shell.d/debug-amd-gpu-test.sh, picked up by the existing shell test runner. The production collector is unchanged.

The suite loads the real collector functions and uses temporary OMARCHY_PCI_DEVICES_PATH fixtures without running unrelated whole-system probes or writing the full debug log. Coverage includes:

  • Display class 038000, VGA, and 3D controllers; active and unsupported runtime PM.
  • Suspended, suspending, resuming, unexpected, missing, and empty runtime states, with no counter reads.
  • A different driver and an unbound device, with no counter reads.
  • Multiple active controllers and a suspended controller before an active one.
  • Non-GPU AMD functions, other vendors, empty/missing PCI roots, and incomplete PCI metadata.
  • Missing, malformed, empty, zero, directory, and dangling-link counter values.

Focused run: 24 checks passed, 0 failed, approximately 1.3 seconds. Bash syntax and whitespace checks also pass. The complete CLI/shell aggregate suites were not run for this test-only follow-up.

@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous testing gap is addressed.

Summary

Adds AMD GPU details to omarchy debug before inxi runs.

  • The debug report adds AMD GPU details before its system scan.

All 24 focused checks passed. Bash syntax checks and git diff --check also passed. No new actionable issues were found.

Reviews (2) · Last reviewed commit: "Cover AMD debug collector guards with PC..." · Reviewed by Greptile

Comment thread bin/omarchy-debug Resolved
@omarchybot omarchybot added the enhancement New feature or request label Oct 21, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at e73b47d. The collector works as described and its tests pass, but the change is a good deal larger than what it adds to a debug report, and its runtime-PM guard defends against a GPU wake that current kernels already refuse. Nothing was pushed; this waits on the author for a smaller version, and on the maintainer for whether they want the section at all.

What ran, and where. On a disposable Omarchy worker (QEMU, virtio GPU, kernel 7.2.8): test/shell.d/debug-amd-gpu-test.sh passed 24/24, ./test/cli passed, and bin/omarchy-debug --no-sudo --print exited 0 with nothing on stderr, printing No AMD display controllers detected. under the new section. The worker has no AMD GPU, so the amdgpu path ran only against your fixtures; the native output in the description is the only evidence for real hardware.

Proportionality. The report already runs inxi -Farz, which prints each GPU's driver, bus ID, chip ID and class-ID (checked in the worker's output). What this adds that the report lacks is the four mem_info_{vram,gtt}_{total,used} values, plus gpu_busy_percent and runtime_status. A loop over /sys/bus/pci/devices/*/mem_info_vram_total printing those values per PCI address would be roughly 15 lines with no test seam, against +80 here and +257 of fixture tests. Most of those tests cover the runtime-state guard below. Keeping the rest means more for a maintainer to read and keep working in a command that six other open pull requests also edit (#8828, #9063, #9477, #14078, #14479, #15274). If the runtime state and busy percentage are worth having, they could be a separate pull request.

The runtime-PM guard (bin/omarchy-debug:84-92). On a kernel Omarchy ships, none of these reads wakes the device. In upstream amdgpu, mem_info_vram_total/_used and mem_info_gtt_total/_used return software accounting (gmc.real_vram_size, ttm_resource_manager_usage, the TTM manager's size) and never touch runtime PM. gpu_busy_percent goes through amdgpu_pm_get_sensor_generic → amdgpu_pm_get_access_if_active, which returns -EPERM for a suspended device rather than resuming it. So the guard does not protect anything. It also has a cost: on a hybrid laptop whose AMD dGPU is runtime-suspended, the report leaves out that card's memory totals, which can be read safely. Without the guard, a suspended card's busy reading would just come out as unavailable, which amd_gpu_counter already handles. This was checked against the kernel source, not on hardware.

Smaller points. The section header appears at the top of every report, including on Intel and NVIDIA machines, where it says only that there is no AMD controller. Printing nothing when no AMD GPU is found would avoid that. OMARCHY_PCI_DEVICES_PATH is a production input that exists only for the tests, and the tests pull functions out of the script with sed, so removing the $(amd_gpu_diagnostics) call from the report would leave them all green.

Second opinion. Codex Medium reviewed the same head. Separately from this review, it traced the kernel handlers above and pointed out that the guard hides readable memory pools on a suspended dGPU. I confirmed both against the upstream amdgpu source before including them. On proportionality and the inxi overlap it agreed with conclusions I had already reached, and that agreement is not guaranteed to be independent. It found no stderr, heredoc or empty-glob defect, and neither did I.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants