Repository navigation
drm/asahi: g17: kill a closed VM the watchdog failed, spare the work behind it - #3644
Conversation
d8e1c27 to
37445a5
Compare
On the M4 Pro on 2026-11-29 (06:59 UTC) the host watchdog failed a compute command of VM 43620 as its own after 30.7 s at the head of its queue. No GPU recovery ran. Its owner closed, but its context was never killed: every kill route first needs the context's render pairs to count as idle for the kill (teardown_idle, counts_idle), and a quarantined pair whose groups never ran counts only when a GPU recovery found its VM guilty (guilty_unretired needs recovery_guilty). Its hung command held the GPU, and every later VM's watchdog deferred behind its publication and then failed for an hour, until a reboot. Compile the production teardown_idle, idle_for and counts_idle, and the Pair predicates they read, against host stubs. Check that a guilty closed VM is killable and that an open owner's or a healthy VM's pair is not, and that a closed VM the watchdog failed with no recovery is killable too. The last check fails on the current code: the harness is registered as expected to fail until the fix. How such a pair is released after its kill, and whether later VMs are spared behind it, are left out on purpose: those rules are still open. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
A closed context's published work leaves the GPU on 25G83 only through its ContextKill: the host cannot take published work back. Every kill route first needs each of the context's render pairs to count as idle for the kill (teardown_idle). A quarantined pair whose groups never ran counted only when a GPU recovery had found its VM guilty and a restart had followed the close (guilty_unretired). A VM that failed as its own without a recovery never qualified. On the M4 Pro on 2026-11-29 the host watchdog failed a compute command that had been at the head of its queue for 30.7 s; no recovery ran and its owner exited. Its context was never killed, its command held the GPU, and the watchdogs of every later VM deferred behind its publication and then failed their own work, for an hour until a reboot. A closed owner's quarantined pair holding a failed VM's published work now counts for the kill decision without a restart when no recovery blamed the VM; a recovery-guilty VM still waits for a restart since the close. As for a guilty pair it never counts for the release: its groups go only after the kill is done and a later restart has completed (guilty_kill_done), whether or not the kill alone stops a running command. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
A watchdog that finds its work behind another VM's older unfinished work renews it up to MAX_RENEWALS times. Behind a blocker that had already failed it then failed the work as its own: such a blocker was expected to be drained by the firmware soon. A failed VM whose owner closed is drained only by the kill of its context, so until that kill is done the work behind it is not hung either. On the M4 Pro on 2026-11-29 every later VM's work behind a VM the watchdog had failed was failed as its own in turn (ETIMEDOUT, a lost device), for an hour. Mark a failed head whose owner closed and whose kill the firmware has not finished (scheduler page, Context::kill_pending). Work behind such a blocker is renewed like work behind an excused live blocker, within the waiting job's excuse limit; once its grace is spent it is spared, not failed as its own, so its VM keeps working. When the kill is done the usual rules apply again. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
The kernel closes, on its client's behalf, a queue whose VM a GPU recovery found guilty, so that its pair can be killed once its owner is closed (close_failed_owners). A VM the host watchdog failed as its own was left alone. A client that ignores its lost device, or waits in an error dialog, then keeps its failed work published: its hung command holds the GPU with no restart to free it, its context is never killed, and every other VM's work waits behind it. Close the open client of any VM that failed as its own: one whose status records the failure, set by a recovery or by the watchdog. A bystander that a restart spared or blamed only collaterally keeps a clear status (Completion::poisons), and is not closed. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
close_failed_owners closes the open client of a VM that failed as its own so that its context can be killed, but it found such a VM only through its render pairs. A VM with compute queues only and an open client was left alone: its hung command held the GPU, its context was never killed, and every other VM's work waited behind it. Walk the compute queues too: an open owner's quarantined queue whose VM's status records a failure (a recovery found it guilty, or the host watchdog failed its command) closes its context the same way. A context found through both a pair and a queue is closed once. A bystander that a restart spared or blamed only collaterally keeps a clear status and is not closed. The close publishes nothing itself: the context's kill takes the same gate as an exited client's (foreign_compute_running). Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
The render owed-stamp harness compiles the render watchdog's head classification, which now reads Context::kill_pending and fills timeout::Head's kill_pending field. Give its Context stub a kill_pending that reports no pending kill, and set the field in its two Head literals. None of its cases has a closed failed context awaiting a kill. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
… page word Context::kill_pending spares the work waiting behind a closed failed context's published work until that context's kill is done. It ends the pending kill once the scheduler page's killed word reads nonzero. On the M4 Pro the word read set before the host could have seen a kill's acknowledgement, so the page word does not prove that this kill finished. Add g17-kill-pending-tests.py. It compiles the production Kill and the Context kill methods against a stub scheduler page and checks: - the kill is pending for a closed context with no kill, with an unacknowledged kill, and after another kill's acknowledgement, whatever the page word says; - it ends on the kill's own acknowledgement. It fails now (registered KILL). Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
…owledged Context::kill_pending spares the work waiting behind a closed failed context's published work (timeout::Head::kill_pending). It ended once the scheduler page's killed word read nonzero. On the M4 Pro the word read set before the host could have seen a kill's acknowledgement. The page word does not prove that this kill finished, and the waiters were then timed out as their own failure. End it only once a kill of the context was published and the firmware acknowledged it with its own ContextKilled event (Context::kill_acknowledged). A closed context with no kill published yet stays pending, as before. g17-kill-pending-tests.py now passes. Mutation page-word, which restores the page word, is caught. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
37445a5 to
2637a9f
Compare
No conflict. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: MERGE at 17c3125
Checked: Reviewed the first failed-owner close, teardown admission and release ordering, compute-only owners, and acknowledgement-driven pending state. The exact owner-kill and pending-state suites each passed all three controls, and kill routing passed 17/17. All four mutation controls were rejected. The watchdog decision spares waiting work after bounded renewals rather than poisoning its VM while the blocker is awaiting its kill. The J616s backport evidence remains separate from the exact-head hardware requirement.
|
Code-owner notice for @aurora-silicon/core @aurora-silicon/aurora-maintainers: |
|
Hardware row at exact head
|
|
Merging under the six-point gate ( |
What: A VM that the host watchdog failed as its own, with no GPU recovery, could never be killed once its owner closed. Its hung command then held the GPU, and every later VM's work behind it was failed too, until a reboot. This makes such a VM's context killable (released by the existing guilty rule: kill done, then a later restart), closes its client's queue on the client's behalf if the client keeps it open, and spares work waiting behind a failed VM whose kill is still pending instead of failing it as its own, until the firmware acknowledges that kill. It builds on #3652's kill state (merged).
Tested: no exact-head Mac run yet at 17c3125. Backport, not an exact-head row: test kernel m4.235 carried commits 1-5, picked from the PR head, with #3652 (including 504a550) and an earlier copy of commit 8 (the same driver change); on the J616s, 2026-12-04 23:59 to 12-05 00:01:44 UTC, a 120 s gpubench load (life.spinkill) whose clients spin until the host watchdog fails their command, then exit: PASS. The watchdog failed 4 VMs as their own, each client's open queue was closed on its behalf (commits 4-5), and each context was then killed: 4 kills published, all 4 acknowledged in 32-49 µs; 0 recoveries, 0 firmware crashes. No work waited behind those VMs, so commit 3 did not act. Earlier heads ran in test kernels on the M4 Pro without a crash, but no load there failed GPU work and then killed. KUnit at 17c3125 (main 0679d3d merged in, no conflict): 1115 run, 1114 pass, 1 skip. All tools/asahi g17-* and neo-* host harnesses pass (61/61). Host harnesses pass, including the new g17-failed-owner-kill, which is red on main and green here.
Risk: two-way door · G17 Macs: the kill rule applies on M4 Pro (J616s) and A18 Pro (Neo), not M5; the spare rule applies to every G17 watchdog
Not yet: a hardware run at the exact head; commit 3 (work waiting behind a failed VM whose kill is pending) acting on hardware.
Details
The wedge (M4 Pro, 2026-11-29). The host watchdog failed a compute command that had been at the head of its queue for 30.7 s ("failed as its own"). No recovery ran. Its process exited. From then on, every new client's render and compute watchdog deferred behind that publication (
blocker_failed=1 blocker_in_allowance=0), then failed its own work afterMAX_RENEWALS(ETIMEDOUT, a lost device). Each of those dead clients stayed quarantined in turn. After an hour, 15 render pairs sat atquarantined=1 active=2 killed=0, with not one kill published (render_kills published=0).Why no kill. On 25G83 the host cannot take published work back; only a ContextKill (and the restart it raises) removes it. Every kill route first needs
teardown_idle: each of the context's render pairs must count as idle for the kill (counts_idle). A quarantined pair whose groups never ran counted only throughguilty_unretired, which needsrecovery_guilty, set only by a GPU recovery, plus a restart since the close. A VM failed by the host watchdog alone never qualified.Commit 2, the kill.
guilty_unretired's VM condition becomeskill_unretired. A recovery-guilty VM still waits for a restart since its close, as before. A VM that failed as its own (status.get() != 0, not recovery-guilty) counts as soon as its owner closed. It feeds only the kill decision; the release side is unchanged. The pair's groups go only after the kill is done and a later restart has completed (guilty_kill_done), whether or not the kill alone stops a running command.Commit 3, the waiters.
timeout::Headgainskill_pending: the head failed, its owner closed, and the firmware has not finished the context's kill (scheduler page; an unreadable page counts as pending). Work behind such a blocker is renewed like work behind an excused live blocker, within the waiting job's excuse limit. Once its grace is spent it is spared (non-sticky), not failed as its own. When the kill is done the old rules apply again.Commit 4, an open client.
close_failed_ownerscloses, on its client's behalf, the queue of a VM that failed as its own (Pair::failed_vm: quarantined, status set by a recovery or by the watchdog), not only of a recovery-guilty one. A client that ignores its lost device then no longer keeps its hung work published. A bystander a restart only spared or blamed collaterally keeps a clear status (Completion::poisons) and is not closed.Commit 5, compute-only VMs.
close_failed_ownersalso walks compute queues (compute::Queue::failed_open_owner: an open owner's quarantined queue whose VM's status records a failure), so a failed VM with compute queues only and an open client is closed and becomes killable, for recovery-guilty and watchdog-failed VMs alike. A context found through both a pair and a queue is closed once; the close step is shared (close_for_open_client). The close publishes nothing itself: the context's kill takes the same gate as an exited client's (foreign_compute_running).Commit 8, the end of a pending kill.
Context::kill_pendingended once the scheduler page's killed word read nonzero. On the M4 Pro that word read set before the host could have seen a kill's acknowledgement, so it does not prove the kill finished, and the waiters could be timed out as their own failure. It now ends only once a kill of the context was published and the firmware acknowledged it (Context::kill_acknowledged, on #3652's kill state). A closed context with no kill published yet stays pending, as before.Known limits.
Evidence
Hardware, backport (not the exact head). Test kernel m4.235 on the M4 Pro (J616s, 25G83): commits 1-5 and #3652 including 504a550, picked from the PR heads (driver code identical by patch-id; only host-harness registry context differs), plus an earlier copy of commit 8 (same driver change) and local kill diagnostics. life.spinkill, 120 s, 2026-12-04 23:59:18 to 12-05 00:01:44 UTC: PASS.
Head
17c31256244b: main0679d3d01ddamerged into2637a9ff604b(no conflict).2637a9ff604b: commits 1-6 rebased onto mainf02bd68a08cb, which contains #3652 (only registry context changed, driver code identical by range-diff), then commits 7-8. Commit 6 is a stub commit for main's newer g17-render-owed-stamp harness, which compiles the watchdog head classification and now needsContext::kill_pendingandHead.kill_pending.tools/asahi/g17-failed-owner-kill-tests.pycompiles the productionteardown_idle,idle_for,counts_idle,kill_unretiredand the Pair predicates against host stubs. Reference cases pass (a guilty closed VM is killable; an open owner's or a healthy VM's pair is not). The watchdog-failed case fails at the first commit (registered as KILL there) and passes with the fix. Mutationguilty-only(the old rule) is caught. The open-client case (commit 4) fails at9c00ecc2ff64(an open client of a VM the watchdog failed is never closed for it) and passes here; mutationclose-guilty-onlyis caught. A spared, collaterally blamed bystander's open queue stays open in the same run.tools/asahi/g17-kill-pending-tests.py(commit 7, red there: registered KILL) compiles the productionKilland theContextkill methods against a stub scheduler page. A closed context's kill is pending with no kill, with an unacknowledged kill and after another kill's acknowledgement, whatever the page word; it ends on its own kill's acknowledgement; an open context's never is. Passes at commit 8; mutationpage-word(the old rule) is caught.17c31256244b. New cases:asahi_g17_render_guilty_kill.a_vm_failed_as_its_own_is_killable_without_a_restartandasahi_g17_execution_allowance.work_behind_a_closed_failed_blocker_awaiting_its_kill_is_renewed_then_spared.run-host-tests.py --onlyeach (the option keeps its last value, so one run per job): g17-failed-owner-kill 3/3, g17-kill-route 13/13 (new mutationclose-pairs-onlycaught), g17-object-fence 15/15, g17-compute-owed-stamp 18/18 (its stubs gain the new field).a_compute_only_failed_vm_with_an_open_client_is_closedfails before it (the queue predicate does not exist) and passes at the head; it also asserts that a spared bystander's compute queue is not closed.tools/asahi/g17-*andneo-*harnesses: 47/48. g17-compute-owed-stamp's stubs needed the newHeadfield andContext::kill_pending, and pass with them. The 1 failure, g17-output-fence, fails the same way on mainde965eb5b26b(fn member_done(matches twice in fence.rs).