Repository navigation
Conversation
|
Thanks for this, and for measuring both the ramp time and the power cost. One structural point. We select behaviour by a hardware property, not by which machines it was tested on. An improvement behind a default-off switch that each SoC opts into ends up selected by test history:
The slow ramp comes from frequency-invariant utilization, which applies to any CPU that idles down under schedutil. Could you pick one of these?
For option 1 we can run ramp and power rows on our M1 Pro, M2, M4 Pro and A18 Pro. The idle power rising from 10.5 to 11 W is worth a look first. |
|
Claude Opus 5.5 on @satchlj's behalf: thanks. I took option 2, in Option 1 would need two things first: an explanation of the idle rise from 10.5 to ~11 W with the boost on, and rows on more than one core design. Your M1 Pro, M2, M4 Pro and A18 Pro ramp and power rows would be the right basis for that later change. I won't propose a default before both exist. 🤖 Generated with Claude Code |
|
Thanks for 787ec44. With the per-driver field gone and |
787ec44 to
13283c3
Compare
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR checklist review (§1–§6) on head 13283c387a7cf1319c7d19f60e878435ffff2e92.
Blockers
- Missing
scx_switched_all()guard insugov_busy_boost()(kernel/sched/cpufreq_schedutil.c) — Right above it,sugov_hold_freq()checksif (scx_switched_all()) return false;so schedutil defers to the BPF scheduler'sscx_cpuperf_target().sugov_busy_boost()omits this check and feedsmax_capintoboost, which overridesutil = max(util, boost)insugov_get_util(), breaking BPF scheduler frequency control wheneverbusy_boost_us > 0. - Cross-CPU data race and 32-bit torn read on
ts->idle_entrytime(kernel/time/tick-sched.c,kernel/sched/cpufreq_schedutil.c) —tick_nohz_get_idle_entrytime_cpu()reads the 64-bitktime_t ts->idle_entrytimewithREAD_ONCE()cross-CPU fromsugov_next_freq_shared()(which runs on every shared-cluster cpufreq policy, including all Apple Silicon CPU clusters):- None of the writers in
kernel/time/tick-sched.c(tick_nohz_idle_enter(),tick_nohz_irq_exit(),tick_nohz_idle_restart_tick()) useWRITE_ONCE(), creating a KCSAN data race even on 64-bit. - Because
cpufreq_schedutil.candtick-sched.care architecture-independent core kernel code, a cross-CPUREAD_ONCE()of a 64-bitktime_tcan tear on 32-bit SMP platforms (unliketick_nohz_get_idle_calls_cpu(), which isunsigned longand explicitly single-CPU-policy only). Either use an architecture-safe primitive /unsigned longper-idle-entry counter (updated withWRITE_ONCE) or guard 64-bit cross-CPU reads safely.
- None of the writers in
busy_boost_ussysfs ABI exposed as a silent no-op when!CONFIG_NO_HZ_COMMON(kernel/sched/cpufreq_schedutil.c) —busy_boost_usis unconditionally registered insugov_attrs[]even thoughsugov_busy_boost()compiles to a stub returning0whenCONFIG_NO_HZ_COMMONis disabled. Userspace can write a value and read it back while the feature silently does nothing. Also, insugov_next_freq_shared(),j_sg_cpu->busy_sinceis stamped and compared using the calling CPU'srq_clock(time) rather thanj's clock, and if a CPU has never idled (entry == 0) acrosssugov_start()/ enablingbusy_boost_us,entry == sg_cpu->busy_idle_entryimmediately triggers boost.- Unexplained idle/periodic power regression & §2 (Default-off manual tunable):
- The PR's own J775c measurements show an unexplained idle power increase (
10.5 W -> 10.9–11.1 W) and a +1.6 W jump on 10% periodic load (11.9 W -> 13.5 W) withbusy_boost_us=4000. Note one likely mechanism insugov_busy_boost(): on shared clusters, a single core running a>= 4 msburst (or a wakeup/dequeue window beforedo_idle()updatesidle_entrytimeandidle_cpu()becomes true) requestsmax_capfor the entire 4–6 core cluster, slamming the whole cluster to peak voltage/OPP. On battery-powered Apple Silicon Macs (M1/M2/M3/M4/M5 laptops), unexplained idle/periodic power overhead is a major battery/thermal risk and needs root-cause analysis before introducing a new coreschedutilsysfs ABI. - Under §2, shipping a default-off (
0) manual sysfs tunable does nothing on the default kernel command line.
- The PR's own J775c measurements show an unexplained idle power increase (
- §5 Evidence — Zero live-head hardware proof:
- The PR body explicitly states: "Not yet built on its own on
26294e82, and not yet measured on the tip... Other SoCs are not tested." The only data cited is from an earlier 2026-11-05 lobata kernel. - Required before approval: standalone build & boot on current
integration/auroratip on the default command line with clean regression checks (0 AVC denials, 0 failed units, 0 new kernel errors), plus same-bootbusy_boost_us=0vs active A/B (ramp latency, workload perf, idle & periodic-load power/thermals) on J775c and at least one other Apple Silicon family (e.g. M1/M2/M4), with the idle power rise explained.
- The PR body explicitly states: "Not yet built on its own on
Non-blocking Notes
- Commit
13283c387a7creverts thepolicy->busy_boost_usfield added in commit6813616556e3; squashing the two commits avoids leaving dead intermediate ABI churn in git history.
Checklist Summary
- §1 No model gating: Pass (per-driver
policy->busy_boost_usremoved in commit 2). - §2 Production-ready / default cmdline: Fail (default-off manual sysfs ABI with unexplained power regression).
- §3 Safety: Needs power/thermal explanation for idle (+0.5 W) and periodic-load (+1.6 W) power rise before enabling by default; note
uclamp_maxstill capssugov_effective_cpu_perf()viamax, which is good. - §4 Clean-room & attribution: Pass (both commits have human author/committer + human
Signed-off-by:only; PR body disclosesAssisted-by:). - §5 Evidence: Fail (live head
13283c387a7chas not been built or measured standalone on any Mac; zero regression run). - §6 Naming: Pass.
- CI:
host-testspassed on13283c387a7c.
Assisted-by: LLM (Gemini 4 Neon)
|
Status: nothing equivalent is on integration/aurora at 4a17f73. kernel/sched/cpufreq_schedutil.c, kernel/time/tick-sched.c and the other two files have not changed since this branch's base, and the branch merges cleanly. The four points of the 2026-11-22 review are open on head 13283c3: the missing |
13283c3 to
58fde2c
Compare
|
Gemini 4 Neon on @satchlj's behalf. Rebased and squashed onto
Remaining §2/§5 items (standalone J775c + cross-SoC A/B ramp/power measurements and root-cause analysis of the idle/periodic power delta) remain open for follow-up hardware trial boots. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR re-review (§1–§6) at 58fde2c97bd6: REQUEST_CHANGES — prior scx_switched_all(), 32-bit tearing/KCSAN, CONFIG_NO_HZ_COMMON sysfs gating, and commit-squash items are all resolved (and host-tests passed), but there is a real logic bug in sugov_busy_boost() that counts idle sleep time as busy time and should be fixed before the 03:00Z hardware boot run.
Prior Blockers Cleared
- Added
scx_switched_all()guard insugov_busy_boost(). - Replaced cross-CPU 64-bit
ts->idle_entrytimereads with a per-CPUunsigned long idle_entriescounter (WRITE_ONCEintick_nohz_idle_enter(),READ_ONCEintick_nohz_get_idle_entries_cpu()), eliminating 32-bit tearing and KCSAN races. - Gated the
busy_boost_ussysfs attribute and fields onCONFIG_NO_HZ_COMMON, switched elapsed-time tracking toktime_get_mono_fast_ns(), and squashed into a single clean commit (58fde2c97bd6).
Remaining Code Blocker (fix before 03:00Z boot run)
- Idle sleep time is counted as busy time in
sugov_busy_boost()(kernel/sched/cpufreq_schedutil.c:448-455):now = ktime_get_mono_fast_ns(); entries = tick_nohz_get_idle_entries_cpu(sg_cpu->cpu); if (!sg_cpu->busy_since || entries != sg_cpu->busy_idle_entries || idle_cpu(sg_cpu->cpu)) { sg_cpu->busy_idle_entries = entries; sg_cpu->busy_since = now; return 0; } return (s64)(now - sg_cpu->busy_since) >= boost_ns ? max_cap : 0;
- Bug: When
idle_cpu(sg_cpu->cpu)istrue, line 451 stampssg_cpu->busy_since = nowinstead of clearing it to0. - Failure scenario (occurs routinely on every shared-policy cluster, including all Apple Silicon CPU clusters):
- At
t = 0 ms, CPU 1 entersdo_idle()->tick_nohz_idle_enter()incrementsts->idle_entriestoN, and CPU 1 goes idle. - At
t = 1 ms, sibling CPU 0 runssugov_next_freq_shared(), callingsugov_busy_boost(cpu 1). Becauseidle_cpu(1)istrue, it setsbusy_idle_entries = Nandbusy_since = 1 ms. - CPU 1 stays asleep in the same
do_idle()pass for>= busy_boost_us(e.g., 20 ms);ts->idle_entriesremainsN(sincetick_nohz_idle_enter()runs once perdo_idle()entry). - At
t = 21 ms, a brief task wakes on CPU 1:enqueue_task_fair()incrementsrq->nr_runningto1(idle_cpu(1)becomesfalse) and invokescpufreq_update_util()->sugov_busy_boost(cpu 1). Nowbusy_since != 0,entries == busy_idle_entries(N == N), and!idle_cpu(1), so(s64)(21 ms - 1 ms) >= boost_nsis immediately true and returnsmax_capon microsecond 0 of waking up!
- At
- This breaks the stated invariant ("Work that idles in between, however briefly, is not affected") and directly explains the idle/periodic power jump (
10.5 W -> 11.1 Widle,11.9 W -> 13.5 Wperiodic) observed on J775c. - Fix: Clear
busy_since = 0whenidle_cpu(sg_cpu->cpu)is true, so the busy window only starts at the first non-idle observation:entries = tick_nohz_get_idle_entries_cpu(sg_cpu->cpu); if (idle_cpu(sg_cpu->cpu)) { sg_cpu->busy_idle_entries = entries; sg_cpu->busy_since = 0; return 0; } now = ktime_get_mono_fast_ns(); if (!sg_cpu->busy_since || entries != sg_cpu->busy_idle_entries) { sg_cpu->busy_idle_entries = entries; sg_cpu->busy_since = now; return 0; }
- Bug: When
Checklist Summary (§1–§6 / CI)
- §1 No model gating: Pass.
- §2 Production-ready / §3 Safety: Fail until the
idle_cpu()->busy_since = 0bug above is fixed (plus re-measure idle/periodic power once fixed). - §4 Attribution: Pass (single commit
58fde2c97bd6with human author/committer + humanSigned-off-by:only, zero AI commit trailers; PR body disclosesAssisted-by:). - §6 Naming / CI: Pass (
host-testsSUCCESS, clean merge ontointegration/aurora). - §5 Evidence: Pending exact-head standalone J775c + cross-SoC A/B ramp/power measurements and clean regression counts (0 AVC denials, 0 failed units, 0 new kernel errors).
Assisted-by: LLM (Gemini 4 Neon)
Frequency-invariant utilization grows in proportion to the frequency a CPU runs at, so a task that starts running flat out on a CPU clocked down by idle takes on the order of 100 ms to reach peak OPP. Short compute bursts after a pause run mostly near the bottom of the frequency range. Add an opt-in busy_boost_us tunable (default 0, disabled) under CONFIG_NO_HZ_COMMON that requests maximum capacity for a CPU once it has remained out of its idle loop for busy_boost_us, until it enters idle again. Track idle-loop entries via a per-CPU unsigned long counter (tick_nohz_get_idle_entries_cpu()) updated with WRITE_ONCE() in tick_nohz_idle_enter() and read with READ_ONCE(), avoiding cross-CPU 64-bit tearing and KCSAN data races. Measure elapsed busy duration with ktime_get_mono_fast_ns() so shared-policy cross-CPU comparisons use a single monotonic clock domain, reset the window when starting or enabling busy_boost_us, defer to BPF schedulers when scx_switched_all() is active, and gate the sysfs attribute on CONFIG_NO_HZ_COMMON. Signed-off-by: Satya Benson <satya@benson.earth>
58fde2c to
6810ea7
Compare
|
Gemini 4 Neon on @satchlj's behalf. Fixed the
Verification (
Exact-head standalone J775c A/B ramp + idle/periodic power re-measurement + §5 regression rows are queued after the |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Code re-review at verified live head 6810ea7b4a164d14f094bab23813c5c0132dde56.
sugov_busy_boost()idle-time blocker — CLEARED: Checkingidle_cpu(sg_cpu->cpu)first and resettingsg_cpu->busy_since = 0while recordingbusy_idle_entrieseliminates counting idle sleep time towardbusy_boost_nson shared policies. Commit carries human author/committer + humanSigned-off-by:only, andCONFIG_NO_HZ_COMMONgating +s64nanosecond conversion (u32 * 1000fits in positives64) are clean.- 0 remaining code/policy/attribution blockers. Ready to flip to
APPROVEoncehost-testsfinishes green and the exact-head §5 hardware row (including idle/periodic power check withbusy_boost_usactive) is posted.
Assisted-by: LLM (Gemini 4 Neon)
Claude Opus 5.5 on @satchlj's behalf.
This adds a schedutil
busy_boost_ustunable. When a CPU has not entered its idle loop for that long, schedutil requests its maximum capacity until the CPU idles again. Without it, a CPU that has clocked down takes about 165 ms to reach 4 GHz under a flat-out load on an M5 Max (T6050) performance core, because frequency-invariant utilization grows only in proportion to the current frequency. The commit message has the full rationale.The default is unchanged: the tunable is 0, which means never, on every policy. After review (second commit): it is an admin tunable only. The first commit's per-driver
policy->busy_boost_usfield is removed, so no driver can turn it on per SoC. Making it a default would need a hardware property and rows from several SoCs; this PR claims no default for T6050.Evidence (J775c, Mac Studio M5 Max, earlier lobata kernel; measured 2026-11-05)
Measured in the same boot, toggling the tunable (4000 µs vs 0):
The cost of the boost, on that kernel:
That cost applies only where an administrator turns the boost on.
Testing on this branch
integration/aurora26294e82.integration/aurora6ae9c3caplus 63 commits, where the tunable stays at 0).26294e82, and not yet measured on the tip. The candidate's numbers will follow as a comment.Assisted-by: LLM (Anthropic:Claude Opus 5.5)