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

Bug: 205906618

Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Change-Id: I8eba66fd0c6d36393ca39045cf228b659834e0ae
Signed-off-by: xieliujie <xieliujie@oppo.com>
This commit is contained in:
Liujie Xie
2021-11-11 17:05:49 +08:00
committed by Todd Kjos
parent 054a3c228a
commit 7e2fbdaeab
3 changed files with 24 additions and 0 deletions

View File

@@ -136,6 +136,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_show_resume_epoch_val);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_max_freq); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_max_freq);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_freq_table_limits); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_freq_table_limits);
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_sched_newidle_balance); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_newidle_balance);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_nohz_balancer_kick); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_nohz_balancer_kick);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_rebalance_domains); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_rebalance_domains);

View File

@@ -543,7 +543,10 @@ EXPORT_SYMBOL_GPL(cpufreq_disable_fast_switch);
unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy, unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
unsigned int target_freq) unsigned int target_freq)
{ {
unsigned int old_target_freq = target_freq;
target_freq = clamp_val(target_freq, policy->min, policy->max); target_freq = clamp_val(target_freq, policy->min, policy->max);
trace_android_vh_cpufreq_resolve_freq(policy, target_freq, old_target_freq);
policy->cached_target_freq = target_freq; policy->cached_target_freq = target_freq;
if (cpufreq_driver->target_index) { if (cpufreq_driver->target_index) {
@@ -2094,9 +2097,11 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
unsigned int target_freq) unsigned int target_freq)
{ {
unsigned int freq; unsigned int freq;
unsigned int old_target_freq = target_freq;
int cpu; int cpu;
target_freq = clamp_val(target_freq, policy->min, policy->max); 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); freq = cpufreq_driver->fast_switch(policy, target_freq);
if (!freq) if (!freq)
@@ -2213,6 +2218,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
/* Make sure that target_freq is within supported range */ /* Make sure that target_freq is within supported range */
target_freq = clamp_val(target_freq, policy->min, policy->max); target_freq = clamp_val(target_freq, policy->min, policy->max);
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", pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
policy->cpu, target_freq, relation, old_target_freq); policy->cpu, target_freq, relation, old_target_freq);

View File

@@ -31,6 +31,21 @@ DECLARE_HOOK(android_vh_cpufreq_acct_update_power,
DECLARE_RESTRICTED_HOOK(android_rvh_cpufreq_transition, DECLARE_RESTRICTED_HOOK(android_rvh_cpufreq_transition,
TP_PROTO(struct cpufreq_policy *policy), TP_PROTO(struct cpufreq_policy *policy),
TP_ARGS(policy), 1); TP_ARGS(policy), 1);
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));
/* macro versions of hooks are no longer required */ /* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_CPUFREQ_H */ #endif /* _TRACE_HOOK_CPUFREQ_H */