From 37f5cf75efdc59f10b32288430efcf365d941459 Mon Sep 17 00:00:00 2001 From: Shaleen Agrawal Date: Wed, 27 Jul 2022 16:49:28 -0700 Subject: [PATCH] sched/walt: Ensure crash only on initialized task In the event where a task is being dequeued from a CPU other than the CPU WALT has recorded as the previous enqueue cpu, a crash is induced. However, it could be the case during WALT initialization that due to a race where task is in the middle of being forked, an attempt is made to dequeue a task where the prev_on_cpu_rq member is not properly initialized. Change-Id: I3a52da5d6cc5ae5b71800d0f8097e6debb3b7187 Signed-off-by: Shaleen Agrawal --- kernel/sched/walt/walt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/sched/walt/walt.c b/kernel/sched/walt/walt.c index cd2dfa3ba6f2..af6c8fda9339 100644 --- a/kernel/sched/walt/walt.c +++ b/kernel/sched/walt/walt.c @@ -2457,6 +2457,7 @@ static void init_new_task_load(struct task_struct *p) wts->mvp_prio = WALT_NOT_MVP; wts->cidx = 0; __sched_fork_init(p); + walt_flag_set(p, WALT_INIT, 1); } static void init_existing_task_load(struct task_struct *p) @@ -4284,7 +4285,8 @@ static void android_rvh_dequeue_task(void *unused, struct rq *rq, struct task_st * therefore the check to ensure that prev_on_rq_cpu is needed to prevent * an invalid failure. */ - if (wts->prev_on_rq_cpu >= 0 && wts->prev_on_rq_cpu != cpu_of(rq)) + if (wts->prev_on_rq_cpu >= 0 && wts->prev_on_rq_cpu != cpu_of(rq) && + walt_flag_test(p, WALT_INIT)) WALT_BUG(WALT_BUG_UPSTREAM, p, "dequeue cpu %d not same as enqueue %d\n", cpu_of(rq), wts->prev_on_rq_cpu);