Repository navigation
drm/asahi: g17: stop desktop and paced workloads from pinning CPU clocks - #3437
Isaac-Duarte wants to merge 2 commits into
Conversation
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Follow-up Machine & build:
|
satchlj
left a comment
There was a problem hiding this comment.
Reviewed and host-tested at exact HEAD bca9f35f5819:
- Code review: moving per-context refill tracking into
Trackerunder its own spinlock (called post-signalling off the wakeup path, never nesting withrequests), gatingRefillBoundon bothSTREAK_ONandFEED_MIN_RUN_TICKS(8 ms), and decouplingFEED_LINGER_NS(8 ms) fromBOUND_LINGER_NS(20 ms) cleanly fixes desktop/paced-frame CPU clock pinning while preserving GPU-bound wait hints. run-host-tests.py --only g17: 250/250 passed in 4 s.
|
Evidence: |
bca9f35 to
98ebb21
Compare
|
@satchlj @RyanTheTide Rebased onto Rebase summary
Verification at
|
There was a problem hiding this comment.
Verdict: MERGE at 98ebb21e (wait for queued CI to finish green before merging)
Blockers: none
Checked:
- Audited
drivers/gpu/drm/asahi/g17/completion.rs,drivers/gpu/drm/asahi/g17/feed.rs,tools/asahi/g17-feed-burst-tests.py, andtools/asahi/run-host-tests.pyafter the rebase ontomain(#2393+#3428):- Per-context tracking (
Tracker): 16-slot LRU table under its own leafSpinLock<Tracker>(released beforeDetector::record()— never nested withrequestsmutex orrunsspinlock). RuntimeTracker::new(counter_hz)cleanly preserves#3428'scounter_hz == 0guard (max_refill_ticks == 0returnsSample::None), whileglobal_last_endmeasures true GPU idle gaps, credits fullend - starton overlapping parallel waves, and drops fully subsumed intervals (end <= global_prev). - Sustained-run gate & split linger: requires
STREAK_ON(8) ANDlast_end - run_start >= min_run_ticks(8 ms) per context before emittingSample::RefillBound, and decouplesFEED_LINGER_NS(8 ms) fromBOUND_LINGER_NS(20 ms) while preservingPolicy::DEFAULT/Policy::M5andgpu_bound_rx_util_min(). - Concurrency & overflow safety:
Detector::record()uses saturating addition + monotonicfetch_maxandSeqCstwake handoff paired withwanted().
- Per-context tracking (
- Verified exact-head
98ebb21e59fcoffline checks:run-host-tests.py --only g17255/255PASS (all 7 mutations killed), arm64 QEMU KUnitasahi_g17_feed_detector13/13PASS (zero_counter_hz_never_detects_refill_or_boundincluded), arm64LLVM=1build 0 warnings,checkpatch.pl --strict0 errors. - Verified prior hardware rows (
bca9f35f5819, unchanged G17S detector behavior): J714s M5 Pro matched quiet-desktop A/B (desktop boost33.15% -> 0.14%,paced60/12099.6%/99.8% -> 0.6%/0.0%,gpu_bound48.2% -> 0.0%+1.6% throughput,refill_d1sustained at98.5%) and J700 MacBook Neo one-shot boot PASS.
Evidence
Risk:two-way · M5, M5 Pro, M5 Max (G17S/G17P/G17C/G17D)present.- All 21 queued CI jobs (
apple-build,host-tests,pr-text,readiness, KUnit suites) pending at98ebb21e. - Minor body nit (non-blocking): refreshing
bca9f35f5819in the top**Tested:**line to mention the98ebb21e59fcrebase checks makes exact-head readiness immediately scannable.
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
erikwb
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 98ebb21e59fc
Blockers:
drivers/gpu/drm/asahi/g17/feed.rs:190resets the streak before it can renew the GPU-bound wait hint when busy contexts alternate. Feed it 40 contiguous 3 ms passes alternating between two contexts. The GPU never goes idle, but each context waits 3 ms between its own passes, trips the 2 ms reset, and never returnsGpuBound. The base classifies the same sequence as GPU-bound andFeed::wait_hint()supplies a hint. Keep the device-wide GPU-bound streak and use the per-context streak for CPU-floor requests. Extend the alternating-client test past the 2 ms cutoff.
Checked: Host tests, build, and KUnit passed at this head, and GitHub reports no merge conflicts. The tracker adds no runtime tunable or hardware gate. The J714s A/B and J700 regression runs both predate the rebase that changed code. The current-head comment cited for readiness asks for a hardware run. Please attach results from the revised head on the affected M5 path and a second G17 Mac. Hardware run request
Evidence
- Ran the base and head detector code with the same timestamp stream. At 1 ms per alternating pass both report GPU-bound, as in the new test. At 2 and 3 ms the base still reports GPU-bound and the head loses the hint. Neither requests a CPU floor.
- The tracker uses a leaf lock after fence signalling. The deadline update and worker handoff remain atomic. The 8 ms and 20 ms constants set scheduling policy, and the run threshold scales with the counter rate passed to the tracker.
- Two follow-up cases for the hardware row. On G17P, logical queues in one VM can share the execution ID used as the tracker key (
runtime.rs:1445,completion.rs:541), so this isolates execution contexts and can still combine queue histories. A synthetic 120 Hz stream of eleven 5 µs passes spaced 650 µs apart also keeps the floor requested across frames after the first frame, because the inter-frame gap is only 1.83 ms. The posted paced tests show the improvement for their workload.
On M5 Pro (J714s / T6050), ordinary desktop, browser, and video workloads with <1% GPU utilization trigger the G17 CPU feed detector and pin all CPU clusters at 100% max frequency (~4.38 GHz / ~4.61 GHz) ~33-74% of the time. Three interactions cause this: 1. Commit 6cfa2da ("drm/asahi: g17: provide syncobj wait hint on GPU-bound streams") raised the shared LINGER_NS constant from 8 ms to 20 ms so bound_until covers a full 60 Hz frame. That also stretched the CPU-floor deadline (`until`) to 20 ms, longer than both 60 Hz (16.67 ms) and 120 Hz (8.33 ms) frame periods, so periodic frame bursts continuously renew a 100% CPU frequency floor across idle frames. 2. A single GPU-wide `last_end`/`streak` merges unrelated DRM contexts (e.g., compositor, browser, video player). Staggered paced clients whose individual bursts last 1-3 ms chain across each other into 30-80+ pass global bursts without resetting `streak`. 3. `STREAK_ON = 8` fires on pass count alone regardless of elapsed run duration, so a short multi-pass UI redraw raises the CPU floor for 20 ms. Track refill-bound streaks per DRM context in a 16-slot LRU `Tracker` under its own spinlock (updated in `Feed::note_pass(context, start, end)` after fence signalling, off the wakeup critical path) while keeping `Detector` deadline/worker state lock-free with monotonic saturating `fetch_max` deadlines and `SeqCst` wake handoff: - Split `LINGER_NS` into `FEED_LINGER_NS = 8_000_000` (8 ms for `until`) and `BOUND_LINGER_NS = 20_000_000` (20 ms for `bound_until`). - Scale `Tracker::new(counter_hz)` thresholds from `Feed`'s firmware command timestamp rate (disabling detection when `counter_hz == 0`) and require a sustained per-context run spanning at least `FEED_MIN_RUN_PER_SEC` (`counter_hz / 125`, 8 ms) before emitting `Sample::RefillBound` so transient frame bursts stay unboosted. - Measure `gpu_idle` against `global_last_end` while crediting actual busy duration on partially overlapping parallel waves (`start < global_prev && end > global_prev`), drop fully subsumed intervals (`end <= global_prev`), and use saturating arithmetic in `decay_add`. - Keep the GPU-bound streak device-wide, as before: busy contexts that alternate each wait longer than a refill gap between their own passes while the GPU never idles, so per-context streaks alone would drop the syncobj wait hint. Per-context streaks only gate CPU-floor requests. Validation (rebased onto main across aurora-silicon#2393 Policy/counter_hz and aurora-silicon#3428): - Host tests (`run-host-tests.py --only g17`, Rust 1.100.0): g17 host tests pass, including `g17-feed-burst-tests.py` and all 8 mutations. - KUnit (`arm64` QEMU, `KUnit asahi`): `asahi_g17_feed_detector` 13/13 pass (including `zero_counter_hz_never_detects_refill_or_bound`). - Full driver build (`LLVM=1 ARCH=arm64 drivers/gpu/drm/asahi/`): passes with `CONFIG_CPU_FREQ=y` and `CONFIG_UCLAMP_TASK=y`. - Hardware rows (run on earlier identical detector logic prior to main aurora-silicon#2393 Policy refactor): J714s M5 Pro (`7.3.0-124e30a`) quiet-desktop A/B (`policy12` boost 33.15% -> 0.14%, `paced60/120` 99.6%/99.8% -> 0.64%/0.00%, `gpu_bound` 48.2% -> 0.00%, `refill_d1` 98.5%), 8-loop `gpubench` vk/gl soak (232/232 ok, 12/12 fresh VK clients, `gpubench-stress-vk` 3/3 pass); J700 MacBook Neo (`G17P`) peer row (8/8 `gpubench-vk` soak, 10/10 fresh VK clients, `s2idle` pass). Fixes: 6cfa2da ("drm/asahi: g17: provide syncobj wait hint on GPU-bound streams") Signed-off-by: Isaac Duarte <isaac.duarte@live.com>
98ebb21 to
dd90b7d
Compare
There was a problem hiding this comment.
Verdict: HOLD at dd90b7d8e40a
Blockers:
- Hosted CI workflows for this fork head (
dd90b7d8e40a) have not yet run (apple-build,host-tests,KUnit asahi, andpr-textneed to be approved/run and finish green). - Exact-head hardware verification at
dd90b7d8e40aon a G17 Mac (e.g., J714s or J700 boot + GPU smoke) is still pending because both the J714s A/B and J700 rows predate the98ebb21erebase and thedd90b7d8device-wideGpuBoundfix indrivers/gpu/drm/asahi/g17/feed.rs. - Requires
@erikwbto verify/clear the priorCHANGES_REQUESTEDreview from98ebb21ebefore merge.
Checked:
drivers/gpu/drm/asahi/g17/feed.rs(Tracker::note()): verified@erikwb's98ebb21ealternating-client blocker is cleanly fixed —Trackernow maintains device-wideglobal_idle,global_busy, andglobal_streak, computes device-widebound(Sample::GpuBoundwhenglobal_streak >= STREAK_ON && global_idle * 4 < global_busy), and returnsboundboth when a context hits its per-contextpacedreset (start >= slot.last_end + max_refill_ticks) and when the per-context sustained-run refill gate does not fire. Alternating 2 ms and 3 ms saturated passes now renewbound_untilcontinuously without triggering CPU-floor boosts, while interleaved short paced bursts stay quiet (global_idle * 4 >= global_busy).- Verified
drivers/gpu/drm/asahi/g17/completion.rspassesself.context_idat bothfeed.note_pass()sites, lock ordering (SpinLock<Tracker>released before lock-freeDetector::record()),counter_hz == 0guard, and KUnit +tools/asahi/g17-feed-burst-tests.pycoverage (includingalternating_saturated_clients_stay_gpu_boundat 1/2/3 ms and the newper-ctx-boundmutation check). - Policy & attribution: human
Signed-off-byandFixes: 6cfa2da1bde8present,MERGEABLEonmain, no runtime tunables or board/SoC gates, no Apple material or AI attribution.
Evidence
- Head:
dd90b7d8e40ab6c6c6a6838e88bb3ffe72bf2aa1(base: main,MERGEABLE,+970/-119, 4 files, 1 commit). - Local verification reported at
dd90b7d8:run-host-tests.py --only g17(including all 8 mutations), KUnitasahi_g17_feed_detector13/13, andLLVM=1 ARCH=arm64 drivers/gpu/drm/asahi/build PASS.
Resolve the host-test registry: keep both the feed-burst tests from this branch and the loader-OPP tests from main. Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
Verdict: HOLD at d9c35e61d4c2
Blockers:
- Hosted CI workflows (
apple-build,host-tests,KUnit asahi,pr-text) have not yet executed on this fork head (d9c35e61d4c2; currentlySKIPPEDwhilereadinessis queued) — wait for CI to be dispatched and complete green. - Exact-head G17 hardware smoke row (
J714sorJ700boot + GPU workload check) atdd90b7d8/d9c35e61d4c2(the existing J714s A/B and J700 rows predate the98ebb21erebase and thedd90b7d8device-wideGpuBoundstreak fix) plus clearing the priorCHANGES_REQUESTEDreview from98ebb21e.
Checked:
- Audited merge commit
d9c35e61d4c2(MERGEABLEagainstmain): cleanly resolves thetools/asahi/run-host-tests.pyregistry conflict, keeping bothg17-feed-burst-tests.pyand the loader-OPP tests frommain. - Confirmed the 4-file diff (
drivers/gpu/drm/asahi/g17/completion.rs,drivers/gpu/drm/asahi/g17/feed.rs,tools/asahi/g17-feed-burst-tests.py,tools/asahi/run-host-tests.py,+970/-119) preserves the auditeddd90b7d8per-context CPU-boost tracking + device-wideGpuBoundstreak fix without introducing regressions.
Evidence
- Head:
d9c35e61d4c227a86e24175603070a4fec7ed240(basemain,MERGEABLE). - Status checks at review time:
readiness / readinessQUEUED; fork checksSKIPPED.
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed the conflict-pass merge commit d9c35e6 only: run-host-tests.py keeps both entries (adds g17-feed-burst-tests). 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.
There was a problem hiding this comment.
Verdict: MERGE at d9c35e61d4c2
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: - Audited merge commit d9c35e61d4c2 (MERGEABLE against main): cleanly resolves the tools/asahi/run-host-tests.py registry conflict, keeping both g17-feed-burst-tests.py and the loader-OPP tests from main.
- Confirmed the 4-file diff (
drivers/gpu/drm/asahi/g17/completion.rs,drivers/gpu/drm/asahi/g17/feed.rs,tools/asahi/g17-feed-burst-tests.py,tools/asahi/run-host-tests.py,+970/-119) preserves the auditeddd90b7d8per-context CPU-boost tracking + device-wideGpuBoundstreak fix without introducing regressions.
Follow-ups (not blocking): fork CI dispatch; G17 smoke row; prior CR on 98ebb21
|
Tested this change on J714s (MacBook Pro M5 Pro,
|
|
The alternating-client finding is fixed at The review request is still recorded on GitHub. Before merge, it needs clearing and a current-head J714s A/B plus a J700 G17 regression row. |
|
J700 G17P exact-head row INCOMPLETE at The module load command exited 0, but the GPU firmware reported device lost during the swap and no render node appeared with the candidate. The sequence stopped with exit 6. Candidate measurements and base2 are absent, so the performance and regression verdict is incomplete (queue exit 5). A matched cold-boot comparison would distinguish the candidate from the hot-swap failure. Verified stock |
|
Tested on a base M5: J704 (MacBook Pro 14", G17G, GPU firmware 26B123), on battery, with the internal panel (3024x1964@120) and two external 1080p120 displays, balanced profile. Build: Method: 60 s windows. I sampled policy0's
With the stock module the floor never let go on this desktop: both clusters stayed at 4.61 / 3.05 GHz the whole time. Lowering only Not tested here: sustained refill-bound GPU workloads, so I have no throughput check for the cases where the boost should still engage. |
On an M5 Pro (J714s), ordinary desktop and 60/120 Hz workloads with <1% GPU load keep triggering the G17 CPU feed boost and pinning all CPU clusters at 4.38/4.61 GHz 33–74% of the time. Commit
6cfa2da1bde8stretched the shared linger window to 20 ms — longer than both 60 Hz and 120 Hz frame periods — and a single GPU-wide streak merges unrelated DRM contexts and fires on pass count regardless of run duration.This change tracks refill streaks per DRM context, requires an 8 ms sustained run before raising the CPU floor, and separates the 8 ms CPU-boost linger from the 20 ms GPU-bound wait-hint linger so idle/paced frames drop back to low clocks while sustained refill-bound work still boosts.
Tested: J714s M5 Pro (G17S, docked 3x1080p165) at
bca9f35f5819: boots cleanly, 0 failed units; matched quiet-desktop A/B cuts desktop boost 33.15% -> 0.14% (PSTR13.86 -> 13.03 W,PHPC5.83 -> 4.81 W), paced 60/120 Hz boost 99.62%/99.75% -> 0.64%/0.00% (PSTR15.29/16.91 -> 14.91/15.46 W), andgpu_boundboost 48.21% -> 0.00% (PSTR33.49 -> 30.47 W, +1.6% throughput), whilerefill_d1stays at 98.50% boost (6240.5 sub/s); host tests 250/250 pass, KUnitasahi_g17_feed_detector12/12 pass.Risk: two-way · M5, M5 Pro, M5 Max (G17S/G17P/G17C/G17D); a plain revert restores the previous detector.
Not yet: Other G17 Macs beyond J714s M5 Pro (G17P, G17C, G17D).
Details
Three interactions in the existing G17 feed detector kept clocks pinned during light workloads:
6cfa2da1bde8("drm/asahi: g17: provide syncobj wait hint on GPU-bound streams") raised the sharedLINGER_NSconstant from 8 ms to 20 ms sobound_untilcovers a full 60 Hz frame. That also stretched the CPU-floor deadline (until) past both 60 Hz (16.67 ms) and 120 Hz (8.33 ms) frame periods, continuously renewing the CPU floor across idle frames.last_end/streakmerged unrelated DRM contexts (compositor, browser, video player), chaining 1–3 ms per-client bursts across each other without resettingstreak.STREAK_ON = 8fired on pass count alone regardless of elapsed run duration, so short multi-pass UI redraws raised the CPU floor for 20 ms.Changes:
Tracker): Moved interval history into a 16-slot LRUTrackerunder its own leafSpinLock<Tracker>, updated inFeed::note_pass(context, start, end)after fence signalling (off the wakeup critical path), while keepingDetectorlock-free. Bothcompletion.rscall sites (compute and render fragment) passself.context_id.LINGER_NSintoFEED_LINGER_NS = 8_000_000(8 ms foruntil) andBOUND_LINGER_NS = 20_000_000(20 ms forbound_until).FEED_MIN_RUN_TICKS = CLOCK_HZ / 125(8 ms) before emittingSample::RefillBound.gpu_idleglobally viaglobal_last_endwhile crediting actualend - startbusy duration on partially overlapping parallel waves (start < global_prev && end > global_prev), drop fully subsumed intervals (end <= global_prev), use saturating arithmetic indecay_addandDetector::record, keepuntil/bound_untilmonotonic withfetch_max, and alignSeqCstwake handoff betweenDetectorandFeed::run.tools/asahi/g17-feed-burst-tests.py(distinct filename from#3251'sg17-feed-tests.py) with 7 mutations (no-min-run,single-context,per-ctx-gap,shared-linger,short-bound-linger,count-subsumed,clip-overlap), plus 7 new KUnit subtests inasahi_g17_feed_detector.Evidence
PR head SHA:
bca9f35f581962fb6a0f9469af2bfa02bfb233b7(parent9af21b00742595424728ac19cc887a455d1e3922)1. Matched Quiet-Desktop A/B on J714s M5 Pro (G17S)
Hardware setup: 14-inch M5 Pro (J714s), kernel
7.3.0-124e30a(with this exactfeed.rs+completion.rsdiff compiled in for patched), docked to 3x1080p165 monitors, AC connected,balancedprofile, quiet desktop (KWin + Brave). Stock (65bc2ed84827bb61) vs patched (eff6d453cd857cfd) across separate boots:policy12boost %policy12max freq %policy12/policy0avg MHzPSTRmean (med)PHPCmeanp50)desktop(15 s)paced60paced120gpu_bound(d4)refill_d1(d1)(
0failed systemd units and cleandmesg/aurorainit after boot on the patched module.)2. Offline Ftrace Replay (Compiled Rust
Tracker+Detector)bound_hits=34.gpu_boundftrace (1,467 completions):refill=0, bound=818.3. Host Tests & KUnit
RUSTUP_TOOLCHAIN=1.96.0 HOSTRUSTC=rustc python3 -I tools/asahi/run-host-tests.py --only g17 --jobs $(nproc)): 250/250 passed in 6s (all 7g17-feed-burst-testsmutations killed with exit code 101)../tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/gpu/drm/asahi/.kunitconfig --timeout=600 asahi_g17_feed_detector):Ran 12 tests: passed: 12.