Repository navigation
drm/asahi: g17: admit a context's ioctls to work states in submission order - #571
Merged
Merged
Conversation
… order Each engine admits a context's ioctls in submission order, but the render and compute engines advance independently. Under deep mixed load, render admission takes work-state nodes for ioctls far ahead of an older ioctl that is still waiting for its turn on the compute queue. gpubench-stress queue.depth keeps 128 compute and 64 render submissions in flight on one queue, each render followed by a compute copy. On a Neo (A18 Pro), every completion of the context stops within 0.5-4 s: compute and render-pair stamps stop together, newly published compute never runs, and the client loses the device. Capping the context's live nodes at 32, 48 or 56 does not prevent this. Native macOS on the same machine and firmware runs the same load (one MTLCommandQueue, 128 compute and 64 render command buffers in flight, each render followed by a compute copy) for 60 s without an error. Metal schedules a queue's command buffers in commit order across engines, with at most 36 between scheduling and completion. An ioctl now takes its node only while at most 8 older ioctls of its context have neither taken one nor left without one. Native scheduling happens at commit, on one thread. Here each engine admits from its own scheduler, so a strictly ordered turn costs a scheduler round trip whenever the other engine's ioctl is ready first; that slowed a windowed Vulkan client. Under the queue.depth load, run-ahead limits up to 16 held and 32 did not, so 8 leaves a factor of two. The turn is tracked under a context mutex taken inside the work-storage lock. Ioctls that fail or are cancelled before taking a node are remembered within 1024 ordinals of the turn. One that leaves further ahead makes the context's admission unordered, as before, rather than stall it. A refused publisher waits on its engine's admission domain, and the turn moving past a refusal wakes both domains. Contexts whose ioctls are never refused, such as single-engine ones, take no wake-ups from this. The last-node rule stays: render ioctls still hold nodes while their copies wait in the compute queue. Link: aurora-silicon/gpubench#5 Signed-off-by: DjDeveloperr <[email protected]>
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the GPU stall that #570 left open ("Still open"), tracked in aurora-silicon/gpubench#5. Under deep mixed render and compute load on one queue, every completion of a G17 context stops within seconds.
What native does differently
The comparison ran natively on the same Neo (A18 Pro, macOS 26.6.2, same GPU firmware), using a Metal copy of
queue.depth:MTLCommandQueue;Every native run passed:
Per-command-buffer scheduled/completed handler times, kernel and GPU timestamps, and a long head command buffer with 191 behind it show how Metal schedules:
commit()never blocks; the rest wait in the driver.Linux has no such order. Each engine admits a context's ioctls in submission order, but render and compute advance independently. Render admission takes work-state nodes for ioctls far ahead of an older ioctl still waiting on the compute queue.
Fix
An ioctl takes its work-state node only while at most 8 older ioctls of its context have neither taken one nor left without one: ordered admission across engines with a bounded run-ahead.
Strict order (run-ahead 0) is the closest copy of native, and it passes the repro too. Native schedules at commit on one thread, though. Here each engine admits from its own scheduler, so a strictly ordered turn costs a scheduler round trip whenever the other engine's ioctl is ready first. That cost showed up in a windowed Vulkan client (below).
Evidence (Neo, diagnostic knobs,
queue.depthc128+r64 on one queue)The run-ahead is empirical. 16 is the largest value that passed, and 32 the first that failed, so 8 leaves a factor of two.
Qualification
asahi_g17*153/153 under QEMU arm64 with 16K pages. That includes four newasahi_g17_work_statescases: run-ahead admission, ioctls leaving early pass the turn, the unordered fallback, and no wake-ups without a refusal. On the omacom tree (omacom/linux-aurora mirror) it is 132/132.clpcd2) with this change as its asahi module:Strict order (run-ahead 0) left vkmark's shading scene about 9% slower in 4 of 11 rounds. Run-ahead 8 showed that once in 23 rounds, and its dedicated 10-round A/B above was a tie.-REGRESSION-PASS`.
synchronization2group: 36516 Pass, 0 non-pass, the same as stock.queue.depthc128+r64 repro: 4 × 30 s pass, plus a 60 s run that completed about 2M checked submissions with 0 errors (the harness's own 60 s timeout cut its verdict line). No kernel GPU lines during any repro run.Performance
Same-boot A/B on the Neo, with this change vs contexts created with the old unordered admission (a diagnostic build only), arms rotated, quietdesk on. Medians, ordered vs unordered:
Strict order (run-ahead 0) left vkmark's shading scene about 9% slower in 4 of 11 rounds. Run-ahead 8 showed that once in 23 rounds, and its dedicated 10-round A/B above was a tie.
Head-of-line microbench (gpubench-stress diagnostic): queue 0's head ioctl waits on ~5 ms of queue-1 work while 4 independent ioctls of the other engine are submitted behind it. In both directions, the independent ioctls finished after the long work in 0 of 60 loops with ordered and unordered admission alike. Queue order before admission already serializes them on this stack, so ordered admission adds no head-of-line wait.