From 492decfdc48c120b51dd5e7616ca5db81a489f25 Mon Sep 17 00:00:00 2001 From: Stephen Dickey Date: Wed, 13 Apr 2022 09:39:26 -0700 Subject: [PATCH] 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 --- kernel/sched/walt/walt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/sched/walt/walt.c b/kernel/sched/walt/walt.c index f277d26a92f2..da36b06cabae 100644 --- a/kernel/sched/walt/walt.c +++ b/kernel/sched/walt/walt.c @@ -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);