From 71f5d6022e02adecdac216de0ddd5f448ad21df1 Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Tue, 27 Apr 2021 16:21:11 +0530 Subject: [PATCH] sched: walt: Fix stale walt CPU reservation flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When CPU trying to move a task to other cpu in active load balance or by other means, then the other helping cpu marked as reserved to avoid it for other scheduler decisions. Once the task moved successfully, the reservation will be cleared enables for other scheduler decisions. The reserved flag is been analogously protected with busy cpu’s rq->active_balance, which is protected with runqueue locks. So whenever rq->active_balance is set for busy cpu, then reserved flag would set for helping cpu. Sometimes, it is observed that, cpu is marked as reserved with no cpu's rq->active_balance set. There are some unlikely possible corner cases may cause this behavior: - On active load balance path, cpu stop machine returns queued status of active_balance work on cpu_stopper, which is not checked on active balance path. so when stop machine is not able to queue ( unlikely), then reserved flag wouldn't be cleared. So, catch the return value and on failure, clear reserved flag for cpu. - Clear_walt_request() called on the cpu to clear any pending walt works, it may possible that, push_task might have changed or cleared, then the reserved cpu would be left uncleared. So clear the push_cpu independent of push_task. Change-Id: I75d032bf399cb3da8e807186b1bc903114168a4e Signed-off-by: Pavankumar Kondeti Signed-off-by: Lingutla Chandrasekhar Signed-off-by: Abhijeet Dharmapurikar --- kernel/sched/walt/walt_lb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kernel/sched/walt/walt_lb.c b/kernel/sched/walt/walt_lb.c index 46f1cbd82392..cbf5c6300593 100644 --- a/kernel/sched/walt/walt_lb.c +++ b/kernel/sched/walt/walt_lb.c @@ -33,7 +33,7 @@ static void walt_attach_task(struct task_struct *p, struct rq *rq) check_preempt_curr(rq, p, 0); } -static int walt_lb_active_migration(void *data) +static int stop_walt_lb_active_migration(void *data) { struct rq *busiest_rq = data; int busiest_cpu = cpu_of(busiest_rq); @@ -307,10 +307,15 @@ static int walt_lb_pull_tasks(int dst_cpu, int src_cpu) * the push_task is really pulled onto this CPU. */ if (active_balance) { + bool success; + wts = (struct walt_task_struct *) p->android_vendor_data1; trace_walt_active_load_balance(p, src_cpu, dst_cpu, wts); - stop_one_cpu_nowait(src_cpu, walt_lb_active_migration, + success = stop_one_cpu_nowait(src_cpu, stop_walt_lb_active_migration, src_rq, &src_rq->active_balance_work); + if (!success) + clear_reserved(dst_cpu); + return 0; /* we did not pull any task here */ } @@ -543,7 +548,7 @@ void walt_lb_tick(struct rq *rq) trace_walt_active_load_balance(p, prev_cpu, new_cpu, wts); ret = stop_one_cpu_nowait(prev_cpu, - walt_lb_active_migration, rq, + stop_walt_lb_active_migration, rq, &rq->active_balance_work); if (!ret) clear_reserved(new_cpu);