On Mon, Jul 04, 2016 at 05:46:18PM +0800, Leo Yan wrote:
On Mon, Jul 04, 2016 at 09:41:45AM +0100, Morten Rasmussen wrote:
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.
Sorry my patches' order introduced the confusion. This patch works for patch 4, after we apply patch 4 so it will add one case is even system is not over "over-utilized", the task still might be migrated to big cluster.
So we cannot rely on "over-utilized" flag anymore but need direct migrate task to big core.
I'm guessing this is due to the boosting of the task utilization?
Wouldn't it be better to just modify the existing over-utilization check to handle boosted task as well so we don't have two conditions that does almost the same thing?
Morten