From cf33d6fae045e439b0dde37c7083ad2cdb5e07ac Mon Sep 17 00:00:00 2001 From: "vincent.wang" Date: Thu, 2 Dec 2021 11:50:26 +0800 Subject: [PATCH] ANDROID: vendor_hooks: add a hook to control the delay time of frequency up and down. balance the power and performance via the different delay time. Bug: 208722787 Signed-off-by: vincent.wang Change-Id: I104a090bc697ab9c68007081e6533820364f1351 --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/sched.h | 5 +++++ kernel/sched/cpufreq_schedutil.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 20bdd67149f9..bb2f17f9a32f 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -188,6 +188,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ftrace_format_check); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ftrace_dump_buffer); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_allow_domain_state); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_map_util_freq); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_update_next_freq); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_report_bug); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_em_cpu_energy); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpu_up); diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index ea001c708eef..ac58cf3b312e 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -236,6 +236,11 @@ DECLARE_HOOK(android_vh_map_util_freq, bool *need_freq_update), TP_ARGS(util, freq, cap, next_freq, policy, need_freq_update)); +DECLARE_HOOK(android_vh_update_next_freq, + TP_PROTO(struct cpufreq_policy *policy, unsigned int old_next_freq, + unsigned int *new_next_freq, s64 delta_ns), + TP_ARGS(policy, old_next_freq, new_next_freq, delta_ns)); + struct em_perf_domain; DECLARE_HOOK(android_vh_em_cpu_energy, TP_PROTO(struct em_perf_domain *pd, diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index b365895c2e2e..fe914ba41832 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -104,6 +104,9 @@ static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time, unsigned int next_freq) { if (!sg_policy->need_freq_update) { + s64 delta_ns = time - sg_policy->last_freq_update_time; + trace_android_vh_update_next_freq(sg_policy->policy, sg_policy->next_freq, + &next_freq, delta_ns); if (sg_policy->next_freq == next_freq) return false; } else {