sched/walt: Fix waking new tasks on higher capacity CPUs

walt_find_best_target() which selects the best CPU has a special
handling for running tasks. The idle CPUs are only considered as
migrating a running task to a busy CPU will result in wait time.

A running task is detected via task->state == TASK_RUNNING check,
which is true for tick path active migration tasks. It is also
true for newly created tasks. These tasks are getting placed on
idle CPUs of the higher capacity clusters though the lower capacity
CPUs are lightly loaded. Detect the running task via task->on_rq to
fix this issue.

Change-Id: I154cd6c6f934061526bce30fe596d9ad36c9e07f
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
This commit is contained in:
Pavankumar Kondeti 2021-02-04 14:10:11 +05:30 committed by Rishabh Bhatnagar
parent d90415f374
commit f3d3bd3f15

View File

@ -196,6 +196,7 @@ static void walt_find_best_target(struct sched_domain *sd,
cpumask_t visit_cpus;
struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1;
struct cfs_rq *cfs_rq;
bool active_task = task_on_rq_queued(p);
/* Find start CPU based on boost value */
start_cpu = fbt_env->start_cpu;
@ -214,7 +215,7 @@ static void walt_find_best_target(struct sched_domain *sd,
most_spare_wake_cap = LONG_MIN;
}
if (p->state == TASK_RUNNING)
if (active_task)
most_spare_wake_cap = ULONG_MAX;
/* fast path for prev_cpu */
@ -340,7 +341,7 @@ static void walt_find_best_target(struct sched_domain *sd,
/*
* Consider only idle CPUs for active migration.
*/
if (p->state == TASK_RUNNING)
if (active_task)
continue;
/*
@ -407,7 +408,7 @@ static void walt_find_best_target(struct sched_domain *sd,
trace_sched_find_best_target(p, min_util, start_cpu,
best_idle_cpu, most_spare_cap_cpu,
target_cpu, order_index, end_index,
fbt_env->skip_cpu, p->state == TASK_RUNNING);
fbt_env->skip_cpu, active_task);
}
static inline unsigned long