sched/walt: catch any set_task_cpu to unaffined cpus

When a task's cpu affinity is changed, do_set_cpus_allowed()
dequeues the task, updates the task's cpus_mask with new
affinity but enqueues the task back on the current cpu, even
if the current_cpu is not in the updated mask. This causes
the affinity check in enqueue path to fail.

Instead add this affinity check to set_task_cpu, this will
catch any selection of an cpu outside allowed cpus.

Change-Id: I6c1eaf77951f20aea961da463c1e8de0189d36e1
Signed-off-by: Stephen Dickey <quic_dickey@quicinc.com>
This commit is contained in:
Stephen Dickey 2022-01-27 15:46:16 -08:00 committed by Rishabh Bhatnagar
parent 59b2ef40cb
commit 32db2ec603

View File

@ -3885,6 +3885,10 @@ static void android_rvh_set_task_cpu(void *unused, struct task_struct *p, unsign
if (unlikely(walt_disabled))
return;
fixup_busy_time(p, (int) new_cpu);
if (!cpumask_test_cpu(new_cpu, p->cpus_ptr))
WALT_BUG(WALT_BUG_WALT, p, "selecting unaffined cpu=%d comm=%s(%d) affinity=0x%x",
new_cpu, p->comm, p->pid, (*(cpumask_bits(p->cpus_ptr))));
}
static void android_rvh_new_task_stats(void *unused, struct task_struct *p)
@ -3938,9 +3942,6 @@ static void android_rvh_enqueue_task(void *unused, struct rq *rq, struct task_st
double_enqueue = true;
}
if (!cpumask_test_cpu(cpu_of(rq), p->cpus_ptr))
WALT_BUG(WALT_BUG_NONCRITICAL, p, "enqueueing on rq=%d comm=%s(%d) affinity=0x%x",
cpu_of(rq), p->comm, p->pid, (*(cpumask_bits(p->cpus_ptr))));
if (cpu_halted(cpu_of(rq)) && !(p->flags & PF_KTHREAD) && !walt_halt_check_last(cpu_of(rq)))
WALT_BUG(WALT_BUG_NONCRITICAL, p,