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 <quic_shalagra@quicinc.com>
This commit is contained in:
Shaleen Agrawal 2022-07-27 16:49:28 -07:00 committed by Sai Harshini Nimmala
parent 9698b4fcb0
commit 37f5cf75ef

View File

@ -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);