Re: [PATCH 04/19] sched/fair: Introduce a static key to enable cache aware only for multi LLCs

From: Chen, Yu C

Date: Mon Oct 27 2025 - 09:15:19 EST


Hi Prateek,

On 10/27/2025 1:42 PM, K Prateek Nayak wrote:
Hello Tim,

On 10/11/2025 11:54 PM, Tim Chen wrote:
@@ -2530,10 +2531,12 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
* between LLCs and memory channels.
*/
nr_llcs = sd->span_weight / child->span_weight;
- if (nr_llcs == 1)
+ if (nr_llcs == 1) {
imb = sd->span_weight >> 3;
- else
+ } else {
imb = nr_llcs;
+ has_multi_llcs = true;

One caution: this will not hold if all the CPUs aren't online during boot.
One case I can think of is when the kernel is booted with "maxcpus" cmdline
and CPUs are hotplugged later.

Unfortunately, I don't think we even have the raw topology data from the
arch/ side under such scenario to accurately make a call if the system
contains single or multiple LLC :(

I'm not sure if it is feasible but assuming the task_work() cannot run if
&sched_cache_allowed is false, can the fist instance of the task work for
sched_cache do the necessary setup?


build_sched_domains() might get invoked to rebuild the corresponding sched
domains during CPU hotplug via cpuset subsystem. So if the CPU gets online
after bootup, we still have the chance to detect multiple LLCs I suppose?

I did a check on my VM:
root@ubuntu:/sys/devices/system/cpu# lscpu
CPU(s): 32
On-line CPU(s) list: 0-7
root@ubuntu:/sys/devices/system/cpu# echo 1 > cpu31/online
Tracing ... Hit Ctrl-C to end.
^C

@build_sched_domains[
build_sched_domains+5
partition_sched_domains+613
cpuset_update_active_cpus+838
sched_cpu_activate+272
cpuhp_invoke_callback+340
cpuhp_thread_fun+139
smpboot_thread_fn+238
kthread+249
ret_from_fork+193
ret_from_fork_asm+26
]: 1

thanks,
Chenyu