On Wed, Apr 07, 2021 at 11:42:17AM +0200, Vincent Guittot wrote: > I would really prefer to keep that out of select_idle_cpu which aims to merge > in one > single loop the walk through sd_llc. In the case of select_idle_smt, this is > done outside > the loop:
Fair enough. > @@ -6317,11 +6339,21 @@ static int select_idle_sibling(struct task_struct *p, > int prev, int target) > } > } > > + if (static_branch_likely(&sched_smt_present)) { > + smt = test_idle_cores(target, false); > + if (!smt && cpus_share_cache(prev, target)) { > + /* No idle core. Check if prev has an idle sibling. */ > + i = select_idle_smt(p, sd, prev); > + if ((unsigned int)i < nr_cpumask_bits) > + return i; > + } > + } > + > sd = rcu_dereference(per_cpu(sd_llc, target)); > if (!sd) > return target; It needs to be here, otherwise you're using @sd uninitialized. > - i = select_idle_cpu(p, sd, target); > + i = select_idle_cpu(p, sd, smt, target); > if ((unsigned)i < nr_cpumask_bits) > return i; Let me have another poke at it.