ANDROID: sched: Add vendor hooks for skipping sugov update

This is to add capability for vendor to decide whether a cpufreq update
is needed, e.g. up/down rate limit.

Using restricted hook since it can be called from scheduler wakeup path.

Bug: 170511085
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: If9adea3a3e31efbf3858fbd009665a07dc70c638
(cherry picked from commit f9f3464532a045257f8138338b1beda86ef0a3be)
Signed-off-by: Will McVicker <willmcvicker@google.com>
This commit is contained in:
Wei Wang 2020-10-29 22:49:45 -07:00 committed by Quentin Perret
parent 06881e01b5
commit 846bf8e8cb
3 changed files with 12 additions and 1 deletions

View File

@ -82,4 +82,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_busiest_queue);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_migrate_queued_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_energy_efficient_cpu);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_sugov_sched_attr);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_iowait);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_iowait);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_sugov_update);

View File

@ -112,6 +112,10 @@ DECLARE_HOOK(android_vh_set_sugov_sched_attr,
DECLARE_RESTRICTED_HOOK(android_rvh_set_iowait,
TP_PROTO(struct task_struct *p, int *should_iowait_boost),
TP_ARGS(p, should_iowait_boost), 1);
struct sugov_policy;
DECLARE_RESTRICTED_HOOK(android_rvh_set_sugov_update,
TP_PROTO(struct sugov_policy *sg_policy, unsigned int next_freq, bool *should_update),
TP_ARGS(sg_policy, next_freq, should_update), 1);
#else
#define trace_android_rvh_select_task_rq_fair(p, prev_cpu, sd_flag, wake_flags, new_cpu)
#define trace_android_rvh_select_task_rq_rt(p, prev_cpu, sd_flag, wake_flags, new_cpu)
@ -136,6 +140,7 @@ DECLARE_RESTRICTED_HOOK(android_rvh_set_iowait,
#define trace_android_rvh_find_energy_efficient_cpu(p, prev_cpu, sync, new_cpu)
#define trace_android_vh_set_sugov_sched_attr(attr)
#define trace_android_rvh_set_iowait(p, should_iowait_boost)
#define trace_android_rvh_set_sugov_update(sg_policy, next_freq, should_update)
#endif
#endif /* _TRACE_HOOK_SCHED_H */
/* This part must be outside protection */

View File

@ -103,6 +103,7 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time)
static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time,
unsigned int next_freq)
{
bool should_update = true;
if (!sg_policy->need_freq_update) {
if (sg_policy->next_freq == next_freq)
return false;
@ -110,6 +111,10 @@ static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time,
sg_policy->need_freq_update = cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS);
}
trace_android_rvh_set_sugov_update(sg_policy, next_freq, &should_update);
if (!should_update)
return false;
sg_policy->next_freq = next_freq;
sg_policy->last_freq_update_time = time;