On Thu, Jun 23, 2016 at 09:43:05PM +0800, Leo Yan wrote:
In old code there has only one possible to directly migrate task for lower capacity CPU to higher capacity CPU: the previous CPU's capacity cannot meet the bandwidth requirement and the CPU is not over-utilized. This is reasonable if we only think to task util_avg signal to judge the task performance requirement with comparing with CPU capacity.
But in some scenarios, the task takes much time to stay on runnable state, so its load_avg value is quite higher than util_avg. So for this case can optimize to use load_avg to help migration decision.
If so, we need add path to migrate to higher capacity CPU if destination CPU has higher capacity than lower capacity CPU.
Signed-off-by: Leo Yan leo.yan@linaro.org
kernel/sched/fair.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 7bd1c5b..185efe1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5633,6 +5633,18 @@ static int energy_aware_wake_cpu(struct task_struct *p, int target) if (target_cpu == -1) target_cpu = task_cpu(p);
- /*
* Destination CPU has higher capacity than previous CPU, so from
* previous path that means pervious CPU has no enough capacity to meet
* the waken up task. Therefore directly return back and select
* destination CPU.
*/
- if (capacity_of(target_cpu) != capacity_of(task_cpu(p))) {
if (capacity_of(target_cpu) ==
cpu_rq(target_cpu)->rd->max_cpu_capacity.val)
return target_cpu;
- }
It is not straightforward to infer that if target_cpu has the highest cpu capacity available in the system, then task_cpu(p) (previous cpu) must be overutilized. IIUC, it is only the case because task_fits_max() and cpu_overutilized() both use capacity_margin as the margin and we only consider cpus accepted by task_fits_max() when finding target_cpu.
Anyway, the scenario you seem to cover is the case where task_cpu() is over-utilized. This scenario should already be covered a little further down in energy_aware_wake_cpu():
/* Not enough spare capacity on previous cpu */ if (cpu_overutilized(task_cpu(p))) return target_cpu;
Are there any cases where this isn't sufficient? I thought we were already covered for this scenario?
The commit message mentions load_avg. I don't see it used anywhere in this patch or how it relates to the code, so I'm a bit puzzled.
Also 'return target_cpu;' seems to need more indentation.
Morten