Skip to content

sched/topology: disable cache-aware LLC aggregation without peer-capacity LLCs - #3993

Open
IronsideXXVI wants to merge 1 commit into
aurora-silicon:mainfrom
IronsideXXVI:j604/sched-topology-multi-llc-asym
Open

IronsideXXVI wants to merge 1 commit into
aurora-silicon:mainfrom
IronsideXXVI:j604/sched-topology-multi-llc-asym

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What: Disable cache-aware LLC aggregation (CONFIG_SCHED_CACHE / sched_cache_present) on topologies that have no equal-capacity peer LLCs within the enclosing partition. In kernel/sched/topology.c, update sd_in_multi_llcs() to climb to the partition root and require at least one CPU outside @sd with matching arch_scale_cpu_capacity(), and update partition_sched_domains_locked() to scan reused partitions across all CPUs rather than only cpumask_first(doms_cur[j]). On asymmetric SoCs with a single LLC per capacity class (such as Apple T8132 with one 4-core P-cluster LLC at capacity 1024 and one 6-core E-cluster LLC at capacity 488), there are no equivalent peer LLCs to aggregate onto; every cross-LLC boundary is an asymmetric capacity boundary already governed by SD_ASYM_CPUCAPACITY and EAS. Leaving sched_cache_active enabled on T8132 adds per-tick epoch tracking, task_work allocations, and LLC-affinity load-balance vetoes that fight asymmetric misfit rotation and unstacking. Heterogeneous chips with multiple equal-capacity LLCs (such as M4 Pro/Max with two P-core LLCs plus an E-core LLC, even when CPU 0 is an E-core) and symmetric multi-CCX systems keep sched_cache_present enabled unchanged.

Tested:

  • Offline on aurora-silicon/linux main (b3a5fda631b9, 0 conflicts against current origin/main f4b229b300bb, branch j604/sched-topology-multi-llc-asym, commit f39dcd8f0ad8):
    • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks (73 lines checked).
    • Clang 18.1.8 ARM64 LLVM=1 W=1 KCFLAGS="-Werror":
      • CONFIG_SCHED_CACHE=y: kernel/sched/topology.o (491952 bytes), 0 warnings, 0 errors.
      • CONFIG_SCHED_CACHE=n: kernel/sched/topology.o (478776 bytes), 0 warnings, 0 errors.
    • Host C unit test (test_sd_in_multi_llcs, -Wall -Wextra -Werror -O2 -fsanitize=undefined): 7/7 PASS (T8132 4P+6E -> false, M4 Pro/Max 2x P-LLC + E-LLC -> true, Symmetric 2-CCX -> true, Single-LLC solo & degenerate -> false, Single-CPU LLC -> false, 2-die asymmetric NUMA -> true, 3-tier 1-LLC-per-tier -> false).
  • Full-kernel release build (linux-aurora 7.3.0.aurora1-1.1687, commit d904832564b4): 0 compiler warnings in kernel/sched/topology.c, ARM64 QEMU KUnit 205/205 passed.
  • Live Apple M4 MacBook Pro 14" (J604, T8132) A/B validation of disabling llc_balancing on T8132 (llc_balancing=0 vs llc_balancing=1): int10 improved from 4990.0 to 5142.0 (+152.0, 99.0% of native), fp10 +1.6, wait_est_int_ms dropped from 1913.5 ms to 122.0 ms, 0 kernel faults.
  • Live Apple M4 MacBook Pro 14" (J604, T8132) hardware verification on integrated linux-aurora 7.3.0.aurora1-1.1687 (carrying this patch alongside the apple-pmp-thermal cool-poll/dark-hold patch, 0 kernel faults across all runs):
    • Multi-core CPU throughput (n=10): int10 median improved 4994.0 -> 5046.4 (96.2% -> 97.2% of native macOS, peak 5145.7/5137.3, fp10 128.6).
    • Detached idle wakeups (n=10): median 114.58 -> 112.44/s (81.0% -> 82.6% parity, steady windows W5–W8 94.92..98.48/s, pmp_sc 4.90/s across 11/12 windows, smc 2.76/s).
    • Idle & sustained power (n=10): PHPC idle 730.5 -> 681.5 mW (96.5% -> 103.5%, -49.0 mW, 600-sample pool), PMVR 2071.0 -> 1979.9 mW (89.3% -> 93.4%, -91.1 mW), PSTR 3915.9 -> 3759.2 mW (107.4% -> 111.9%, -156.7 mW), sustained all-core pwrspin chain10 3661.0 MHz/W (98.5%, fan_max 0 rpm).
    • Release gates: 619 s idle PMP window (pmp_sc 9.61 -> 4.89/s, PMPEV events=0 supp=0 serr=0), idle die 33.8 C <= 34.0 C, deep-sleep suspend/wake rc=0 (pmp_err=0), compositor frame-rate gate 1584.3 fps, 0 kernel faults.

