On Thu, Jun 23, 2016 at 09:43:03PM +0800, Leo Yan wrote:
In previous EAS waken up path, it will select any possible CPU which have higher capacity which can meet the task requirement. This patch will prefer to fall back to previous CPU as possible. So this can avoid unnecessary task migration between the cluster.
Signed-off-by: Leo Yan leo.yan@linaro.org
kernel/sched/fair.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 7e5ffe8..c4bc7ae 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5569,7 +5569,7 @@ static int energy_aware_wake_cpu(struct task_struct *p, int target) struct sched_domain *sd; struct sched_group *sg, *sg_target; int target_max_cap = INT_MAX;
- int target_cpu = task_cpu(p);
int target_cpu = -1; int i;
sd = rcu_dereference(per_cpu(sd_ea, task_cpu(p)));
@@ -5612,7 +5612,7 @@ static int energy_aware_wake_cpu(struct task_struct *p, int target) */ int new_util = cpu_util(i) + boosted_task_util(p);
if (new_util > capacity_orig_of(i))
if (new_util > capacity_orig_of(i) && target_cpu != -1) continue;
if (new_util < capacity_curr_of(i)) {
@@ -5621,11 +5621,18 @@ static int energy_aware_wake_cpu(struct task_struct *p, int target) break; }
/* cpu has capacity at higher OPP, keep it as fallback */
if (target_cpu == task_cpu(p))
/*
* cpu has capacity at higher OPP, keep it as fallback;
* give the previous cpu more chance to run
*/
}if (task_cpu(p) == i || target_cpu == -1) target_cpu = i;
Don't you end up potentially using an over-utilized cpu as target_cpu?
The new_util > capacity_orig_of(i) condition used to reject all cpus that are over-utilized. With additional target_cpu != -1 this is no longer the case. In the first iteration target_cpu is still -1, if the cpu is over-utilized the first criteria is now false, the second (new_util < capacity_curr_of(i)) is false as well, and the last one (above) is true, so we end up setting target_cpu = i, despite the cpu having no spare cycles.
Did I miss something?
- /* If have not select any CPU, then to use previous CPU */
- if (target_cpu == -1)
target_cpu = task_cpu(p);
You could just return task_cpu(p) here.