lkml.org 
[lkml]   [2020]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] sched/fair: Simplify the code of should_we_balance()
Date
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
\
 
 \ /
  Last update: 2020-04-14 10:51    [W:0.097 / U:0.880 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site