Re: [PATCH v4] sched/fair: do not scan twice in detach_tasks()

From: Valentin Schneider
Date: Tue Jul 22 2025 - 05:01:53 EST


On 22/07/25 09:53, Vincent Guittot wrote:
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 1b3879850a9e..636798d53798 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -11702,12 +11702,16 @@ static int sched_balance_rq(int this_cpu,
>> struct rq *this_rq,
>> * still unbalanced. ld_moved simply stays zero, so it is
>> * correctly treated as an imbalance.
>> */
>> - env.loop_max = min(sysctl_sched_nr_migrate,
>> busiest->nr_running);
>>
>> more_balance:
>> rq_lock_irqsave(busiest, &rf);
>> update_rq_clock(busiest);
>>
>> + if (!env.loop_max)
>> + env.loop_max = min(sysctl_sched_nr_migrate,
>> busiest->cfs.h_nr_runnable);
>
> it should be h_nr_queued as mentioned by Huang and my patch has been
> messed up by my web browser
>

Works for me.