2020-03-26 05:55:02

by Aubrey Li

[permalink] [raw]
Subject: [PATCH] sched/fair: Fix negative imbalance in imbalance calculation

A negative imbalance value was observed after imbalance calculation,
this happens when the local sched group type is group_fully_busy,
and the average load of local group is greater than the selected
busiest group. Fix this problem by comparing the average load of the
local and busiest group before imbalance calculation formula.

Suggested-by: Vincent Guittot <[email protected]>
Signed-off-by: Aubrey Li <[email protected]>
Cc: Phil Auld <[email protected]>
---
kernel/sched/fair.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c1217bf..4a2ba3f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8761,6 +8761,14 @@ 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 selected
+ * busiest group don't try to pull any tasks.
+ */
+ if (local->avg_load >= busiest->avg_load) {
+ env->imbalance = 0;
+ return;
+ }
}

/*
--
2.7.4


2020-03-26 13:33:28

by Phil Auld

[permalink] [raw]
Subject: Re: [PATCH] sched/fair: Fix negative imbalance in imbalance calculation

On Thu, Mar 26, 2020 at 01:42:29PM +0800 Aubrey Li wrote:
> A negative imbalance value was observed after imbalance calculation,
> this happens when the local sched group type is group_fully_busy,
> and the average load of local group is greater than the selected
> busiest group. Fix this problem by comparing the average load of the
> local and busiest group before imbalance calculation formula.
>
> Suggested-by: Vincent Guittot <[email protected]>
> Signed-off-by: Aubrey Li <[email protected]>
> Cc: Phil Auld <[email protected]>
> ---
> kernel/sched/fair.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index c1217bf..4a2ba3f 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8761,6 +8761,14 @@ 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 selected
> + * busiest group don't try to pull any tasks.
> + */
> + if (local->avg_load >= busiest->avg_load) {
> + env->imbalance = 0;
> + return;
> + }
> }
>
> /*
> --
> 2.7.4
>

I like this one better. Thanks!

Reviewed-by: Phil Auld <[email protected]>

--

2020-03-26 16:06:30

by Vincent Guittot

[permalink] [raw]
Subject: Re: [PATCH] sched/fair: Fix negative imbalance in imbalance calculation

On Thu, 26 Mar 2020 at 06:53, Aubrey Li <[email protected]> wrote:
>
> A negative imbalance value was observed after imbalance calculation,
> this happens when the local sched group type is group_fully_busy,
> and the average load of local group is greater than the selected
> busiest group. Fix this problem by comparing the average load of the
> local and busiest group before imbalance calculation formula.
>
> Suggested-by: Vincent Guittot <[email protected]>
> Signed-off-by: Aubrey Li <[email protected]>
> Cc: Phil Auld <[email protected]>

Reviewed-by: Vincent Guittot <[email protected]>

> ---
> kernel/sched/fair.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index c1217bf..4a2ba3f 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8761,6 +8761,14 @@ 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 selected
> + * busiest group don't try to pull any tasks.
> + */
> + if (local->avg_load >= busiest->avg_load) {
> + env->imbalance = 0;
> + return;
> + }
> }
>
> /*
> --
> 2.7.4
>

2020-03-27 11:49:19

by Mel Gorman

[permalink] [raw]
Subject: Re: [PATCH] sched/fair: Fix negative imbalance in imbalance calculation

On Thu, Mar 26, 2020 at 01:42:29PM +0800, Aubrey Li wrote:
> A negative imbalance value was observed after imbalance calculation,
> this happens when the local sched group type is group_fully_busy,
> and the average load of local group is greater than the selected
> busiest group. Fix this problem by comparing the average load of the
> local and busiest group before imbalance calculation formula.
>
> Suggested-by: Vincent Guittot <[email protected]>
> Signed-off-by: Aubrey Li <[email protected]>
> Cc: Phil Auld <[email protected]>

Acked-by: Mel Gorman <[email protected]>

--
Mel Gorman
SUSE Labs

2020-03-30 10:40:00

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH] sched/fair: Fix negative imbalance in imbalance calculation

On Thu, Mar 26, 2020 at 05:03:10PM +0100, Vincent Guittot wrote:
> On Thu, 26 Mar 2020 at 06:53, Aubrey Li <[email protected]> wrote:
> >
> > A negative imbalance value was observed after imbalance calculation,
> > this happens when the local sched group type is group_fully_busy,
> > and the average load of local group is greater than the selected
> > busiest group. Fix this problem by comparing the average load of the
> > local and busiest group before imbalance calculation formula.
> >
> > Suggested-by: Vincent Guittot <[email protected]>
> > Signed-off-by: Aubrey Li <[email protected]>
> > Cc: Phil Auld <[email protected]>
>
> Reviewed-by: Vincent Guittot <[email protected]>

Thanks!

2020-04-08 13:31:44

by tip-bot2 for Haifeng Xu

[permalink] [raw]
Subject: [tip: sched/urgent] sched/fair: Fix negative imbalance in imbalance calculation

The following commit has been merged into the sched/urgent branch of tip:

Commit-ID: 111688ca1c4a43a7e482f5401f82c46326b8ed49
Gitweb: https://git.kernel.org/tip/111688ca1c4a43a7e482f5401f82c46326b8ed49
Author: Aubrey Li <[email protected]>
AuthorDate: Thu, 26 Mar 2020 13:42:29 +08:00
Committer: Ingo Molnar <[email protected]>
CommitterDate: Wed, 08 Apr 2020 11:35:20 +02:00

sched/fair: Fix negative imbalance in imbalance calculation

A negative imbalance value was observed after imbalance calculation,
this happens when the local sched group type is group_fully_busy,
and the average load of local group is greater than the selected
busiest group. Fix this problem by comparing the average load of the
local and busiest group before imbalance calculation formula.

Suggested-by: Vincent Guittot <[email protected]>
Reviewed-by: Phil Auld <[email protected]>
Reviewed-by: Vincent Guittot <[email protected]>
Acked-by: Mel Gorman <[email protected]>
Signed-off-by: Aubrey Li <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
kernel/sched/fair.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 95cbd9e..02f323b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9036,6 +9036,14 @@ 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 selected
+ * busiest group don't try to pull any tasks.
+ */
+ if (local->avg_load >= busiest->avg_load) {
+ env->imbalance = 0;
+ return;
+ }
}

/*