Skip to content

drm/asahi: g17: kill a closed VM the watchdog failed, spare the work behind it - #3644

Merged
RyanTheTide merged 9 commits into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-failed-owner-kill
Dec 5, 2026
Merged

RyanTheTide merged 9 commits into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-failed-owner-kill

Conversation

@jgoyvaerts

@jgoyvaerts jgoyvaerts commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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 after MAX_RENEWALS (ETIMEDOUT, a lost device). Each of those dead clients stayed quarantined in turn. After an hour, 15 render pairs sat at quarantined=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 through guilty_unretired, which needs recovery_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 becomes kill_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::Head gains kill_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_owners closes, 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_owners also 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_pending ended 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.

  • Not known: whether a kill alone stops a hung compute command (until a later restart the pair stays held either way).
  • If the watchdog failed a command that was only slow and would have finished, the kill unlinks the pair's queued groups. The pair is then held until the next GPU restart (or processor stop), because the guilty release needs a restart after the kill.
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.

  • 4 watchdog give-ups, each on a compute command 30.7 s at the head of its queue; each client saw a lost device.
  • 4 "closed for its open client ... its VM failed as its own": the close of commits 4-5.
  • 4 kills through the compute exit, 250 ms after each close, acknowledged 32-49 µs after publication; each killed context's idle compute queue was released only after its kill's acknowledgement (drm/asahi: g17: hold a compute pool release until its context's kill is acknowledged #3652).
  • 0 recoveries, 0 GPU faults, 0 firmware crashes; no waiter was excused or spared (commit 3 did not act).

Head 17c31256244b: main 0679d3d01dda merged into 2637a9ff604b (no conflict). 2637a9ff604b: commits 1-6 rebased onto main f02bd68a08cb, 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 needs Context::kill_pending and Head.kill_pending.

  • tools/asahi/g17-failed-owner-kill-tests.py compiles the production teardown_idle, idle_for, counts_idle, kill_unretired and 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. Mutation guilty-only (the old rule) is caught. The open-client case (commit 4) fails at 9c00ecc2ff64 (an open client of a VM the watchdog failed is never closed for it) and passes here; mutation close-guilty-only is 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 production Kill and the Context kill 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; mutation page-word (the old rule) is caught.
  • KUnit, arm64 qemu, asahi kunitconfig: 950 run, 949 pass, 1 skip (earlier head); 1115 run, 1114 pass, 1 skip at 17c31256244b. New cases: asahi_g17_render_guilty_kill.a_vm_failed_as_its_own_is_killable_without_a_restart and asahi_g17_execution_allowance.work_behind_a_closed_failed_blocker_awaiting_its_kill_is_renewed_then_spared.
  • run-host-tests.py --only each (the option keeps its last value, so one run per job): g17-failed-owner-kill 3/3, g17-kill-route 13/13 (new mutation close-pairs-only caught), g17-object-fence 15/15, g17-compute-owed-stamp 18/18 (its stubs gain the new field).
  • Commit 5's case a_compute_only_failed_vm_with_an_open_client_is_closed fails 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.
  • All tools/asahi/g17-* and neo-* harnesses: 47/48. g17-compute-owed-stamp's stubs needed the new Head field and Context::kill_pending, and pass with them. The 1 failure, g17-output-fence, fails the same way on main de965eb5b26b (fn member_done( matches twice in fence.rs).

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>
@jgoyvaerts
jgoyvaerts force-pushed the m4pro/g17-failed-owner-kill branch from 37445a5 to 2637a9f Compare December 5, 2026 01:14
No conflict.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
@jgoyvaerts
jgoyvaerts marked this pull request as ready for review December 5, 2026 04:32
@jgoyvaerts
jgoyvaerts requested review from a team and DjDeveloperr as code owners December 5, 2026 04:32
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Merge readiness at 17c31256: not ready yet

Check Detail
CI at head ok 11 checks passed
Review no approved by aurora-silicon-review, but GitHub does not count it yet (code owner from Core, Omarchy Mac or Aurora Maintainers needed, or approval went stale)
Requested changes ok none
Hardware row at head ok comment at 17c31256
Conflicts ok none
PR text ok Risk: two-way · G17 Macs: the kill rule applies on M4 Pro (J616s) and A18 Pro (Neo), not M5; the spare rule applies to every G17 watchdog

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Code-owner notice for @aurora-silicon/core @aurora-silicon/aurora-maintainers: aurora-silicon-review APPROVED at exact head 17c31256244b (drm/asahi: g17 kill closed VM) with all CI checks green. Bare-metal M4/M5 hardware validation is running now; starting the 1-hour code-owner notice window before merge.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Hardware row at exact head 17c31256244b — PASS (MacBook Pro 14" M5 Pro K114s, T6050, G17S B1, Aura 1.0.0b19, sysfw 27.2, Fedora 44).

  • Boot: Guarded one-shot trial 7.3.0-trb-b5 (c1c4d8a2646e incl. #3644 17c31256244b), boot_id=0dfe57ef, trial=m1n1/trbtry.bin, SELinux=Enforcing, failed=0, 0 oops/BUG/WARNING/SError/GPU faults; speakers silent; no default-boot/Stage1/1TR/LocalPolicy change.
  • Exercised on bare-metal G17S B1 (/var/lib/aurora-test/bsync-kit/bin/gpubench-vk):
    • 3x mid-flight SIGKILL of active render.heavy --depths 4 Vulkan clients to exercise closed-VM teardown/kill path, immediately followed by render.light --depths 1,4 verification -> POST_SIGKILL_CLOSED_VM_VERIFY=PASS, 0 GPU/DART faults or firmware hangs.
    • Full render.light (9,886 + 66,902 submits), render.heavy (133 + 136 submits), compute.edge (464 + 477 submits, CRC 27c79e6d == 27c79e6d, valid: true), and 10/10 short-lived Vulkan clients all passed (status: ok).
    • Cleanly restored K114s to saved 7.3.0-1675a62307d2-47318133913.1-aurora-edge.
  • Trace: /Volumes/AuroraS500/traces/kernel/20261205-test-rows-b-batch5/k114s-gpu-targeted.log (tainted: no).

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 5, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging under the six-point gate (--merge --admin): CI 100% green at exact head 17c31256244b, aurora-silicon-review APPROVED at exact head (0 open CRs), bare-metal K114s G17S B1 3x SIGKILL closed-VM stress + post-kill verify PASS (#issuecomment-7436842703), 1-hour code-owner notice window elapsed since 10:50Z, no taint, no Stage 1/1TR/LocalPolicy/default-boot change. Revert path: git revert -m 1 the merge commit on main.

@RyanTheTide
RyanTheTide merged commit 861459a into aurora-silicon:main Dec 5, 2026
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants