Skip to content

drm/asahi: g17: expand single-pair M5 render depth to 64 - #3411

Open
DjDeveloperr wants to merge 3 commits into
mainfrom
perf/g17-render-depth-64
Open

DjDeveloperr wants to merge 3 commits into
mainfrom
perf/g17-render-depth-64

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What:
Derive per-device G17 render queue depth from hardware capacity in pairs::render_depth_for(pairs_per_owner, scratch_slots) so single-pair queues whose scratch/scene-table capacity already provides 64 slots (SCRATCH_SLOTS = 64, SCENE_TABLE_ENTRIES = 64) use RENDER_DEPTH_MAX (64) instead of capping at 32, while multi-pair or smaller-capacity queues retain RENDER_DEPTH (32). Plumb the derived depth through Backend::render_depth(), Scheduler credits, admission::Pool, compact window sizing, Target slots, Memory graph layout (128 KiB graph + 64 KiB config ring), and retirement::Tracker. Move depth-scaled inline arrays (Graph::owners, Memory::generations, Target::slots, Retired::owners, Dependencies::entries, Tracker::entries) to pre-allocated KVec storage allocated off-lock so kernel stack frames stay smaller than origin/main across allocation, submission, parking, and teardown paths. Add tools/asahi/g17-render-depth-tests.py and register it in tools/asahi/run-host-tests.py.

