Skip to content

drm/asahi: g16: provide syncobj wait hint on GPU-bound streams - #4194

Merged
DjDeveloperr merged 1 commit into
aurora-silicon:mainfrom
IronsideXXVI:j604/asahi-g16-syncobj-wait-hint
Dec 3, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-silicon:mainfrom
IronsideXXVI:j604/asahi-g16-syncobj-wait-hint

Conversation

@IronsideXXVI

Copy link
Copy Markdown
Contributor

What: Provide the drm_syncobj wait capacity hint on GPU-bound G16 streams (drivers/gpu/drm/asahi/g16/feed.rs, drivers/gpu/drm/asahi/g16/feed/detector.rs), mirroring G17 commit 6cfa2da1bde8 ("drm/asahi: g17: provide syncobj wait hint on GPU-bound streams"):

  • On main, g16::Gpu::syncobj_wait_hint() already delegates through g16::Shared::syncobj_wait_hint() to g16::feed::Feed::wait_hint(), and g16::feed::detector::Detector::note() already classifies GPU-bound back-to-back streams (idle_sum * 4 < busy_sum) into bound_until / Detector::bound(). However, unlike G17 (g17/feed.rs), g16::feed::Feed::wait_hint() still only checks detector.wanted(now) && applied, leaving Detector::bound() unused (#[allow(dead_code)]) and returning None for GPU-bound compute and render streams.
  • On asymmetric T8132 systems (E-core capacity 488, fits_capacity threshold 390.4; P-core capacity 1024), a single-threaded blocking Vulkan submitter (vkWaitForFences / DRM_IOCTL_SYNCOBJ_WAIT) without a temporary uclamp_min hint can fall into a capacity-invariant PELT bistable fixed point on an E-core: e.g. ~3.8 ms host CPU + ~6.3 ms GPU execution per token (~10.12 ms/tok, 98.8 tok/s on a P-core) stretches to ~5.76 ms host CPU + ~6.3 ms GPU (~12.08 ms/tok, 82.75 tok/s, +1.96 ms/tok host 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%.
  • Return Some((WAIT_UTIL_MIN, WAIT_HINT_MS)) (512, 20 ms) from g16::feed::Feed::wait_hint() when cfg!(CONFIG_UCLAMP_TASK) and either (self.detector.wanted(now) && self.applied.load(Ordering::Relaxed)) or self.detector.bound(now) holds — without waking the cpufreq worker or raising the cpufreq floor for GPU-bound work, and without mutating persistent task uclamp attributes or CPU affinity (0 module parameters).
  • Extend LINGER_NS from 8 ms to 20 ms in g16/feed/detector.rs and WAIT_HINT_MS from 8 ms to 20 ms in g16/feed.rs so neither bound() nor the wait hint expires mid-pass across 8-16 ms compute/render passes (covering a full 60 Hz frame and HZ=250 4 ms jiffy boundaries), 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 with 20 ms linger assertions and gpu_bound_long_pass_lingers_for_full_frame.

Tested:

  • Offline at exact head ea79c2f6e858 on origin/main (786a426ecae9, git merge-tree --write-tree clean 48fe84696ae1):
    • 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: 0 errors, 0 warnings, 0 checks (68 lines checked).
    • Clang 18.1.8 + Rust 1.85.0 ARM64 LLVM=1 (CONFIG_DRM_ASAHI=m, CONFIG_DRM_ASAHI_G16=y, CONFIG_UCLAMP_TASK=y): drivers/gpu/drm/asahi/asahi_core.o (102501968 B) and drivers/gpu/drm/asahi/aurora.o (105103016 B) — 0 errors, 0 warnings in g16/feed.rs or g16/feed/detector.rs (pre-existing unrelated warnings in asahi_core.o unchanged).
    • Direct rustc 1.85.0 --edition=2021 --test -Dwarnings on drivers/gpu/drm/asahi/g16/feed/detector.rs: 7/7 PASSED (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).
    • Full tools/testing/selftests/drivers/gpu/asahi-m4/test-thermal-policy.py: 24/24 Rust unit tests PASSED, 571828 oracle rows PASSED (passed: true, 0 failures).
    • 0 new module parameters.
  • Live Apple M4 MacBook Pro 14" (J604, T8132) root-cause evidence (l.712 on linux-aurora 1.1694 + Mesa 1.8327):
    • Without G16 syncobj_wait_hint, llama-bench tg128 landed bimodally at 98.79 tok/s (8/10 runs, 10.12 ms/tok) vs 82.75 tok/s (2/10 runs, 12.08 ms/tok, +1.96 ms/tok host delta, sd=0.26..0.45) while GPU hardware timestamps in perf62 remained identical to < 0.1% (360.05..360.88 ms) and pp512 moved by only -0.2%.
    • Primary release ship linux-aurora-next 1.1695 (1df3ddcb45f9, boot 433bd8d2, carrying this G16 syncobj_wait_hint change) paired with mesa-aurora/vulkan-aurora 1.8327 (set 9a38001371d141eb): tg128 = 98.82 tok/s (iqr 0.09%, trim1 1.07% — zero bimodal E-core outliers vs 82.75 tok/s 2/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 fps display/GPU gate, 0 faults, 0 PMPEV.

Risk: two-way door · G16 feed wait-hint policy only (drivers/gpu/drm/asahi/g16/{feed.rs,feed/detector.rs}, +30 / -7 lines, of which +16 lines are unit tests). Detector::bound() never wakes feed_wq or raises cpufreq FREQ_QOS_MIN floors, MAX_REFILL_NS remains 2 ms so 60/120 Hz desktop pacing stays inactive, and the drm_syncobj wait hint uses sched_util_min_scope_enter/exit without mutating task uclamp attributes or affinity. A plain revert restores wanted-only hints and 8 ms linger.

Not yet:

  • Standalone exact-head origin/main (ea79c2f6e858) hardware A/B on J604 (T8132) measuring tg128 (n=10 bimodal outlier rate and spread), pp512, rh64, and 60/120 Hz desktop idle power with g16::feed::Feed::wait_hint() GPU-bound hints enabled vs disabled on one boot.
Details and verification

Scope (j604/asahi-g16-syncobj-wait-hint, head ea79c2f6e858 on main 786a426ecae9)

  • drivers/gpu/drm/asahi/g16/feed.rs (+12 / -4)
  • drivers/gpu/drm/asahi/g16/feed/detector.rs (+18 / -3)
  • Sign-off: 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 (68 lines checked).
  • git merge-tree --write-tree origin/main HEAD: clean (48fe84696ae1a82b7cb6fff66a319cbe1aafc5fa).
  • Clang 18.1.8 + Rust 1.85.0 ARM64 LLVM=1: drivers/gpu/drm/asahi/asahi_core.o (102501968 B) + drivers/gpu/drm/asahi/aurora.o (105103016 B), 0 warnings in touched files.
  • rustc 1.85.0 --edition=2021 --test -Dwarnings (g16/feed/detector.rs): 7/7 PASSED.
  • tools/testing/selftests/drivers/gpu/asahi-m4/test-thermal-policy.py: 24/24 Rust unit tests PASSED, 571828 oracle rows PASSED (passed: true).
  • Live J604 primary release ship (linux-aurora-next 1.1695, 1df3ddcb45f9, boot 433bd8d2, + Mesa 1.8327 set 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, 0 faults, 0 PMPEV.

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>
@IronsideXXVI
IronsideXXVI requested review from a team and DjDeveloperr as code owners December 3, 2026 13:02
@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 Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Merge readiness at ea79c2f6: ready to merge

Check Detail
CI at head ok 9 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at ea79c2f6
Conflicts ok none
PR text ok Risk: two-way · G16 feed wait-hint policy only (drivers/gpu/drm/asahi/g16/{feed.rs,feed/detector.rs}, +30 / -7 lines, of which +16 lines are unit tests). Detector::bound() never wakes feedwq or raises cpufreq FREQQOSMIN floors, MAXREFILLNS remains 2 ms so 60/120 Hz desktop pacing stays inactive, and the drmsyncobj wait hint uses schedutilminscopeenter/exit without mutating task uclamp attributes or affinity. A plain revert restores wanted-only hints and 8 ms linger.

Areas: area:gpu
Merge: gh pr merge 4194 --merge (Owners and Core through the bypass: add --admin).

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

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

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.rs at this head: 7 of 7 tests. Mutations: LINGER_NS back to 8 ms, bound() reading until, and a classifier that never calls a stream GPU-bound all fail tests.
  • Merge of the head with main cff875630c61 is clean by files: #3990 and #3685 touch other files. g16/feed.rs and feed/detector.rs only.
  • No build of the Rust driver was run here.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

J773g (Apple Mac mini M4, T8132, G16G B0, os-fw 27.2, 24 GB RAM) hardware row for head ea79c2f6e858f9e9031f5ab946baadcf9a8c217d (work/m4rows-b8818ae1-j773g-20261203, kernel 7.3.0-j773g-r1480, local merge b8818ae173f0 on main c43014f079f5, vmlinux build ID ff1e987389e53799e752ac3fc62c843fdb77f70d):

  • HEAD arm (aurora.ko e9f7ddf237173979e4e50c5c3e9308d9b7ceec3d, boot 5812289d-cae8-43c5-bc9c-0e56c002cce0) vs A arm (aurora-base4194.ko 21b85e03c4fc31574811ceaeb603eefb08ceed8d, boot 79a99fbe-13a2-4fbe-b8bc-499162147506):
  • Verbatim judge lines:
    • linux#4194: PASS: tg128 median 191.34 vs A 186.87 t/s (slow 0/0), pp512 2948.9 vs 2977.5, idle top-two share 8.7 vs 5.9 %, gpubench light within 5 %, 0 GPU recoveries
    • #4194 idle part: top-two P-state share 8.7 % vs A 5.9 % (more than 2 points: tell the PR; LINGER_NS)
  • Note: 60 Hz compositor part is not covered by this kit.
  • Stock 7.3.0-j773g-main3685+ cleanly restored (boot beaa437c-6c1c-44f0-87be-9a073461f45d).

Verdict: PASS (compute/LLM bench + gpubench + 0 GPU recoveries; noting idle top-two P-state share 8.7% vs 5.9% on LINGER_NS and 60 Hz compositor part uncovered).

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Hardware check on MacBook Pro 16-inch (M3 Pro, J516s, T6030, G15S B1, 18 cores, OS firmware 27.2) at head ea79c2f6e858:

  • Kernel: 7.3.0-j516s-r1940 (main dc68a27f33d8 + #4213 a313071a0aad + #4225 9dd2888214bf + #3993 f39dcd8f0ad8 + #4014 33a87e888ec3 + #3951 d2dcb0af97d9 + #3953 fd11c9d886c1 + #4194 ea79c2f6e858, merge b9d21a54482f, tree fa8faef7a54f), boot 4d298191-adbc-4ad0-af5d-dc0f2b26e3f3
  • Result: PASS:
    • 24/24 verified Vulkan compute/render/idle benchmark rows passed (feed_bench_rc=0, 0 failed calls, 40 s, CRC valid on all 24 rows).
    • 0 GPU recoveries, 0 GPU fault lines, health: failed 0 errno 0 degraded 0, and clean Vulkan rendering before and after both committed deep sleeps.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

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.

@DjDeveloperr
DjDeveloperr merged commit 9c9e5f0 into aurora-silicon:main Dec 3, 2026
10 checks passed
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) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants