Skip to content

drm/asahi: g17: count a queue's overlapping stages once in fdinfo - #1869

Merged
DjDeveloperr merged 1 commit into
integration/aurorafrom
djdev/g17-engine-time-union
Nov 14, 2026
Merged

DjDeveloperr merged 1 commit into
integration/aurorafrom
djdev/g17-engine-time-union

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

The G17 backend runs several commands of one queue at once, so the stages a queue retires overlap in time. fdinfo summed their intervals, so a client's drm-engine-* counted the same engine time once per command in flight. On the A18 Pro, one client saturating compute at queue depth 4 read 3.00 s of drm-engine-compute per second of wall time. In completion traces of ordinary GL and Vulkan loads, the sum per queue reached 1.1 to 2.25 times the queue's busy time, with overlaps up to about 40 ms.

This charges each G17 queue's stages through a per-queue usage::Lane. For each engine, the lane keeps the latest end it has charged and adds only the part of a stage after that mark. In the same traces (about 280k completions on 52 loads), no queue ever retired a stage that started before an earlier-retired one. A queue's retirement order is its start order, so the mark gives the exact union of the queue's intervals. It is lock-free: one compare-and-swap per stage before the existing counter update.

  • Queues of one file still add up (one union each), and vertex and fragment keep separate marks, as before.
  • A stage more than 60 s behind the mark (longer than any stage runs) is treated as a timestamp jump and restarts the mark, so a bad stamp can't stall the accounting.
  • G13/G14, G15 and G16 are unchanged and still sum. Documentation/gpu/asahi-usage-stats.rst now says which backend does what.

Tests (tools/asahi/usage-tests.rs, rustc --test): 14/14 pass with 0 warnings, of which 7 are new: depth 1/4/8 pipelines count exactly the wall time (the plain sum counts depth times it), idle gaps and disjoint stages, a covered stage keeps the mark, separate engine marks, queues of one file add up, the timestamp-jump restart, and 8 threads on one lane never exceed the union. Mutations are killed: dropping the clip, the jump rule, or the covered-stage return each fail at least one test.

A kernel compile against the 2129f55 kit tree and a hardware check on the A18 Pro (the same depth-4 compute load should read at most 1 s/s) follow; results will be posted here.

🤖 Generated with Claude Code

The G17 firmware runs several commands of one queue at once, so a queue
that keeps commands in flight retires stages whose intervals overlap.
fdinfo summed them, and a client's drm-engine-* counted the same engine
time once per command in flight: on the A18 Pro one client saturating
compute at queue depth 4 read three seconds of compute per second, and
ordinary GL and Vulkan loads read up to 2.2 times their busy time.

Charge each queue's stages through a lane that keeps, per engine, the
latest end it has charged, and add only the part of a stage after it.
A queue's stages retire in the order they started, so this is the exact
union of its intervals, without a lock. Queues of one file still add
up. A stage more than 60 s behind the mark, longer than any stage runs,
restarts it, so a timestamp jump cannot stop the accounting.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr merged commit 96fcb3c into integration/aurora Nov 14, 2026
1 check passed
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Compile/link gate: full arm64 build of integration/aurora 5d112b1 + #1853 + this PR (Image, modules, aurora.ko) OK, same warning count as without it. host-tests passed on this head. The hardware check (the depth-4 compute load reading at most 1 s/s of drm-engine-compute) runs on the A18 Pro on the next default kernel; its result will be posted here.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Hardware check on the A18 Pro (J700, Fedora), new default kernel (integration 2129f55), same slot, same load (one client saturating compute at queue depth 4, then a light render at depth 1):

stock module with #1853 + this PR
drm-engine-compute, compute load 3.00 s per s 1.00 s per s
drm-engine-fragment, light render 0.08 s per s 0.07 s per s

The light render barely overlaps at depth 1, so it is unchanged. #1853's frequency keys were checked in the same run: drm-curfreq-* 1470000000 Hz at work and 0 Hz while gated, and drm-maxfreq-* 1470000000 Hz, on every aurora client. No GPU kernel lines during the run; the default boot was restored.

@RyanTheTide
RyanTheTide deleted the djdev/g17-engine-time-union branch November 16, 2026 05:03
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