Risk: two-way door · all platforms (kernel/sched/topology.c, +32 / -11 lines) — preserves CONFIG_SCHED_CACHE=y, the debugfs ABI, symmetric multi-LLC topologies, DTs without capacities, and multi-equal-capacity-LLC Apple Silicon chips (T6000/T6020, T6031, T6040/T6041, T6050, Ultras). On single-LLC-per-capacity-class asymmetric Apple Silicon SoCs — base chips T8103, T8112, T8122, T8132, T8140, and T6030 (one P-core LLC and one E-core LLC, where cluster capacities are closer at 851 vs 1024) — sched_cache_present stays false so sched_cache_enabled() compiles to static-key NOPs; a plain revert restores the previous span-only check.

Not yet:

  • Exact-head main (b3a5fda631b9) bare-metal J604 (T8132) multi-core A/B + sched/verbose hotplug row at commit f39dcd8f0ad8 (the live J604 linux-aurora 1.1687 runs above also carried thermal: apple-pmp: 200 ms cool slow poll on #3949 + #3766 #3994; the llc_balancing 0/1 A/B isolated this knob).
  • T6030 (J516s) and T8140 (J700) multi-core/compile A/B vs base, and T6050 (J714s) / T6000 (J414s) confirmation that sched_cache_present remains active across hotplug and cpuset partition create/remove.
Details and verification

Scope (j604/sched-topology-multi-llc-asym, head f39dcd8f0ad8 on main b3a5fda631b9)

  • kernel/sched/topology.c (+32 / -11)
  • Sign-off: Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
  • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks (73 lines checked).
  • Clang 18.1.8 ARM64 LLVM=1 W=1 KCFLAGS="-Werror":
    • CONFIG_SCHED_CACHE=y: kernel/sched/topology.o 0 warnings (491952 bytes).
    • CONFIG_SCHED_CACHE=n: kernel/sched/topology.o 0 warnings (478776 bytes).
  • Host C unit test (test_sd_in_multi_llcs, UBSan enabled): 7/7 passed.

Mechanism summary

  • Previously sd_in_multi_llcs() returned !!sdp after skipping same-span parents, so any asymmetric SoC with one P-core LLC and one E-core LLC under a package domain had sched_cache_present = true even though no equal-capacity sibling LLC existed.
  • Climbing to the enclosing partition root (while (sdp->parent) sdp = sdp->parent;) and checking for_each_cpu_andnot(cpu, sched_domain_span(sdp), sched_domain_span(sd)) for arch_scale_cpu_capacity(cpu) == cap ensures cache-aware LLC aggregation activates only when at least one peer LLC of matching capacity exists.
  • Scanning all CPUs in doms_cur[j] for reused partitions in partition_sched_domains_locked() prevents a single-LLC capacity class on CPU 0 (e.g., an E-core cluster) from masking peer P-core LLCs in the same partition.

…city LLCs

Cache-aware LLC aggregation (CONFIG_SCHED_CACHE) aggregates related
tasks onto a preferred LLC chosen among equivalent sibling LLCs. On
asymmetric SoCs that have only a single LLC per CPU capacity class
(such as Apple T8132 with one P-core LLC and one E-core LLC), there
are no equal-capacity peer LLCs to choose between; every cross-LLC
boundary is already an asymmetric capacity boundary governed by
SD_ASYM_CPUCAPACITY and EAS.

Enabling sched_cache_active on such topologies adds per-tick epoch
tracking, task_work allocations, and LLC-affinity load-balance vetoes
that fight asymmetric misfit rotation and unstacking without any
symmetric peer LLC to benefit from.

Require at least one CPU outside @sd in the enclosing partition with
matching arch_scale_cpu_capacity() in sd_in_multi_llcs() before
enabling sched_cache_present, and scan reused partitions in
partition_sched_domains_locked() so heterogeneous chips that do have
multiple equal-capacity LLCs (such as two P-core LLCs plus one E-core
LLC) keep cache-aware scheduling enabled even when CPU 0 belongs to
a single-LLC capacity class.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI
IronsideXXVI requested review from a team as code owners December 2, 2026 20:40
@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merge readiness at f39dcd8f: ready to merge

Check Detail
CI at head ok 1 check passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at f39dcd8f
Conflicts ok none
PR text ok Risk: two-way · all platforms (kernel/sched/topology.c, +32 / -11 lines) — preserves CONFIGSCHEDCACHE=y, the debugfs ABI, symmetric multi-LLC topologies, DTs without capacities, and multi-equal-capacity-LLC Apple Silicon chips (T6000/T6020, T6031, T6040/T6041, T6050, Ultras). On single-LLC-per-capacity-class asymmetric Apple Silicon SoCs — base chips T8103, T8112, T8122, T8132, T8140, and T6030 (one P-core LLC and one E-core LLC, where cluster capacities are closer at 851 vs 1024) — schedcachepresent stays false so schedcacheenabled() compiles to static-key NOPs; a plain revert restores the previous span-only check.

Areas: none matched in CODEOWNERS
Merge: gh pr merge 3993 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at f39dcd8f0ad8: the code is right and has the shape upstream would want (generic, no board or SoC test). Approving; it still needs the rows below before merge.

  • sd_in_multi_llcs() now asks whether another CPU of the same capacity exists in the partition, outside this LLC. The walk works both before and after degeneration. A partition with a single LLC, or only one CPU in the LLC, still returns false.
  • The reused-partition change is needed with it: CPU 0 is an E core on our Macs, so looking only at the first CPU would have switched the feature off on T60x0/T60x1. Scanning stops at the first hit, under the same RCU guard.
  • Capacity changes are covered: the arch topology update forces a full rebuild, so the key is re-evaluated.
  • I ran the helper over each SoC's cluster layout from the DTs. Still on: T6000/T6020 (J414s), T6031, T6040/T6041 (both P tables top out at 4512 MHz), T6050 (two equal M clusters, J714s), the Ultras, and any DT without capacities. Now off: T8103, T8112, T8122, T8132, T8140 and T6030 (one P and one E LLC).

So it's wider than T8132. All the numbers in the PR are from T8132, and 1.1687 also carried #3994; the llc_balancing 0/1 A/B is the clean one. T6030's two clusters are close in capacity (851 vs 1024), so that's where losing aggregation could cost something. Please list T6030, T8140 and the other base chips in Risk, and send this to the scheduler list as well. I'd add one line to the comment saying an LLC's CPUs are taken to share one capacity.

Checked on main 2c667a4b + this head: kernel/sched/topology.o W=1 with SCHED_CACHE on and off, no warnings; checkpatch --strict clean. Hosted host-tests shows as skipped at this head.

Rows before merge, at this head:

  1. J773g (T8132): multi-core A/B vs base. With sched/verbose on, a CPU hotplug logs "not supported on this platform".
  2. J516s (T6030) and J700 (T8140): multi-core and compile A/B vs base, no loss.
  3. J714s (T6050): the same hotplug still logs "enabling cache aware scheduling", also after a cpuset partition is made and removed around it. J414s too, once it is back.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks for checking the cluster layouts across the DTs and for the approval.

  • Updated the PR description Risk (and Not yet) to list T6030, T8140, and the other base chips (T8103, T8112, T8122, T8132) where sched_cache_present is now disabled, alongside the multi-equal-capacity-LLC chips where it stays enabled (T6000/T6020, T6031, T6040/T6041, T6050, Ultras), and noted T6030's closer 851 vs 1024 cluster capacities.
  • Leaving f39dcd8f0ad8 unchanged here so approval stays intact; noted the one-line comment clarifying that an LLC's CPUs are taken to share one capacity and will include it when posting this upstream to the Linux scheduler list as well.
  • Will follow up with the standalone J604 (T8132) multi-core A/B and sched/verbose hotplug row at f39dcd8f0ad8.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) ready-to-merge Meets the merge policy: merge it (bot) labels Dec 2, 2026
