sched: walt: handle CTS failure for sched_set/getaffinity

During CTS testing, the user-space code can get an affinity
that includes a halted cpu, and immediately use that to set
the affinity. Currently sched_setaffinity will cause an error
if a halted cpu is selected.

Port the change that was in use prior to the introduction of
pause, correcting the CTS test case.

Change-Id: I9bfc819e4a6904494c199931e76f2702b7990758
Signed-off-by: Stephen Dickey <quic_dickey@quicinc.com>
This commit is contained in:
Stephen Dickey 2022-04-13 09:39:26 -07:00 committed by Rishabh Bhatnagar
parent 7f927567ff
commit 492decfdc4

View File

@ -4464,6 +4464,16 @@ static void android_rvh_update_cpus_allowed(void *unused, struct task_struct *p,
*ret = set_cpus_allowed_ptr(p, &wts->cpus_requested);
}
static void android_rvh_sched_getaffinity(void *unused, struct task_struct *p,
struct cpumask *in_mask)
{
if (unlikely(walt_disabled))
return;
if (!(p->flags & PF_KTHREAD))
cpumask_andnot(in_mask, in_mask, cpu_halt_mask);
}
static void android_rvh_sched_setaffinity(void *unused, struct task_struct *p,
const struct cpumask *in_mask,
int *retval)
@ -4551,6 +4561,7 @@ static void register_walt_hooks(void)
register_trace_android_rvh_cpu_cgroup_online(android_rvh_cpu_cgroup_online, NULL);
register_trace_android_rvh_update_cpus_allowed(android_rvh_update_cpus_allowed, NULL);
register_trace_android_rvh_sched_setaffinity(android_rvh_sched_setaffinity, NULL);
register_trace_android_rvh_sched_getaffinity(android_rvh_sched_getaffinity, NULL);
register_trace_android_rvh_sched_fork_init(android_rvh_sched_fork_init, NULL);
register_trace_android_rvh_ttwu_cond(android_rvh_ttwu_cond, NULL);
register_trace_android_rvh_sched_exec(android_rvh_sched_exec, NULL);