Re: [PATCH v2 1/2 RESEND] sched/fair: take into account scheduling domain in select_idle_smt()

From: Vincent Guittot
Date: Thu Jan 11 2024 - 03:53:17 EST


On Wed, 10 Jan 2024 at 18:57, Keisuke Nishimura
<keisuke.nishimura@xxxxxxxx> wrote:
>
> >>
> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> >> index 533547e3c90a..66457d4b8965 100644
> >> --- a/kernel/sched/fair.c
> >> +++ b/kernel/sched/fair.c
> >> @@ -7311,13 +7311,19 @@ static int select_idle_core(struct task_struct *p, int core, struct cpumask *cpu
> >> /*
> >> * Scan the local SMT mask for idle CPUs.
> >> */
> >> -static int select_idle_smt(struct task_struct *p, int target)
> >> +static int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int target)
> >> {
> >> int cpu;
> >>
> >> for_each_cpu_and(cpu, cpu_smt_mask(target), p->cpus_ptr) {
> >> if (cpu == target)
> >> continue;
> >> + /*
> >> + * Check if the CPU is in the LLC scheduling domain of @target.
> >> + * Due to isolcpus, there is no guarantee that all the siblings are in the domain.
> >> + */
> >> + if (!cpumask_test_cpu(cpu, sched_domain_span(sd)))
> >
> > commit df3cb4ea1fb6 ("sched/fair: Fix wrong cpu selecting from isolated domain")
> > also checked if (!cpumask_test_cpu(cpu, p->cpus_ptr) ||
> >
> > Why didn't you also re-add this test ?
> >
> >
>
> Thank you for your comment. This is because the iterator "for_each_cpu_and(cpu,
> cpu_smt_mask(target), p->cpus_ptr)" ensures that cpu is included in p->cpus_ptr.

Ah yes indeed. I didn't notice that it was now included in the for_each_cpu_and

Reviewed-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>


>
> The iterator has changed. FYI, here is the change made in commit df3cb4ea1fb6:
>
> for_each_cpu(cpu, cpu_smt_mask(target)) {
> - if (!cpumask_test_cpu(cpu, p->cpus_ptr))
> + if (!cpumask_test_cpu(cpu, p->cpus_ptr) ||
> + !cpumask_test_cpu(cpu, sched_domain_span(sd)))
> continue;
> if (available_idle_cpu(cpu) || sched_idle_cpu(cpu))
>
> best,
> Keisuke
>