Skip to content

drm/asahi: enable two render pairs per queue on G17C - #2553

Merged
DjDeveloperr merged 2 commits into
mainfrom
j716c/g17c-two-render-pairs
Nov 24, 2026
Merged

DjDeveloperr merged 2 commits into
mainfrom
j716c/g17c-two-render-pairs

Conversation

@erikwb

@erikwb erikwb commented Nov 20, 2026 •

Copy link
Copy Markdown

Problem

On 4-cluster M5 Max (G17C, J716c), each logical render queue is limited to a single physical render pair, unlike 8-cluster G17D which uses two pairs. Across back-to-back deep render submissions, one physical render ring leaves the wider 40-core shader array underutilized.

Enabling two pairs per owner also exposes admission accounting edges under multi-queue and mixed render/compute load: idle siblings—including siblings that have already published work and subsequently drained—must yield rather than halve logical queue capacity, shrinking render capacity after compute growth must not let warmed siblings promote past the remaining first-pair budget, and idle unpublished siblings filling the QID table must yield to fresh compute channels.

Change

  • Enable two physical render pairs per logical render queue at board.clusters >= 4 (drivers/gpu/drm/asahi/g17/pairs.rs), covering 40-core G17C and 80-core G17D (8-16 GiB render-pool inventory). Narrower M5 parts (1-cluster J813, 2-cluster J714, 2-4 GiB inventory) stay at one pair per queue to avoid the extra per-pair ring/graph/parameter-buffer footprint and doubled ray-query render-pool extras (fw::render_rt::required_blocks) until measured.
  • Preserve full logical queue capacity under both unpublished and drained published sibling claims:
    • Track explicit firmware publication in admission (State::published) via State::mark_published(), shared by Pool::note_published() and RenderLease::note_publication(), gated on a live, unclosed slot (!closed / owners[slot] != 0 && released & bit == 0) so a slot released while a lease is out off-lock cannot have published re-set.
    • Count only non-reclaimable live siblings (busy or in-flight) and teardown-held released pairs in Pool::pair_demand() / Pool::render_demand().
    • Allow idle, drained published siblings (no active lease/refs, no in-flight footprint, Pair::detachable() true, owner retains another usable pair, and owner context is not releasing) to detach on demand in reclaim_unused_render_sibling() and reclaim_unused_render_spare() via Pool::release_unused_sibling(slot, expected, true) + Pair::release_owner(), keeping the installed QIDs (owners[slot] retained with released |= bit and published cleared) in sync with entry.reservation.owner and entry.context until a new queue claims the released slot via acquire_render() and rebinds it via bind_owner(). Also skip spare reclamation when the caller already owns a live pair. When a later owner rebinds a detached slot whose prior owner is still open, rebind_pair() passes entry.closed to teardown.displace(), entering Phase::Deferred so the live owner's scheduler stays active and its displaced backing retires when that owner later closes.
    • Keep owners/released invariants clean in release_unused_sibling(..., keep_installed): keep_installed == true retains owners[slot] and sets released |= bit (matching release_owner() on close), while keep_installed == false clears both owners[slot] and released.
  • Prevent over-commitment when compute shrinks render_capacity:
    • Gate every lease that would promote a reclaimable sibling into protected demand (acquire_for, join_for, can_pick_for, warmable_sibling) against render_capacity under the admission lock.
  • Keep compute admission live when idle unpublished siblings fill the QID table:
    • Account for cancelable unpublished render spares in QueueIds::compute_fits_with_reclaim(), Registry::compute_qid_fits(), rebind_compute(), compute_readiness(), and reserve_compute_reclaiming(), dropping reclaimed backing after releasing the device mutex.
  • Protect current pair demand above queue_limit(floor) in QueueIds::compute_room() while capping future queue headroom at FULL_RENDER_RESERVE - floor, and size QueueIds::reserve() for queue_limit(floor) so floored tables retain compute capacity.
  • Extend KUnit tests (asahi_g17_two_pairs, asahi_g17_shared_capacity, asahi_g17_qid_accounting) to cover published sibling detachment up to full logical queue capacity, busy published protection vs idle published reuse, Pool::note_published() and RenderLease::note_publication() no-op on released slots, compute-shrink sibling gating, full-table compute admission over cancelable siblings, teardown-held pairs, and compute reserve above MAX_EXECUTION_CONTEXTS; update G17 host tests and add spare_detach_keeps_exit_kill_ownership (--mutation spare-detach-reassigns) in tools/asahi/g17-admission-order-tests.py.

Testing

Host and KUnit verification on f3497c695381:

  • python3 tools/asahi/run-host-tests.py --only g17- --jobs 16: 91/91 passed (including g17-admission-order-tests --mutation spare-detach-reassigns, g17-admission-deadline-tests, g17-quarantine-drain-tests, g17-pool-release-tests, and g17-resource-tests).
  • python3 tools/asahi/run-host-tests.py --only asahi- --jobs 16: 3/3 passed (asahi-g15, asahi-m4, asahi-stats-raw-tests).
  • KUnit asahi_g17* in arm64 QEMU (drivers/gpu/drm/asahi/.kunitconfig): 269/269 passed.
  • CONFIG_KUNIT=n arm64 LLVM=1 Rust 1.99.0 build of drivers/gpu/drm/asahi/: clean (0 errors, 0 new warnings).
  • scripts/checkpatch.pl --no-tree -g f5931f9a2adf..HEAD: 0 errors, 0 warnings.

