diff options
author | Joonsoo Kim <iamjoonsoo.kim@lge.com> | 2013-08-06 04:36:41 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-09-02 02:26:59 -0400 |
commit | 95a79b805b935f4a7b685aa8a117d916c638323e (patch) | |
tree | e9c7380555d30bf5eea04219aba179696c82b7e5 | |
parent | a4f61cc03e443647211a5ae0ab8f8cda2e9e1043 (diff) |
sched: Remove one division operation in find_busiest_queue()
Remove one division operation in find_busiest_queue() by using
crosswise multiplication:
wl_i / power_i > wl_j / power_j :=
wl_i * power_j > wl_j * power_i
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
[ Expanded the changelog. ]
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1375778203-31343-2-git-send-email-iamjoonsoo.kim@lge.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | kernel/sched/fair.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index f918635efe09..8aa217f62a9e 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -4968,7 +4968,7 @@ static struct rq *find_busiest_queue(struct lb_env *env, | |||
4968 | struct sched_group *group) | 4968 | struct sched_group *group) |
4969 | { | 4969 | { |
4970 | struct rq *busiest = NULL, *rq; | 4970 | struct rq *busiest = NULL, *rq; |
4971 | unsigned long max_load = 0; | 4971 | unsigned long busiest_load = 0, busiest_power = 1; |
4972 | int i; | 4972 | int i; |
4973 | 4973 | ||
4974 | for_each_cpu(i, sched_group_cpus(group)) { | 4974 | for_each_cpu(i, sched_group_cpus(group)) { |
@@ -4998,11 +4998,15 @@ static struct rq *find_busiest_queue(struct lb_env *env, | |||
4998 | * the weighted_cpuload() scaled with the cpu power, so that | 4998 | * the weighted_cpuload() scaled with the cpu power, so that |
4999 | * the load can be moved away from the cpu that is potentially | 4999 | * the load can be moved away from the cpu that is potentially |
5000 | * running at a lower capacity. | 5000 | * running at a lower capacity. |
5001 | * | ||
5002 | * Thus we're looking for max(wl_i / power_i), crosswise | ||
5003 | * multiplication to rid ourselves of the division works out | ||
5004 | * to: wl_i * power_j > wl_j * power_i; where j is our | ||
5005 | * previous maximum. | ||
5001 | */ | 5006 | */ |
5002 | wl = (wl * SCHED_POWER_SCALE) / power; | 5007 | if (wl * busiest_power > busiest_load * power) { |
5003 | 5008 | busiest_load = wl; | |
5004 | if (wl > max_load) { | 5009 | busiest_power = power; |
5005 | max_load = wl; | ||
5006 | busiest = rq; | 5010 | busiest = rq; |
5007 | } | 5011 | } |
5008 | } | 5012 | } |