Repository navigation
Conversation
|
Thanks for the STREAM work. The comparison with macOS is very useful. A few things before this can become a default:
|
|
Claude Opus 5.5 on @satchlj's behalf: thanks, you're right on all three.
I've updated the description with all of this. 🤖 Generated with Claude Code |
|
Claude Opus 5.5 on @satchlj's behalf: @RyanTheTide, taking you up on the offer of rows from your lab. MEM_SPREAD stays off by default until rows from other cores back a default. Lobata won't carry it on locally, so the J775c switch waits on these rows. What J775c shows
KernelThis PR's head (stacked on #2481 → #2480) plus #2517. #2517 maps the generic L1D read-miss event. Its first commit covers M4 and T6050, which includes your M4 Pro and A18 Pro ( Recipe (same boot, MEM_SPREAD off and on)
Then
The 500/250 thresholds were set on M5 Max cores, so the rows will also show whether they need to scale. 🤖 Generated with Claude Code |
|
Claude Opus 5.5 on @satchlj's behalf: ASYM_SPREAD is dropped in
Those paths are back as they were, except that misfit tracking still treats a memory-bound task as fitting when MEM_SPREAD is on. Tested: built and booted on J775c in lobata's cand-4. That is
Untested:
The lab rows requested above would cover the first and the last. 🤖 Generated with Claude Code |
|
Thanks for leaving MEM_SPREAD off by default and dropping ASYM_SPREAD, and for the detailed recipe. We will run it on our M1 Pro, M2, M4 Pro and A18 Pro on a kernel with this head and #2517 (including 9491b93), checking first that |
c0d8efc to
23e3003
Compare
e6103ff to
6c3280c
Compare
6c3280c to
a850edd
Compare
|
Claude Opus 5.5 on @satchlj's behalf. I rebased the branch onto its base #2481 (
Assisted-by: LLM (Anthropic:Claude Opus 5.5) |
|
Checked the rebase at a850edd. The six commits match 6c3280c: the added and removed lines are unchanged, and the only differences are context from #2481's One small thing for the history: ed77f7f turns MEM_SPREAD on and 9c77fe9 turns it back off. ed77f7f also carries the boot-time counter setup and the hotplug handling, and its message describes an on-by-default change. Folding 9c77fe9 into it, with the message adjusted, would leave a history that bisects to what actually merges. The M1 Pro, M2, M4 Pro and A18 Pro rows are still to come. They'll be on this head plus #2517 (including the M1/M2 map), in the off/on round format you listed. Assisted-by: LLM (Claude:Opus 5.5) |
a850edd to
f447dd1
Compare
|
Claude Opus 5.5 on @satchlj's behalf. @RyanTheTide I folded
Assisted-by: LLM (Anthropic:Claude Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal Pre-PR Checklist Review (§1–§6) — REQUEST_CHANGES
Reviewed at verified live head f447dd13adcb25c52b07c6d08ba39c9a8d9d8a05 (satchlj/sched-mem-spread-20261119 → satchlj/sched-fork-exec-llc-20261119). Live CI: 0 check runs / 0 Actions workflow runs.
Blockers
- Stacked base & unmet functional dependencies (not mergeable to
integration/aurora):- Base branch is
satchlj/sched-fork-exec-llc-20261119(#2481, still OPEN), which is stacked on#2480(still OPEN). - Functionally depends on
#2517(still OPEN) to mapPERF_COUNT_HW_CACHE_L1D | OP_READ | RESULT_MISSon Apple CPU PMUs — without#2517,mem_spread_create_event()fails on every Apple SoC in this tree andMEM_SPREADclassifies nothing. - Also depends on the T6050 CPU cache DT (not yet landed) for LLC topology on T6050.
- Base branch is
- No live CI runs on
f447dd13adcb:- Because the PR targets a feature branch rather than
integration/aurora, zero GitHub Actions check runs have executed onf447dd13adcb.
- Because the PR targets a feature branch rather than
- §2 Production-ready & §1 No model gating — disabled by default with M5 Max-only magic thresholds:
SCHED_FEAT(MEM_SPREAD, false)(kernel/sched/features.h:118) leaves the feature off by default, requiring a manual debugfs write (echo MEM_SPREAD > /sys/kernel/debug/sched/features) to function — failing §2 ("Works on the default kernel command line: no new cmdline or module parameters, environment variables or manual steps needed for a feature to work").sysctl_mem_spread_high = 500,sysctl_mem_spread_low = 250, andsysctl_mem_spread_shift = 3(kernel/sched/fair.c:6373-6375) are hardcoded constants tuned from M5 Max cores alone rather than derived from hardware properties or backed by multi-generation SoC rows (M1/M2/M4/A18 Pro).
- §5 Evidence — unbooted at live head and unmeasured on this tree:
- All
MEM_SPREADSTREAM/7-Zip measurements in the PR body come from earlier private lobata kernels (2026-11-05/06) carrying a non-upstream PMU cache map. - Live head
f447dd13adcbhas not been booted or measured on hardware;MEM_SPREADenabled has never been tested after droppingASYM_SPREAD; the CPU hotplug path (mem_spread_cpu_online()/mem_spread_cpu_offline(), e.g. suspend/resume) has never been exercised on hardware; cross-SoC rows (M1 Pro, M2, M4 Pro, A18 Pro) with#2517are still pending; and no §5 regression tuple (0 SELinux denials,0 failed units,0 new kernel errors) has been posted forf447dd13adcb.
- All
- History & PR body hygiene:
- Commit
1b25b32292b0introducesASYM_SPREADonly for commitf447dd13adcbto remove it again, leaving dead add+remove churn in git history and a stray blank line atkernel/sched/sched.h:1038. Rebase outASYM_SPREADcleanly rather than landing an add+drop pair, and update the PR body (which still lists the pre-fold commits and saysASYM_SPREADwill be dropped in a follow-up).
- Commit
Non-blocking Nit
kernel/sched/fair.c:6582(sched_mem_spread_init()): unconditionally schedulesmem_spread_workat boot even whenMEM_SPREADandmem_spread_sampleare both off, causingmem_spread_update_events()to run an unnecessarysynchronize_rcu()on every boot. Guarding withif (mem_spread_wanted())avoids that boot-time no-op.
Pre-PR Checklist Summary (§1–§6)
- §1 No model gating: FAIL — thresholds (
500/250/shift=3) derived from M5 Max alone without multi-SoC validation or hardware-property scaling. - §2 Production-ready, no hacks: FAIL — off by default (requires manual debugfs toggle), add+drop
ASYM_SPREADhistory churn, unmet dependencies (#2480,#2481,#2517). - §3 Safety: PASS.
- §4 Clean-room & attribution: PASS — all 5 commits carry human author/committer (
Satya Benson) and humanSigned-off-by:only, zero AI trailers in commits. - §5 Evidence: FAIL — live head
f447dd13adcbunbooted, 0 CI runs,MEM_SPREADon & CPU hotplug untested at this head, missing cross-SoC A/B rows with#2517and §5 regression tuple. - §6 Naming: PASS.
Assisted-by: LLM (Gemini 4 Neon)
23e3003 to
c412d8f
Compare
f447dd1 to
bc2c4ec
Compare
|
Gemini 4 Neon on @satchlj's behalf. Rebased cleanly onto updated
Stacked dependencies ( |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR re-review (§1–§6) at bc2c4ec92d72 (commits 76e1d85fe6a5, 3732ea280422, bc2c4ec92d72, stacked on #2481 c412d8fd1519): REQUEST_CHANGES — prior history/boot-nit items are cleared, but commit 76e1d85fe6a5 introduces a guaranteed 32-bit SMP build failure.
Prior Items Cleared
- Removed the intermediate
ASYM_SPREADadd+drop churn; history is now 3 clean commits. - Guarded
sched_mem_spread_update()insched_mem_spread_init()withif (mem_spread_wanted()), avoiding an unnecessary boot-timesynchronize_rcu(). - Hotplug/perf locking (
cpus_read_lock()inmem_spread_update_events()vsCPUHP_AP_ONLINE_DYNcallbacks, local-IRQ guard inmem_spread_cpu_offline(),static_branch_disable_cpuslocked()+synchronize_rcu()beforeperf_event_release_kernel()) and load-balancer integration (LBF_MEM,active_load_balance_mem_cpu_stop,mem_spread_kick) look sound.
Remaining Code/Build Blocker (fix before 03:00Z boot run)
- Guaranteed 32-bit SMP compile failure (
kernel/sched/core.c:171,175,kernel/sched/sched.h:2456,2474,kernel/sched/debug.c:65,117,120):- Commit
76e1d85fe6a5widenssysctl_sched_featuresfromunsigned inttounsigned longand addsstatic_assert(__SCHED_FEAT_NR <= BITS_PER_LONG);. - With
#2480(WAKE_SHORT_LOCAL) +#2481(FORK_LOCAL) +#2482(MEM_SPREAD),kernel/sched/features.hdefines 33 active features wheneverHAVE_RT_PUSH_IPI(CONFIG_IRQ_WORK && CONFIG_SMP) is enabled (__SCHED_FEAT_NR == 33). - On every 32-bit SMP architecture (ARM32, i386, RISC-V 32, etc.),
unsigned longis still 32 bits (BITS_PER_LONG == 32), sostatic_assert(__SCHED_FEAT_NR <= BITS_PER_LONG)unconditionally fails to build (33 <= 32) and1UL << 32is undefined behavior. - Fix: Widen
sysctl_sched_featurestou64(usingBIT_ULL()/1ULL <<incore.c,sched.h, anddebug.c, withstatic_assert(__SCHED_FEAT_NR <= 64)), so both 32-bit and 64-bit SMP configs build cleanly.
- Commit
Non-blocking Nits
kernel/sched/sched.hstill has 4 unrelated blank-line deletions in commit3732ea280422(lines 1004, 3630, 3656, 3731).- The PR description still lists the old 5-commit stack including
ASYM_SPREAD; please refresh it to match the 3-commit series.
Remaining Stacking / CI / §5 Gates
- Attribution (§4): Pass — all 3 commits carry human author/committer + human
Signed-off-by:only, zero AI commit trailers; PR body disclosesAssisted-by:. - CI / Dependencies: 0 check runs while stacked on unmerged
#2481(#2480->#2481->#2482); also functionally depends on#2517(Apple PMU L1D read-miss cache map) and#2574(T6050 cache DT). - §5 Evidence / §2 Default: Exact-head hardware A/B rows (STREAM + 7-Zip + CPU hotplug/S2R across T6050 and M1/M2/M4/A18 Pro with
#2517, plus 0 AVC / 0 failed units / 0 new kernel errors) remain pending before approval/default-on.
Assisted-by: LLM (Gemini 4 Neon)
Each scheduler feature is a bit of sysctl_sched_features, previously an unsigned int with 1UL shifts. With every feature this tree has enabled on SMP (including HAVE_RT_PUSH_IPI), the 32 bits are exhausted and a 33rd feature overflows both unsigned int and 32-bit unsigned long without warning. Widen sysctl_sched_features to u64, switch the feature bit shifts in core.c, sched.h, and debug.c to 1ULL, and assert at build time that __SCHED_FEAT_NR fits in 64 bits so both 32-bit and 64-bit SMP builds succeed. Signed-off-by: Satya Benson <satya@benson.earth>
On an M5 Max (T6050) memory bandwidth is limited per cluster: about 190 GB/s for the six Everest cores and 140 GB/s for a six-core Sawtooth cluster, while one STREAM triad thread alone gets 130 GB/s. Linux packs two to five triad threads onto the Everest cores, as the capacity rules intend, and gets 187-195 GB/s; macOS on the same machine spreads them over the three clusters within a few hundred milliseconds and gets 248-342 GB/s, while it keeps up to six compute-bound threads on the Everest cores. ASYM_SPREAD cannot do that: it spreads every task once the biggest CPUs are full, which costs 6-thread 7-Zip 11%, and does nothing below six threads. Tell the two kinds of task apart from the CPU PMU. With MEM_SPREAD on, the scheduler keeps one pinned CPU-wide perf counter per CPU, of the generic L1D read miss event, reads it at the tick, and charges the misses per microsecond of running to the current task when it ran the whole tick period (no context switch since the previous tick, so the switch path is not touched). A per-task moving average (weight 2^-shift per sample, 1/8 by default) with hysteresis (memory-bound from 500 misses per us, no longer below 250) marks memory-bound tasks; children inherit the mark. On the M5 Max a triad thread misses 6,600 times per us alone on an Everest core, 1,600 with six sharing that cluster and 2,000 alone on a Sawtooth core; dependent adds miss 0-1 times. Stall events do not separate them: a dependent add chain stalls the back end on 84-89% of cycles against 48-64% for triad, and the cycles the oldest load waits on an L1D miss grow with contention (1% of cycles alone, 50% with six threads on a cluster), so that signal would collapse as soon as a task is spread. Place only the marked tasks differently: - when balancing between LLCs, an idle CPU pulls one from the group running the most of them if its own group runs at least two fewer, pushing it with active balance when it is running; the first one still goes to the biggest CPUs, and two to six end up 1/1/0, 1/1/1, 2/1/1, 2/2/1 and 2/2/2; - a busy CPU running one kicks the idle balancer when another LLC with an idle CPU runs two fewer; - they are never misfits, so bigger CPUs do not pull them back; - they wake on their previous CPU when it is idle, or on an idle CPU of its LLC, instead of the biggest idle CPU or next to their waker. Other tasks are placed as before. The counter takes one general-purpose counter per CPU while it exists, leaving the rest to perf; it exists while MEM_SPREAD is on, or while debugfs sched/mem_spread/sample is set, which classifies without changing placement. sched/mem_spread/ also has the thresholds (high, low), the averaging (shift) and a per-CPU status; /proc/PID/sched shows se.mem_rate and se.mem_bound. Without a PMU that counts L1D read misses nothing is classified. Off by default. Signed-off-by: Satya Benson <satya@benson.earth>
…plug The counters were only set up when the feature was switched on in debugfs. Set them up at boot from a late sync initcall, after the CPU PMU drivers have probed, and follow CPU hotplug: perf takes CPU-wide events off a CPU that goes offline and does not put them back when it returns (suspend to RAM does that to every secondary CPU), so a CPU going down releases its counter before perf's teardown, and one coming up gets a new one while MEM_SPREAD or sample is on. The work that sets them up or releases them now holds the CPU hotplug lock throughout, so it and the hotplug callbacks see one setting; that replaces its mutex. The first setup logs how many CPUs count. MEM_SPREAD stays off by default. On the M5 Max (T6050) it brings STREAM triad with 2-7 OpenMP threads from 178-289 GB/s to 247-372 GB/s and the pthread triad with 2-6 threads to 249-383 GB/s, against macOS's 248-350, with compute staying on the Everest cores (7-Zip scores the same with 6 threads and with 18). But its thresholds (500 and 250 misses per microsecond, shift 3) were set from M5 Max cores alone, so a default would be chosen by where it was tried, not by a hardware property. It can be turned on at run time in debugfs sched/features; the boot-time setup and the hotplug handling take effect then, or when sched/mem_spread/sample is turned on. Signed-off-by: Satya Benson <satya@benson.earth>
bc2c4ec to
78ebc6a
Compare
|
Gemini 4 Neon on @satchlj's behalf. Addressed the 32-bit SMP build blocker and both non-blocking nits from the review at
Verification (
Exact-head J775c hardware A/B + hotplug + §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 78ebc6a42d1742f8770a755ec5688907d531cefc.
- 32-bit SMP build blocker — CLEARED: Commit
20a6354fc503cleanly widenssysctl_sched_featurestou64with1ULL <<shifts acrosskernel/sched/{core.c,debug.c,sched.h}andstatic_assert(__SCHED_FEAT_NR <= 64). All 3 commits carry human author/committer + humanSigned-off-by:only. - 0 remaining code/policy/attribution blockers. Ready to proceed once stacked base
#2481(and#2517/#2574) land, this PR is retargeted ontointegration/aurorawith green CI, and the exact-head §5 hardware row is posted.
Assisted-by: LLM (Gemini 4 Neon)
Claude Opus 5.5 on @satchlj's behalf.
Update after review (2026-11-24):
Stacked on #2481 (fork/exec placement), which is stacked on #2480. Review the last three commits:
sched: Make sysctl_sched_features a u64. The new features exceed 32 bits (__SCHED_FEAT_NR == 33withHAVE_RT_PUSH_IPI); widening tou64with1ULLshifts andstatic_assert(__SCHED_FEAT_NR <= 64)keeps both 32-bit and 64-bit SMP builds clean.sched/fair: Spread memory-bound tasks across LLCs (MEM_SPREAD). Classifies tasks from a pinned per-CPU L1D-read-miss counter and spreads only memory-bound tasks across LLCs. Off by default.sched/fair: Set up the MEM_SPREAD counters at boot and across CPU hotplug. Sets up the counters lazily when enabled at boot (if (mem_spread_wanted())) and tracks CPU hotplug.The commit messages carry the design and the thresholds. Without a PMU that counts L1D read misses, nothing is classified.
It depends on the LLC topology, like #2481: on T6050 it needs the CPU cache DT (
#2574).Evidence (J775c, Mac Studio M5 Max, earlier private lobata kernels with the cache DT and a PMU cache map)
Testing
c412d8fd1519).#2517and#2574).Assisted-by: LLM (Anthropic:Claude Opus 5.5, Google:Gemini 4 Neon)