J716c (M5 Max, G17C, 128 GB RAM, firmware 27.2) on f3497c695381 applied to integration/aurora f5931f9a2adf plus #2185 and #2187 (G17C GPU and display on firmware 27.2, which f5931f9a2adf alone does not admit), with the machine's daily boot arguments:

  • Boot: G17C GPU firmware admitted, capacity crashed=0, and every render context reports render_total=2 (two pairs per logical queue on G17C).
  • Multi-client queue-creation stress (each Vulkan client submits 6 back-to-back deep render passes, waits until they drain, and then stays open and idle while the next client opens): 55 clients plus the compositor's 2 queues reached 58/58 logical queues, and the 56th client was refused at the logical-queue cap. The only refusals were LogicalQueues=2, both at that cap. Peaks: render slots 60/63, parameter buffers 87/127, retired_render_bindings 26/128. Sustained churn (60 rounds, each closing one random client and opening a new one, 55 open): 60/60 opened, retired_render_bindings at most 27/128, parameter buffers at most 87/127, drained_render_pairs failures=0 recovered=0. After all clients closed: logical queues 3/58, render slots 2/63 (61 retained), parameter buffers 2/127; a new client still opens and renders.
  • dEQP-VK.api.object_management.* (vk-default mustpass, 457 cases): 453 Pass, 4 Warn (alloc_callback_fail.{descriptor_set_layout,pipeline_layout}_{empty,single}), 0 Fail.
  • Cyberpunk 2077 T2 (2560x1600 High, same Mesa/FEX/settings as the table below), head only: pass 1 19.94 avg / 17.18 min / 23.31 max / 13.64 1% low mean / 64.52 ms p99; pass 2 21.73 / 18.82 / 25.36 / 15.27 / 56.72 ms. The GPU stayed at pstates 12-13. These numbers come from a different kernel tree than the table below, so they do not compare with it.
  • Regression counts on that boot: 0 GPU recoveries, no new GPU kernel errors (the boot errors match the daily kernel's: DCP lane count, SEP sensor, PCIe IRQ parse), systemctl --failed shows only aurora-peripherals.service, which fails the same way on the daily kernel. SELinux: N/A (not installed).

Pre-reclamation hardware A/B on J716c (M5 Max, Borealis Mesa t2-ubo64-2636c4762529, FEX nov17-pr-null-profile, Cyberpunk 2077 T2 benchmark, 2560x1600 High, upscaling/FG/RT/VSync off):

Build Avg FPS Min FPS Max FPS 1% low mean p99 FPS (p99 frametime)
base (1 pair on G17C) 38.38 32.72 46.00 29.51 31.05 (32.21 ms)
PR, pre-reclamation (2 pairs on G17C), run 1 38.94 33.48 46.58 30.53 31.76 (31.49 ms)
PR, pre-reclamation (2 pairs on G17C), run 2 38.79 33.20 46.60 29.77 31.51 (31.74 ms)

Delta on that pre-fix build: +0.41 to +0.56 FPS (+1.1% to +1.5%) average and +0.26 to +1.02 FPS 1% low mean.

Still to run

  • J716c: dEQP-VK.renderpasses.* and dEQP-VK.synchronization*.
  • J714 (2-cluster M5) and G17P (Neo or J616s): regression smoke check confirming unchanged single-pair selection and admission behavior (try_reserve_queue_reclaiming() and QueueIds::compute_room() affect all G17 backends).

@RyanTheTide

Copy link
Copy Markdown

host-tests fails in tools/asahi/g17-resource-tests.py line 24 (admission_tests): it asserts that the driver still has const G17D_PAIRS: u8 = RENDER_PAIRS_MAX as u8;. This PR changes the per-queue render-pair setup, so the test's expected text needs updating in the same PR (or the assertion moved to whatever now defines the G17D pair count).

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb
erikwb force-pushed the j716c/g17c-two-render-pairs branch from 2b86d99 to 746e388 Compare November 21, 2026 00:30
@erikwb

erikwb commented Nov 21, 2026

Copy link
Copy Markdown
Author

Note

🤖 Claude Opus 5.5 responding on behalf of erikwb

Fixed in 746e388. host-tests now gives the same results as the base.

  • tools/asahi/g17-resource-tests.py asserts the new pair selection (MULTI_PAIRS, g17d_forms() || clusters >= 4) and extracts the new admission helpers (acquire_for, pair_demand, live_owners, live_siblings, unavailable_released).
  • Four more host tests were broken by this PR's API changes: g17-admission-order, g17-admission-deadline, g17-pool-release and g17-quarantine-drain. They are fixed the same way. g17-admission-order --mutation no-held-sibling had stopped failing: the new capacity check returns before the held-slot mask in the crowded table, so I added a case with spare pair capacity where only the held mask keeps slot 5 out.
  • Fixing the QID test turned up a real bug. QueueIds::reserve() passed MAX_EXECUTION_CONTEXTS as the demand, and with this PR's "always protect 2 * pairs + 2" rule it reserved 118 QIDs on a qid_floor 32 table (96 host QIDs), leaving compute none. It now uses queue_limit(self.floor), the most queues that table can open. Production compute goes through reserve_for() with live demand, and production reserve() callers allocate tiling and fragment IDs only, so this is the default path only.

@RyanTheTide

Copy link
Copy Markdown

Re-review of 746e388: Blockers: 1.

Our last point is resolved. tools/asahi/g17-resource-tests.py:24 now asserts the new selection line, and at this head g17-resource, g17-admission-order, g17-admission-deadline, g17-pool-release and g17-quarantine-drain all pass. g17-admission-order --mutation no-held-sibling fails again, as it should. We had only flagged CI before, so this time I read the whole commit.

  1. Blocker. drivers/gpu/drm/asahi/g17/queue/admission.rs:300-305 counts every live sibling in pair_demand(), and try_reserve_queue() (:702-703) refuses a new logical queue once that demand fills render_capacity. Siblings are still claimed eagerly: acquire_for() calls claim_sibling() on an owner's first render whenever surplus exists (:251, :290). A sibling that claim_sibling() has only recorded (owners[slot] = owner, nothing built) counts too, and reassign_unused_spare() (:348) could hand that one to a new owner. On a multi-pair part, the first clients therefore take siblings while the table has room, and later clients get ENOSPC at queue creation once siblings fill it. That can happen at about half the queue count that was admitted before. The new KUnit test asserts exactly that (:1752, "a second queue is refused"). Before this change a sibling came only from surplus and gave way to a first pair. Fix: before refusing in try_reserve_queue() and in the render_fits(render_demand(1)) check (g17/runtime.rs:801), take back a sibling that is unbuilt or idle (the reassign_unused_spare() path). Count only siblings that cannot be given back, such as busy or quarantined ones, in pair_demand(). Add a test that opens more queues than render_capacity / 2 with siblings claimed and expects them all to be admitted.

  2. drivers/gpu/drm/asahi/g17/pairs.rs:29: board.clusters >= 4 reads a probed hardware value, since g17/mod.rs:1675 checks it against the GPU's reported cluster count. But the threshold is not explained. Nothing in the commit says why two pairs are right at four clusters and wrong at two (J714) or one (J813). If two pairs are correct on every M5 GPU, enable them for all of them and measure J714. If they are not, put the reason, a measured cost or a firmware limit, in the commit message next to the threshold.

  3. Attribution. The commit body has "Developed with Claude Code." Commit messages should carry only the human Signed-off-by, so drop that line. The PR body ends with "Created with Antigravity (reviewed with ...)" where the disclosure line is expected, Assisted-by: LLM (<Vendor>:<Model>).

  4. Evidence. "Booted and benchmarked on J716c with Cyberpunk 2077" gives no numbers and no conformance run. Some changes reach every G17 GPU, not only the multi-pair parts: try_reserve_queue(), the compute reserve in QueueIds::compute_room() (g17/kick.rs:172-189), and counting teardown-held released pairs. The same-owner cross-pair ordering in firmware (g17/hazard.rs) has so far only run on G17D, and with this change it also runs on G17C.

HW row: J716c (M5 Max) on this head against its base, one boot each: dEQP-VK.renderpass*, dEQP-VK.synchronization* and dEQP-VK.api.object_management.*, plus a client-count test that opens render queues until refused. Pass: no new failures, a refusal count no lower than on the base, and 0 GPU recoveries, 0 failed units, 0 new kernel errors. Repeat the same no-change row on J714 (M5 Pro) and a G17P Mac (Neo or J616s), because the admission accounting changes there too. Add the Cyberpunk numbers (average and 1% low, base against head).

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb
erikwb force-pushed the j716c/g17c-two-render-pairs branch from 746e388 to de71b89 Compare November 22, 2026 01:30
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Addressed all four points in de71b8971f67:

  1. Queue capacity under eager sibling claims: Pool::pair_demand() now counts only non-reclaimable siblings (busy, published, quarantined, or held) alongside open queues and teardown-held released pairs, and Backend::new() / Pool::try_reserve_queue_reclaiming() reclaim idle unpublished siblings (unbuilt, parked, reusable, or warmed unpublished with backing dropped off the device mutex) before refusing a new logical queue with ENOSPC. Also added explicit State::published tracking so sibling leases dropped before publication remain reclaimable, gated reclaimable-sibling promotion against shrunk render_capacity after compute growth, and updated compute readiness/reservation to account for cancelable unpublished render spares on a full QID table. Covered by new KUnit tests (idle_siblings_yield_to_open_queues_up_to_full_capacity, unpublished_sibling_lease_drop_stays_reclaimable, compute_shrink_gates_warmed_sibling_promotion, cancelable_siblings_do_not_block_compute_on_full_qid_table) — 268/268 asahi_g17* KUnit tests, 90/90 G17 host tests, and CONFIG_KUNIT=n build all pass.
  2. clusters >= 4 rationale: simplified pairs::select_board() to board.clusters >= 4 alone and documented the hardware basis (40-core G17C and 80-core G17D with 8–16 GiB render-pool inventory vs 1-cluster J813 and 2-cluster J714 with 2–4 GiB inventory and doubled ray-query render-pool extras) in g17/pairs.rs, the commit message, and the PR body.
  3. Commit and PR attribution: stripped Developed with Claude Code. from the commit (human Signed-off-by only) and rewrote the PR body to the standard prose sections ending with a single Assisted-by: line.
  4. Hardware evidence: added the pre-fix J716c Cyberpunk 2077 T2 A/B numbers (38.38 → 38.79–38.94 FPS avg, 29.51 → 29.77–30.53 FPS 1% low mean on Borealis) and listed the post-reclamation hardware matrix (dEQP-VK.renderpass*, dEQP-VK.synchronization*, dEQP-VK.api.object_management.*, live multi-client queue capacity stress test, and clean-base vs head Cyberpunk A/B across J716c, J714, and G17P) under Still to run.

@RyanTheTide

Copy link
Copy Markdown

Re-review of de71b89.

Earlier points:

  • Sibling capacity: partly fixed. Unbuilt, parked and warmed-but-unpublished siblings now give way before ENOSPC (g17/queue/admission.rs:404, :891, g17/runtime.rs:830-860), and the can_lease_slot() gate against a shrunk render_capacity looks right. A sibling that has been published once still cannot be given back until its owner closes: reclaimable_siblings_in() excludes published (admission.rs:333), reclaim_sibling() skips it (:534), and published is only cleared on ownership change or release_owner() (:1176). Any render on the sibling sets it (g17/runtime/render/submit.rs:840). That is the normal state for a client that actually used both pairs, so idle clients that rendered deep once still hold two pairs each and later clients get ENOSPC at about half the earlier queue count. The test at admission.rs:2174 asserts this ENOSPC. Please give back an idle published sibling (no lease, no in-flight footprint) through the released-pair path release_owner() already uses, for that one slot, and extend idle_siblings_yield_to_open_queues_up_to_full_capacity so the siblings are published before the extra queues open. If firmware does not allow this, say so in the commit message and give the measured queue limit on J716c.
  • clusters >= 4: fixed, the reason is now in g17/pairs.rs:14-19 and the commit message.
  • Attribution: fixed.
  • Evidence: still open. The Cyberpunk table is from the pre-reclamation build, and the body says nothing has run on this head.

HW rows needed on de71b89 against its base, one boot each: J716c with dEQP-VK.renderpass*, dEQP-VK.synchronization*, dEQP-VK.api.object_management.*, a client-count test that opens render queues until refused (with each client rendering on both pairs first), and the Cyberpunk A/B. Pass: no new failures, a refusal count no lower than the base, 0 GPU recoveries, 0 new kernel errors. The same no-change row on J714 and on a G17P Mac (Neo or J616s), because try_reserve_queue_reclaiming() and QueueIds::compute_room() (g17/kick.rs:182) change admission there too.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr 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.

Adversarial review of de71b897 against the pre-PR checklist.

Checklist summary

  • §1 (No model gating): Pass — board.clusters >= 4 (drivers/gpu/drm/asahi/g17/pairs.rs:29) uses the probed cluster count, and the commit message / doc comment explain the 4+ cluster render-pool inventory and ray-query footprint rationale.
  • §2–§4, §6: Pass — default cmdline, human author/committer + human Signed-off-by: only, PR body carries Assisted-by:, Borealis naming clean, host-tests green.
  • Code/capacity logic: 1 blocker remaining below.
  • §5 (Hardware evidence): Still owed on current head.

Blocker

  1. Idle published siblings still permanently pin pairs and halve logical queue capacity:
    • State::published (drivers/gpu/drm/asahi/g17/queue/admission.rs:96, :1166, :1485) is set on any published render (runtime/render/submit.rs:840, runtime/render/direct.rs:258) and is never cleared until ownership changes or release_owner() runs on queue close (admission.rs:1176).
    • Both reclaimable_siblings_in() (admission.rs:333) and reclaim_sibling() (admission.rs:534) skip slots with published set, and reclaim_unused_render_sibling() (runtime/render.rs:451-458) only yields pair.reusable() (which requires owner.is_none()) or pair.can_yield_unused() (which requires !self.graph_started in queue/render/parked.rs:64).
    • As a result, once clients render deep enough to publish on their second pair even once, those idle siblings remain counted in pair_demand() until the clients close, so later queue creations still hit ENOSPC in Backend::new() (runtime.rs:830) / try_reserve_queue_reclaiming() (admission.rs:919) at roughly half the prior queue limit (currently asserted by unpublished_sibling_lease_drop_stays_reclaimable at admission.rs:2174).
    • Fix: Reclaim idle, drained published siblings (no active lease/refs, no in-flight footprint, idle_for_context() == true, owner retains another usable pair) by detaching the owner on that single slot (pair.release_owner(), marking the slot released, clearing published) so a new queue reuses the installed QIDs through the existing bind_owner() path, and extend idle_siblings_yield_to_open_queues_up_to_full_capacity to publish on the siblings before opening the remaining queues. If a firmware constraint prevents detaching an idle published pair while its logical queue stays open, document that constraint in the commit message and report the measured J716c queue limit.

Non-blocking notes

  • drivers/gpu/drm/asahi/g17/runtime/render/direct.rs:247-259: if entry.closed became true while the pair was lent out, release_owner() already marked the slot released and cleared published; gating if published && !entry.closed avoids re-setting published on a released slot.
  • drivers/gpu/drm/asahi/g17/queue/admission.rs:507-528: release_unused_sibling(..., keep_installed = true) clears owners[slot] = 0 via reassign_unused_spare() and then sets released |= bit. Current callers handle owners == 0 && released != 0 because released is checked before unowned, but it introduces a new state combination worth keeping invariant-clean.

§5 Evidence owed (after fixing the blocker)

  • J716c (G17C) on updated head vs clean base: dEQP-VK.renderpass*, dEQP-VK.synchronization*, dEQP-VK.api.object_management.*, live multi-client queue-creation stress test (after each client publishes on both pairs) confirming refusal count does not regress vs base, same-machine Cyberpunk 2077 T2 A/B on Borealis, and 0 GPU recoveries / 0 failed units / 0 new kernel errors / 0 SELinux denials.
  • J714 (2-cluster M5) and a G17P Mac (Neo or J616s): regression smoke row confirming unchanged single-pair selection and admission behavior (try_reserve_queue_reclaiming() and QueueIds::compute_room() affect all G17 backends).

Assisted-by: LLM (Gemini 4 Neon)

Enable two physical render pairs per logical render queue on 4+ cluster
M5 parts (40-core G17C and 80-core G17D, 8-16 GiB render-pool inventory),
where a single physical render ring underutilizes the wider shader array
across back-to-back deep renders. Narrower M5 parts (1-cluster J813 and
2-cluster J714, 2-4 GiB inventory) keep one pair per queue to avoid the
extra per-pair ring/graph/PB footprint and doubled ray-query render-pool
extras until measured.

Preserve both full logical queue capacity and guaranteed first-pair
capacity when two pairs per owner are enabled:
- Track explicit pair publication (`State::published`) so unpublished
  siblings yield before published ones, and gate `note_published()` on
  a live, unclosed slot so a slot released while a lease was out cannot
  have `published` re-set.
- Allow idle, drained published siblings (no active lease/refs, no
  in-flight footprint, `Pair::detachable()` true, owner retains another
  usable pair) to detach on demand via `Pair::release_owner()` while
  keeping their installed QIDs (`released |= bit`, `owners[slot]` kept
  to identify the previous owner until reuse, `published` cleared) so
  new queues reuse the installed QIDs via `bind_owner()`. When a later
  owner rebinds a detached slot whose prior owner is still open,
  `rebind_pair()` passes `entry.closed` to `teardown.displace()`,
  deferring context teardown until the prior owner closes instead of
  draining its live scheduler.
- Count only non-reclaimable live siblings and teardown-held released
  pairs in `Pool::pair_demand()` / `Pool::render_demand()`, while
  `Pool::try_reserve_queue_reclaiming()` and `Backend::new()` reclaim
  idle siblings (unbuilt, parked, reusable/warmed unpublished, or idle
  drained published) before refusing a new logical queue.
- Gate every lease that would promote an idle reclaimable sibling into
  protected demand (`acquire_for`, `join_for`, `can_pick_for`, and
  `warmable_sibling`) against `render_capacity` under the admission lock
  so compute growth cannot leave an open queue without a first pair.
- Account for cancelable unpublished render spares in compute readiness
  (`compute_qid_fits`) and reservation (`reserve_compute_reclaiming`),
  cancelling one idle unpublished spare before reserving a fresh compute
  QID on a full table and dropping reclaimed backing off-lock.
- In `QueueIds::compute_room()`, cap future queue headroom at
  `FULL_RENDER_RESERVE - floor` while always protecting current pair
  demand (`2 * pairs + 2`), and size `QueueIds::reserve()` for
  `queue_limit(floor)` open queues so a floored table does not lock out
  compute.
- Add KUnit coverage for sibling reclamation up to full queue capacity
  including published siblings, busy published protection vs idle
  published detachment and `note_published` on released slots,
  compute-shrink sibling gating, full-table compute admission with
  cancelable siblings, teardown-held released pairs, and compute reserve
  above `MAX_EXECUTION_CONTEXTS`; update the host tests accordingly.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb
erikwb force-pushed the j716c/g17c-two-render-pairs branch from de71b89 to 76f6062 Compare November 22, 2026 07:52
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Fixed the blocker and both follow-up notes in 76f6062b812e: idle, drained published siblings now detach on demand so logical queue capacity stays at the full single-pair limit even after clients publish work on their second pair.

  • Idle published sibling detachment (blocker): Verified that the existing Pair::release_owner() -> bind_owner() -> Pair::switch() path and teardown.displace() Phase::Deferred state already support detaching a single published pair from a live owner without draining its scheduler.
    • Added Pair::detachable() (drivers/gpu/drm/asahi/g17/queue/render.rs) and extended reclaim_unused_render_sibling() / reclaim_unused_render_spare() (drivers/gpu/drm/asahi/g17/runtime/render.rs) with a final pass that yields an idle, drained published sibling (when the owner still has another usable pair and its context is not releasing) via pair.release_owner() + hold_render_slot(slot), preserving the installed QIDs for bind_owner().
    • Updated rebind_pair() (drivers/gpu/drm/asahi/g17/runtime/render/prepare.rs) to pass entry.closed instead of true to teardown.displace(), keeping the displaced prior owner in Phase::Deferred while its queue remains open and retiring its displaced backing when it later closes.
    • Updated reclaimable_siblings_in(), promotes_reclaimable_sibling(), and reclaim_sibling() (drivers/gpu/drm/asahi/g17/queue/admission.rs) so idle published siblings are reclaimable (preferred after unpublished ones) while busy/in-flight published siblings remain protected.
  • Note 1 (direct.rs / submit.rs note_published gate): Gated note_published(slot) on !closed / !entry.closed at both publish sites and on owners[index] != 0 && released & bit == 0 inside Pool::note_published(), so a slot released while lent out cannot have published re-set.
  • Note 2 (owners / released invariants in release_unused_sibling): When keep_installed is true, release_unused_sibling() now keeps owners[index] intact alongside released |= bit (clearing published and epochs[index]), matching release_owner() on close; when keep_installed is false, it clears both owners[index] and released. Live-ownership checks use State::owns_live() / State::has_live_owner().
  • Tests & verification: Extended idle_siblings_yield_to_open_queues_up_to_full_capacity to publish on both primary and sibling pairs before opening the remaining queues up to full capacity, and extended unpublished_sibling_lease_drop_stays_reclaimable to cover busy published protection, idle published sibling detachment/reuse, and note_published() no-op on released slots. tools/asahi/run-host-tests.py --only g17- passed 90/90, arm64 QEMU KUnit asahi_g17* passed 268/268, CONFIG_KUNIT=n arm64 LLVM build of drivers/gpu/drm/asahi/ passed with 0 new warnings, and checkpatch.pl passed with 0 errors and 0 warnings.

@DjDeveloperr DjDeveloperr 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.

Formal §1–§6 pre-PR checklist re-review at live head 76f6062b812e.

Checked (clean / resolved since de71b8971f67)

  • §1–§4, §6: Pass — probed board.clusters >= 4 with documented inventory/ray-query rationale, default cmdline, clean single-commit human attribution (Signed-off-by: only, plain Assisted-by: in PR body), Borealis naming clean, host-tests CI green (90/90 G17 host tests, 268/268 KUnit). Not superseded on integration/aurora.
  • Prior blocker progress: reclaim_unused_render_sibling(), release_unused_sibling(..., keep_installed), Pool::note_published(), and rebind_pair() (entry.closed passed to teardown.displace()) address the main idle published-sibling capacity issue and clean up the owners/released invariants.

Blockers

  1. Code bug — reclaim_unused_render_spare() pass 2 breaks exit_scope() / hold_render_slots_for_exit_kill() ownership (drivers/gpu/drm/asahi/g17/runtime/render.rs:346-401):
    • When reclaim_unused_render_spare(Some(new_owner), ...) detaches an idle published sibling of live old_owner (pass == 2, detach == true), line 366 calls self.admission.reassign_unused_spare(slot, Some(old_owner), Some(new_owner)), immediately overwriting admission.owners[slot] = new_owner and clearing released[slot], while line 399 only calls pair.release_owner() — leaving entry.reservation.owner == old_owner and entry.context == Some(ctx_old) until new_owner later calls rebind_pair().
    • Concrete failure: If old_owner closes/exits requiring a context kill before new_owner completes rebind_pair(slot), exit_scope(ctx_old) (runtime/render/exit.rs:19-21) still includes slot (since entry.context == Some(ctx_old)), and hold_render_slots_for_exit_kill(old_owner, hold, ...) (queue/admission.rs:1599-1601) returns false because self.owners[slot] is now new_owner (and released is cleared), triggering RENDER_KILL_HOLD refusal in runtime/compute_exit.rs:518-524 and stranding ctx_old's teardown. Similarly, if new_owner cancels or closes before calling build_render_pair(slot), release_render(new_owner) skips slot while admission.release_owner(new_owner) leaves admission.owners[slot] = new_owner out of sync with entry.
    • Fix: For detach == true in reclaim_unused_render_spare(), detach via self.admission.release_unused_sibling(slot as u8, expected, true) (matching reclaim_unused_render_sibling()), keeping admission.owners[slot] == old_owner with released |= bit until new_owner's next acquire_render() claims the released slot normally.
  2. Code bug — RenderLease::note_publication() unguarded against concurrent owner release (drivers/gpu/drm/asahi/g17/queue/admission.rs:1506-1508):
    • RenderLease::note_publication() unconditionally executes state.published |= (1u64 << self.slot) & State::MASK; without the state.owners[index] != 0 && state.released & bit == 0 guard that Pool::note_published() has (admission.rs:1194).
    • On the off-lock direct render path (runtime/render/direct.rs:362), pair.publish() invokes note_render_publication() -> lease.note_publication() outside shared.state.lock(). A concurrent release_queue() can mark released |= bit and clear published &= !bit while the pair is lent out, after which lease.note_publication() re-sets published on the already-released slot.
    • Fix: Guard state.published |= bit in RenderLease::note_publication() with the same index > 0 && index < cfg::RENDER_SLOTS && state.owners[index] != 0 && state.released & bit == 0 check.
  3. §5 hardware evidence — 0 live hardware runs on the post-reclamation implementation:
    • This PR rewrites ~1,400 lines of shared G17 admission, QID accounting, and teardown displacement affecting every G17 GPU, and no hardware run has executed since the reclamation/detachment rewrite (the Cyberpunk 2077 T2 numbers in the body are pre-reclamation).
    • Once Blockers 1–2 are fixed, please run on the final head: J716c conformance (dEQP-VK.renderpass*, dEQP-VK.synchronization*, dEQP-VK.api.object_management.*), live multi-client queue-creation stress test (clients publishing on both pairs before additional queues open) confirming no refusal-count regression vs base, clean-base vs head Borealis Cyberpunk 2077 T2 A/B, and §5 regression counts (0 GPU recoveries, 0 failed units, 0 new kernel errors, 0 SELinux denials / N/A), plus J714 and G17P no-regression smoke rows.

Non-blocking note

  • Under sustained multi-client churn where a long-lived open client's published sibling is repeatedly detached and rebound (while the client stays open and later re-claims new siblings), each displaced graph stays in render.retired (capacity 128) holding a BufferId (capacity 127) in Phase::Deferred until that client closes (runtime/render/teardown.rs:99). Worth checking retired_render_bindings / PB headroom during the live multi-client stress run.

Assisted-by: LLM (Gemini 4 Neon)

Detach idle drained published siblings in
Registry::reclaim_unused_render_spare() via
Pool::release_unused_sibling(..., true) instead of reassign_unused_spare(),
keeping admission.owners[slot] synced with entry.reservation.owner and
entry.context in the released state until the requester acquires the slot.
Skip reclamation when the caller already owns a live pair.

Share State::mark_published() between Pool::note_published() and
RenderLease::note_publication() so an off-lock direct publication cannot
re-set published on a slot concurrently released by release_owner().

Add KUnit (render_lease_note_publication_ignores_released_slot) and host
(spare_detach_keeps_exit_kill_ownership, --mutation spare-detach-reassigns)
regression tests.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb

erikwb commented Nov 24, 2026

Copy link
Copy Markdown
Author

Note

🤖 Gemini 4 Hydrogen responding on behalf of erikwb

Fixed both code blockers from the review of 76f6062b812e in f3497c695381 and added regression tests for each, with initial J716c hardware runs recorded below.

  • Blocker 1 (drivers/gpu/drm/asahi/g17/runtime/render.rs:289, 367-374, 398-401, drivers/gpu/drm/asahi/g17/queue/admission.rs:1198-1200): In Registry::reclaim_unused_render_spare() pass 2 (detach == true), detaching an idle drained published sibling now calls self.admission.release_unused_sibling(slot as u8, expected, true) (matching reclaim_unused_render_sibling()) instead of reassign_unused_spare(). This keeps admission.owners[slot] synced with entry.reservation.owner and entry.context in the released state until the requester acquires the released slot normally, preserving exit_scope() and hold_render_slots_for_exit_kill(). Also added an early owns_live_slot(owner) guard in reclaim_unused_render_spare() so a caller that already owns a live pair cannot detach another client's sibling.
  • Blocker 2 (drivers/gpu/drm/asahi/g17/queue/admission.rs:137-145, 1201-1203, 1511-1520): Extracted State::mark_published(), checking index > 0 && index < cfg::RENDER_SLOTS && self.owners[index] != 0 && self.released & bit == 0, and shared it between Pool::note_published() and RenderLease::note_publication(). A concurrent release_owner() while a pair is lent out off-lock can no longer have published re-set on the released slot, while in-flight footprint fragment tracking still updates for active barriers.
  • Regression tests & checks (f3497c695381): Added render_lease_note_publication_ignores_released_slot (drivers/gpu/drm/asahi/g17/queue/admission.rs) and spare_detach_keeps_exit_kill_ownership plus --mutation spare-detach-reassigns (tools/asahi/g17-admission-order-tests.py, tools/asahi/run-host-tests.py). Host tests pass 91/91 (g17-) and 3/3 (asahi-), arm64 QEMU KUnit asahi_g17* passes 269/269, CONFIG_KUNIT=n arm64 LLVM=1 Rust 1.99.0 build of drivers/gpu/drm/asahi/ is clean, and scripts/checkpatch.pl --no-tree -g f5931f9a2adf..HEAD reports 0 errors and 0 warnings.
  • J716c hardware on f3497c695381 (applied to f5931f9a2adf + drm/asahi: t6050: identify the M5 Max's 27.2 (26B123) G17C firmware (on #1650) #2185 + drm/apple: J716c external displays and display sleep on firmware 27.2 #2187, needed for firmware 27.2): boots with two pairs per G17C queue (render_total=2). The multi-client queue-creation stress reached the full 58/58 logical queues (55 clients, each publishing on both pairs, plus the compositor's 2); the only refusals were LogicalQueues=2, at the cap. 60/60 churn rounds opened, retired_render_bindings peaked at 27/128 and parameter buffers at 87/127, with 0 drained-pair failures. dEQP-VK.api.object_management.*: 453 Pass, 4 Warn, 0 Fail. Cyberpunk 2077 T2 on head: 19.94 / 21.73 avg FPS (pass 1 / pass 2), on a different kernel tree than the earlier table. 0 GPU recoveries, no new GPU kernel errors, and the one failed unit also fails on the daily kernel.
  • Still to run on hardware: clean-base Cyberpunk 2077 T2 and queue-stress A/B, dEQP-VK.renderpasses.* / dEQP-VK.synchronization*, and J714 / G17P no-regression smoke checks (listed under Still to run in the PR body).

@erikwb

erikwb commented Nov 24, 2026

Copy link
Copy Markdown
Author

I'm starting to hate Hydrogen, it did run the cyberpunk T2 and then claimed that it didn't

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026

@DjDeveloperr DjDeveloperr 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: FINISH at f3497c695381

Blockers:

  • PR description (end of body): remove the trailing attribution trailer line so the PR body complies with §4 (both commits and the PR title are already clean).
  • §5 hardware evidence (J716c at f3497c695381): complete the remaining dEQP-VK.renderpasses.* and dEQP-VK.synchronization* runs, and add a matched same-tree clean-base vs f3497c695381 Borealis Cyberpunk 2077 T2 A/B to back the performance claim (the current table is pre-reclamation and the f3497c695381 run is head-only on a different tree).
  • §5 second-Mac no-regression row (shared G17 admission/QID code): add one regression smoke row at f3497c695381 on another G17 Mac (J714 or G17P Neo/J616s) confirming unchanged single-pair selection and admission behavior with 0 GPU recoveries, 0 new kernel errors, 0 failed units, and 0 SELinux denials (or N/A).

Checked:

  • Both code blockers from 76f6062b812e are cleanly fixed in f3497c695381: reclaim_unused_render_spare() pass 2 now detaches idle published siblings via release_unused_sibling(..., true) with an early owns_live_slot guard (drivers/gpu/drm/asahi/g17/runtime/render.rs:289,367-373,404-408), and State::mark_published() gates both Pool::note_published() and RenderLease::note_publication() on a live unclosed slot (drivers/gpu/drm/asahi/g17/queue/admission.rs:137-145,1511-1520), with new KUnit and mutation host-test coverage.
  • Full diff (f5931f9a2adf..f3497c695381): §1 (board.clusters >= 4 probed cluster gate with documented inventory/ray-query rationale), §2 (default cmdline, no hacks), §3 (safety, lock ordering, off-lock backing drops), §6 (Borealis naming), and CI (host-tests green) all pass with zero remaining code blockers.
Evidence
  • Head: f3497c695381c018fa055582e569804ee99a7749 (2 commits: 76f6062b812e, f3497c695381; OPEN, MERGEABLE).
  • CI: host-tests SUCCESS (https://github.com/aurora-silicon/linux/actions/runs/45295035557/job/138113142599).
  • Commits & attribution: Both commits authored/committed by Erik Bourget <erik@ebourget.net> with human Signed-off-by: only; PR title clean; PR body still ends with a trailing attribution line (§4 blocker above).
  • Exact-head J716c results already present: Boot with render_total=2, crashed=0; multi-client queue-creation stress hit full 58/58 logical queues (55 clients publishing on both pairs + 2 compositor) and 60/60 churn rounds (retired_render_bindings max 27/128, PB max 87/127, 0 drained-pair failures); dEQP-VK.api.object_management.* 453 Pass / 4 Warn / 0 Fail; 0 GPU recoveries, no new GPU kernel errors.
  • Remaining §5 items: J716c dEQP-VK.renderpasses.* + dEQP-VK.synchronization*, matched same-tree J716c Cyberpunk 2077 T2 A/B, and one second-Mac G17 smoke row (J714 or G17P).

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at f3497c69: not ready yet

Check Detail
CI at head ok 1 check passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes no requested by DjDeveloperr
Hardware row at head ok in the PR body at f3497c69
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:gpu

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

@DjDeveloperr DjDeveloperr 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.

Checked two render pairs per queue on G17C (cluster-count gated), clean commit history, green host-tests CI, and the J716c hardware verification row. No blocking findings.

@DjDeveloperr
DjDeveloperr merged commit 660ccb9 into main Nov 24, 2026
2 checks passed
@DjDeveloperr
DjDeveloperr deleted the j716c/g17c-two-render-pairs branch November 24, 2026 18:40
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) changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants