mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/fair: fix imbalance overflow
@ 2023-04-11  9:06 Vincent Guittot
  2023-04-11 20:41 ` Tingjia Cao
  2023-04-12 12:50 ` Peter Zijlstra
  0 siblings, 2 replies; 3+ messages in thread
From: Vincent Guittot @ 2023-04-11  9:06 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, dietmar.eggemann, rostedt, bsegall,
	mgorman, bristot, vschneid, linux-kernel, tjcao980311
  Cc: Vincent Guittot

When local group is fully busy but its average load is above system load,
computing the imbalance will overflow and local group is not the best
target for pulling this load.

Fixes: 0b0695f2b34a ("sched/fair: Rework load_balance()")
Reported-by: Tingjia Cao <tjcao980311@gmail.com>
Link: https://lore.kernel.org/lkml/CABcWv9_DAhVBOq2=W=2ypKE9dKM5s2DvoV8-U0+GDwwuKZ89jQ@mail.gmail.com/T/
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
---

Hi Tingjia,

Thanks for the detailed bug report. I have been able to reproduce the problem and this
patch fixes it on my setup. Could you try it ?

Thanks,
Vincent

 kernel/sched/fair.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f5da01a6b35a..184b0dbb2a69 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10209,6 +10209,16 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
 
 		sds->avg_load = (sds->total_load * SCHED_CAPACITY_SCALE) /
 				sds->total_capacity;
+
+		/*
+		 * If the local group is more loaded than the average system
+		 * load, don't try to pull any tasks.
+		 */
+		if (local->avg_load >= sds->avg_load) {
+			env->imbalance = 0;
+			return;
+		}
+
 	}
 
 	/*
-- 
2.34.1


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

* Re: [PATCH] sched/fair: fix imbalance overflow
  2023-04-11  9:06 [PATCH] sched/fair: fix imbalance overflow Vincent Guittot
@ 2023-04-11 20:41 ` Tingjia Cao
  2023-04-12 12:50 ` Peter Zijlstra
  1 sibling, 0 replies; 3+ messages in thread
From: Tingjia Cao @ 2023-04-11 20:41 UTC (permalink / raw)
  To: Vincent Guittot
  Cc: mingo, peterz, juri.lelli, dietmar.eggemann, rostedt, bsegall,
	mgorman, bristot, vschneid, linux-kernel

Hello Vincent,

Thanks for the reply. The patch also fixes the issue on my side!

Cheers,
Tingjia


On Tue, Apr 11, 2023 at 5:06 AM Vincent Guittot
<vincent.guittot@linaro.org> wrote:
>
> When local group is fully busy but its average load is above system load,
> computing the imbalance will overflow and local group is not the best
> target for pulling this load.
>
> Fixes: 0b0695f2b34a ("sched/fair: Rework load_balance()")
> Reported-by: Tingjia Cao <tjcao980311@gmail.com>
> Link: https://lore.kernel.org/lkml/CABcWv9_DAhVBOq2=W=2ypKE9dKM5s2DvoV8-U0+GDwwuKZ89jQ@mail.gmail.com/T/
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
>
> Hi Tingjia,
>
> Thanks for the detailed bug report. I have been able to reproduce the problem and this
> patch fixes it on my setup. Could you try it ?
>
> Thanks,
> Vincent
>
>  kernel/sched/fair.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index f5da01a6b35a..184b0dbb2a69 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -10209,6 +10209,16 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
>
>                 sds->avg_load = (sds->total_load * SCHED_CAPACITY_SCALE) /
>                                 sds->total_capacity;
> +
> +               /*
> +                * If the local group is more loaded than the average system
> +                * load, don't try to pull any tasks.
> +                */
> +               if (local->avg_load >= sds->avg_load) {
> +                       env->imbalance = 0;
> +                       return;
> +               }
> +
>         }
>
>         /*
> --
> 2.34.1
>

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

* Re: [PATCH] sched/fair: fix imbalance overflow
  2023-04-11  9:06 [PATCH] sched/fair: fix imbalance overflow Vincent Guittot
  2023-04-11 20:41 ` Tingjia Cao
@ 2023-04-12 12:50 ` Peter Zijlstra
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2023-04-12 12:50 UTC (permalink / raw)
  To: Vincent Guittot
  Cc: mingo, juri.lelli, dietmar.eggemann, rostedt, bsegall, mgorman,
	bristot, vschneid, linux-kernel, tjcao980311

On Tue, Apr 11, 2023 at 11:06:11AM +0200, Vincent Guittot wrote:
> When local group is fully busy but its average load is above system load,
> computing the imbalance will overflow and local group is not the best
> target for pulling this load.
> 
> Fixes: 0b0695f2b34a ("sched/fair: Rework load_balance()")
> Reported-by: Tingjia Cao <tjcao980311@gmail.com>
> Link: https://lore.kernel.org/lkml/CABcWv9_DAhVBOq2=W=2ypKE9dKM5s2DvoV8-U0+GDwwuKZ89jQ@mail.gmail.com/T/
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---

Thanks, added Tested-by Tingjia per his reply.

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

end of thread, other threads:[~2023-04-12 12:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-11  9:06 [PATCH] sched/fair: fix imbalance overflow Vincent Guittot
2023-04-11 20:41 ` Tingjia Cao
2023-04-12 12:50 ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®