Repository navigation
sched/topology: disable cache-aware LLC aggregation without peer-capacity LLCs - #3993
IronsideXXVI wants to merge 1 commit into
Conversation
…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>
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
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:
- J773g (T8132): multi-core A/B vs base. With
sched/verboseon, a CPU hotplug logs "not supported on this platform". - J516s (T6030) and J700 (T8140): multi-core and compile A/B vs base, no loss.
- 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.
|
Thanks for checking the cluster layouts across the DTs and for the approval.
|
J700 (MacBook Neo, A18 Pro, T8140: one 2-core P-cluster and one 4-core E-cluster) at
|
| 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.
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. Inkernel/sched/topology.c, updatesd_in_multi_llcs()to climb to the partition root and require at least one CPU outside@sdwith matchingarch_scale_cpu_capacity(), and updatepartition_sched_domains_locked()to scan reused partitions across all CPUs rather than onlycpumask_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 bySD_ASYM_CPUCAPACITYand EAS. Leavingsched_cache_activeenabled on T8132 adds per-tick epoch tracking,task_workallocations, 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 keepsched_cache_presentenabled unchanged.Tested:
aurora-silicon/linuxmain(b3a5fda631b9, 0 conflicts against currentorigin/mainf4b229b300bb, branchj604/sched-topology-multi-llc-asym, commitf39dcd8f0ad8):scripts/checkpatch.pl --strict:0errors,0warnings,0checks (73lines checked).LLVM=1 W=1 KCFLAGS="-Werror":CONFIG_SCHED_CACHE=y:kernel/sched/topology.o(491952bytes),0warnings,0errors.CONFIG_SCHED_CACHE=n:kernel/sched/topology.o(478776bytes),0warnings,0errors.test_sd_in_multi_llcs,-Wall -Wextra -Werror -O2 -fsanitize=undefined):7/7PASS (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).linux-aurora 7.3.0.aurora1-1.1687, commitd904832564b4):0compiler warnings inkernel/sched/topology.c, ARM64 QEMU KUnit205/205passed.llc_balancingon T8132 (llc_balancing=0vsllc_balancing=1):int10improved from4990.0to5142.0(+152.0,99.0%of native),fp10+1.6,wait_est_int_msdropped from1913.5 msto122.0 ms,0kernel faults.linux-aurora 7.3.0.aurora1-1.1687(carrying this patch alongside theapple-pmp-thermalcool-poll/dark-hold patch,0kernel faults across all runs):n=10):int10median improved4994.0 -> 5046.4(96.2% -> 97.2%of native macOS, peak5145.7/5137.3,fp10128.6).n=10): median114.58 -> 112.44/s(81.0% -> 82.6%parity, steady windows W5–W894.92..98.48/s,pmp_sc 4.90/sacross 11/12 windows,smc 2.76/s).n=10):PHPCidle730.5 -> 681.5 mW(96.5% -> 103.5%,-49.0 mW, 600-sample pool),PMVR2071.0 -> 1979.9 mW(89.3% -> 93.4%,-91.1 mW),PSTR3915.9 -> 3759.2 mW(107.4% -> 111.9%,-156.7 mW), sustained all-corepwrspin chain103661.0 MHz/W(98.5%,fan_max 0 rpm).pmp_sc9.61 -> 4.89/s,PMPEV events=0 supp=0 serr=0), idle die33.8 C <= 34.0 C, deep-sleep suspend/wakerc=0(pmp_err=0), compositor frame-rate gate1584.3 fps,0kernel faults.Risk: two-way door · all platforms (
kernel/sched/topology.c,+32 / -11lines) — preservesCONFIG_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_presentstays false sosched_cache_enabled()compiles to static-key NOPs; a plain revert restores the previous span-only check.Not yet:
main(b3a5fda631b9) bare-metal J604 (T8132) multi-core A/B +sched/verbosehotplug row at commitf39dcd8f0ad8(the live J604linux-aurora 1.1687runs above also carried thermal: apple-pmp: 200 ms cool slow poll on #3949 + #3766 #3994; thellc_balancing0/1 A/B isolated this knob).sched_cache_presentremains active across hotplug and cpuset partition create/remove.Details and verification
Scope (
j604/sched-topology-multi-llc-asym, headf39dcd8f0ad8onmainb3a5fda631b9)kernel/sched/topology.c(+32 / -11)Signed-off-by: Dylan Ironside <dylan@dylanironside.io>scripts/checkpatch.pl --strict:0 errors, 0 warnings, 0 checks(73lines checked).LLVM=1 W=1 KCFLAGS="-Werror":CONFIG_SCHED_CACHE=y:kernel/sched/topology.o0warnings (491952bytes).CONFIG_SCHED_CACHE=n:kernel/sched/topology.o0warnings (478776bytes).test_sd_in_multi_llcs, UBSan enabled):7/7passed.Mechanism summary
sd_in_multi_llcs()returned!!sdpafter skipping same-span parents, so any asymmetric SoC with one P-core LLC and one E-core LLC under a package domain hadsched_cache_present = trueeven though no equal-capacity sibling LLC existed.while (sdp->parent) sdp = sdp->parent;) and checkingfor_each_cpu_andnot(cpu, sched_domain_span(sdp), sched_domain_span(sd))forarch_scale_cpu_capacity(cpu) == capensures cache-aware LLC aggregation activates only when at least one peer LLC of matching capacity exists.doms_cur[j]for reused partitions inpartition_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.