Skip to content

cpufreq: apple: switch T6050 frequencies from the scheduler - #2484

Closed
satchlj wants to merge 1 commit into
integration/aurorafrom
satchlj/cpufreq-apple-fast-switch-20261119
Closed

satchlj wants to merge 1 commit into
integration/aurorafrom
satchlj/cpufreq-apple-fast-switch-20261119

Conversation

@satchlj

@satchlj satchlj commented Nov 19, 2026

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf.

cpufreq: apple: verify T6050 frequency requests lazily, as on T8140, so schedutil can switch from the scheduler instead of through the sugov kthread. Also report the measured 100 µs transition latency, which sets schedutil's rate limit to 150 µs instead of 6 ms. This is selected by the per-SoC info of the T6050 compatible. A new transition_latency_us field carries the latency, and other SoCs keep the bound derived from their timeout.

Evidence (J775c, Mac Studio M5 Max, earlier lobata kernel, 2026-11-05)

  • Inputs measured: a transition between 300 MHz or 1.3 GHz and the fastest state takes 12–75 µs at p50 and at most about 100 µs (userspace governor). The sugov kthread ran for 30–58 µs per update in a sched_switch trace.
  • No on/off measurement of the effect of this commit exists. It went into a kernel together with other scheduler changes. On that kernel the pipe wake-up between threads fell from about 13 µs to 1.1 µs, which is not credited to this commit.

Testing

  • Applies cleanly on integration/aurora 26294e82.
  • Built and booted inside the J775c candidate kernel (6ae9c3ca plus 63 commits).
  • Not yet built on its own on 26294e82, and not measured on the tip.
  • Only T6050 behaviour changes. Other SoCs are not tested and keep their current path.

🤖 Generated with Claude Code

T6050 verifies each frequency request by waiting for the transition, so
schedutil cannot switch from the scheduler: every change goes through the
sugov kthread, which preempts the task it is raising the clock for and
then polls the DVFS command register until the cluster is done. Without
OPP latencies the driver also reports a transition latency of twice the
2 ms timeout, 4 ms, so schedutil changes the clock at most every 6 ms.

Timed on J775c through the userspace governor, a transition between
300 MHz or 1.3 GHz and the fastest state takes 12-75 us, at most about
100 us, as the lazy-verification comment says for T8140 (about 50 us).
The sugov kthread ran for 30-58 us per update in a sched_switch trace.

Verify T6050 requests lazily, as on T8140, so schedutil switches from the
scheduler, and report the measured 100 us transition latency, which sets
schedutil's rate limit to 150 us. A transition_latency_us field carries
it; other SoCs keep the conservative bound derived from their timeout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Satya Benson <satya@benson.earth>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for measuring the T6050 transition latency.

We select behaviour by a hardware property, not by a list of SoCs where it was tried. drivers/cpufreq/apple-soc-cpufreq.c:358 adds .lazy_verify = true to the T6050 entry, which adds T6050 to a list of SoCs that may fast-switch. The reason for lazy verification, letting schedutil switch from the scheduler instead of the kthread, applies to every SoC whose match data sets verify_transition. Open PR #2302 does exactly that: it drops the lazy_verify flag and keys fast switching on verify_transition, which gives T6050 the same behaviour with no T6050-specific line.

Could you rebase on #2302 and keep only the measured latency (transition_latency_us = 100 at :361 and its use at :1544)? A measured per-SoC hardware value in match data is fine. If you like, we can measure the same latency on our M1 Pro, M2, M4 Pro and A18 Pro so the other SoCs get real values instead of the timeout-derived bound.

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: thanks, agreed. Closing this in favour of #2302, which gives every verify_transition SoC, T6050 included, the lazy-verification path with no T6050 line.

The measured part stays as its own commit, stacked on #2302: #2516 adds only transition_latency_us = 100 for T6050 and its use when the OPP table has none. Your offer to measure the same latency on the M1 Pro, M2, M4 Pro and A18 Pro would give those SoCs real values there too.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants