Repository navigation
drm/asahi: g16: provide syncobj wait hint on GPU-bound streams - #4194
DjDeveloperr merged 1 commit into
Conversation
Mirror commit 6cfa2da ("drm/asahi: g17: provide syncobj wait hint on GPU-bound streams") on the G16 backend. g16::feed::Feed::wait_hint() currently returns a syncobj wait uclamp_min hint only while detector.wanted() and applied are true (host-refill-bound streams with an active cpufreq floor). On GPU-bound compute and render streams where idle_sum * 4 < busy_sum, Detector::note() updates bound_until instead of until, leaving Feed::wait_hint() returning None and Detector::bound() unused (#[allow(dead_code)]). Without the temporary capacity hint during blocking DRM_IOCTL_SYNCOBJ_WAIT, EAS on asymmetric T8132 systems (E-core capacity 488, P-core capacity 1024) can demote a low-duty-cycle GPU-feeder waiter into an E-core PELT fixed point, adding host turnaround latency between back-to-back submissions. Return Some((WAIT_UTIL_MIN, WAIT_HINT_MS)) from Feed::wait_hint() while either (detector.wanted(now) && applied) or detector.bound(now) holds, without waking the cpufreq worker or raising the cpufreq floor for GPU-bound work. Extend LINGER_NS from 8 ms to 20 ms and WAIT_HINT_MS from 8 ms to 20 ms so neither bound() nor the wait hint expires mid-pass across 8-16 ms compute/render passes (covering a full 60 Hz frame), while keeping MAX_REFILL_NS at 2 ms so 2 ms idle-wake gaps and 60/120 Hz paced desktop rendering continue to reset the streak. Remove #[allow(dead_code)] from Detector::bound() and extend the g16::feed::detector unit tests to cover 20 ms bound() linger across 8-16 ms GPU-bound passes. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: MERGE at ea79c2f
Checked: The GPU-bound predicate can supply the syncobj waiter hint without scheduling the CPU-frequency floor worker. Refill-bound waits still require an applied floor, and the ioctl restores the task's scoped hint on exit. All seven tests from the exact detector source passed, covering the 20 ms boundary, GPU-bound and refill-bound streams, 60/120 Hz desktop pacing, and pause/resume.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: MERGE at ea79c2f6e858 once the row below is in.
Blockers: none in the code.
Missing row: J773g (M4 mini, ours), base and head: llama.cpp tg128 n=20 per boot with the number of slow runs, pp512, gpubench light rows; and 10 s idle after a burst of compute.light with time_in_state of each cpufreq policy. The J604 numbers compare two different releases.
Question: LINGER_NS also sets until, so a refill-bound stream now holds the 100 % frequency floor for 20 ms after the last refill instead of 8 (G17 uses 20 for both, but its DEFAULT policy takes half the top frequency). The body says the floor doesn't change. If the idle or 60 Hz rows show it, give bound_until its own 20 ms constant and leave LINGER_NS at 8.
Checked: GPU-bound waits get the hint without waking the frequency worker; refill-bound ones still need an applied floor; bound() is cleared on pause and stop. Same shape as the G17 change. The same numbers (512, 20 ms) as G17's policy. No module parameter, no board gate.
Evidence
detector.rsat this head: 7 of 7 tests. Mutations:LINGER_NSback to 8 ms,bound()readinguntil, and a classifier that never calls a stream GPU-bound all fail tests.- Merge of the head with main
cff875630c61is clean by files: #3990 and #3685 touch other files.g16/feed.rsandfeed/detector.rsonly. - No build of the Rust driver was run here.
|
J773g (Apple Mac mini M4, T8132, G16G B0, os-fw 27.2, 24 GB RAM) hardware row for head
Verdict: PASS (compute/LLM bench + |
|
Hardware check on MacBook Pro 16-inch (M3 Pro, J516s, T6030, G15S B1, 18 cores, OS firmware 27.2) at head
|
|
The exact-head J773g A/B and J516s Vulkan control passed. The affected asahi-m4 host suite and checkpatch passed on the merge tree. The current tip has the same Asahi driver and test files as that tree. |
What: Provide the
drm_syncobjwait capacity hint on GPU-bound G16 streams (drivers/gpu/drm/asahi/g16/feed.rs,drivers/gpu/drm/asahi/g16/feed/detector.rs), mirroring G17 commit6cfa2da1bde8("drm/asahi: g17: provide syncobj wait hint on GPU-bound streams"):main,g16::Gpu::syncobj_wait_hint()already delegates throughg16::Shared::syncobj_wait_hint()tog16::feed::Feed::wait_hint(), andg16::feed::detector::Detector::note()already classifies GPU-bound back-to-back streams (idle_sum * 4 < busy_sum) intobound_until/Detector::bound(). However, unlike G17 (g17/feed.rs),g16::feed::Feed::wait_hint()still only checksdetector.wanted(now) && applied, leavingDetector::bound()unused (#[allow(dead_code)]) and returningNonefor GPU-bound compute and render streams.488,fits_capacitythreshold390.4; P-core capacity1024), a single-threaded blocking Vulkan submitter (vkWaitForFences/DRM_IOCTL_SYNCOBJ_WAIT) without a temporaryuclamp_minhint can fall into a capacity-invariant PELT bistable fixed point on an E-core: e.g.~3.8 mshost CPU +~6.3 msGPU execution per token (~10.12 ms/tok,98.8 tok/son a P-core) stretches to~5.76 mshost CPU +~6.3 msGPU (~12.08 ms/tok,82.75 tok/s,+1.96 ms/tokhost delta) on an E-core, where capacity-scaled PELT (0.477 * 488 = 233 << 390.4) fits the E-core with wide margin and locks the thread onto the E-core for the entire run while GPU hardware timestamps stay identical to< 0.1%.Some((WAIT_UTIL_MIN, WAIT_HINT_MS))(512,20 ms) fromg16::feed::Feed::wait_hint()whencfg!(CONFIG_UCLAMP_TASK)and either(self.detector.wanted(now) && self.applied.load(Ordering::Relaxed))orself.detector.bound(now)holds — without waking the cpufreq worker or raising the cpufreq floor for GPU-bound work, and without mutating persistent taskuclampattributes or CPU affinity (0module parameters).LINGER_NSfrom8 msto20 msing16/feed/detector.rsandWAIT_HINT_MSfrom8 msto20 msing16/feed.rsso neitherbound()nor the wait hint expires mid-pass across8-16 mscompute/render passes (covering a full 60 Hz frame andHZ=2504 ms jiffy boundaries), while keepingMAX_REFILL_NSat2 msso2 msidle-wake gaps and 60/120 Hz paced desktop rendering continue to reset the streak.#[allow(dead_code)]fromDetector::bound()and extend theg16::feed::detectorunit tests with 20 ms linger assertions andgpu_bound_long_pass_lingers_for_full_frame.Tested:
ea79c2f6e858onorigin/main(786a426ecae9,git merge-tree --write-treeclean48fe84696ae1):rustfmt --edition=2021 --check drivers/gpu/drm/asahi/g16/feed.rs drivers/gpu/drm/asahi/g16/feed/detector.rs: PASS (rustfmt 1.10.0-stable).scripts/checkpatch.pl --strict --git origin/main..HEAD:0errors,0warnings,0checks (68lines checked).LLVM=1(CONFIG_DRM_ASAHI=m,CONFIG_DRM_ASAHI_G16=y,CONFIG_UCLAMP_TASK=y):drivers/gpu/drm/asahi/asahi_core.o(102501968B) anddrivers/gpu/drm/asahi/aurora.o(105103016B) —0errors,0warnings ing16/feed.rsorg16/feed/detector.rs(pre-existing unrelated warnings inasahi_core.ounchanged).rustc 1.85.0 --edition=2021 --test -Dwarningsondrivers/gpu/drm/asahi/g16/feed/detector.rs:7/7PASSED (cpu_refill_bound_burst_requests_boost_and_expires_after_linger,gpu_bound_back_to_back_flights_do_not_boost_cpu,gpu_bound_long_pass_lingers_for_full_frame,pipelined_d2_cpu_recording_burst_sustains_boost_and_expires_after_linger,pipelined_d2_gpu_bound_flights_do_not_boost_cpu,desktop_60hz_and_120hz_pacing_never_triggers_boost,short_runs_and_pause_resume_lifecycle_gate_boost_cleanly).tools/testing/selftests/drivers/gpu/asahi-m4/test-thermal-policy.py:24/24Rust unit tests PASSED,571828oracle rows PASSED (passed: true,0failures).0new module parameters.l.712onlinux-aurora 1.1694+Mesa 1.8327):syncobj_wait_hint,llama-benchtg128landed bimodally at98.79 tok/s(8/10 runs,10.12 ms/tok) vs82.75 tok/s(2/10 runs,12.08 ms/tok,+1.96 ms/tokhost delta,sd=0.26..0.45) while GPU hardware timestamps inperf62remained identical to< 0.1%(360.05..360.88 ms) andpp512moved by only-0.2%.linux-aurora-next 1.1695(1df3ddcb45f9, boot433bd8d2, carrying this G16syncobj_wait_hintchange) paired withmesa-aurora/vulkan-aurora 1.8327(set 9a38001371d141eb):tg128 = 98.82 tok/s(iqr 0.09%,trim1 1.07%— zero bimodal E-core outliers vs82.75 tok/s2/10 outliers before),pp512 = 1627.26 tok/s(101.1%vs macOS),RH64 = 246.99 us(100.9%),MLX = 90.66 tok/s,Quake = 1195.0 fps,1644.6 fpsdisplay/GPU gate,0faults,0PMPEV.Risk: two-way door · G16 feed wait-hint policy only (
drivers/gpu/drm/asahi/g16/{feed.rs,feed/detector.rs},+30 / -7lines, of which+16lines are unit tests).Detector::bound()never wakesfeed_wqor raises cpufreqFREQ_QOS_MINfloors,MAX_REFILL_NSremains2 msso 60/120 Hz desktop pacing stays inactive, and thedrm_syncobjwait hint usessched_util_min_scope_enter/exitwithout mutating taskuclampattributes or affinity. A plain revert restoreswanted-only hints and 8 ms linger.Not yet:
origin/main(ea79c2f6e858) hardware A/B on J604 (T8132) measuringtg128(n=10bimodal outlier rate and spread),pp512,rh64, and 60/120 Hz desktop idle power withg16::feed::Feed::wait_hint()GPU-bound hints enabled vs disabled on one boot.Details and verification
Scope (
j604/asahi-g16-syncobj-wait-hint, headea79c2f6e858onmain786a426ecae9)drivers/gpu/drm/asahi/g16/feed.rs(+12 / -4)drivers/gpu/drm/asahi/g16/feed/detector.rs(+18 / -3)Signed-off-by: Dylan Ironside <dylan@dylanironside.io>rustfmt --edition=2021 --check: PASS (rustfmt 1.10.0-stable).scripts/checkpatch.pl --strict --git origin/main..HEAD:0 errors, 0 warnings, 0 checks(68lines checked).git merge-tree --write-tree origin/main HEAD: clean (48fe84696ae1a82b7cb6fff66a319cbe1aafc5fa).LLVM=1:drivers/gpu/drm/asahi/asahi_core.o(102501968B) +drivers/gpu/drm/asahi/aurora.o(105103016B),0warnings in touched files.rustc 1.85.0 --edition=2021 --test -Dwarnings(g16/feed/detector.rs):7/7PASSED.tools/testing/selftests/drivers/gpu/asahi-m4/test-thermal-policy.py:24/24Rust unit tests PASSED,571828oracle rows PASSED (passed: true).linux-aurora-next 1.1695,1df3ddcb45f9, boot433bd8d2, +Mesa 1.8327set 9a38001371d141eb):tg128 = 98.82 tok/s(iqr 0.09%,trim1 1.07%),pp512 = 1627.26 tok/s(101.1%),RH64 = 246.99 us(100.9%),MLX = 90.66 tok/s,Quake = 1195.0 fps,1644.6 fps,0faults,0PMPEV.