Repository navigation
drm/asahi: g17: kill a hung client's work instead of letting it take the GPU down - #2504
Conversation
0868df5 to
f2f239a
Compare
f2f239a to
54e48a2
Compare
|
Commit messages only, for the pre-PR checklist: the commits no longer carry Assisted-by: LLM (Claude:Opus 5.5) |
|
Blockers: 1. Checked the new close latch (
HW row: J616s on this head, default command line: the deqp-vk memory_model hang case run 10 times in a row beside a drawing desktop, with at least one run where the first blame lands on a bystander. Pass: no restart-storm stop, the desktop keeps its device, Assisted-by: LLM (Claude:Opus 5.5) |
54e48a2 to
3efdb5d
Compare
|
Fixed in
Testing: arm64 The J616s row will follow the next kernel build of our tree. The memory_model hang case stays with the owner. We'd take your offer to run the M4 Max (J616C) row in your lab. Assisted-by: LLM (Claude:Opus 5.5) |
|
Re-review of 3efdb5d: Blockers: 1. Earlier points:
Since then (only the third commit changed; I diffed the old and new heads):
HW row: unchanged from last time: J616s on this head, default command line, the deqp-vk memory_model hang case 10 times in a row beside a drawing desktop, at least one run with the first blame on a bystander. Pass: no restart-storm stop, the desktop keeps its device, Assisted-by: LLM (Claude:Opus 5.5) |
3efdb5d to
ca0bda2
Compare
|
Fixed in
Test: g17-kill-route-tests.py now compiles the real Results:
The J616s hang row follows our next kernel build (m4.179). We have no J616C (25G83) here. Could you, or someone with one, run that boot? Assisted-by: LLM (Claude:Opus 5.5) |
|
Re-reviewed at ca0bda2: the blocker is fixed. On rows: to be precise about what we have, it's an M4 Pro (J616s, T6040), not a J616C, so we can't give a 25G83 M4 Max boot. The J616s hang row you plan on m4.179 is the one that matters for this head; once it's posted (hung client killed, other clients keep rendering, no device loss, default command line), this is approved from our side. Assisted-by: LLM (Claude:Opus 5.5) |
There was a problem hiding this comment.
Adversarial review at ca0bda2152a2 against the pre-PR checklist.
CI (host-tests), commit attribution/sign-off (§4), naming (§6), and firmware-profile scoping (is_m5(), §1) are clean, and the earlier close_failed_owners pre-/post-latch error handling fix in ca0bda2152a2 looks solid.
Blocker (code)
- Permanent render-slot leak when
try_render_earlyraces with a kernel-closed open client (drivers/gpu/drm/asahi/g17/runtime/compute_exit.rs:434-466,drivers/gpu/drm/asahi/g17/runtime/backend.rs:110-126,drivers/gpu/drm/asahi/g17/runtime/render/submit.rs:569-580,drivers/gpu/drm/asahi/g17/queue/admission.rs:173, 202-215):- Commit 3 (
close_failed_owners) is the first path that callsadmission.release_owner(owner)while the userspaceQueueis still open (context.is_closed() == true,context.held_by_open_client() == true,Backend::closed == false), and makesBackend::release_queueskipadmission.release_owner(self.owner)when the client later closes (backend.rs:110). - Once the killed guilty pair drains on the guilty proof while the client still holds its queue open,
release_drained_render(runtime/render/settle.rs:348-350) callsadmission.pair_drained(slot), clearingstate.quarantinedon that slot whilestate.owners[slot] == ownerandstate.released & (1 << slot) != 0. - Unlike
admit_render(submit.rs:165-169),Backend::try_render_early(submit.rs:569-580) does not checkpacket.completion.status().get() != 0orself.context.is_closed()before callingself.admission.try_acquire_render(self.owner, self.pairs.into(), Request::of(packet)). - A
Queue::submitthat already passed the initialstatus().get() != 0check before recovery (or between commands of a multi-command submit) can entertry_render_early->try_acquire_render:state.refusal(owner)succeeds (owner_quarantine(owner)is nowNoneandowners.contains(&owner)istrue).state.acquire(owner, pairs)(admission.rs:202-215) selects the owner's idle slot without checkingreleased,held, orkill_hold, callstake_idle(slot, owner)which clearsself.released &= !(1u64 << slot)(admission.rs:173), and whenpairs > 1can also callclaim_sibling(owner, pairs)(admission.rs:213) to claim a fresh sibling slot for the already-closed owner withreleased = 0.render_with_leasethen fails immediately withEIO(submit.rs:398) and drops theRenderLease, leavingowners[slot] == ownerwithreleased == 0(and any newly claimed sibling slot withreleased == 0).
- When the client later closes its queue,
Backend::release_queueseesself.context.is_closed() == trueand skipsadmission.release_owner(self.owner). Afterdetach_contextclearsheld/kill_hold, those slot(s) stay permanently leaked in admission (even acrossrelease_retained_owners_after_processor_stop(),admission.rs:803-813, which only clearsstate.released & !state.active). - Fix: Check
packet.completion.status().get() != 0 || self.context.is_closed()(orself.admission_open().is_err()) intry_render_earlybeforetry_acquire_render, preventState::acquire/take_idlefrom reusing or sibling-claiming slots for an owner whose slots are alreadyreleased, and/or callfirmware.queues.admission.release_owner(self.owner)unconditionally inBackend::release_queue(release_owneris idempotent onowners[slot] == self.owner).
- Commit 3 (
Nit
drivers/gpu/drm/asahi/g17/queue/render.rs(Pair::guilty_unretireddoc comment): still reads "since the context's latest close" instead of "first close" (matching thecontext.rs:220fix).
Hardware evidence still owed (§5)
- J616s run on current head (
ca0bda21/ post-fix head), default command line: repeateddeqp-vkmemory_modelhang beside a drawing desktop (no restart-storm stop, desktop keeps its device,kept_guilty_pairs=reported and bounded) plus a regression check (0 SELinux denials, 0 failed units, 0 new kernel errors).
ca0bda2 to
4f5c986
Compare
|
Thanks, the race is real. Fixed in I confirmed it in the code: the sleeping path ( Fix chosen: admission itself gives no lease to a released owner. The new
Owner IDs come from a 64-bit sequence and are never reused, so released means closed for good. Nit: Tests:
Results:
The J616s rows (the hang case and the regression check) follow our next kernel build. Assisted-by: LLM (Claude:Opus 5.5) |
|
Checked 4f5c986: Assisted-by: LLM (Claude:Opus 5.5) |
4f5c986 to
9a1843f
Compare
|
Rebased onto integration/aurora 110861f; head is now
The J616s hang row comes on our next test kernel. Assisted-by: LLM (Claude:Opus 5.5) |
|
Checked the rebase to 9a1843f with a range-diff against 4f5c986. Commits 2 and 3 are unchanged; commit 1 only picks up the new task-stage-order context in No new points. Approval still stands once the J616s hang row is posted at this head (unchanged ask). Assisted-by: LLM (Claude:Opus 5.5) |
|
J616s hang row: FAIL. Kernel: our combined test kernel m4.179, which carries this series at r4 (the same code as 9a1843f minus the merge with #2500, which m4.179 doesn't have). Same 7 runs. In runs 2-4 and 6 the firmware blamed deqp first: 1 recovery, only deqp failed. Run 5 passed. In runs 1 and 7 the first blame landed on a bystander: t3code in run 1, and t3code then Hyprland in run 7. Each time it was reason 0 with both fault banks clear. The bystander's started render was failed as guilty, and Hyprland lost its device, which ended the session. Root cause is in the reason-0 path. Attribution returns Second issue, from run 1: after the t3code blame, 16 restarts blamed deqp. The kernel closed deqp's scheduler at gen 3, then 14 restarts were forgiven as dropped work of a failed VM, and deqp's work was never killed (0 kills). Next: a diagnostic in our test kernel that logs, per recovery, every running pair's front render (VM, tiler start, fragment end, and whether the firmware blamed it). Then we pick a fix on that evidence. I've updated the description to match and moved the PR to draft until then. Assisted-by: LLM (Claude:Opus 5.5) |
|
Still working on this, so the PR stays in draft. A fix for the bystander-first blame is written and passes KUnit and the g17 host tests. It is not on this branch yet. A blame that only the firmware gives, with no slot, pass-record or earlier-guilt evidence behind it, is now collateral the first time: the blamed command fails and the VM stays usable. The VM becomes guilty when its render pair is blamed again before any of its work retires. Queues that keep no collateral mark (compute queues, M5) stay guilty at once, as before. A real culprit costs one more restart. In the run 7 shape, t3code and Hyprland each lose one command, and only deqp is failed. It goes on this branch once the hang row passes with it on hardware. The second issue from run 1 (deqp's work not killed after its close) is separate and still open. |
|
Updated to
J616s hang row (the same KUnit on this branch 759/760 (1 skip), |
|
Merged main Conflict: only Checks at
The J616s hang row at |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verified the main merge-forward resolution in tools/asahi/run-host-tests.py: cleanly preserves both main's new M5 host tests and this branch's superset mutation entries with no unintended diff. Holding merge until CI completes green and updated hardware verification clears.
|
This branch conflicts with |
Conflicts, and how they were resolved: - g17/context.rs: main replaced the compute_binding_hint flag with the compute_bindings count and added compute_ordinal. Both are kept, next to this branch's kill_seen, closed_generation and closed_for_open_client fields. The branch never used the old flag. - g17/queue/admission.rs: main's admits_render() takes the pairs the owner asks for. This branch's a_released_owner_takes_no_pair_again test now passes the 2 pairs its owner asks for elsewhere. - tools/asahi/g17-admission-order-tests.py: the held fixture extracts both this branch's owner_released() and main's set_owner(). No behaviour changes: set_owner() is the single writer of owners[], and try_acquire_render() still checks owner_released() before take_idle(). Signed-off-by: Jonathan Goyvaerts <[email protected]>
|
Merged main Conflicts, and how they were resolved:
No change to the recovery path. Apart from that test argument, the branch's diff against main is line for line the same as at Checks at
The J616s hang row at |
|
J616s (M4 Pro) hang row at Kernel: our m4.195 test kernel, booted 2026-11-26 19:06 UTC. It is aurora main
Caveat (the foreign-compute case in Known limits, as in run 8 at Seen on the desktop, outside this PR: one visible pink flicker in t3code during generations 19-20, which lasted until the window redrew. The kernel had failed a spared render that a recovery interrupted after it started ("interrupted by a GPU recovery after it started; failing it"), and the client presented that frame. That path is main's, not this PR's; it is tracked as its own follow-up. Not covered: M5, Neo, M4 and M4 Max. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict at 1b0abfeb: code OK; merge after the Neo or M5 row at this head.
Blockers: none in the code. The shared-code regression row is still owed: your "Not yet" lists one M5 or Neo run at this head, and the merge policy needs it for shared G17 code. The J616s 10/10 row covers the target.
Checked
- Since Dj's last approval at
cf9355f7, the only change to the PR's own diff is one test call,admits_render(1, 2, None). It follows main's newpairsargument (admission.rson main has the same signature). The rest is merges of main. - The KUnit jobs marked failed at this head were cancelled after 47 min (runner limit), not real failures; I re-ran them.
|
|
RyanTheTide
left a comment
There was a problem hiding this comment.
Merge-train status at 1b0abfeb: not mergeable yet. The full adversarial review (it's 1.5k lines of recovery code) will come once the missing row is in, so it's done against the head that will merge.
Missing before merge: the run the body lists under Not yet, at this head, on the other G17 generation: Neo (A18 Pro) or an M5. Kill and attribution are shared G17 code, and the body says M5 is excluded but the A18 Pro is untested. We can run the hang row on our Neo if you'd like. Please say so here.
Seen so far: J616s 10/10 hang rows at this head (26 recoveries, no desktop client lost, one collateral EIO with the VM kept), KUnit 875/876, and g17 host tests pass. The known limits are stated plainly.
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict at 1b0abfeb: approve.
Blockers: none.
Checked
- Code: since Dj's last approval, the only change is one test call adapted to main's
admits_render(owner, pairs, req)(my comment above). - Rows at this head: J616s hang row 10/10 (target), and Neo J700 regression row PASS on the shared G17 path (g17 host tests 227/227, boot, GL + VK smoke, 0 GPU faults or recoveries, 0 failed units).
- CI: 18/18 green after re-running the cancelled KUnit jobs.
- The M4 Max and M5 stay listed under "Not yet"; follow-up rows don't hold the merge.
|
Correction to my merge-train hold above: the Neo (J700) row at |
What: G17 recovery: kill a hung client's work instead of letting it take the GPU down for every client, and stop a firmware blame that lands on a bystander from failing the bystander's VM.
Tested: J616s M4 Pro (25G83) at
1b0abfeb7e03(on aurora main a851ca0, no other G17 recovery changes): the hang row passes 10/10. 26 recoveries; deqp-vk failed in all 10 runs; of 9 bystander blames none failed or closed a desktop client, and the off-screen renderer took one collateral EIO with its VM kept; 0 storm-limit lines, 0 err-level kernel lines, 0 failed units, no AVC denials. The same row passed 10/10 atb731bf1a34b0on main 8c6bd8d. KUnit 875/876 (1 skip), every g17 host test passes.Risk: two-way door · G17P Macs (M4 family on 25G83); M5 is excluded from the kill and attribution paths.
Not yet: one M5 or Neo run at this head; the M4, M4 Max and A18 Pro are untested.
Known limits:
Details
1. Kill a closed guilty context instead of waiting for its work. A recovery found a client's render work guilty and failed its VM. The client exited, but its work stayed published. On 25G83 the host cannot take published groups back; only a kill of the context unlinks them, and that kill never came:
kill_route()gave no route to a pair that holds a started group with never-started groups behind it.kill_unsafe()held any kill while another client rendered, for up to 5 s.Each restart reached the hung group again, about every 83 ms, until the storm limit stopped the GPU. Now a quarantined pair of a closed owner, with all its work published and its VM
recovery_guilty, is killed at once. This applies only after a restart since the close, so a guilty client's healthy queued groups can still retire on their stamps. Its groups go only after the kill is done and a later restart has run. At detach the pair parks if its rings were consumed; otherwise it is kept out of service until the processors stop. debugfs counts kept pairs (kept_guilty_pairs=).2. Log the restart table of each recovery in one line: the record count, then the first 24 records as
q<qid>:<stamp>:<flags>/<match>.3. Close a guilty failed VM's queue for a client that keeps it open. The kill in 1 needs a closed queue. A client that ignores
VK_ERROR_DEVICE_LOSTkeeps its guilty work published. A VM that a recovery found guilty and whose status recorded the failure can't run anything again, because every submission, install and publication checks that status. So the kernel now closes its queue on the client's behalf, asrelease_queuewould, and logsscheduler N closed for its open client.State::owner_released, checked inacquire_renderandtry_acquire_renderunder the pool lock). The client of a kernel-closed queue may still publish early once its drained pair left quarantine; taking that pair back, or claiming a sibling, would clear its released bit with nothing left to release it. Owner IDs are never reused.4. Blame a spared culprit's hang on it the second time.
classify()treats a blame on a queue whose oldest work an earlier recovery spared as collateral, not as guilt. When a cascade's first restart blames a client that the spinning culprit starved, the culprit's work is spared, and every later blame on it is collateral. The culprit's VM then never turns guilty: no forgiveness, no kill. Now a restart that blames a render pair's spared work as collateral marks that pair. A later restart that blames the marked pair again, with none of its work retired in between, makes its VM guilty.5. Fail the culprit's VM when that repeated blame finds it guilty. The culprit's commands had all failed already without poisoning it: earlier restarts listed them as interrupted while its VM was innocent. Failing them again changes nothing, so
classify()records the failure itself. It does so after the restart's forgiveness decision, so the restart that finds the VM guilty still counts.6. Fail a VM only when evidence or a repeat confirms its blame. A timeout restart names the queue the firmware chose. Without slot keys, a bystander whose render had started while waiting behind the culprit's was failed as guilty on the spot; with the compositor that ends the session. Now a blame only the firmware gives (
Attribution::Firmware) is collateral the first time: the blamed command fails, the VM stays usable, and its render pair is marked. Blamed again before any of its work retires, the VM is guilty. Evidence (slot identity, the host's pass records, earlier guilt) still makes a VM guilty at once. Compute queues and M5 keep no collateral mark (Queues::marks_collateral), so their unconfirmed blame stays guilty at once, as before.7. Suspect the oldest running render, never an unstarted one. The host's pass records now pick the suspect: the running render whose tiler started first is taken as the hang, since the others started after it and wait behind it. Its VM's running pairs are suspected (
Attribution::Suspects), whether or not the firmware blamed them. A suspicion is not proof (a slow innocent render that started just before the hung one looks the same), soclassify()treats it like the firmware's blame: collateral the first time, guilty on a repeat before the pair's work retires. A blamed render that never started is never the hang: with nothing running, or with another VM's compute in flight (which these records cannot see), nobody is blamed (NoCulprit). A VM an earlier recovery found guilty still comes first, as evidence.Known limits
fault_overridenames the faulting slots' work when it excludes the blamed queue (evidence, guilty at once). A page fault inside the blamed VM stays the firmware's blame, so it is collateral once and turns guilty at its next fault, one restart later than before 6.Not done
killed: 0. Not seen in the m4.184 row; not yet explained.Evidence
Tested on the J616s (M4 Pro, 48 GiB, 25G83)
Changes 1-5 run in our daily kernel (m4.176); 6 and 7 ran in our test kernels (m4.183, m4.184). The hardware runs used one deqp-vk
memory_modelcase whose fragment shader spins, guarded, beside a drawing desktop:kept_guilty_pairs=0throughoutintegration/aurora110861f. Since drm/asahi: g17: keep the GPU running for other clients when one client's commands hang or restart the firmware #2500,classify()also returns whether the restart is charged to its guilty clients. In the rebase, that return and this series'generationparameter are merged, and the poison of a repeat culprit (5) runs before drm/asahi: g17: keep the GPU running for other clients when one client's commands hang or restart the firmware #2500's per-VM command count. Neither depends on the other: the count covers every active command whatever the VM's error. The rest of the rebase is context only.a43b5e2d83da: 761 tests, 760 passed, 1 skipped (needsCONFIG_UCLAMP_TASK), no failures.run-host-tests.py --only g1797/97.counts_idle, the kept-slot hold, the table line and the first close.classify(): the 2026-11-19 storm (4 counted restarts instead of 8), the m4.174 and m4.175 runs, a culprit blamed first (now guilty at its second blame), a confirmed first blame (guilty at once), the m4.179 run 7 bystanders, a bystander that retires between blames, a retirement on the culprit's other pair, and a pair rebound to a new owner.culprit()cases replay the m4.183 run 2 restarts with their tiler starts (deqp named each time, quickshell never), and cover an unstarted blamed render, foreign compute and a VM with several running pairs. They fail on the previous rule. A new case shows an innocent slow render that is suspected once is not failed, while a render suspected twice is.tools/asahi/run-host-tests.py --only g17: 97/97 passed. The harnesses that compile the changed code are updated, with new mutations for the guilty kill route, a second close, a close that counts before its teardown entry is reserved (a failed allocation, then the retry), the kernel's close of a failed owner (a failed reservation retried without aborting the pass; a failed release after the latch fails it), and a released owner asking admission for its pair again.Regression check at the previous rule (m4.184 row): 0 failed units, 0 err-level kernel lines, 0 storm-limit lines; our kernels load no SELinux or AppArmor policy, so there are no denials to count.