Commit 64297f2b authored by Peng Wang's avatar Peng Wang Committed by Peter Zijlstra

sched/fair: Simplify the code of should_we_balance()

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: default avatarPeng Wang <rocking@linux.alibaba.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarValentin Schneider <valentin.schneider@arm.com>
Reviewed-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
Link: https://lkml.kernel.org/r/245c792f0e580b3ca342ad61257f4c066ee0f84f.1586594833.git.rocking@linux.alibaba.com
parent ab93a4bc
...@@ -9413,7 +9413,7 @@ static int active_load_balance_cpu_stop(void *data); ...@@ -9413,7 +9413,7 @@ static int active_load_balance_cpu_stop(void *data);
static int should_we_balance(struct lb_env *env) static int should_we_balance(struct lb_env *env)
{ {
struct sched_group *sg = env->sd->groups; struct sched_group *sg = env->sd->groups;
int cpu, balance_cpu = -1; int cpu;
/* /*
* Ensure the balancing environment is consistent; can happen * Ensure the balancing environment is consistent; can happen
...@@ -9434,18 +9434,12 @@ static int should_we_balance(struct lb_env *env) ...@@ -9434,18 +9434,12 @@ static int should_we_balance(struct lb_env *env)
if (!idle_cpu(cpu)) if (!idle_cpu(cpu))
continue; continue;
balance_cpu = cpu; /* Are we the first idle CPU? */
break; return cpu == env->dst_cpu;
} }
if (balance_cpu == -1) /* Are we the first CPU of this group ? */
balance_cpu = group_balance_cpu(sg); return group_balance_cpu(sg) == env->dst_cpu;
/*
* 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;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment