diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 918879fa091f..bc8dd375d491 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -195,6 +195,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_file_open); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_bpf_syscall); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_cpus_allowed_ptr_locked); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_rto_next_cpu); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_is_cpu_allowed); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_em_dev_register_pd); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_logbuf); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_logbuf_pr_cont); diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index 2fc98949e761..faee3c807d39 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -61,6 +61,10 @@ DECLARE_RESTRICTED_HOOK(android_rvh_rto_next_cpu, TP_PROTO(int rto_cpu, struct cpumask *rto_mask, int *cpu), TP_ARGS(rto_cpu, rto_mask, cpu), 1); +DECLARE_RESTRICTED_HOOK(android_rvh_is_cpu_allowed, + TP_PROTO(int cpu, bool *allowed), + TP_ARGS(cpu, allowed), 1); + DECLARE_RESTRICTED_HOOK(android_rvh_set_user_nice, TP_PROTO(struct task_struct *p, long *nice, bool *allowed), TP_ARGS(p, nice, allowed), 1); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index e48423480fbc..4c367580e628 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2205,6 +2205,8 @@ static inline bool rq_has_pinned_tasks(struct rq *rq) */ static inline bool is_cpu_allowed(struct task_struct *p, int cpu) { + bool allowed = true; + /* When not in the task's cpumask, no point in looking further. */ if (!cpumask_test_cpu(cpu, p->cpus_ptr)) return false; @@ -2214,8 +2216,14 @@ static inline bool is_cpu_allowed(struct task_struct *p, int cpu) return cpu_online(cpu); /* Non kernel threads are not allowed during either online or offline. */ - if (!(p->flags & PF_KTHREAD)) - return cpu_active(cpu) && task_cpu_possible(cpu, p); + 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; + } + } /* KTHREAD_IS_PER_CPU is always allowed. */ if (kthread_is_per_cpu(p))