Repository navigation
soc: apple: clpc: use per-CPU deferrable timers when idle on idle_on_time SoCs - #3293
Merged
Merged
Conversation
…time SoCs On idle_on_time SoCs with PMC sampling, replace the continuous 4 ms idle sampling timer while no floor vote is held with per-CPU pinned deferrable timers (minimum 2 jiffies step) whenever nohz_full is not enabled. Idle NO_HZ CPUs take zero CLPC wakeups while any busy CPU kicks active sampling once its tick resumes. Preserve any fresh client demand already queued on clpc->work when entering idle, serialize timer drain/re-arm with CPU hotplug and halt via a dedicated idle_lock (ordered inside cpuhp and sample_lock) and an idle_online_cpus mask so teardown never migrates a pinned timer and newly onlined CPUs start with a fresh baseline, and refresh the baseline on backwards or invalid idle deltas. Signed-off-by: Erik Bourget <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Mirror the new idle_armed, idle_timers, idle_lock, and cpuhp fields in the CLPC host-test harnesses and accept the extra pre-timer work cancel in apple_clpc_halt() while preserving the --old-ref control. Signed-off-by: Erik Bourget <[email protected]>
RyanTheTide
approved these changes
Nov 27, 2026
RyanTheTide
left a comment
Contributor
There was a problem hiding this comment.
Verdict at a5e14b7: merge.
Blockers: none.
Checked:
- Scope comes from the hardware data: per-CPU timers only where
has_pmc && hw->idle_on_time(T6041, T6050 entries), and only whennohz_fullis off. Other SoCs get a cpuhp state with no instance, so their callbacks return early. - Init order:
cpuhp_setup_state_multi()failing fails the driver, so a probe never runs with an emptyidle_online_cpus(which would have meant no idle sampling at all). - Teardown:
haltsetsstoppedand disarms first, cancels the works, thentimer_delete_sync()s every per-CPU timer underidle_lock, then runs the existing two cancel rounds. A callback that raced past thestoppedcheck can queueworkonce, which the later round cancels.stopremoves the cpuhp instance (nocalls) beforehalt. - Hotplug:
cpu_downdeletes the pinned timer on the dying CPU before migration;cpu_onlinere-arms only while armed and not stopped. Lock order is cpuhp/sample_lock -> idle_lock, and nothing takescpus_read_lock()underidle_lock. - Row validity: the J716c row ran kernel commit
6125e3d724b0, which the head carries unchanged (the head commit touches onlytools/asahi/host tests), as the fast-track byte-identical rule allows. ftrace shows 1apple_clpcexecution per 3 s idle (was ~750); hotplug, 2x s2idle and 2x deep all pass.
Follow-up: a T6041 row (J614c/J616c/J575c owners) is welcome as the second idle_on_time SoC; not a merge blocker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: On
idle_on_timeSoCs with PMC sampling, replace the continuous 4 ms idle polling work with per-CPU pinned deferrable timers while no floor vote is held (whenevernohz_fullis not enabled), eliminating idle CLPC CPU wakeups while keeping active sampling responsive when any CPU becomes busy.Tested: J716c M5 Max (T6050) at
a5e14b7862a0(kernel commit6125e3d724b0unchanged in batched trial build7.3.0-ewb321+and7.3.0-ewb323+, default command line; head commita5e14b7862a0updates only host tests intools/asahi/): boots cleanly, 0 new failed units, 0 kernel errors; 3 s idleftrace(workqueue_execute_start) saw 1apple_clpcexecution (down from ~750/3 s),cpu17offline/online hotplug passed, 2×s2idle+ 2×deepS2R passed, and batteryBAAClit idle draw dropped from 5,284 mW (ewb317) to 4,857 mW (-427 mW combined across the 5 PRs).Risk: two-way door ·
idle_on_timeApple Silicon SoCs with PMC CLPC (apple,t6050-clpcand any otheridle_on_timeSoCs).Not yet: Hardware run on a second
idle_on_timeboard (e.g. J714s).Details
TIMER_DEFERRABLE | TIMER_PINNEDtimers whenclpc->has_pmc && clpc->hw->idle_on_time.apple_clpc_queue(clpc, true)) withouttick_nohz_full_enabled(), preserves any fresh client demand already queued onclpc->work(delayed_work_pending(&clpc->work)) instead of cancelling it, then arms pinned deferrable timers acrossidle_online_cpus.cpuhp_setup_state_multi) andapple_clpc_halt()through a dedicatedidle_lock(strictly ordered insidecpuhpandsample_lock), deleting timers on CPU teardown before migration and initializing fresh baselines when CPUs come online.di > dwidle samples rather than triggering spurious workqueue wakeups.Evidence
7.3.0-ewb321+(ac261293cd3f, contains6125e3d724b0unchanged) on J716c (T6050):ftrace3 s idleworkqueue_execute_start:clpc_wq_3s=1.echo 0 > /sys/devices/system/cpu/cpu17/online && echo 1 > ...succeeded (online=0-17), 0 lockdep/kernel warnings.s2idle+ 2×deepS2R resumed cleanly, 0 kernel errors.