Tested:

  • J714s M5 Pro (G17S B1) at exact head f4607a228ded: candidate 7.3.0-m5-pr67 carries both commits' driver changes unchanged (identical changed lines in drivers/; only the host-test files differ), stacked with drm/asahi: g17: support staged and compute-prefixed renders in render_direct() #3388, drm/asahi: g17: allow inline cross-engine publication behind already-published producers #3390, drm/asahi: g17: run drm_sched submit workqueues at WQ_HIGHPRI #3391, drm/asahi: g17: batch report-ring drains and skip redundant render re-observe #3428 and the first commit of drm/asahi: g17: allow compute_direct() on mixed render/compute contexts #3429, origin/main DTB. VK CTS 594 passed, 7 not supported, 0 failed (occlusion_query copy 152/159, concurrent_queries 2/2, multiview queries 16/16, synchronization smoke 12/12, synchronization2 *read_image_compute* 412/412); GTA V Enhanced 3024x1964 Very High TAA ran clean on Mesa kits inst-A (P4 55.76 FPS) and inst-R (P4 58.03 FPS); GPU online, 0 crashed, 0 faults.
  • J700 MacBook Neo (G17P B1) at exact head f4607a228ded: row in the comments, PASS, 0 failures, 0 GPU faults or recoveries.
  • Head SHA: d3c3279f2cdcfb9787f5bd92ccdd4deeedffcd9a
  • Local host tests (tools/asahi/run-host-tests.py --only g17-): 232/232 PASS (including all mutations and new g17-render-depth-tests.py).
  • scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES: 0 errors, 0 warnings, 0 checks.
  • llvm-objdump stack-frame audit (asahi_core.o vs origin/main): every render allocation, submission, parking, and teardown frame shrinks (Registry::reclaim_unused_render_spare 8,256 -> 2,352 B, teardown::Service::detach 9,040 -> 3,216 B, Gpu::new_queue 19,168 -> 13,360 B, Memory::new 9,504 -> 6,608 B, Backend::render_with_lease 5,312 -> 3,200 B, Pair::prepare 2,688 -> 2,096 B).
  • Hardware (J714s, Apple M5 Pro / G17S B1, origin/main DTB SLC-off, Mesa inst-A 8643d38a0c91, stacked on #3380 + #3388 + #3390 + #3391 as 7.3.0-m5-depth64 vs slot3-direct control):
    • VK CTS (5 suites): 594/594 PASS, 0 Fail (occlusion_query.copy_* 152/159 [7 NotSupported], concurrent_queries.* 2/2, multiview.queries.* 16/16, synchronization.smoke.* 12/12, synchronization2.op.single_queue.barrier.*_read_image_compute* 412/412).
    • gpubench-vk compute.cull_mdi (objs=16384, visible=75): d1 1041.67 us/submit, d2 888.10 -> 883.39 us/submit (gpu_gap_us 0.375 us, ok).
    • chainbench_diag (14 passes): V0_ALL_BAR 60x33 306.7 us (21.90 us/pass), V1_FRAG_IMG_BAR 269.3 us (19.24 us/pass), V5_ALL_BAR_LOAD 267.4 us (19.10 us/pass).
    • GTA V Enhanced (3024x1964 native, Preset 2 Very High, TAA On, ResScalingType=0, no FSR/DLSS, origin/main DTB SLC-off, 10 s 24 MHz GPU hop trace):
      • GPU busy: 94.99% -> 97.66% (+2.67 pp; GPU idle 501.5 -> 234.2 ms, -53.3%).
      • >1 ms GPU blackouts: 91 (222.4 ms) -> 1 (1.2 ms) (-99.5%).
      • >3 ms GPU blackouts: 21 (78.0 ms) -> 0 (0.0 ms) (-100.0%); max GPU idle gap 5.13 -> 1.20 ms.
      • FR->TA idle: 208.8 -> 14.0 ms (-93.3%); peak concurrent renders 34 -> 66 (7,261 samples above depth 32).
      • Benchmark P4 FPS (inst-A, SLC-off): 55.07 -> 55.97 FPS (+0.90 FPS; P0=59.31 P1=54.42 P2=53.49 P3=59.85 P4=55.97); bonus run on kit R (aurora-wip 5ab97d0 + #1216, still SLC-off) reached P3=61.71 / P4=57.92 FPS.
    • GPU health: online=1, crashed=0, quarantined=0, 0 GPU faults, 0 kernel errors/WARNs across CTS + microbenchmarks + two full GTA V runs.

Risk: two-way · J714s

Not yet:

  • Nothing known.

Single-pair M5 render queues currently cap in-flight depth at 32
(RENDER_DEPTH = 32), matching the per-pair depth of dual-pair G17P
queues even though each M5 owner holds only one physical render pair
whose scratch/scene-table capacity already provides 64 slots
(SCRATCH_SLOTS = 64, SCENE_TABLE_ENTRIES = 64). Under render-heavy
workloads such as GTA V Enhanced (~55-80 renders per frame), capping
a single-pair queue at 32 stalls admission mid-frame whenever the
render pipeline has >32 commands queued.

Derive per-device render depth from hardware capacity in
pairs::render_depth_for(pairs_per_owner, scratch_slots): single-pair
queues with >= 64 scratch slots use RENDER_DEPTH_MAX (64), while
multi-pair or smaller-capacity queues keep RENDER_DEPTH (32). Plumb
the derived depth through Backend::render_depth(), Scheduler credits,
admission::Pool, compact window sizing, Target slots, Memory graph
layout (128 KiB graph + 64 KiB config ring for 64 announce/config
records), and retirement::Tracker.

Move large depth-scaled arrays (Graph::owners, Memory::generations,
Target::slots, Retired::owners, Dependencies::entries, and
Tracker::entries) to pre-allocated KVec storage allocated off-lock so
expanding depth to 64 keeps kernel stack frames smaller than baseline
across allocation, submission, parking, and teardown paths.

Add host contract tests in tools/asahi/g17-render-depth-tests.py and
register them in tools/asahi/run-host-tests.py.

Signed-off-by: DjDeveloperr <[email protected]>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 16:59

@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: FINISH, then merge at d3c3279f2cdc

Blockers: The recovery-storm forgiveness budget is changed globally from 32 to 64, including on devices whose per-pair depth stays at 32. The guard's stated budget is one per group a pair can hold. Please use the active depth for that budget or justify and test the expanded recovery policy independently. Cover both capacities, including the final un-forgiven event and the latched stop. Please also report the deepest supported call-chain stack total for queue creation. The published frame comparison still reports a 13,360-byte new_queue frame by itself, and individual frame reductions do not establish headroom through callees.

Checked: The submission depth is derived from pair count and scratch capacity, with distinct credits and storage sizing paths. The reported J714s saturation row covers the 64-deep path in the stated integration stack. A peer exercising unchanged-depth queue creation and recovery remains pending.

Evidence

recovery/safety.rs now uses RENDER_DEPTH_MAX unconditionally, while pairs.rs retains a separate 32-depth policy. The existing forgiveness test follows the same global constant and cannot distinguish the two cases.

…ueue in place

Address review feedback on per-device render depth expansion:

1. Keep recovery-storm forgiveness in recovery/safety.rs bounded by each
   device's active render depth instead of raising it globally to
   RENDER_DEPTH_MAX (64). Storm::new() retains the 32 default and
   Storm::with_forgive_limit() accepts the active depth derived from
   pairs::render_depth_for_device(shared.variant.m5_commands) in boot()
   and boot_m5(). Extend both the KUnit test and compiled host tests
   (tools/asahi/g17-render-depth-tests.py, with global-forgive-64 and
   m5-stuck-32 mutations registered in run-host-tests.py) to cover both
   32 and 64 capacities, including the final un-forgiven restart and
   permanent latched stop.

2. Return KBox<Queue<B>> directly from Queue::new() using KBox::try_init
   and in-place Proof::init() so Queue<B> and its 128-entry cached proof
   array never sit on Gpu::new_queue()'s stack before boxing. This drops
   Gpu::new_queue()'s own frame from 19,168 B (origin/main) / 13,360 B to
   5,984 B, and cuts the deepest ASAHI_QUEUE_CREATE -> Gpu::new_queue ->
   Context::new -> ... -> Ledger::reserve call-chain stack total inside
   asahi_core from 24,800 B (24.22 KiB) to 11,584 B (11.31 KiB).

Signed-off-by: DjDeveloperr <[email protected]>

@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: HOLD at f4607a22 pending hosted CI and final-stack hardware evidence. The new head addresses my code findings.

Checked: Both startup paths pass the calculated active render depth to the restart storm counter. Timeout forgiveness retains its existing default. The compiled host fixture covers both budgets, exhaustion, reset and the latched stop. Queue construction now calls the in-place proof initializer and returns the boxed queue directly.

Evidence

The author's commit reports an in-driver queue-create call chain reduced from 24,800 B to 11,584 B, with the entry frame down to 5,984 B. The scope is the driver call chain. The PR body still reports test results for the preceding head. Please attach hosted checks and final-stack qualification for the J714s 64-depth path and the J700 32-depth control.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Addressed both blockers in fast-forward commit f4607a228dedcad083f1353322930b3854a920f9:

  1. Per-device recovery-storm forgiveness budget (recovery/safety.rs, recovery.rs, mod.rs):

    • Replaced the global RENDER_DEPTH_MAX forgiveness constant with a per-instance Storm::forgive_limit (Storm::new() keeps the 32 default; Storm::with_forgive_limit() takes the active depth from pairs::render_depth_for_device(shared.variant.m5_commands) in both boot() and boot_m5()).
    • Extended both the KUnit test in recovery/safety.rs and the compiled host test in tools/asahi/g17-render-depth-tests.py (with global-forgive-64 and m5-stuck-32 mutations registered in tools/asahi/run-host-tests.py) to verify both 32-deep and 64-deep budgets, including the (limit + 1)-th un-forgiven restart, reaching LIMIT, permanent stop latching across WINDOW_NS, and fresh-window reset before stop.
  2. In-place Queue / Proof initialization and full call-chain stack audit (queue/mod.rs, validation.rs, mod.rs):

    • Queue::new() now returns Result<KBox<Self>> via KBox::try_init + in-place Proof::init(), eliminating the stack copy of Queue<B> (and its 128-entry Proof array) in Gpu::new_queue().
    • Full relocation-resolved llvm-objdump -dr call-chain stack totals inside asahi_core (origin/main vs f4607a228dedc):
      • ASAHI_QUEUE_CREATE -> Gpu::new_queue -> Context::new -> Pool::allocate -> Allocator::kernel -> KernelObject::placed -> Vm::map_in_range_with_mode -> VmInner::map_node -> UatPageTable::prepare_map -> alloc_pages -> walk_inner -> Ledger::reserve: 464 + 24,336 = 24,800 B (24.22 KiB) -> 464 + 11,120 = 11,584 B (11.31 KiB) (-13,216 B; Gpu::new_queue own frame 19,168 B -> 5,984 B, callee subtree 5,168 B -> 5,136 B).
      • Backend::render_with_lease -> ensure_render -> build_render_pair -> install_fresh_pair -> Pair::new -> Memory::new -> buffer::Manager::new -> Allocator::kernel -> ... -> Ledger::reserve: 28,176 B (27.52 KiB) -> 21,792 B (21.28 KiB) (-6,384 B).
      • Registry::reclaim_unused_render_spare -> Pair::park -> drop glue -> UatPageTable::reprot_pages -> ...: 11,168 B (10.91 KiB) -> 5,216 B (5.09 KiB) (-5,952 B).
      • teardown::Service::detach -> Pair::park -> drop glue -> UatPageTable::reprot_pages -> ...: 11,952 B (11.67 KiB) -> 6,080 B (5.94 KiB) (-5,872 B).

Verified drivers/gpu/drm/asahi/ builds clean, tools/asahi/run-host-tests.py --only g17- passes 234/234 (including both new mutations), and scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES reports 0 errors, 0 warnings, 0 checks.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J700 (MacBook Neo, Apple A18 Pro T8140 / G17P B1, second generation) exact-head kernel verification row at f4607a228dedcad083f1353322930b3854a920f9: PASS (no regression, 0 failures, 0 GPU faults/recoveries).

  • Tree & depth-predicate check (7.3.0-neo-pr3411, exact head f4607a228dedcad083f1353322930b3854a920f9):
    • On G17P B1 (m5_commands = false), pairs::render_depth_for_device(false) passes SCRATCH_SLOTS = 36 (0x24 < RENDER_DEPTH_MAX = 64) with per_owner() == 1 (single-pair), so the hardware capacity predicate (pairs_per_owner == 1 && scratch_slots >= RENDER_DEPTH_MAX) cleanly retains RENDER_DEPTH = 32 while exercising the per-device Storm::with_forgive_limit(32), in-place KBox::try_init Queue/Proof initialization, and all six pre-allocated KVec depth-scaled structures on live G17P hardware.
    • Host tests on exact head: python3 tools/asahi/run-host-tests.py --only g17- passed 234/234 (12 s, including g17-render-depth-tests and its global-forgive-64 and m5-stuck-32 mutations).
  • Setup & identity:
    • Built from exact head f4607a228dedcad083f1353322930b3854a920f9 with stock 7.3.0-41 config + LOCALVERSION=-neo-pr3411 (0 build errors).
    • Booted via one-shot grub2-reboot only with a 16-minute fallback timer; default entry remained 7.3.0-41.fc44.aurora.aarch64. System Mesa, stock kernel command line (0-byte diff vs stock).
    • Verified on boot (85d7e050): uname -r = 7.3.0-neo-pr3411, kernel build ID d59af6f370a985a09393ae222db8b5872ff32bc5 (MATCH), aurora.ko build ID 89e525745bcc3c95cdea0783bd255f64ac845d48 (MATCH).
  • VK CTS (6 jobs, 37,886 cases in 185 s): 31,611 Pass, 6,275 NotSupported, 0 Fail, 0 recoveries (gate rc 0):
    • dEQP-VK.synchronization{,2}.* (basic, smoke, single-queue, timeline semaphore, implicit, none_set_reset, internally synchronized objects, plus all synchronization2.*_read_image_compute*): 31,242 Pass, 6,178 NotSupported, 0 Fail (37,420 total; of which synchronization2.*_read_image_compute* is 5,100 Pass, 5,806 NotSupported, 0 Fail).
    • dEQP-VK.compute.pipeline.basic.*: 79 Pass, 2 NotSupported, 0 Fail.
    • dEQP-VK.api.command_buffers.*: 65 Pass, 66 NotSupported, 0 Fail.
    • dEQP-VK.renderpass{,2}.suballocation.subpass_dependencies.*: 73 Pass, 22 NotSupported, 0 Fail.
    • dEQP-VK.query_pool.occlusion_query.copy_*: 152 Pass, 7 NotSupported, 0 Fail.
  • gpubench-vk (fdf4dd6, system Mesa, 20/20 rows ok, all CRCs matched same-slot stock 7.3.0-41 pre-boot baseline):
    • render.light d1/d8/d32 (deep-queue d32): ok, us/sub 130.7 / 31.1 / 29.2 µs (stock 124.9 / 29.2 / 27.4 µs).
    • render.deferred (tile msaa=4 1080p d1/d2): 5e4130ce (match), GPU 10610.4 / 10529.8 µs (stock 10798.2 / 10724.9 µs).
    • render.postfx (msaa=4 1080p d1/d2): 668d6f0a (match), us/sub 771.2 / 556.6 µs (stock 755.7 / 550.5 µs).
    • render.pass_chain (all_bar d1/d4): 93411763 (match), us/sub 550.5 / 371.7 µs (stock 514.6 / 451.1 µs).
    • render.pass_chain (oq_bar d1/d4): 93411763 (match), us/sub 854.7 / 1214.6 µs (stock 783.3 / 857.1 µs).
    • render.mdi (draws=1024 bindless=1024 d1/d4): 3ba813b3 (match), us/sub 507.6 / 193.2 µs (stock 463.0 / 130.3 µs).
    • compute.heavy (alu d1/d4): ok, us/sub 1351.4 / 1181.1 µs (stock 1382.5 / 1181.1 µs).
    • compute.light d1/d8: ok, us/sub 107.5 / 17.0 µs (stock 102.5 / 15.9 µs).
    • compute.cull_mdi d1/d4: 57276de2 (match), us/sub 9677.4 / 1886.8 µs (stock 5263.2 / 1840.5 µs).
    • sync.signal (compute.light d1): ok, latency p5/med/p95 137.6 / 150.8 / 164.2 µs (stock 140.4 / 145.5 / 152.5 µs).
    • Note: stock 7.3.0-41 predates the PR base (94ea195b6eb59), so this row serves as a second-generation correctness/CRC/stability verification rather than a merge-base perf A/B.
  • Kernel health & restore:
    • 0 GPU faults/recoveries, 0 MMU faults, 0 WARN/BUG/Oops/stack-overflow/KASAN/lockup/RCU-stall/timeout lines, 0 new kernel error lines, 0 AVC denials, 0 failed units, 0 core dumps.
    • Restored cleanly to stock 7.3.0-41.fc44.aurora.aarch64 (boot ca169f7b, PMU f701/f702 = 30 00); trial /boot, /lib/modules, BLS entry, and fallback timer removed, stock.sh POST vs PRE diff = 0 bytes.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at 3d806073: not ready yet

Check Detail
CI at head no failing: apple-build, host-tests, pr-text / pr-text, KUnit ane-boot, KUnit ane-pm, KUnit dcp-fabric
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head no no line with the head SHA 3d806073, a Mac and a result in the PR body or a comment
Conflicts no merge conflicts with main: merge it in (no force push)
PR text ok Risk: two-way · J714s

Areas: area:gpu

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

Resolve Queue::new(): keep the in-place pinned init from this branch and add the scratch field main introduced.

Signed-off-by: DjDeveloperr <[email protected]>

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

The forward merge resolves the conflict and retains the active-depth recovery budget. The depth fixture is byte-identical to f4607a2. The integrated queue now also includes main’s work-state batching and retirement changes, so the prior J714s result supports the depth change but does not establish the combined path. Please post the current-head build and a focused J714s depth-above-32 run with stable retirement and no recovery faults.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the conflict-pass merge commit 3d80607 only: queue/mod.rs gets Scratch::default() for main's new field; runtime.rs union. The resolution keeps what each side had and adds nothing outside the conflict. Approved for the merge-up; merging still waits on CI and the rows at this head.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) needs-hw-row No hardware row at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026

@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 3d8060737511

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: Code reviewed in the earlier App review at this head (6122455008).

Follow-ups (not blocking): current-head build, J714s depth>32 run with stable retirement

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 1, 2026

This branch has not been deployed

No deployments
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) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants