Repository navigation
drm/asahi: g17: count busy time across power gates, in timestamp order (#1611 follow-up) - #1879
Conversation
2fc8086 to
99daf59
Compare
|
Rebased on integration/aurora 1f5037a, after #1853. Head is now 99daf59, still two commits. #1853 moved the M5 decoder onto
Host tests ( |
|
@DjDeveloperr out of draft (#1611 follow-up). On the J815, pstate stays valid across the ~95 power gates per second under load (36/36 records), and busy_ns tracks fdinfo engine time. Green and mergeable; please review. |
|
Blockers: 1. I checked the ordering logic in drivers/gpu/drm/asahi/g17/telemetry.rs:288-305. The
HW row: the J815 comment reports pstate valid across gates (36/36) and busy_ns tracking fdinfo, but gives no numbers. Post busy_ns delta against the fdinfo engine-time delta over the 20 s es2gears + vkcube run (ratio, and power_epoch count). The A18 Pro now uses the new gap rule too, so run the same on a Neo. Pass criteria: busy_ns within a few percent of fdinfo, never above elapsed time, and the regression line showing 0 failed units, 0 SELinux denials and 0 new kernel errors. Assisted-by: LLM (Claude:Opus 5.5) |
6440b4c to
4f86a73
Compare
|
@RyanTheTide fixed.
Rebased onto cc14570, and |
|
Re-review of 4f86a73: No blockers. Earlier points:
What changed since: only the rebase bound above. The other differences in channel.rs and sysfs.c come from the new base. I found no problems.
HW row (still open): over the 20 s es2gears + vkcube run on a J815 and on a Neo, the busy_ns delta against the fdinfo engine-time delta (ratio, and the power_epoch count). It passes if busy_ns is within a few percent of fdinfo, never above elapsed time, with 0 failed units, 0 SELinux denials and 0 new kernel errors. Assisted-by: LLM (Claude:Opus 5.5) |
4f86a73 to
412fe1e
Compare
|
Re-review of 412fe1e: no blockers. The only change since 4f86a73 is the compile-time check that ties the decoder's ring size to the firmware ring (drivers/gpu/drm/asahi/g17/channel.rs:18-20; both are HW row (still owed, at 412fe1e): run the 20 s es2gears + vkcube load on a J815 and on a Neo, and post the busy_ns delta against the fdinfo engine-time delta (ratio and Assisted-by: LLM (Claude:Opus 5.5) |
|
@RyanTheTide nit done in Checks: The busy_ns against fdinfo rows (J815 and a Neo) are still owed. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: HOLD at 412fe1e8
Blockers:
drivers/gpu/drm/asahi/g17/channel.rs:20/tools/asahi/g17-telemetry-integration-tests.py:70(CI failure):host-testsfailed (E0080:assertion failed: super::telemetry::STATISTICS_RING_RECORDS == STATISTICS_SLOTS) because the integration fixture stubsSTATISTICS_SLOTS = 8whileSTATISTICS_RING_RECORDS = 256. Fix by guarding the compile-time assertion (e.g.#[cfg(not(test))]) or passingSTATISTICS_SLOTSinto the decoder so the constant is not duplicated, and re-verify the fulltools/asahi/run-host-tests.py --only telemetrysuite (including the integration fixture and its mutations).- Rebase / merge conflicts (
CONFLICTINGagainstmain): #2864 (ad9558d5860d) refactoredProtocol(Protocol::PSTATE_8MS/Protocol::PSTATE_16MS),Rings::new(graph, protocol, max_pstate),sysfs.c, the integration fixture, and the stats docs to enable pstate/busy-time telemetry on T6041 (M4 Max, 25G83). Rebase onto livemainand update the PR/docs/comments where they still assume 25G83 never integrates busy time (only T6040 25G83 stays onProtocol::NONE). - PR body (§4 attribution): remove the AI-attribution footer at the end of the PR description (current policy prohibits tool/model attribution anywhere in PR bodies, comments, or commits; commits
27320d85and412fe1e8are already clean). - PR body & HW evidence (§5): add the required
What:,Tested:,Risk:, andNot yet:header lines, and post on-hardware results at the rebased head SHA (busy_nsdelta vs fdinfo engine-time delta, ratio,power_epochcount, bounded by elapsed time) plus the regression line (0 SELinux denials, 0 failed units, 0 new kernel errors) on M5 and A18 Pro (and T6041 after rebasing onto #2864, or explicitly request runs on hardware you don't have).
Checked: Code diff (telemetry.rs, channel.rs, sysfs.c, docs, integration tests), §1–§6 pre-PR checklist, commit hygiene (27320d85, 412fe1e8), CI (host-tests failed), mergeability (CONFLICTING), and HW evidence rows.
Evidence
Code audit
- Timestamp ordering & math (
drivers/gpu/drm/asahi/g17/telemetry.rs:102-104,278-314): Core algorithm is sound.gap = timestamp - markis guarded bytimestamp > mark;mark - timestampis only evaluated whentimestamp <= mark(no underflow).- For
gap <= max_window_ticks()(at most2 * util_period_ticks, 768,000 ticks at 16 ms),window * u64::from(device) * 1_000_000_000is at most7.68e16(< u64::MAX), andbusy_nsusessaturating_add. - After a gap
> 2 * util_period_ticks, crediting onlyutil_period_ticks([ts - period, ts]) starts strictly aftermark, so credited windows never overlap andbusy_nsstays bounded by elapsed time. - Interleaved Primary/Secondary role drains serialize under the device mutex and share one
busy_mark, preventing double-counting in any drain order. - Clock-restart fallback (
mark - timestamp > rebase_ticks()) resetsbusy_markwithout crediting.
- Power-gate / suspend / quarantine gating (
drivers/gpu/drm/asahi/g17/channel.rs:180-194,225-245,305-313):accept_busykeeps suspend, invalidation discard (discard_statistics), and quarantine (statistics_quarantined()) out of bothrecord()andrecord_busy(). Only power-gate cutoffs and records drained while gated route torecord_busy(), leaving utilisation averages, delivery cadence, and pstate untouched.read_statistics()convertsbusy_statusfromVALIDtoSTALEonce either role's statistics ring is quarantined.channel.rs:20compile-time assertion breaks the host integration fixture whereSTATISTICS_SLOTSis stubbed to8.
- Sysfs formatting & non-regression (
drivers/gpu/drm/asahi/sysfs.c:105-130):- Legacy G13–G16 path (
stats->read == NULL) is untouched. - On
Protocol::NONE,g17::stats::qualify()forcespstate_status = UNSUPPORTEDandbusy_status = UNSUPPORTED, keeping output unchanged. - Minor non-blocking nit: the comment on the
busy_status == 2branch insysfs.csaysM5:, whereas after #1853 and #2864 busy-time integration applies to every protocol withutil_period_ticks != 0(M5, A18 Pro, T6041). Same for the commit/doc notes that say 25G83 never integrates busy time.
- Legacy G13–G16 path (
Pre-PR checklist (§1–§6)
- §1 (No model gating): Pass in the diff logic (keyed on
Protocol::integrates_busy()andutil_period_ticks). Needs rebase onto #2864'sProtocol::PSTATE_8MS/PSTATE_16MSrefactor. - §2 (Production-ready): Pass — default kernel command line, no new params, no sleep/retry workarounds.
- §3 (Safety): Pass — read-only telemetry accounting and sysfs output; no hardcoded hardware protection limits.
- §4 (IP & attribution): Commits
27320d85and412fe1e8carry onlySigned-off-by: Nick <[email protected]>(clean). Blocker: PR body still carries an attribution footer at the bottom; remove it. - §5 (Evidence & PR structure): Blocker: PR body lacks
What:/Tested:/Risk:/Not yet:lines, and exact-head HW + regression rows are still owed. - §6 (Naming): Pass.
CI & Mergeability
host-tests(Host tests, run45039037435/ job137259128493): FAILURE —g17-telemetry-integration-tests.pyfails to compileg17/channel.rs:20(error[E0080]: evaluation panicked: assertion failed: super::telemetry::STATISTICS_RING_RECORDS == STATISTICS_SLOTS).- Mergeability:
CONFLICTING(mergeStateStatus: DIRTY) againstmain(base371066885814predates #2864ad9558d5860d).
pstate and achieved_frequency_hz printed "unsupported" whenever pstate_status wasn't valid. On a firmware that reports its state (M5, A18 Pro), the state is "stale" after the cores power up, until the firmware's next state report, and the file then read as a missing feature. Print the status word instead. achieved_frequency_hz keeps "unsupported" for a valid state with no frequency in the board's table. busy_ns also gets a "stale" reading, for a total that stopped (used by the next change); every other non-valid busy status still reads "unsupported". Where pstate is unsupported (25G83, and always there through g17::stats::qualify), the status word is "unsupported", so that output is byte for byte the same. The integration test's formatter cases follow the new readings and check "busy_ns stale". Signed-off-by: Nick <[email protected]>
On a J815 (M5) under a frame-paced load (es2gears + vkcube, 20 s), the cores power-gate about 95 times a second (power_epoch 10861), usually with one utilisation record per power epoch. busy_ns stayed 0 although the 0x13 records kept arriving: - busy time needed two records in one epoch, because every boundary cleared the window start (busy_ts); - the records queued before a boundary, and those drained while the cores read gated, never reached the decoder. Busy time now has its own ordering, separate from the utilisation epoch, on every firmware whose Protocol integrates it (M5, T6041 and A18 Pro): - The decoder keeps the firmware timestamp up to which it has credited busy time (busy_mark). Epoch boundaries keep it. A record at or before it adds nothing, so an older queued record, a repeat, or the other role's record for the same time is never credited twice, whatever the drain order. - A later record closes the window since the mark when that is at most two utilisation periods, as before. After a longer gap it closes only its own period (8 ms on M5 and T6041, 16 ms on the A18 Pro), which lies after the mark: the gap is never credited. Before, such a record only set the baseline. The first record after a gate now credits its period at its own device utilisation. - Records a power boundary keeps out of the averaging epoch (cut off, or drained while gated) are decoded for busy time only (record_busy). The utilisation average, its delivery cadence and the performance state do not see them. Suspend, a real invalidation's discard and quarantine still keep everything out. - A record further behind the mark than a full statistics ring of utilisation records (256 x the record interval, twice over: 4.1 s at 8 ms, 8.2 s at 16 ms) cannot still be queued; it means the firmware clock started again and only sets a new mark. - busy_ns reads stale once a statistics ring is quarantined, since nothing adds to it any more. Credited windows never overlap and each lies at or before its own record's timestamp, so busy_ns stays bounded by elapsed time. T6040 25G83 integrates no busy time and is unchanged. The gated performance state (off, valid 0) is left as it is. Host tests: tools/asahi/run-host-tests.py --only telemetry passes: the decoder's 13 cases, the integration fixture and every listed mutation. New decoder cases: gates between every record, records kept out of the epoch, interleaved roles, clock restart. The A18 Pro window case now and the T6041 cases (decoder and reader) now expect a record after a gap longer than two periods to credit its own period. The fixture drops the kernel's ring-size check, since its firmware ring has 8 slots. New ring case: records cut off at a gate and drained while gated count, a repeat from the other role does not, suspend keeps them out, quarantine reads stale. The fixture's quarantine mutation now hits both the admission and the read, through statistics_quarantined(). Not yet run on hardware in this form; the M5 behaviour is the one measured on the J815 before the A18 Pro protocol work. Signed-off-by: Nick <[email protected]>
412fe1e to
33abd87
Compare
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
@DjDeveloperr updated to
Still owed: A18 Pro and T6041 rows. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Code approved at 33abd8703519. The kernel still checks its firmware ring size at compile time, and the eight-slot host fixture now builds and passes. The J815 reported 2,429 ms busy over 20,075 ms elapsed. Before merge, check the shared integration path across a power transition on another G17 generation, including the epoch counter.
Superseded by the review at 33abd87
|
J700 (MacBook Neo, A18 Pro G17P), PR head On the stock command line, |
|
33abd87 Neo (J700, A18 Pro, G17P) PASS: batched on main 7f00dc6 (0 merge-tree diffs), default cmdline; Borealis Vulkan loads: compute.heavy 10s agx_stats busy_ns delta 13281.0 ms vs fdinfo 13242.4 ms (ratio 1.003, <= elapsed 13674.8 ms); render.heavy 20s busy_ns delta 17162.8 ms vs fdinfo 22684.8 ms (<= elapsed 23744.8 ms, 32459 submits); 25x power-gated bursts busy_ns delta 1754.0 ms (<= elapsed 25317.8 ms); post-3x-rtc0-s2idle Borealis smoke 20966 submits ok; 0 GPU faults, 0 failed units, Enforcing, 0 AVC, 0 new kernel errors; stock fleet89 restored. |
|
Merged into main. Thank you! It merged on your J815 row, Dj's review and our Neo (G17P) no-regression row at this head. |
What: g17
busy_nscounts GPU busy time across power gates and in firmware timestamp order, so it no longer reads 0 on an M5 that gates its cores ~95 times a second. Follow-up to #1611. Rebased ontomain: it now sits on #2864'sProtocolrefactor and covers T6041 as well.Tested: J815 (MacBook Air 15" M5) at
33abd8703519: under a 20 s vkcube + es2gears load,busy_nsrose 2429 ms against fdinfo's 2641 ms (ratio 0.92), never above the elapsed 20075 ms. Regression at boot: 0 SELinux denials (SELinux off), 0 failed units, 0 new kernel errors.Risk: two-way door. Telemetry readout only; M5, T6041 and A18 Pro stats output. G16S/G17P firmwares without busy time are unchanged.
Not yet: A18 Pro and T6041 rows at this head; the
power_epochcount was not read in this run.Details
The problem. On a J815 under a frame-paced load the cores power-gate about 95 times a second, usually with one utilisation record per power epoch.
busy_nsstayed 0 although the 0x13 records kept arriving:The change.
busy_mark); gates, suspend and restarts keep it. A record at or before the mark adds nothing, so a queued older record, a repeat or the other role's record for the same time is never credited twice.busy_nsstays bounded by elapsed time.record_busy()); the utilisation average, its cadence and the performance state never see them.busy_nsreadsstaleonce a statistics ring is quarantined.stale/unavailableforpstateandachieved_frequency_hzinstead ofunsupported. Where pstate is unsupported, the output is byte-for-byte the same.Changed on this head (review).
main(on drm/asahi: g17: T6041: report the performance state, its frequency and busy time #2864): the period comes fromProtocol, and T6041 gets the same gap rule. The T6041 decoder and reader cases now expect a record after a gap longer than two periods to credit its own period.host-testsfix:telemetry.rskeeps its localSTATISTICS_RING_RECORDS, and the kernel-only check againstSTATISTICS_SLOTSstays ing17/channel.rs. The integration fixture's firmware ring has 8 slots, so the fixture drops that one check when it compileschannel.rs.Evidence
J815, macOS 27.2 stub (GPU firmware 26B123), this head merged with the other J815 PRs into one test kernel on
main2943fff. Command line: default pluspcie_aspm=offand three opt-ins that don't touch the GPU.busy_nsdeltaagx_statsbefore/after:utilisation_source firmware-statistics-tag-0x13; after the load the readout correctly saysstale(idle, gated).