From 81ebefd895e596471052a68c31e9412f4394b660 Mon Sep 17 00:00:00 2001 From: Jing-Ting Wu Date: Mon, 9 Jan 2023 14:42:39 +0800 Subject: [PATCH] ANDROID: sched: add vendor hook in find_new_ilb Add new vendor hook to find new ilb cpu for power tuning. We also set ilb initial is -1 by this patch, and we set ilb as nr_cpu_ids by our vendor when ilb cpu not be found. If ilb initial is 0, then when hook is not registered, find ilb will return CPU 0. But when hook is not registered, it should do for_each_cpu_and() to find best ilb cpu, instead of return CPU 0 direct. So we set ilb initial is -1, it means anyone doesn't register the hook or the registered hook doesn't do anything, instead of ilb cpu not be found by vendor. Bug: 264821176 Change-Id: Idb5a8bd5862f7dd1fa30fa99aec3b42214375915 Signed-off-by: Jing-Ting Wu --- include/trace/hooks/sched.h | 4 ++++ kernel/sched/fair.c | 6 +++++- kernel/sched/vendor_hooks.c | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index c94e0484cb39..3b0816d22931 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -325,6 +325,10 @@ DECLARE_HOOK(android_vh_set_wake_flags, TP_PROTO(int *wake_flags, unsigned int *mode), TP_ARGS(wake_flags, mode)); +DECLARE_RESTRICTED_HOOK(android_rvh_find_new_ilb, + TP_PROTO(struct cpumask *nohz_idle_cpus_mask, int *ilb), + TP_ARGS(nohz_idle_cpus_mask, ilb), 1); + /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_SCHED_H */ diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e60a414c31cf..e560b86ad9a2 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10887,9 +10887,13 @@ static inline int on_null_domain(struct rq *rq) static inline int find_new_ilb(void) { - int ilb; + int ilb = -1; const struct cpumask *hk_mask; + trace_android_rvh_find_new_ilb(nohz.idle_cpus_mask, &ilb); + if (ilb >= 0) + return ilb; + hk_mask = housekeeping_cpumask(HK_TYPE_MISC); for_each_cpu_and(ilb, nohz.idle_cpus_mask, hk_mask) { diff --git a/kernel/sched/vendor_hooks.c b/kernel/sched/vendor_hooks.c index 26dc388f983d..1a4b48951044 100644 --- a/kernel/sched/vendor_hooks.c +++ b/kernel/sched/vendor_hooks.c @@ -84,3 +84,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_update_topology_flags_workfn); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_thermal_stats); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_wake_up_sync); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_wake_flags); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_new_ilb);