Function energy_aware_wake_cpu() selects CPU for task with two levels; on the first level it will firstly select schedule domain which can meet performance requirement, and on the second level it will choose CPU. When it choose CPU it will add CPU utilization and task utilization together and select one possible CPU with lowest OPP. The previous CPU of the task usually has kept historic utilization value for the task, so the previous CPU will get higher value than its real value; as result the previous CPU will be taken as the CPU which will introduce higher OPP so the task will be migrated to other CPUs. But the migration actually is not necessary and we cannot get benefit for cache hot with previous CPU.
Based on Morten's patch to calibrate previous CPU utilization for waken up task, we can get consistent utilization value for the CPU. So finally this will help to keep the task on the previous CPU.
Signed-off-by: Leo Yan leo.yan@linaro.org --- kernel/sched/fair.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 0385723..9d8a6fd 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5985,13 +5985,14 @@ static int energy_aware_wake_cpu(struct task_struct *p, int target, int sync) for_each_cpu_and(i, tsk_cpus_allowed(p), sched_group_cpus(sg_target)) {
int cap_idx; + int cpu_wake_util = cpu_util_wake(i, p);
/* * p's blocked utilization is still accounted for on prev_cpu * so prev_cpu will receive a negative bias due to the double * accounting. However, the blocked utilization may be zero. */ - new_util = cpu_util(i) + task_util_boosted; + new_util = cpu_wake_util + task_util_boosted;
/* * Ensure minimum capacity to grant the required boost. -- 1.9.1