From f41f3a4e0c0f026e6d00f9d353bea54cf188b26e Mon Sep 17 00:00:00 2001 From: Shaleen Agrawal Date: Wed, 15 Jun 2022 15:30:11 -0700 Subject: [PATCH] sched/walt: Fix excess detach_task in walt_lb_pull_tasks There's three loops to find a task to pull. In the first iteration, we look for a task that is not running, which fits a strict criteria. In the second iteration, we look for a task that is not running, which fits a lax criteria. If we have still not found a valid task to pull, we intended to pull the running task servicing an active load migration. However, there is some leftover code, wherein a task that is not running will end up being detached and pulled. This was not intended, and leads to incorrect behavior. Essentially, this is negating the effects of the first two iterations. Change-Id: Ia225d89043c76ec6e661771a39d058498346920d Signed-off-by: Shaleen Agrawal --- kernel/sched/walt/walt_lb.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/kernel/sched/walt/walt_lb.c b/kernel/sched/walt/walt_lb.c index e9aa3770cad6..62f92715236b 100644 --- a/kernel/sched/walt/walt_lb.c +++ b/kernel/sched/walt/walt_lb.c @@ -341,11 +341,9 @@ static int walt_lb_pull_tasks(int dst_cpu, int src_cpu) list_for_each_entry_reverse(p, &src_rq->cfs_tasks, se.group_node) { - if (!cpumask_test_cpu(dst_cpu, p->cpus_ptr)) - continue; - if (task_running(src_rq, p)) { - if (need_active_lb(p, dst_cpu, src_cpu)) { + if (cpumask_test_cpu(dst_cpu, p->cpus_ptr) + && need_active_lb(p, dst_cpu, src_cpu)) { bool success; active_balance = true; src_rq->active_balance = 1; @@ -371,12 +369,8 @@ static int walt_lb_pull_tasks(int dst_cpu, int src_cpu) return 0; /* we did not pull any task here */ } - continue; + goto unlock; } - - walt_detach_task(p, src_rq, dst_rq); - pulled_task = p; - goto unlock; } unlock: /* lock must be dropped before waking the stopper */