Repository navigation
drm/asahi: g17: trim compute completion critical-path locks and batch clear - #3080
Conversation
… clear Reduce per-completion overhead on G17 compute retirement without moving sleeping locks or VM pin release into interrupt context: 1. In Completion::release_healthy() and complete_with_compute(), skip the unused render-lease mutex on compute commands, move feed.note_pass() and feed.note_work() spinlocks after output.finish() signals the exported fence, and return whether healthy pins were already released so Deferred::Retired and Deferred::RetiredCompute skip redundant vm_job and render mutex re-acquisitions in release_after_retirement(). Keep tools/asahi/g17-quarantine-drain-tests.py in sync with the updated Completion helper signature. 2. Track touched QIDs in retirement::Batch (touched_slots and touched_frontiers u128 bitmasks) so Batch::clear() resets only active QIDs instead of zeroing 3 KiB of slots and frontier arrays on every completion, and extend the asahi_g17_completion_index KUnit suite to cover multi-batch clear reuse. Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH at 7cf06de21f76
Blockers:
- §5 hardware evidence at exact head
7cf06de21f76: the J616C M4 Max hardware row inTested:ran on an earlier combined branch (781012ba1158), while only build/checkpatch/KUnit/host tests ran at7cf06de21f76. Please add an exact-head hardware row at7cf06de21f76(or a batched fleet candidate containing7cf06de21f76unchanged) with same-machine A/B + regression checks (0 SELinux denials, 0 failed units, 0 new kernel errors) on G17P (e.g. J616C M4 Max), plus a non-regression row on a second G17 generation sharing these paths (e.g. M5 family coveringDeferred::RetiredCompute, or A18 Pro / Neo). No code, safety, or policy blockers remain.
Checked: §1–§4 and §6 pass; §5 waiting on exact-head hardware rows; mergeable on main; CI green (host-tests, pr-text, readiness).
Evidence
drivers/gpu/drm/asahi/g17/completion.rs:release_healthy()skippingself.render.lock().take()whenself.is_computeis sound:is_computeis immutable (engine == Engine::Computeing17/queue/mod.rs), andattach_render_lease()is only invoked on render packets ing17/runtime/render/submit.rs.complete_with_compute()keepscheck_source_inputs(),signalled.swap(true, AcqRel),interrupted(),usage.add(),report(),release_healthy(),signal_terminal(), andoutput.finish()in their original order before fence signalling, moving onlyfeed.note_pass()andfeed.note_work()afteroutput.finish(). BothDetector::note()(lock-free atomics withfetch_max) andBusyRuns::note()(runsspinlock withsaturating_add/max) tolerate concurrent or slightly out-of-order completion timing,self.feed(Option<Arc<Feed>>) remains alive while&selfis borrowed, andDeferredBatch::finish()still completes allfeedupdates beforerun_runtime_events()callsself.queue_feed().- Returning
boolfromcomplete()/complete_with_compute()and gatingrelease_after_retirement()inDeferred::Retired/Deferred::RetiredComputeon!complete*()preserves recovery/fault safety: whencomplete*()winssignalled.swap(true, AcqRel),release_healthy()has already releasedsources,render(when!is_compute), andvm_job, andattach_render_lease()recheckssignalled.load(Acquire)underself.renderso no late lease can attach; when an earlierfail_while_owned()already claimedsignalled,complete*()returnsfalseandrelease_after_retirement()still runs to releasesources, dropvm_job, and rehabilitate/droprender.Deferred::DrainedandDeferred::Releasestill callrelease_after_retirement()unconditionally. - Non-blocking nit: the comment at
completion.rs:873-874refers to "their spinlocks", whereasFeed::note_pass()is lock-free atomics and onlyFeed::note_work()acquiresFeed::runs(SpinLock).
drivers/gpu/drm/asahi/g17/queue/compute/retirement.rs:touched_slotsandtouched_frontiers(u128, compile-time assertedQIDS <= 128) cover every write site toslots(request()) andfrontiers(stage_frontier()). Both methods bounds-check via.get_mut(...)?.ok_or(EINVAL)?before shifting1u128 << qid, with no fallible steps between array mutation and bitmask update.clear()clears only touched QIDs withtrailing_zeros()andx &= x - 1guarded by!= 0, then zeroes both masks;headslazy initialization onslot.1 == 0stays valid. KUnit testclear_resets_touched_slots_and_frontiers_across_batchescovers both QID0andQIDS - 1(127) and reuse afterclear().
tools/asahi/g17-quarantine-drain-tests.py: synced cleanly withboolreturn andis_compute: falsein the render fixture; verified passing inhost-tests.- Cross-generation scope: isolated to
drivers/gpu/drm/asahi/g17/(no G13/G14/G15/G16/G18 impact); shared across G17P (M4 family), A18 Pro / Neo, and M5 family (Deferred::RetiredCompute). - Policy & CI: 1 commit (
7cf06de21f7699df115bdd6c6bbf8f0b473a813d), human author/committer +Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>, zero AI attribution, no banned names, no newunsafe;host-tests,pr-text / pr-text, andreadiness / readinessallSUCCESS.
|
Neo (J700, T8140 / G17P B1) PASS at 7cf06de (combined kit 7.3.0-aurora-prneo1a+, default cmdline, Stage 2 b17): gpubench-vk 8/8 OK (compute.heavy alu d1 1370us/d4 1181us, bw d1 2778us/d4 2586us, query timestamp d1/d4), gl-smoke 32/32 + gpubench-gl 2/2 OK, dEQP-VK short CTS 30/30 PASS (compute.pipeline.basic shared_var 4/4, copy_ssbo 6/6), s2idle 1/1 (10 s) + post-sleep GPU PASS, 0 GPU faults/timeouts, 0 failed units, Enforcing + 0 AVC, 0 new GPU kernel errors; restored to saved fleet89. |
satchlj
left a comment
There was a problem hiding this comment.
Gemini 4 Neon on @satchlj's behalf
Verdict at 7cf06de21f76
Approve. Compute-completion lock trimming, post-signal feed-heuristic ordering, pin-release deduplication, and bitmask-scoped Batch::clear() are sound across all 3 changed files.
Blockers
None.
Checked
- Diff audit (3 files, +81/-23):
drivers/gpu/drm/asahi/g17/completion.rs: verifiedrelease_healthy()skippingself.render.lock().take()whenself.is_computeis true is safe (compute completions never hold a render lease);complete_with_compute()preservesusage.add(),report(),release_healthy(), andsignal_terminal()strictly beforeoutput.finish(), deferring only internalfeed.note_pass()/feed.note_work()updates past fence signalling. Confirmed returningboolfromcomplete()/complete_with_compute()letsDeferred::Retired/Deferred::RetiredComputeskip redundantrelease_after_retirement()whencomplete()claimed signalling and already releasedsources,vm_job, andrender, while still runningrelease_after_retirement()(including render-lease rehabilitation) whenfail_while_owned()signalled first.drivers/gpu/drm/asahi/g17/queue/compute/retirement.rs: verifiedtouched_slotsandtouched_frontiers(u128, compile-timeassert!(QIDS <= 128)) are set after bounds checks instage_frontier()andrequest(), andclear()resets every touched slot/frontier viatrailing_zeros()+ bit-clearing, covered by the newclear_resets_touched_slots_and_frontiers_across_batchesunit test.tools/asahi/g17-quarantine-drain-tests.py: updated fixture matches the newboolsignature andis_computefield.
- CI at
7cf06de21f76:host-tests=SUCCESS,readiness=SUCCESS,pr-text=SUCCESS. - Posted hardware evidence: J700 Neo (T8140 / G17P B1) PASS at exact head
7cf06de21f76(gpubench-vk8/8,gl-smoke32/32,gpubench-gl2/2,dEQP-VK30/30,s2idle1/1, 0 faults); J616C M4 Max (T6041) verified on combined branch781012ba1158(8,146/8,146 Borealis Vulkan CTS, 0 faults). - Untested scope: Static source + CI + posted-evidence review only (no kernel install/boot run by this reviewer); standalone exact-head A/B on M4 Max / M5 family remains noted under
Not yet.
Evidence
- Verified files:
drivers/gpu/drm/asahi/g17/completion.rs,drivers/gpu/drm/asahi/g17/queue/compute/retirement.rs,tools/asahi/g17-quarantine-drain-tests.py. - CI:
host-testsSUCCESS,readiness / readinessSUCCESS,pr-text / pr-textSUCCESS at7cf06de21f76.
|
J714s (M5 Pro / T6050 / G17S B1), exact head Headless RTC0 was set for +28 s. One deep suspend returned on the same boot in 34.04 s with the RTC wake event recorded. Apple WD2 was active and counting before and after, with 29 s remaining at the first sample after resume. There were 0 panics, GPU faults, recoveries, or observed AVC denials (SELinux inactive). The one failed unit, |
|
J616C (Apple MacBook Pro 16", M4 Max, 32-core T6041 / G17P B1,
|
What: Reduce per-completion CPU overhead on G17 compute retirement by skipping the unused render-lease mutex on compute commands, moving
Feed::note_pass()andFeed::note_work()spinlocks after fence signalling, skipping redundantrelease_after_retirement()mutex re-acquisitions whencomplete()already released healthy pins, and clearing only touched QIDs inretirement::Batch::clear()viau128bitmasks instead of zeroing 3 KiB of arrays per pass.Tested: J616C M4 Max (T6041, G17P B1) exact-head standalone PASS at
7cf06de21f76(default cmdline, guarded Stage 2):compute.light d=16/32/6412.05 / 11.61 / 11.37 us(submit_cpu_us 7.88 / 8.02 / 4.88 usvs13.43 / 13.21 / 12.62 usand10.83 / 10.83 / 8.77 usonmain4abf0f83c290),concurrent.croverlap=1.1293,render.deferred(2cfe9a54) andcompute.conv2d(2d55a14d) CRCs valid, idleagx_statspstate 0 / 0 Hz / 0% util, 0 GPU faults, 0 failed units, 0 new kernel errors; combined latency branch781012ba1158also passed 8,146/8,146 Borealis Vulkan CTS (ASAHI_MESA_DEBUG=verify). Neo (J700, G17P B1) second-Mac PASS row posted by RyanTheTide (gpubench-vk8/8,gl-smoke32/32,dEQP-VK30/30,s2idle1/1). ARM64 LLVM=1aurora.ko+KUNIT=y/M5=ybuild PASS,checkpatch.pl --strict0/0/0,asahi_g17_completion_indexKUnit 11/11 PASS,g17-quarantine-drain7/7 PASS,g17-capacity-fault1/1 PASS,g17-compute-owed-stamp14/14 PASS.Risk: two-way · G17 Macs (M4, M4 Pro, M4 Max, A18 Pro / Neo, and M5 family; shared G17 completion and compute retirement paths).
Not yet: M5 family hardware check not yet run.
Details
Completion::release_healthy()skips lockingself.renderwhenself.is_computeis true.Completion::complete_with_compute()keepsusage.add(),report(),release_healthy(), andsignal_terminal()strictly beforeoutput.finish(), moving onlyfeed.note_pass()/feed.note_work()after fence signalling.complete()andcomplete_with_compute()return whether this call claimed signalling and released healthy pins soDeferred::Retired/Deferred::RetiredComputecallrelease_after_retirement()only when an earlier failure already signalled the fence.retirement::Batchtrackstouched_slots/touched_frontiers(u128, compile-time assertedQIDS <= 128) and updatestools/asahi/g17-quarantine-drain-tests.py.runtime/events.rs/runtime.rsheld out).