Re: [Patch v4 18/22] sched/cache: Enable cache aware scheduling for multi LLCs NUMA node

Peter Zijlstra
2026-04-09T13:38:23Z

On Wed, Apr 01, 2026 at 02:52:30PM -0700, Tim Chen wrote:

> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 995a42cb4697..0b1fc1b0709d 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -809,6 +809,7 @@ enum s_alloc {
> };
>
> #ifdef CONFIG_SCHED_CACHE
> +DEFINE_STATIC_KEY_FALSE(sched_cache_present);
> static bool alloc_sd_llc(const struct cpumask *cpu_map,
> struct s_data *d)
> {
> @@ -2674,6 +2675,7 @@ static int
> build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *attr)
> {
> enum s_alloc alloc_state = sa_none;
> + bool has_multi_llcs = false;
> struct sched_domain *sd;
> struct s_data d;
> struct rq *rq = NULL;
> @@ -2784,10 +2786,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;
> + }
> imb = max(1U, imb);
> sd->imb_numa_nr = imb;
>

Well that all don't apply :/

Also, this seems sub-optimal, we can have multi-llc without NUMA.

Doesn't the LLC domain having a parent more or less imply there being
multiple and we should be doing this, irrespective of having NUMA?