In energy aware path for waken task, it calculates energy difference to select power saving CPU. For some corner case, the task utilization is 0, this means the task has run very short time and don't cross 1024us (1ms). At the end energy difference = 0 when task utilized is 0, so finally select an unexpected target CPU for below scenario:
If the task previously run on CPUA and CPUA is a higher capacity CPU, when calculate energy difference between CPUA with another lower capacity CPU (CPUB), we will get energy_diff = 0. Finally this task sticks on CPUA and miss the chance to migrate to CPUB.
If the energy difference calculation happens between two CPUs with same capacity, it will always stay on previous CPU so the calculation is pointless.
This patch checks if the task util_avg is 0, it directly returns back 'target_cpu' which is selected by the power efficiency loop.
Signed-off-by: Leo Yan leo.yan@linaro.org --- kernel/sched/fair.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d1d5dad..7b1f65b 100755 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5616,6 +5616,9 @@ static int energy_aware_wake_cpu(struct task_struct *p, int target, int sync) } }
+ if (unlikely(!task_util(p))) + return target_cpu; + if (target_cpu != task_cpu(p)) { struct energy_env eenv = { .util_delta = task_util(p), -- 2.7.4