Repository navigation
drm/asahi: g17: let an exhausted excuse end the blocker's allowance - #2887
Conversation
A compute command of a queue that asked for a watchdog allowance is not failed while it runs inside that allowance, and work of another VM queued behind it on the GPU is excused meanwhile. The excuse is bounded per waiting job, the longest allowance the system permits, but every command of the long queue starts an allowance of its own. When the queue keeps submitting long commands, the waiting job runs out of its excuse and its deferrals and is failed as spared, while the queue that holds the GPU keeps running. Charge the end of the excuse to the blocker instead. Once a waiting job has used its whole excuse and is deferred behind a live blocker that is still inside its allowance, the blocker loses the rest of its allowance and its other renewals; its next expiry goes straight to attribution, and the waiting job's remaining deferrals cover the teardown. The blocker is failed as spared, not as hung. The command the waiting job was first excused behind keeps its allowance: it started before the wait, and an allowance placed late (after a wait in publication) could otherwise end after the excuse. A blocker that itself waits behind older work of the waiting job's VM keeps it too, and a waiting job that is spared anyway does not take the blocker with it. Signed-off-by: Ryan Murray <[email protected]>
|
Review at 732d813. The mechanism holds together. A forfeit fires at most once per blocker, because
|
|
Review at 732d813 (non-author). Changes requested. The host tests reproduce:
Rows still owed before this can be judged on hardware:
Assisted-by: LLM (Claude:Opus 5.5) |
There was a problem hiding this comment.
Formal §1–§6 review at 732d813c51ad.
§1 (no model gating), §4 (human commit + Signed-off-by, clean-room, PR Assisted-by), and §6 (naming) pass, and host tests pass (host-tests green). However, there are functional, safety, and evidence blockers that prevent merge:
- Blocker — Forfeit does not stop the blocker and regresses M5 timeout kills (
compute_control.rs:53-57,queue/compute.rs:2375-2395,queue/compute/exit.rs:139-145):- Classifying a forfeited blocker as
Class::SparedcausesQueue::timeout()to setself.spared_quarantine = true. Queue::timed_out()requires!self.spared_quarantine, so it returnsfalseon M5, suppressingopen_timeout_kill(). A non-terminating compute dispatch that gets forfeited is therefore no longer killed on M5 (regression from base, where it was killed when its allowance ended).- On non-M5 G17, open queues are never killed either, so the blocker keeps running on the GPU and remains ahead as a failed head; the waiting job then exhausts
MAX_RENEWALSand fails asOwn(worse thanSparepreviously). blockers_taking_turns_lose_their_allowance_not_the_waiting_jobmocks the blocker disappearing 3 polls after forfeit, which does not reflect actual queue teardown, andg17-compute-owed-stamp-tests.pystubsforfeit_allowance()/allowance_forfeited(), leaving the runtime path uncovered.
- Classifying a forfeited blocker as
- Blocker — Cross-VM DoS via publication-order-only forfeit (§3):
Verdict::forfeits()decides solely on publication order with no check that the waiting command has not started executing. Any client can submit a non-terminating job behind a legitimate long-allowance compute queue, wait outexcuse_limit, forfeit the queue's next command, and causecompute_control.rsto fail that queue's entire active set. Either require evidence that the waiting job has not been consumed/started, or revisit the policy and document the exact failure semantics ininclude/uapi/drm/asahi_drm.h.
- Blocker — Expiry timing & late-renewal edge case:
- Because forfeit only takes effect on the blocker's next watchdog expiry, a queue continuously beginning jobs re-arms its scheduler timer (
drm_sched_job_begin()) and can delay expiry past the waiting job's remaining renewals whilewithin_allowance()is alreadyfalse. - Firing
forfeits()atrenewals == MAX_RENEWALS - 1leaves too few renewals for the blocker to expire and drain, failing both jobs.
- Because forfeit only takes effect on the blocker's next watchdog expiry, a queue continuously beginning jobs re-arms its scheduler timer (
- Blocker — §5 hardware evidence missing:
- No hardware runs have been completed yet. Before merge, this needs default-cmdline hardware rows (with 0 AVC / 0 failed units / 0 new kernel errors) across affected G17 generations (G17P, M4 Pro/Max, M5): two-client compute sharing showing the waiting job completing after forfeit, render-behind-long-compute, and single-client 30 s allowance with no forfeit.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 732d813c51ad
Blockers:
drivers/gpu/drm/asahi/g17/compute_control.rs:53-57withqueue/compute.rs:2375-2395: a forfeited blocker is classedClass::Spared, which setsspared_quarantine, andQueue::timed_out()then returns false while that flag is set (queue/compute/exit.rs:139-145). So on M5 a blocker that used up its excuses is never killed on timeout. Fix: give the forfeit its own class that ends the allowance and still allows the timeout kill, and add a case for it.
Rows before merging: this G17 code is shared by M4, M5 and the Neo, so at the new head it needs one M5 run with a forfeited blocker killed on timeout, and one M4 or Neo run showing no change.
Checked: no Apple material, no gates.
Superseded by the review at 732d813
Signed-off-by: Ryan Murray <[email protected]>
A blocker that lost its allowance to another VM's waiting work was classified spared when its own watchdog failed it. Queue::timeout() then recorded a spared quarantine, and Queue::timed_out() is false while that flag is set, so on M5 the open timeout kill never stopped it: a forfeited dispatch that never ends kept its queue until the owner closed it, where before the forfeit it was killed when its allowance ended. Give the forfeit a class of its own, recovery::Class::Forfeited. It is not spared: its timeout fails its VM as for any command past its allowance, its queue's quarantine is not a spared one, so the queue never returns to service, and on M5 the timeout kill applies. That keeps open_timeout_kill()'s premise that the owner's VM has already failed; the kill names every queue of the context, sibling channels included, so it must not reach a VM that can still submit to them. A later zero-duration record keeps the class, as it keeps a recovery's. The UAPI comment now says the settled command fails with -ETIMEDOUT, as a lost device, with the commands queued behind it. The compute owed-stamp host test now compiles the real Queue::classify() and Queue::timed_out() and checks that a forfeited blocker is classed forfeited with its active set, fails with ETIMEDOUT and fails its VM, holds a non-spared quarantine and is due for the M5 kill; two new mutations (forfeit classed spared again, or not classified) fail it. Signed-off-by: Ryan Murray <[email protected]>
|
@DjDeveloperr, I've pushed a fix for your blocker. The branch is forward-merged onto main Blocker: a forfeited blocker was classed
I checked whether a forfeited blocker could keep its VM, the way spared work does. It cannot do so safely:
So Consequence: a forfeit costs the blocker's client its device, not only that queue's commands as under the old Test case ( The fixture now compiles the real
Tests at
Mutants (each must fail the new case; all did):
Both new mutants are registered in Still open from the 11-22 reviews, not changed here:
Rows owed at 223077c: M5 (forfeited blocker killed on timeout) from @DjDeveloperr or an M5 owner; M4 Pro (J616s) no-change row by FIXUP-A. Tested: run-host-tests 729/729 (--only g17 233/233); KUnit asahi 493/497 (4 skip); fleet-config asahi build OK; mutants forfeit-spared and forfeit-unclassified both killed. |
|
No-change rows at this head (223077c). Both ran the combined fixa5 test kernel, linux main fca33ed plus the heads of #2887 #2959 #3384 #2919 #2393 #2895. Eleven of the twelve files this PR changes are byte-identical to this head. M4 Pro (T6040, J616s):
A18 Pro (T8140, J700):
Neither row ran a compute job long enough to reach its 30 s allowance, so neither row exercised Both Macs were restored to fleet89 and verified: saved entry unchanged, next_entry empty, test kernel removed, Enforcing, 0 failed units. Evidence (lab store): |
There was a problem hiding this comment.
Verdict: MERGE at 223077c3
Blockers: none (re-run the cancelled readiness check before landing; 21/21 build/host/KUnit/pr-text checks green).
Checked:
drivers/gpu/drm/asahi/g17/recovery.rs,completion.rs,compute_control.rs,queue/compute.rs,queue/compute/exit.rs: commit223077c3cleanly resolves the prior M5 timeout-kill blocker by introducingClass::Forfeited(3) distinct fromClass::Spared(1), so a forfeited blocker does not setspared_quarantine, fails its VM on timeout, and kills its context on M5 rather than stalling indefinitely.- Host tests & mutations (
tools/asahi/g17-compute-owed-stamp-tests.py,run-host-tests.py) and 21/21 CI jobs pass; exact-head no-change hardware rows PASS on M4 Pro (J616s) and peers (fixa5);MERGEABLEonmain. - Checked for Apple material, tool attribution, private serials, and gating: clean; human
Signed-off-bypresent.
Evidence
- Head:
223077c37716(base: main,mergeable: MERGEABLE,+366/-47across 12 files).
main's #2228 builds the g17 packet in its allocation; the two fields this branch adds (forfeited, first_excuse) move into the new in-place initialiser. The forfeit logic is unchanged. Signed-off-by: Ryan Murray <[email protected]>
|
Forward-merged main into this branch, new head 45f59d7 (no force push). The only conflict was `g17/job.rs`: main's #2228 now builds the packet inside its allocation (`init_with(init!(Self { .. }))` followed by `Ok(packet.into())`). I moved this PR's two new fields, `forfeited` and `first_excuse`, into that new initialiser and dropped the old `GFP_KERNEL)?)` form. Compared with main, the merge adds exactly what the PR already added: the struct fields, their initialisers and the forfeit methods. The forfeit and excuse logic is byte-identical to 223077c. |
There was a problem hiding this comment.
Verdict: FINISH, then merge at 45f59d73 — the #2228 g17/job.rs merge resolution is clean, but the branch is still CONFLICTING (DIRTY) against current main.
Blockers:
- Forward-merge current
origin/main(8ebb0f75ae2dor later, no force push) to resolve the remaining conflicts:45f59d7346mergedd2532e9034, which is 104 commits behindmain, leaving conflicts acrossdrivers/gpu/drm/asahi/g17/job.rs,g17/queue/compute.rs,g17/recovery.rs,g17/runtime/backend.rs,g17/timeout.rs, andtools/asahi/run-host-tests.py. WhileCONFLICTING, the PR cannot merge andpull_requestCI cannot run.
Checked:
45f59d7346conflict resolution indrivers/gpu/drm/asahi/g17/job.rs: movingforfeited: AtomicBool::new(false)andfirst_excuse: AtomicU64::new(0)into the in-placeinit!(Self { ... })initializer matches#2228cleanly and keeps223077c3'sClass::Forfeited/Verdict::forfeits()logic byte-identical.- Live mergeability against
main(8ebb0f75ae2d):CONFLICTING/DIRTY(19CI checks queued/blocked).
Evidence
- Head:
45f59d734677(CONFLICTING/DIRTYagainstmain8ebb0f75ae2d). - Parent 2 of
45f59d7346isd2532e9034(104commits behind8ebb0f75ae2d).
Forward-merge main. Main (e861dd8, M5 overtaken renewals) added Packet::ordinal and now reports shared renewals in every give-up line (GaveUp::new(.., true, ..)). job.rs keeps this branch's forfeited and first_excuse fields beside main's ordinal, and both callers of Timeout::settle() pass true so the forfeit path logs like main's. The owed-stamp host test stand-in for recovery::note_retired() still took no argument although main's retire() now passes the publication; give it main's signature so the test builds again. Signed-off-by: Ryan Murray <[email protected]>
|
Forward-merged current main (2fd49a6) into this branch; new head 0f8628f (no force push). |
There was a problem hiding this comment.
Verdict: MERGE at 0f8628f81b82
Blockers: None (wait for the 19 queued CI checks at 0f8628f81b82 to finish green and for @DjDeveloperr to re-review/dismiss the prior 732d813c change request).
Checked:
- Forward-merge
0f8628f81b82(main2fd49a614f3d): Cleanly resolves the45f59d73merge conflicts (MERGEABLEonmain):drivers/gpu/drm/asahi/g17/job.rs: keepsforfeited: AtomicBool::new(false)andfirst_excuse: AtomicU64::new(0)besidemain'sordinal: AtomicU64::new(0)insideinit!(Self { ... }); bothTimeout::settle()call sites passrenews_shared = truematchingmain'sGaveUp::new(.., true, ..).drivers/gpu/drm/asahi/g17/{completion.rs,queue/compute.rs,queue/compute/exit.rs,recovery.rs,runtime/backend.rs,runtime/compute_control.rs,timeout.rs}:Class::Forfeited(3),forfeit_head(),forfeit_blocker(), andVerdict::forfeits()logic remains intact from approved223077c3.tools/asahi/g17-compute-owed-stamp-tests.py: updatesrecovery::note_retired(_published: u64)to matchmain'sretire()signature while keeping thea_forfeited_blocker_is_failed_and_killed_on_timeouttest andforfeit-spared/forfeit-unclassifiedmutations (run-host-tests.py --only g17: 276/276 PASS).
- Hardware evidence: Prior
fixa5J616s (M4 Pro) and J700 (A18 Pro) no-regression rows from223077c3stand (forfeit logic unchanged across themainmerge). - Checked for Apple material, tool attribution, private serials, and gating: clean.
Evidence
- Head:
0f8628f81b82(base: main,mergeable: MERGEABLE,+367/-48across 12 files). - Hosted CI at
0f8628f81b82:3P/0 real failures/19Q(priorreadinesscancelled;apple-build,host-tests,kunit,rust-build,asahiKUnit queued).
|
code-owner ping @DjDeveloperr: closeout merge at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
Problem
A G17 compute queue that asked for a watchdog allowance (
compute_timeout_ms) keeps each of its commands alive for up to that allowance. Work of another VM queued behind such a command is excused meanwhile, for at most the longest allowance the system permits, and then deferred and failed as spared. Every command of the long queue starts a fresh allowance, so a queue that keeps submitting long commands outlasts the other VM's excuse: the waiting job is the one that fails, while the queue holding the GPU keeps running.Change
When a waiting job has used its whole excuse and is deferred behind a live blocker that is still inside its allowance, the blocker loses the rest of its allowance and its other renewals (
timeout::Verdict::forfeits,Packet::forfeit_allowance). Its next expiry goes straight to attribution, normally failing it, and the waiting job's remaining deferrals cover the teardown. The blocker's failure is classedrecovery::Class::Forfeited(since 223077c; it was spared before). It fails as a command past its allowance does: its VM fails with ETIMEDOUT, its queue's quarantine is not a spared one, and on M5 the open timeout kill stops it. Both the compute and the render watchdog apply it and log one line when they do.It does not apply to:
Queues whose commands stay inside their allowance with no other VM waiting behind several of them in turn behave as before. The UAPI comment for
compute_timeout_msis updated to say which command is settled once the excuse is used up.Testing
run-host-tests.py --only g17): 90/90.g17-ray-query-timeout-tests: 36 passed, three new:an_exhausted_excuse_charges_the_blocker,a_blocker_waiting_on_the_waiting_vm_keeps_its_allowanceandblockers_taking_turns_lose_their_allowance_not_the_waiting_job. Against the oldtimeout.rs(with aforfeits()that never fires) all three fail, the last with the waiting job ending inSpare.g17-compute-owed-stamp-testsnow also models the new lookup (46 passed).drivers/gpu/drm/asahi/.kunitconfig), integration/aurora 110861f plus this branch and the G17 watchdog change submitted alongside it:Ran 374 tests: passed: 372, skipped: 2, no new warnings in the touched files.checkpatch.pl: no warnings.Still to run
Tested: run-host-tests --only g17 233/233 at 223077c (new case a_forfeited_blocker_is_failed_and_killed_on_timeout, mutants forfeit-spared/forfeit-unclassified killed); KUnit asahi 493/497 (4 skip); fleet-config asahi build OK. Hardware rows still owed (see the comments).
Risk: G17 compute watchdog on M4 Pro/Max, M5, A18 Pro; only a queue whose allowance was forfeited behaves differently (its command fails and its VM is lost, on M5 it is killed); queues inside their allowance with nobody waiting behave as before.