From a024fc656b9a3eb289b372b3ff8662ab7dd08430 Mon Sep 17 00:00:00 2001 From: Jing-Ting Wu Date: Thu, 23 Jun 2022 16:10:44 +0800 Subject: [PATCH] ANDROID: sched: add vendor hook to set_cpus_allowed Add new vendor hook when set affinity to detect task status for performance tuning. Bug: 236775946 Change-Id: I407637c85e2ea93585877312f090981fee848979 Signed-off-by: Jing-Ting Wu --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/sched.h | 5 +++++ kernel/sched/core.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index d7424d8a828e..63826529b032 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -156,6 +156,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_selinux_is_initialized); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_mmap_file); 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_by_task); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_post_init_entity_util_avg); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_uclamp_eff_get); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_util_est_update); diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index 66e9ba6f6632..36154293451e 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -194,6 +194,11 @@ DECLARE_RESTRICTED_HOOK(android_rvh_check_preempt_wakeup, TP_ARGS(rq, p, preempt, nopreempt, wake_flags, se, pse, next_buddy_marked, granularity), 1); +DECLARE_RESTRICTED_HOOK(android_rvh_set_cpus_allowed_by_task, + TP_PROTO(const struct cpumask *cpu_valid_mask, const struct cpumask *new_mask, + struct task_struct *p, unsigned int *dest_cpu), + TP_ARGS(cpu_valid_mask, new_mask, p, dest_cpu), 1); + DECLARE_HOOK(android_vh_free_task, TP_PROTO(struct task_struct *p), TP_ARGS(p)); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 96dcf05d6faa..4a53b1cf6fde 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2950,6 +2950,8 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p, * immediately required to distribute the tasks within their new mask. */ dest_cpu = cpumask_any_and_distribute(cpu_valid_mask, new_mask); + trace_android_rvh_set_cpus_allowed_by_task(cpu_valid_mask, new_mask, p, &dest_cpu); + if (dest_cpu >= nr_cpu_ids) { ret = -EINVAL; goto out;