@github-actions github-actions Bot added the ready-to-merge Meets the merge policy: merge it (bot) label Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

J700 (MacBook Neo, A18 Pro, T8140: one 2-core P-cluster and one 4-core E-cluster) at f39dcd8f0ad8: PASS

Two one-shot trial boots on 2026-12-03: base = main 4c6f0f70 + #2700 + #1688, head = the same + this PR (commit ff0c223eb276), exact head blobs on 4c6f0f70, not GitHub's merge commit. The same .config and toolchain. One boot per arm.

Check Result
Cache-aware scheduling state base logs _sched_cache_active_set: enabling cache aware scheduling, head logs cache aware scheduling not supported on this platform. The PR does what it says on this two-cluster Mac
Throughput (5 rounds, pinned checksums, schedutil) int6 1.0013, fp6 1.0089, int2 0.9759, compile 1.0209 (head over base). All inside the spread of the runs (base 3.4 to 13 %, head 4 to 6 %)
wake4 (recorded only) 1.0217, but the spread is 87 to 115 %, so it says nothing
CPUs, governors 0 to 5 online, schedutil throughout, no frequency cap seen
Sleeps (3 × s2idle, 1 × mem), display, kernel log, watchdog PASS on both arms, 0 WARN, BUG, Oops or fault lines

Not covered: one boot per arm; int2 at 0.976 is inside the head's 6.2 % spread and wasn't rerun, so I can't rule out a 2 % effect there. No other SoC.

This branch has not been deployed

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

Labels

blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants