* [PATCH] sched/fair: Simplify the code of should_we_balance()
@ 2020-04-11 9:20 Peng Wang
2020-04-12 8:42 ` Peng Wang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Peng Wang @ 2020-04-11 9:20 UTC (permalink / raw)
To: mingo, peterz, uri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman
Cc: linux-kernel
We only consider group_balance_cpu() after there is no idle
cpu. So, just do comparison before return at these two cases.
Signed-off-by: Peng Wang <rocking@linux.alibaba.com>
---
kernel/sched/fair.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 1ea3ddd..81b2c647 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9413,7 +9413,7 @@ static int active_load_balance_cpu_stop(void *data);
static int should_we_balance(struct lb_env *env)
{
struct sched_group *sg = env->sd->groups;
- int cpu, balance_cpu = -1;
+ int cpu;
/*
* Ensure the balancing environment is consistent; can happen
@@ -9434,18 +9434,12 @@ static int should_we_balance(struct lb_env *env)
if (!idle_cpu(cpu))
continue;
- balance_cpu = cpu;
- break;
+ /* Are we the first idle CPU? */
+ return cpu == env->dst_cpu;
}
- if (balance_cpu == -1)
- balance_cpu = group_balance_cpu(sg);
-
- /*
- * First idle CPU or the first CPU(busiest) in this sched group
- * is eligible for doing load balancing at this and above domains.
- */
- return balance_cpu == env->dst_cpu;
+ /* Are we the first balance CPU of this group? */
+ return group_balance_cpu(sg) == env->dst_cpu;
}
/*
--
2.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] sched/fair: Simplify the code of should_we_balance()
2020-04-11 9:20 [PATCH] sched/fair: Simplify the code of should_we_balance() Peng Wang
@ 2020-04-12 8:42 ` Peng Wang
2020-04-13 20:32 ` Valentin Schneider
2020-04-14 7:25 ` Vincent Guittot
2020-04-14 8:48 ` [PATCH v2] " Peng Wang
2 siblings, 1 reply; 6+ messages in thread
From: Peng Wang @ 2020-04-12 8:42 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman
Cc: linux-kernel
On 4/11/20 5:20 PM, Peng Wang wrote:
> We only consider group_balance_cpu() after there is no idle
> cpu. So, just do comparison before return at these two cases.
>
> Signed-off-by: Peng Wang <rocking@linux.alibaba.com>
> ---
> kernel/sched/fair.c | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 1ea3ddd..81b2c647 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9413,7 +9413,7 @@ static int active_load_balance_cpu_stop(void *data);
> static int should_we_balance(struct lb_env *env)
> {
> struct sched_group *sg = env->sd->groups;
> - int cpu, balance_cpu = -1;
> + int cpu;
>
> /*
> * Ensure the balancing environment is consistent; can happen
> @@ -9434,18 +9434,12 @@ static int should_we_balance(struct lb_env *env)
> if (!idle_cpu(cpu))
> continue;
>
> - balance_cpu = cpu;
> - break;
> + /* Are we the first idle CPU? */
> + return cpu == env->dst_cpu;
> }
>
> - if (balance_cpu == -1)
> - balance_cpu = group_balance_cpu(sg);
> -
> - /*
> - * First idle CPU or the first CPU(busiest) in this sched group
> - * is eligible for doing load balancing at this and above domains.
> - */
> - return balance_cpu == env->dst_cpu;
> + /* Are we the first balance CPU of this group? */
> + return group_balance_cpu(sg) == env->dst_cpu;
> }
>
> /*
>
+juri.lelli@redhat.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sched/fair: Simplify the code of should_we_balance()
2020-04-12 8:42 ` Peng Wang
@ 2020-04-13 20:32 ` Valentin Schneider
0 siblings, 0 replies; 6+ messages in thread
From: Valentin Schneider @ 2020-04-13 20:32 UTC (permalink / raw)
To: Peng Wang
Cc: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, linux-kernel
On 12/04/20 09:42, Peng Wang wrote:
> On 4/11/20 5:20 PM, Peng Wang wrote:
>> We only consider group_balance_cpu() after there is no idle
>> cpu. So, just do comparison before return at these two cases.
>>
It's not really changing much, but if it helps making it a bit more
readable, why not. Small nit below.
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
>> Signed-off-by: Peng Wang <rocking@linux.alibaba.com>
>> ---
>> kernel/sched/fair.c | 16 +++++-----------
>> 1 file changed, 5 insertions(+), 11 deletions(-)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 1ea3ddd..81b2c647 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -9413,7 +9413,7 @@ static int active_load_balance_cpu_stop(void *data);
>> static int should_we_balance(struct lb_env *env)
>> {
>> struct sched_group *sg = env->sd->groups;
>> - int cpu, balance_cpu = -1;
>> + int cpu;
>>
>> /*
>> * Ensure the balancing environment is consistent; can happen
>> @@ -9434,18 +9434,12 @@ static int should_we_balance(struct lb_env *env)
>> if (!idle_cpu(cpu))
>> continue;
>>
>> - balance_cpu = cpu;
>> - break;
>> + /* Are we the first idle CPU? */
>> + return cpu == env->dst_cpu;
>> }
>>
>> - if (balance_cpu == -1)
>> - balance_cpu = group_balance_cpu(sg);
>> -
>> - /*
>> - * First idle CPU or the first CPU(busiest) in this sched group
>> - * is eligible for doing load balancing at this and above domains.
>> - */
>> - return balance_cpu == env->dst_cpu;
>> + /* Are we the first balance CPU of this group? */
Nit: That should be either "the balance CPU" or "the first CPU in the group
balance mask"
>> + return group_balance_cpu(sg) == env->dst_cpu;
>> }
>>
>> /*
>>
>
> +juri.lelli@redhat.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sched/fair: Simplify the code of should_we_balance()
2020-04-11 9:20 [PATCH] sched/fair: Simplify the code of should_we_balance() Peng Wang
2020-04-12 8:42 ` Peng Wang
@ 2020-04-14 7:25 ` Vincent Guittot
2020-04-14 10:57 ` Peter Zijlstra
2020-04-14 8:48 ` [PATCH v2] " Peng Wang
2 siblings, 1 reply; 6+ messages in thread
From: Vincent Guittot @ 2020-04-14 7:25 UTC (permalink / raw)
To: Peng Wang
Cc: Ingo Molnar, Peter Zijlstra, uri.lelli, Dietmar Eggemann,
Steven Rostedt, Ben Segall, Mel Gorman, linux-kernel
On Sat, 11 Apr 2020 at 11:21, Peng Wang <rocking@linux.alibaba.com> wrote:
>
> We only consider group_balance_cpu() after there is no idle
> cpu. So, just do comparison before return at these two cases.
>
> Signed-off-by: Peng Wang <rocking@linux.alibaba.com>
With the small fix in the comment below
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
> kernel/sched/fair.c | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 1ea3ddd..81b2c647 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9413,7 +9413,7 @@ static int active_load_balance_cpu_stop(void *data);
> static int should_we_balance(struct lb_env *env)
> {
> struct sched_group *sg = env->sd->groups;
> - int cpu, balance_cpu = -1;
> + int cpu;
>
> /*
> * Ensure the balancing environment is consistent; can happen
> @@ -9434,18 +9434,12 @@ static int should_we_balance(struct lb_env *env)
> if (!idle_cpu(cpu))
> continue;
>
> - balance_cpu = cpu;
> - break;
> + /* Are we the first idle CPU? */
> + return cpu == env->dst_cpu;
> }
>
> - if (balance_cpu == -1)
> - balance_cpu = group_balance_cpu(sg);
> -
> - /*
> - * First idle CPU or the first CPU(busiest) in this sched group
> - * is eligible for doing load balancing at this and above domains.
> - */
> - return balance_cpu == env->dst_cpu;
> + /* Are we the first balance CPU of this group? */
/* Are we the first CPU of this group ? */
> + return group_balance_cpu(sg) == env->dst_cpu;
> }
>
> /*
> --
> 2.9.5
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] sched/fair: Simplify the code of should_we_balance()
2020-04-11 9:20 [PATCH] sched/fair: Simplify the code of should_we_balance() Peng Wang
2020-04-12 8:42 ` Peng Wang
2020-04-14 7:25 ` Vincent Guittot
@ 2020-04-14 8:48 ` Peng Wang
2 siblings, 0 replies; 6+ messages in thread
From: Peng Wang @ 2020-04-14 8:48 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman
Cc: linux-kernel
We only consider group_balance_cpu() after there is no idle
cpu. So, just do comparison before return at these two cases.
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Peng Wang <rocking@linux.alibaba.com>
---
kernel/sched/fair.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 02f323b..c3f57f4 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9409,7 +9409,7 @@ static int active_load_balance_cpu_stop(void *data);
static int should_we_balance(struct lb_env *env)
{
struct sched_group *sg = env->sd->groups;
- int cpu, balance_cpu = -1;
+ int cpu;
/*
* Ensure the balancing environment is consistent; can happen
@@ -9430,18 +9430,12 @@ static int should_we_balance(struct lb_env *env)
if (!idle_cpu(cpu))
continue;
- balance_cpu = cpu;
- break;
+ /* Are we the first idle CPU? */
+ return cpu == env->dst_cpu;
}
- if (balance_cpu == -1)
- balance_cpu = group_balance_cpu(sg);
-
- /*
- * First idle CPU or the first CPU(busiest) in this sched group
- * is eligible for doing load balancing at this and above domains.
- */
- return balance_cpu == env->dst_cpu;
+ /* Are we the first CPU in the balance mask of this group? */
+ return group_balance_cpu(sg) == env->dst_cpu;
}
/*
--
2.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] sched/fair: Simplify the code of should_we_balance()
2020-04-14 7:25 ` Vincent Guittot
@ 2020-04-14 10:57 ` Peter Zijlstra
0 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2020-04-14 10:57 UTC (permalink / raw)
To: Vincent Guittot
Cc: Peng Wang, Ingo Molnar, uri.lelli, Dietmar Eggemann,
Steven Rostedt, Ben Segall, Mel Gorman, linux-kernel
On Tue, Apr 14, 2020 at 09:25:00AM +0200, Vincent Guittot wrote:
> On Sat, 11 Apr 2020 at 11:21, Peng Wang <rocking@linux.alibaba.com> wrote:
> >
> > We only consider group_balance_cpu() after there is no idle
> > cpu. So, just do comparison before return at these two cases.
> >
> > Signed-off-by: Peng Wang <rocking@linux.alibaba.com>
>
> With the small fix in the comment below
Done
> Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Thanks Guys!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-04-14 10:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-11 9:20 [PATCH] sched/fair: Simplify the code of should_we_balance() Peng Wang
2020-04-12 8:42 ` Peng Wang
2020-04-13 20:32 ` Valentin Schneider
2020-04-14 7:25 ` Vincent Guittot
2020-04-14 10:57 ` Peter Zijlstra
2020-04-14 8:48 ` [PATCH v2] " Peng Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.