Re: [PATCH] sched/fair: fix returning possible non-optimal candidate
From: Vincent Guittot
Date: Wed Jun 21 2023 - 04:30:31 EST
On Wed, 21 Jun 2023 at 09:16, Miaohe Lin <linmiaohe@xxxxxxxxxx> wrote:
>
> In best_fits < 0 case, best_thermal_cap > prev_thermal_cap is checked to
> determine whether best_energy_cpu should be returned. But prev_fits can
> be > 0 in this case and it should be preferred.
IIRC, (best_thermal_cap > prev_thermal_cap) makes the condition
(prev_fits < 0) useless
Do you have a use case where
(best_fits < 0)
&& (prev_fits > 0)
&& (best_thermal_cap > prev_thermal_cap)
?
>
> Fixes: e5ed0550c04c ("sched/fair: unlink misfit task from cpu overutilized")
> Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
> ---
> kernel/sched/fair.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 28ff831ee847..a4e300fc44be 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7684,7 +7684,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
>
> if ((best_fits > prev_fits) ||
> ((best_fits > 0) && (best_delta < prev_delta)) ||
> - ((best_fits < 0) && (best_thermal_cap > prev_thermal_cap)))
> + ((best_fits < 0) && (prev_fits < 0) && (best_thermal_cap > prev_thermal_cap)))
> target = best_energy_cpu;
>
> return target;
> --
> 2.27.0
>