ANDROID: vendor_hooks: Add hooks for frequency optimization

These hooks will do the following works:
a) Record the number of times when target_freq being clamped
b) Record the number of times when target_freq is greater than policy->cur
c) Make corresponding optimization strategies in different hooks
d) change the value of target_freq for some scenarios

Bug: 205906618
Bug: 206896672
Bug: 265246457
Bug: 314452030
Bug: 375411880

Change-Id: I8eba66fd0c6d36393ca39045cf228b659834e0ae
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Signed-off-by: vincent.wang <vincent.wang@unisoc.com>
Signed-off-by: Han Lin <han.lin%mediatek.com@gtempaccount.com>
Signed-off-by: Wade Wu <wei-ya.wu@mediatek.corp-partner.google.com>
This commit is contained in:
Liujie Xie
2021-11-11 17:05:49 +08:00
committed by Treehugger Robot
parent 93ad3e593c
commit 799be8c1e1
3 changed files with 24 additions and 0 deletions
+3
View File
@@ -57,6 +57,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_suspend_epoch_val);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_resume_epoch_val);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_freq_table_limits);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpufreq_online);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpufreq_resolve_freq);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpufreq_fast_switch);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpufreq_target);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpu_cgroup_attach);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpu_cgroup_online);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_fill_prdt);
+6
View File
@@ -540,8 +540,10 @@ static unsigned int __resolve_freq(struct cpufreq_policy *policy,
unsigned int target_freq, unsigned int relation)
{
unsigned int idx;
unsigned int old_target_freq = target_freq;
target_freq = clamp_val(target_freq, policy->min, policy->max);
trace_android_vh_cpufreq_resolve_freq(policy, &target_freq, old_target_freq);
if (!policy->freq_table)
return target_freq;
@@ -2179,9 +2181,11 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
unsigned int target_freq)
{
unsigned int freq;
unsigned int old_target_freq = target_freq;
int cpu;
target_freq = clamp_val(target_freq, policy->min, policy->max);
trace_android_vh_cpufreq_fast_switch(policy, &target_freq, old_target_freq);
freq = cpufreq_driver->fast_switch(policy, target_freq);
if (!freq)
@@ -2338,6 +2342,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
target_freq = __resolve_freq(policy, target_freq, relation);
trace_android_vh_cpufreq_target(policy, &target_freq, old_target_freq);
pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
policy->cpu, target_freq, relation, old_target_freq);
+15
View File
@@ -24,6 +24,21 @@ DECLARE_HOOK(android_vh_cpufreq_online,
TP_PROTO(struct cpufreq_policy *policy),
TP_ARGS(policy));
DECLARE_HOOK(android_vh_cpufreq_resolve_freq,
TP_PROTO(struct cpufreq_policy *policy, unsigned int *target_freq,
unsigned int old_target_freq),
TP_ARGS(policy, target_freq, old_target_freq));
DECLARE_HOOK(android_vh_cpufreq_fast_switch,
TP_PROTO(struct cpufreq_policy *policy, unsigned int *target_freq,
unsigned int old_target_freq),
TP_ARGS(policy, target_freq, old_target_freq));
DECLARE_HOOK(android_vh_cpufreq_target,
TP_PROTO(struct cpufreq_policy *policy, unsigned int *target_freq,
unsigned int old_target_freq),
TP_ARGS(policy, target_freq, old_target_freq));
#endif /* _TRACE_HOOK_CPUFREQ_H */
/* This part must be outside protection */
#include <trace/define_trace.h>