Repository navigation
drm/asahi: g17: batch report-ring drains and skip redundant render re-observe - #3428
Conversation
…-observe Rings::consume_report() drains firmware trace (up to 512 slots) and statistics (up to 256 slots) rings from write-combined firmware memory while holding the device mutex during periodic housekeeping. Currently it copies all 18 words per trace record even when asahi_g17_report tracing is disabled (discarding words 1..18 after validating words[0]) and issues a full SeqCst barrier and write-combined consumer store (plus a second SeqCst barrier on trace rings) for every individual record. Under render-heavy workloads after >= 1 ms passes, a single housekeeping turn can hold the device mutex and stall the event worker for 180-570 us. Batch consumer advancement in consume_report() to a single SeqCst-bracketed consumer_word store per drain (flushing any drained valid prefix before returning EIO on a bad tag), and read only the single tag word for trace records when asahi_g17_report is disabled. In runtime_event_turn(), run try_fast_observe_render() before unlocking for deferred.finish() even when requested housekeeping is set, and clear the consumed render masks when try_fast_observe_render() succeeds so the slow housekeeping path skips redundant drain_render_deferred() and observe_renders() device-mutex round-trips while preserving rescan poll arming. Add compiled host contract tests and mutations in tools/asahi/g17-report-drain-tests.py. Signed-off-by: DjDeveloperr <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
J700 (MacBook Neo, Apple A18 Pro
|
The org licenses its new tooling GPL-2.0-only; drop the MIT alternative from the new host test's SPDX line. Signed-off-by: DjDeveloperr <[email protected]>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict — hold for the J714s hardware row at c7e48c245f48. No blocking code findings. The only change since 6481baa33c34 corrects the host test's SPDX identifier. The J700 exact-head result at that parent carries forward (31,611 CTS passes, zero failures).
The recorded J714s candidate 7.3.0-m5-pr67 has tip 6bd9c511315f. It tested cherry-pick 39479d108938, which has the same patch ID and different surrounding code in drivers/gpu/drm/asahi/g17/runtime/events.rs. Please record a J714s run from the reviewed kernel or a candidate containing its head.
I checked producer bounds and wraparound, the barriers around consumer publication, the valid-prefix flush on a bad tag, and retained render masks across fallback, rescan and recovery. The report-drain host test passed locally. All 20 checks, including the replacement pr-text run, passed on 6481baa33c34.
|
J714s (MacBook Pro M5 Pro, T6050 / G17S B1) exact-head correctness row at
|
There was a problem hiding this comment.
Verdict: MERGE at c7e48c24
Blockers: none (re-run the cancelled pr-text and readiness checks before landing; 20/20 build/host/KUnit checks green and exact-head J700 + J714s rows PASS).
Checked:
c7e48c24corrects only the host test's SPDX identifier (GPL-2.0-only) on top of6481baa3(batching G17 report-ring drains and skipping redundant render report reads).- Tests & exact-head hardware rows across two G17 generations:
run-host-tests.py --only g17-243/243 pass; J700 (A18 Pro / G17P) 31,611 CTS pass, 0 failures, 0 GPU faults; J714s (M5 Pro / G17S) exact-headc7e48c24PASS, 0 failures, 0 GPU faults; 20/20 build/host/KUnit CI checks green. - Checked for Apple material, tool attribution, private serials, and gating: clean;
MERGEABLEonmain.
Evidence
- Head:
c7e48c245f48(base: main,mergeable: MERGEABLE,+399/-30across 6 files).
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
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`. 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): 255/255 pass, including `g17-feed-burst-tests.py` and all 7 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 <[email protected]>
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 <[email protected]>
What:
Cut device-mutex hold time in the G17 event worker's housekeeping passes.
Rings::consume_report()(channel.rs,trace.rs) now advances the write-combinedconsumer_wordonce per drain, between twoSeqCstbarriers, instead of a barrier plus an uncached store for every trace or statistics record. On an invalid record tag the valid prefix already drained is flushed beforeErr(EIO)is returned.asahi_g17_reporttracepoint off, trace records read only their 1-word tag (trace::report_enabled(),status_read_words::<1>) instead of copying 18 uncached payload words that are thrown away.runtime/events.rs:try_fast_observe_render()now runs before unlocking even when housekeeping was requested (requestedis passed intohousekeeping_due()), so ready renders retire and signal their fences atdeferred.finish()before housekeeping. Whenrender_clean && !recover, the handled masks are cleared so the slow path does not re-enterdrain_render_deferred()/observe_renders()for renders already retired;render_rescanpoll arming is kept.tools/asahi/g17-report-drain-tests.py(4 contract mutations).Tested:
7.3.0-m5-pr67that carries 6481baa unchanged (same patch-id), stacked with drm/asahi: g17: expand single-pair M5 render depth to 64 #3411 and the first commit of drm/asahi: g17: allow compute_direct() on mixed render/compute contexts #3429,origin/mainDTB: VK CTS 594/594 passed, 0 failed (occlusion_query 152/159 with 7 not supported, synchronization2*read_image_compute*412/412, synchronization smoke 12/12, multiview queries 16/16, concurrent_queries 2/2); gpubench-vkcompute.cull_mdiCRC valid, d2 submit CPU time 26.85 -> 23.48 us; GTA V Enhanced 3024x1964 Very High TAA, 10 s trace: GPU busy 97.658% -> 97.765% (idle 234.25 -> 223.49 ms), P4 57.92 -> 58.03 FPS; 0 GPU faults, WARNs or errors.g17-*passed;checkpatch.pl --strict0 errors, 0 warnings, 0 checks.Risk: two-way · G17 Macs (M5 Pro, Neo)
Not yet:
origin/mainDTBs, which boot with the SLC off on that Mac; the FPS and GPU-busy deltas are relative to a base taken the same way.