linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/fair: fix returning possible non-optimal candidate
@ 2023-06-21  7:16 Miaohe Lin
  2023-06-21  8:30 ` Vincent Guittot
  0 siblings, 1 reply; 2+ messages in thread
From: Miaohe Lin @ 2023-06-21  7:16 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot
  Cc: dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
	linux-kernel, linmiaohe

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.

Fixes: e5ed0550c04c ("sched/fair: unlink misfit task from cpu overutilized")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sched/fair: fix returning possible non-optimal candidate
  2023-06-21  7:16 [PATCH] sched/fair: fix returning possible non-optimal candidate Miaohe Lin
@ 2023-06-21  8:30 ` Vincent Guittot
  0 siblings, 0 replies; 2+ messages in thread
From: Vincent Guittot @ 2023-06-21  8:30 UTC (permalink / raw)
  To: Miaohe Lin
  Cc: mingo, peterz, juri.lelli, dietmar.eggemann, rostedt, bsegall,
	mgorman, bristot, vschneid, linux-kernel

On Wed, 21 Jun 2023 at 09:16, Miaohe Lin <linmiaohe@huawei.com> 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@huawei.com>
> ---
>  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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-21  8:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-21  7:16 [PATCH] sched/fair: fix returning possible non-optimal candidate Miaohe Lin
2023-06-21  8:30 ` Vincent Guittot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).