Repository navigation
drm/asahi: g16: reuse a pass slot's retired PB epoch - #1543
Conversation
RyanTheTide
left a comment
There was a problem hiding this comment.
@aeries0x Two things before we take this. Pools now keeps an Arc of the last bound epoch per slot even with the parameter at 0, which keeps that VM's state and admission permit alive until another render uses the slot; please drop those references when the VM goes away or when the submit fails before publication. And if the stress results hold, we would rather have the reuse on by default than behind a parameter; is there a case you know of where it must stay off? We will run the default and =1 cases on an M4 Pro.
|
Results with the parameter at its default (0), on our J616s (M4 Pro, G16S), merged on integration e661192 as a one-shot test kernel:
We haven't run the |
63a115b to
cdb7d9c
Compare
|
Thanks for testing on the J616s. Pushed a new revision for both points. References: the change adds no reference to Default: now on, with Also new: any firmware recovery, also one that resumes, makes the next render on each slot start fresh, and a host test in The numbers in the description are from this change on top of 673f618 (the tested build differs from the pushed commit only in comments and the commit message). I have not tested suspend with reuse on; if your M4 Pro run includes s2idle again, that would be the first one with the default. |
|
A correction to the desktop line in the description: "also with blur at 2 passes" measured nothing extra. Omarchy ships blur off and blurs only behind see-through surfaces, and the test window was opaque. Measured again with Omarchy's Glassy look (every window 75 % + blur 2 passes), same kernel (673f618 + this change), a 900x600 client pinned in front, 15 s per row,
Hyprland does ~19-27 renders per frame there. With the default look (no blur) it is 120 fps with both settings. |
|
Tested on a J604 (MacBook Pro 14", M4, Mac16,1; os-fw 26.6.2, system-fw 27.0; aura 1.0.0b13). The kernel was alarm-aurora's pkgrel 38 recipe on
No GPU fault or recovery line in the log. This is not a same-boot A/B: Disclosure: an LLM (Claude) ran these tests on my Mac and drafted this. I did the listening and looking, reviewed it, and am responsible for it. Assisted-by: LLM |
|
Re-ran our J616s row on head cdb7d9c, now with the parameter at its new default (1): cherry-picked onto integration/aurora fc05050, one-shot test kernel, SELinux enforcing. The J616s (T6040) binds the G17 backend (
0 GPU faults, firmware crashes or recoveries, 0 DART faults, 0 AVC. One s2idle cycle completed, and render.light afterwards was 117.5 us at depth 1. The production queue.exhaust failure was one run on a kernel without this change, not something this branch fixes. |
|
J604 (M4, G16G) results for cdb7d9c, GPU firmware 25G83. I cherry-picked it unchanged onto integration/aurora
compute.light does not use a PB, so its difference is boot-to-boot spread. queue.exhaust ends in the driver's ENOMEM No GPU faults, firmware crashes, recoveries or DART faults with either setting. I also ran 6 s2idle cycles with |
|
Tested on J773g (Mac mini M4, 24 GB): a large win, and no regressions in what I ran. Kernel gpubench c36cbbe (Vulkan, KWin running, headless), median µs per submit, best of the passes:
Correctness:
Open, not attributed: gpubench 🤖 Generated with Claude Code |
|
Correction to my J773g report above: the My benchmark ran in a systemd unit with Run without the cap, or under 20 GB, the case passes, with stock and with this PR. Nothing is open against #1543 from my side. 🤖 Generated with Claude Code |
|
Tested on the J773g Mac mini (M4, G16G B0) as the base of #2419, which stacks on this commit: with it, almost every render reuses its slot's retired epoch (30,582 reused / 114 fresh over a gpubench round), and Vulkan CTS 1/16 (84,219 Pass, 0 Fail) and the public GLES/EGL plan (0 Fail) are clean on the stack. #2419 also keeps never-exposed epochs for the next render, which takes render submit CPU from ~190-435 µs to 35-46 µs. 🤖 Generated with Claude Code |
|
Not on integration/aurora yet, and the commit (cdb7d9c) applies cleanly to the tip 110861f. Since the last review it has rows on the J604 (aeries0x, =0 vs default), the J773g (DjDeveloperr, Vulkan CTS 1/16 and GLES clean on the #2419 stack) and a no-regression row on the J616s, which does not run the G16 path. The two review questions (references held after a VM goes away, reuse on by default) are answered in the current revision. What's left is the final review; #2419 builds on this commit, so it does not replace it. Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches. |
Every G16 render gets a fresh parameter buffer epoch at SUBMIT and an InitBM ahead of its TA work, so the firmware rebuilds the allocator state for each render. Reusing the epoch instead cuts a small triangle render at queue depth 1 on a base M4 MacBook Pro (J604) from 1121 to 492 us. With this change, the next render of the same VM on a pass slot gets the slot's owner epoch, without a reseed or InitBM, if that epoch's render retired normally and was exposed. InitBM binds the device-wide slot to one epoch and VM, so this happens only while no other epoch was handed to the slot since; after another VM's render on the slot, after a failed or aborted render, after any firmware recovery, or after a deep-sleep firmware restart, the next render starts fresh. SUBMIT still allocates a fresh epoch for every render, so one is always at hand. Renders are bound, published and retired one at a time, so the slot's owner is the epoch it is bound to whenever reuse is allowed. The reused epoch is the slot's existing owner lease, so this holds no epoch, VM or admission permit beyond what the lease already holds: a slot binding is tracked by a counter, not by a reference. A host test covers when an epoch may be reused and that nothing else holds it. The stats line counts reused and fresh bindings. Signed-off-by: Friedrich <[email protected]>
cdb7d9c to
e5f348e
Compare
|
Updated and rebased onto current
Booted this exact head on the J604 (base M4 MacBook Pro 14"),
One s2idle cycle (lid closed about 90 s, woken by the lid): it resumed and the kernel log stayed clean. render.light after the resume was 484 to 491 us at depth 1 and 324 to 338 at depth 8 (GPU time per render unchanged at 22 us; the difference is on the submit side, still well below ~1120 us without reuse, though no base-only s2idle comparison was run on Checks on this head: |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at e5f348ef1f43ebd307f81c8e3f21615c90264d35 against integration/aurora (70a00e583b03):
- §1 No model gating: PASS. Applies uniformly to all G16 devices with zero board/SoC/firmware gates. Validated on J604 (two separate machines) and J773g, with a no-regression run on J616s (G17).
- §2 Production-ready, no hacks: PASS. The earlier
g16_pb_reusemodule parameter has been dropped so reuse is always on with the default kernel command line. State machine and lifetime invariants verified ing16/{engine,poll,pools,recovery,sleep}.rs:- Adds no extra
Arc<PbEpoch>references beyond the existingownersslot lease (binds: [u64; 2]+keep: [bool; 2]). Pools::reusable()requireskeep[k],Arc::ptr_eq(&owner._vm, vm), andowner.exposed(Acquire).Pools::bind(k, false)incrementsbinds[k]and clearskeep[k]immediately, so a deferred (EAGAIN) or failed fresh binding conservatively forces a fresh InitBM next time; a deferred reused binding leaves the retired epoch untouched and safely reusable.Pools::retire_epoch()checksbinds[k] == bindingundersizes::FLIGHTS == 1and clearskeep[k]whenresult.is_err(); aborted receipts callPools::forget(k).- Both
Firmware::recover()(recovery.rs) andFirmware::sleep_restart()(sleep.rs) callPools::invalidate(), bumpingbindsand clearingkeepso post-recovery and post-deep-sleep renders start fresh with InitBM.
- Adds no extra
- §3 Safety: PASS. No safety bounds weakened; ownership/invalidation invariants are covered by the new host test in
test-resources.py. - §4 Clean-room & attribution: PASS. Commit
e5f348ef1f43carries human author/committer (Friedrich <[email protected]>) and a single humanSigned-off-by:with zero AI trailers (the priorAssisted-bycommit trailer was removed); PR body ends withAssisted-by:. - §5 Evidence: PASS. Strong same-machine A/B wins on J604 (
render.lighttri d1 1121→492 us, d8 984→312 us, glmark2 485→983, Hyprland Glassy 30–40→51–61 fps; re-verified on rebased head at 432/237 us withgpubench-stress --all12 pass / 0 fail / 5 skip and clean s2idle resume), independent J773g A/B (1351→740us d1,992→331us d8) with Vulkan CTS 1/16 (84,183 Pass / 0 Fail) and GLES/EGL (0 Fail), J616s no-regression (0 GPU/DART faults, 0 AVC), and green live CIhost-testsone5f348ef1f43. (Minor non-blocking note: the PR body still mentions05032b14abf9in two places instead of the pushed heade5f348ef1f43.) - §6 Naming: PASS.
No blockers found; ready for MERGETRAIN-LINUX4.
Assisted-by: LLM (Gemini 4 Neon)
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
The approved head |
Keep current main's G16 engine, pools, recovery, and resource selftest (which already carry the PB epoch reuse and phase-1 recovery invalidation from aurora-silicon#2676), preserving the sleep_restart() pool invalidation in g16/sleep.rs and the matching doc comments in g16/pools.rs. Signed-off-by: Friedrich <[email protected]>
|
@RyanTheTide Merged Note that #2676 ( Rechecked on
|
satchlj
left a comment
There was a problem hiding this comment.
Gemini 4 Neon on @satchlj's behalf
Verdict at bca99aa2ee3f
APPROVE — Minimal, targeted fix invalidating the G16 PB pools at Firmware::sleep_restart() entry on top of #2676, with green CI and an exact-head J604 (M4) hardware row.
Blockers
None.
Checked
- Full diff audit (2 files,
+10/-5):drivers/gpu/drm/asahi/g16/sleep.rs: callsself.pools.invalidate();at the start ofFirmware::sleep_restart()so stale cached pool entries from before sleep cannot be reused after restart.drivers/gpu/drm/asahi/g16/pools.rs: updates doc comments to reflect sleep-restart invalidation alongside recovery invalidation.
- Hosted CI at
bca99aa2ee3f: 3 successful, 1 skipped, 0 failing (Host tests7m54s,pr-text13s,pr-readiness5s). - Hardware evidence: Exact-head J604 (M4) hardware row posted at
bca99aa2ee3f. - Untested scope: Static diff audit, CI verification, and posted hardware row review only (no local kernel build or boot performed).
Evidence
- Head:
bca99aa2ee3f(OPEN|false|MERGEABLE) - Diff audited in full: 2 files (
+10/-5) - CI:
All checks were successful (3 successful, 1 skipped, 0 failing, 0 pending)
Keep main's Pools layout and preserve the sleep-restart doc-comment updates in drivers/gpu/drm/asahi/g16/pools.rs. Signed-off-by: Dj <[email protected]>
satchlj
left a comment
There was a problem hiding this comment.
Gemini 4 Neon on @satchlj's behalf
Audited 8cf7c48a5d09 (drivers/gpu/drm/asahi/g16/sleep.rs, drivers/gpu/drm/asahi/g16/pools.rs):
- Correctness: Calling
self.pools.invalidate()at entry toFirmware::sleep_restart()(beforeself.session.rtkit.warm_restart()?) bumps every pass slot'sbindsgeneration and clearskeep = false(g16/pools.rs:1085-1090), ensuring the next render on every slot after a sleep restart runsInitBMfresh rather than assuming firmware retained the pre-sleep PB epoch. - CI (
8cf7c48a5d09):host-tests,readiness, andpr-textare all green.
LGTM — approving.
What
Reuse a G16 pass slot's retired parameter buffer (PB) epoch for the same VM without a reseed or
InitBM, and invalidate pass slots on firmware recovery and deep-sleep firmware restart (sleep_restart()).PR #2676 (
0fb26972a7d6and02370c0d89cd) landed the PB epoch reuse logic, pool/recovery handling, andtest-resources.pyunit test onmain. Mergingmain(dff34de7c681) into this branch keepsmain's current G16 engine, pools, phase-1 recovery invalidation, and selftest intact; the remaining net diff againstmainisself.pools.invalidate()indrivers/gpu/drm/asahi/g16/sleep.rs::sleep_restart()(so the first render on each pass slot after a deep-sleep firmware restart starts fresh withInitBM) plus the three matching doc comments indrivers/gpu/drm/asahi/g16/pools.rs.Tested
Tested: MacBook Pro 14" M4 (J604, T8132, GPU firmware 25G83) at
bca99aa2ee3f: clean boot (0failed units,0new kernel errors,0GPU faults or recoveries,352,620GPU jobs /393,761commands,pb: reused 127642 fresh 1218 bad 0,pipeline: behind 138596 max_flights 5),gpubench-vkrender.light255 / 207 / 204 us/submit (depth 1/8/64),compute.light205 / 73 us/submit (depth 1/8),gpubench-stress-vk --all12 pass / 0 fail / 5 skip,glmark2-es2-drm --off-screenbuild 1355 fps / shading 1328 fps (score 1340).CI container checks (
tools/asahi/run-host-tests.py): 491/532 passed on head and on basedff34de7c681(asahi-m4pass, 0 regressions);scripts/checkpatch.pl --strict0 errors / 0 warnings;drivers/gpu/drm/asahi/aurora.o(LLVM=1) builds with 0 warnings.Risk
Risk: two-way · G16 (M4 / T8132) Macs. A plain revert removes the
sleep_restart()pool invalidation; the PB epoch reuse itself is already onmainvia #2676.Not yet
PM_SUSPEND_MEM/sleep_restart()) is not reachable on J604 today becausesleep-controller@380700000isdisabledint8132-j604.dts;Pools::invalidate()is covered bytest-resources.py(pb_reuse_needs_the_same_binding_vm_and_a_completed_render_and_holds_nothing), and a deep-sleep wake run on a deep-sleep-enabled T8132 Mac (such as J773g or J713) has not been executed on this head.Original design notes and earlier J604 A/B comparison (pre-#2676)
Every G16 render originally got a fresh parameter buffer (PB) epoch at SUBMIT and an InitBM ahead of its TA work, so the firmware rebuilt the allocator state for every render. Reusing the slot's owner epoch instead cut a small triangle render at queue depth 1 on a base M4 MacBook Pro (J604) from 1121 to 492 us.
The reused epoch is the slot's existing owner lease, tracked by a binding counter (
binds: [u64; 2]) andkeep: [bool; 2]rather than an extra reference, so no epoch, VM, or admission permit lives longer than it does without reuse. After another VM's render on the slot, a failed or aborted render, firmware recovery, or a deep-sleep firmware restart (sleep_restart()), the next render on the slot starts fresh.Earlier same-machine A/B comparison on J604 (GPU firmware 25G83,
integration/aurora673f618425,gpubenchcore-a Vulkan,performanceprofile, median us/submit across two boots per setting):g16_pb_reuse=0=1vm_bindingsaround 20 short-livedlife.churnclients matched the baseline (5 to 6 live with desktop running, 1 without).glmark2-es2-wayland485 (=0) vs 983 (=1); Glassy blur (2 passes) 30-40 fps (=0) vs 51-61 fps (=1).