Repository navigation
Conversation
|
Blockers: 2.
The burst accounting in HW row: J775c, this commit alone on Assisted-by: LLM (Claude:Opus 5.5) |
…f too A pipe or futex ping-pong between two threads costs 13-17 us per round trip on an M5 Max (T6050) against 2.4-2.7 us on macOS on the same machine, and 1.1 us when both threads are pinned to one CPU. Traced with sched_waking/ipi/cpu_idle/sched_switch events, every wake-up of the partner's idle CPU takes about 3 us from the IPI to the core leaving WFI (the hardware powers idle cores down in WFI) and about 5 us until the wakee runs; and with each CPU busy only ~10% of the time, schedutil keeps the clusters at 1.3-2.3 GHz instead of 4.4-4.6 GHz. Even with the performance governor a cross-CPU round trip stays at 5-7 us. When the wakee and the waker both run only briefly between sleeps and the waker is alone on its CPU, wake the wakee there. Such a pair takes turns, so the wakee runs as soon as the waker sleeps, without an IPI or a core wake-up, and the pair keeps one CPU busy at a high clock. "Briefly" is a decaying average of the run time between sleeps below sysctl_sched_migration_cost / 8 (62.5 us by default) for both tasks, and the waker's runtime since its last sleep below the same limit. Include the unaccounted portion from exec_start to the refreshed rq task clock under the local rq lock, so a scheduler tick is not needed to see it. Requiring the waker to be alone stacks at most one wakee on a CPU. wake_wide() still spreads tasks that wake many others. The run time between sleeps is accounted in dequeue_task_fair() when a task sleeps. Give energy-aware scheduling first choice. This keeps its placement when it finds a CPU and leaves the short-wake heuristic for the normal fair wake path. The T6050 tables on this base have neither OPP power nor a CPU dynamic-power coefficient, so the DT-based cpufreq energy model is unavailable. The WAKE_SHORT_LOCAL scheduler feature turns it off at run time. Signed-off-by: Satya Benson <satya@benson.earth>
dd4abcc to
c86e358
Compare
|
Codex GPT-6.2 Sol on @satchlj's behalf Removed the co-author trailer and updated the PR footer. The waker check now adds the time from EAS keeps first choice when it returns a CPU. The T6050 DT on this base supplies neither OPP power data nor a dynamic-power coefficient for the cpufreq energy model. I found no saved runtime EAS readback for the measured lobata boot. ARM64 |
|
Codex GPT-6.2 Sol on @satchlj's behalf J775c same-boot A/B on exact Three independent invocations per state, ordered on/off/off/on/on/off. The unpinned pipe and pthread condvar/futex probes each ran five internal passes of 50,000 round trips. The table gives median and range across invocations.
schbench used one message thread, 18 workers, 15 s runtime and 3 s warmup. Initial die temperatures were 47.3/82.2/83.9 °C for on and 81.0/82.9/84.0 °C for off. The schbench ranges overlap. 0 AVC denials, one failed unit ( |
|
Re-review of c86e358: No blockers. Points from the last review:
What changed since then is the locked runtime sample in HW row: this head merged onto the current Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR checklist review (§1–§6) on head c86e358c4a4c725ea3eb822317f142f0ad40ffef.
Blockers
- Unsigned underflow in
wake_short_local()(kernel/sched/fair.c) —burst += rq_clock_task(rq) - waker->se.exec_start;performs an unclamped unsignedu64subtraction before adding toburst. Bothupdate_se()andpreempt_sync()inkernel/sched/fair.cexplicitly guard againstrq_clock_task(rq) < se->exec_startwith a signed check (s64 delta = rq_clock_task(rq) - waker->se.exec_start; if (delta > 0) burst += delta;). Without clamping, a negative delta wraps and can falsely pushburstbelowlimit(whenburst > limit) or overflow. - Missing core-scheduling cookie check in
wake_short_local()(kernel/sched/fair.c) —WAKE_SHORT_LOCALis enabled by default (SCHED_FEAT(WAKE_SHORT_LOCAL, true)) for all architectures and returnscpudirectly, bypassingselect_idle_sibling()/__select_idle_cpu(). On SMT systems withCONFIG_SCHED_COREactive, returningcpuwithout checkingsched_cpu_cookie_match(rq, p)can stack an incompatible-cookie wakee ontowaker's CPU and cause unnecessary forced-idle on SMT siblings. - Burst-accounting gaps across throttled cgroups and scheduling-class transitions (
kernel/sched/fair.c):- In
dequeue_task_fair(), the early return forif (task_is_throttled(p))runs beforeupdate_burst_avg(p). A task sleeping while its CFS bandwidth group is throttled skips recordingprev_sleep_sum_runtime, corrupting its next burst sample. - When a task switches into
fair_sched_class(e.g.,SCHED_FIFO/SCHED_RR/SCHED_DEADLINE->SCHED_NORMALinswitched_to_fair()),prev_sleep_sum_runtimeis never resynced tosum_exec_runtime(which RT/DL also advance viaupdate_curr_common()->update_se()), so its first fair sleep attributes all prior RT/DL runtime as a single burst.
- In
- §2 (Default command line) & §5 (Cross-Mac hardware evidence & clean regression run):
- The J775c A/B row (
c86e358c4a4c) was collected 370 commits behindintegration/aurora, with non-default boot parameters/config (arm64.nomte console=tty0 console=ttyDC0, PCI SDHCI disabled), and reported 1 failed unit (ac-power-mode.service) and 3 new kernel errors (Gen4 SPMI IRQ + AOP). Under §2 and §5, re-prove on currentintegration/auroratip on the default command line with 0 AVC denials, 0 failed units, and 0 new kernel errors. - Zero non-T6050 Mac testing: Across
arch/arm64/boot/dts/apple/, M1/M2/M3/M4/A18 SoCs (t8103,t600x,t8112,t602x,t8122,t8132,t6040/t6041,t8140) all defineopp-microwattand run with EAS active (unliket6050-base.dtsi, which currently has none). That means on every other Apple Silicon Mac,find_energy_efficient_cpu()preemptswake_short_local()whenever!is_rd_overutilized(rd)(so the feature won't fire for light ping-pong there, and will stop firing on T6050 once T6050 gains OPP power data), while it does fire whenever the root domain is overutilized — a regime that is completely untested on any asymmetric E/P Mac. Please run same-bootWAKE_SHORT_LOCALon/off A/B (includinghackbench -p -g 8 -l 10000, temperature-matchedschbenchp99, and unpinned ping-pong) on J775c and at least one M1/M2/M4 Mac with EAS state recorded.
- The J775c A/B row (
Non-blocking Notes
__sched_fork()initializesburst_avg = 0, which is belowlimit(62.5 µs), andupdate_avg()uses a1/8EWMA step — meaning a newly created worker can run bursts up to ~500 µs beforeburst_avgexceedslimitand stops stacking onto a brief dispatcher. Worth checking under fan-out / thread-pool workloads.
Checklist Summary
- §1 No model gating: Pass.
- §2 Production-ready / default cmdline: Fail (J775c proof used
arm64.nomte+ disabled PCI SDHCI on a 370-commit-stale base). - §3 Safety: Pass.
- §4 Clean-room & attribution: Pass (commit has human author/committer + human
Signed-off-by:only; PR body disclosesAssisted-by:). - §5 Evidence: Fail (1 failed unit + 3 kernel errors on stale base; zero non-T6050 M1/M2/M4 A/B; low-resolution
hackbenchand skewed initial die temps onschbench). - §6 Naming: Pass.
- CI:
host-testspassed onc86e358c4a4c.
Assisted-by: LLM (Gemini 4 Neon)
WAKE_SHORT_LOCALkeeps a brief wakee on the waking CPU when the waker is also brief and alone. The wake path adds the unaccounted time sinceexec_startto the waker's recorded runtime since its last sleep using the refreshed runqueue task clock.EAS gets first choice. The T6050 CPU DT on this base has no OPP power data or dynamic-power coefficient to register its cpufreq energy model. The prior lobata evidence has no runtime EAS readback for the measured boot.
This is the base of the scheduler stack. #2481 adds fork placement, and #2482 adds MEM_SPREAD.
Evidence
On earlier J775c kernels, pinned S↔S pipe ping-pong took 12.8–13.1 µs and condvar ping-pong took 13.5 µs. A kernel that combined this heuristic with fork placement, the busy boost (#2479), and cpufreq fast switch measured 1.10 µs for pipe and 1.24 µs for condvar. The isolated effect of this change remains unmeasured. The heuristic applies to task-context wakes.
Testing
kernel/sched/fair.obuilt withW=1.Assisted-by: LLM (OpenAI:GPT-6.2 Sol)