From ab41af2f79b164d2814865660fbf26a73fbcd0aa Mon Sep 17 00:00:00 2001 From: Atul Pant Date: Wed, 19 Jun 2024 15:17:41 +0530 Subject: [PATCH] sched/walt: Prevent active migration of pipeline task during newidle balance If a pipeline task is the last task on a cpu and it sleeps, then during newidle balance don't pull any other pipeline task on that cpu. If we allow this, we will end up with two pipeline tasks on the same cpu in the following series of events: 1. Task1 is about to sleep on a cpu7. 2. Task2 is selected to be pulled from another cpu. So, migration thread is scheduled to pull this task. 3. Task1 wakeup up again on cpu7 before migration of Task2 completes. 4. Task2 migrates to cpu7. Thus we end up having Task1 and Task2 on cpu7. Change-Id: I7b1430ebb565a21358995849b33a30af32ac1e4b Signed-off-by: Atul Pant --- kernel/sched/walt/walt_lb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/sched/walt/walt_lb.c b/kernel/sched/walt/walt_lb.c index 9d3ccfa52c06..b4e786f5d713 100644 --- a/kernel/sched/walt/walt_lb.c +++ b/kernel/sched/walt/walt_lb.c @@ -287,6 +287,17 @@ static inline bool need_active_lb(struct task_struct *p, int dst_cpu, if (task_reject_partialhalt_cpu(p, dst_cpu)) return false; + /* + * If the sleeping task on the dst_cpu and the task for which we are + * doing active load balance, are pipeline tasks then don't do active + * load balance. If we allow this, the sleeping task might wakeup + * again on dst_cpu before the migration of actively pulled task. This + * will result in two pipeline tasks on the same cpu + */ + if (walt_pipeline_low_latency_task(p) && + walt_pipeline_low_latency_task(cpu_rq(dst_cpu)->curr)) + return false; + return true; }