From f3d3bd3f15feee0e1d080dec93a6ad58878613a2 Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Thu, 4 Feb 2021 14:10:11 +0530 Subject: [PATCH] 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 --- kernel/sched/walt/walt_cfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/sched/walt/walt_cfs.c b/kernel/sched/walt/walt_cfs.c index 78c45a3aa058..63e43de2f310 100644 --- a/kernel/sched/walt/walt_cfs.c +++ b/kernel/sched/walt/walt_cfs.c @@ -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