summaryrefslogtreecommitdiff
path: root/kernel/sched
diff options
context:
space:
mode:
authorSyed Rameez Mustafa <rameezmustafa@codeaurora.org>2014-04-25 11:48:53 -0700
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 19:59:27 -0700
commitb7b5f7911932c94fa036d6d92a0aa2c9bf2c21b0 (patch)
tree970b1c07205407fe0848902300fa5949dd49070e /kernel/sched
parent3f9d4439f21b715d60d8e8bf89ec0ec6c12370b2 (diff)
sched/fair: Help out higher capacity CPUs when they are overcommitted
If we have a task to schedule, we currently don't consider CPUs where it will not fit even if they are idle. Instead we choose the previous CPU which is sub-optimal for performance if an idle CPU is present. This change introduces tracking of any idle CPUs irrespective of whether the task fits on them or not. If we don't have a good place to put the task, prefer the lowest power idle CPU. Change-Id: I4e8290639ad1602541a44a80ba4b2804068cac0f Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org> Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org> [rameezmustafa@codeaurora.org]: Port to msm-3.18] Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org
Diffstat (limited to 'kernel/sched')
-rw-r--r--kernel/sched/fair.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 02cc8168c93f..cabc223ffd32 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2790,9 +2790,9 @@ int mostly_idle_cpu(int cpu)
/* return cheapest cpu that can fit this task */
static int select_best_cpu(struct task_struct *p, int target)
{
- int i, best_cpu = -1;
+ int i, best_cpu = -1, fallback_idle_cpu = -1;
int prev_cpu = task_cpu(p);
- int cpu_cost, min_cost = INT_MAX;
+ int cpu_cost, min_cost = INT_MAX, min_idle_cpu_cost = INT_MAX;
int small_task = is_small_task(p);
trace_sched_task_load(p);
@@ -2812,23 +2812,31 @@ static int select_best_cpu(struct task_struct *p, int target)
if (!small_task && !mostly_idle_cpu(i))
continue;
- if (!task_will_fit(p, i))
- continue;
-
- /* Prefer lowest cost cpu that can accommodate task */
- cpu_cost = power_cost(p, i);
/* Assume power_cost() returns same number for two
* cpus that are nearly same in their power
* rating.
*/
- if (cpu_cost < min_cost) {
- min_cost = cpu_cost;
- best_cpu = i;
+ cpu_cost = power_cost(p, i);
+
+ if (!task_will_fit(p, i)) {
+ if (cpu_cost < min_idle_cpu_cost) {
+ min_idle_cpu_cost = cpu_cost;
+ fallback_idle_cpu = i;
+ }
+ } else {
+ if (cpu_cost < min_cost) {
+ min_cost = cpu_cost;
+ best_cpu = i;
+ }
}
}
- if (best_cpu < 0)
- best_cpu = prev_cpu;
+ if (best_cpu < 0) {
+ if (unlikely(fallback_idle_cpu < 0))
+ best_cpu = prev_cpu;
+ else
+ best_cpu = fallback_idle_cpu;
+ }
return best_cpu;
}