From 4345c3db8492caa9b2c812becb0302e97bd114af Mon Sep 17 00:00:00 2001 From: Stephen Dickey Date: Wed, 2 Mar 2022 16:46:49 -0800 Subject: [PATCH] ANDROID: sched: update is_cpu_allowed tracehook Currently, the trace hook for is_cpu_allowed only executes if the cpu is not a kthread. Modules need to be able to reject cpus regardless of whether the task is a kthread or not. Modules also need to have the flexibility to execute, or not, the remainder of is_cpu_allowed. Move the tracepoint for is_cpu_allowed so that it is invoked regardless of task's kthread status, but do not interfere with per-cpu-kthread cpu assignment. Bug: 222550772 Change-Id: Ide48a82a33129448bb22be28814267b0b76535a2 Signed-off-by: Stephen Dickey --- kernel/sched/core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index c187e18461b9..f832b7aa0554 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2228,20 +2228,20 @@ static inline bool is_cpu_allowed(struct task_struct *p, int cpu) if (is_migration_disabled(p)) return cpu_online(cpu); + /* check for all cases */ + trace_android_rvh_is_cpu_allowed(cpu, &allowed); + /* Non kernel threads are not allowed during either online or offline. */ - if (!(p->flags & PF_KTHREAD)) { - if (cpu_active(cpu) && task_cpu_possible(cpu, p)) { - trace_android_rvh_is_cpu_allowed(cpu, &allowed); - return allowed; - } else { - return false; - } - } + if (!(p->flags & PF_KTHREAD)) + return cpu_active(cpu) && task_cpu_possible(cpu, p) && allowed; /* KTHREAD_IS_PER_CPU is always allowed. */ if (kthread_is_per_cpu(p)) return cpu_online(cpu); + if (!allowed) + return false; + /* Regular kernel threads don't get to stay during offline. */ if (cpu_dying(cpu)) return false;