v2 2026-10-20

加速大规模系统CPU热插拔 · v2

该系列优化 x86/sched/mm 大系统 CPU 热插拔;回复询问中断向量过多致 CPU 下线失败。

原始补丁链接

子 Patch(8)

1/8
x86/realmode: Remove unnecessary WBINVD from AP startup trampoline
trampoline_start 的 WBINVD 只为已删除的 Sequent NUMA-Q;INIT IPI 保持缓存状态,现代大 LLC 上 wbinvd 耗时且干扰在线 CPU,故移除该实模式全缓存刷新。
2/8
x86/smp: Remove unnecessary WBINVD from mwait_play_dead()
mwait_play_dead() 进入 MWAIT C-state 前的 WBINVD 会长时间阻塞物理核及 SMT 兄弟;硬件 C-state 已维护缓存一致性,且同 LLC 在线 CPU 可处理全局回写,故删除。
3/8
x86/mce/intel: Bound cmci_rediscover() to a single topology peer
cmci_rediscover() 原用 on_each_cpu 广播 IPI 让所有 CPU 争抢 cmci_discover_lock;记录 cmci_clear() 禁用的 cmci_orphaned_banks,只选一个同 die/package 或 SMT 的在线 peer 重新发现共享 bank。
4/8
x86/cacheinfo, mtrr: Skip stop_machine rendezvous in cache_ap_online() when MTRRs match
cache_ap_online() 原在 CPU 上线时无条件 stop_machine,让 AP 禁用缓存并重写 MTRR;新增 mtrr_generic_state_matches() 比较硬件 MTRR 与 mtrr_state,匹配则仅本地初始化 PAT 并返回,避免全局停机。
5/8
sched/topology: Avoid redundant O(N^3) group capacity walks and unused allocations in build_sched_domains()
build_sched_domains() 热插拔时对共享 sched_group/sgc 重复执行 init_sched_groups_capacity()/init_overlap_sched_group() 的整环容量和掩码计算,并预分配所有 CPU 表项;改为共享项只算一次、按需分配,消除 O(N^3) 热路径。
6/8
sched/deadline, topology: Avoid O(N^2) dl_server bandwidth walks during root_domain rebuilds
root_domain 重建时每个 CPU 的 rq_attach_root()->__dl_server_attach_root() 都重算 rd span 权重并遍历活跃 CPU 更新 rq->dl.extra_bw,产生 O(N^2) 甚至热插拔 O(N^3);避免中间 partial span 的重复带宽更新。
7/8
sched/topology: Avoid redundant percpu allocations and bitmap walks in build_sched_domains()
build_sched_groups()/build_overlap_sched_groups() 逐个 CPU 检查 covered 掩码,改为维护 uncovered 并用 cpumask_andnot 跳组;同时复用 __visit_domain_allocation_hell() 的 per-CPU 指针数组,避免每次重建 alloc_percpu/free_percpu。
8/8
mm/vmstat: Avoid redundant per-CPU stat_threshold writes in refresh_zone_stat_thresholds()
refresh_zone_stat_thresholds() 每次 CPU 热插拔都清零并重写所有在线 CPU 的 stat_threshold,造成远程 per-CPU cacheline 抖动且短暂暴露 0;先算 pgdat_threshold、上移 nodestats 更新,并仅在值变化时写入。