ANDROID: sched: Add vendor hooks for override sugov behavior

Upstream moved the sugov to DEADLINE class which has higher prio than RT
so it can potentially block many RT use case in Android.

Also currently iowait doesn't distinguish background/foreground tasks
and we have seen cases where device run to high frequency unnecessarily
when running some background I/O.

Bug: 344826816
Bug: 297343949
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I21e9bfe9ef75a4178279574389e417c3f38e65ac
(cherry picked from commit e08c5de06e)
[Trivial conflict in includle/trace/hooks/sched.h due to new code added
in same location.]
Signed-off-by: Qais Yousef <qyousef@google.com>
This commit is contained in:
Wei Wang 2020-10-29 00:13:26 -07:00 committed by John Stultz
parent b7f2df29a2
commit 1a7550f7c9
4 changed files with 17 additions and 1 deletions

View File

@ -445,6 +445,16 @@ DECLARE_RESTRICTED_HOOK(android_rvh_update_blocked_fair,
TP_PROTO(struct rq *rq),
TP_ARGS(rq), 1);
struct sched_attr;
DECLARE_HOOK(android_vh_set_sugov_sched_attr,
TP_PROTO(struct sched_attr *attr),
TP_ARGS(attr));
DECLARE_RESTRICTED_HOOK(android_rvh_set_iowait,
TP_PROTO(struct task_struct *p, struct rq *rq, int *should_iowait_boost),
TP_ARGS(p, rq, should_iowait_boost), 1);
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_SCHED_H */

View File

@ -608,6 +608,7 @@ static int sugov_kthread_create(struct sugov_policy *sg_policy)
if (policy->fast_switch_enabled)
return 0;
trace_android_vh_set_sugov_sched_attr(&attr);
kthread_init_work(&sg_policy->work, sugov_work);
kthread_init_worker(&sg_policy->worker);
thread = kthread_create(kthread_worker_fn, &sg_policy->worker,

View File

@ -6641,6 +6641,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
struct sched_entity *se = &p->se;
int idle_h_nr_running = task_has_idle_policy(p);
int task_new = !(flags & ENQUEUE_WAKEUP);
int should_iowait_boost;
/*
* The code below (indirectly) updates schedutil which looks at
@ -6655,7 +6656,9 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
* utilization updates, so do it here explicitly with the IOWAIT flag
* passed.
*/
if (p->in_iowait)
should_iowait_boost = p->in_iowait;
trace_android_rvh_set_iowait(p, rq, &should_iowait_boost);
if (should_iowait_boost)
cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT);
for_each_sched_entity(se) {

View File

@ -114,3 +114,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_load_avg);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_remove_entity_load_avg);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_blocked_fair);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_uclamp_validate);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_sugov_sched_attr);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_iowait);