From f503db11786d937ce9cabd31b08e7280ed0f4b5a Mon Sep 17 00:00:00 2001 From: Qais Yousef Date: Thu, 19 Dec 2019 11:24:41 +0000 Subject: [PATCH] ANDROID: Re-use SUGOV_RT_MAX_FREQ to control uclamp rt behavior By default uclamp RT tasks will use the max frequency, which is not the desired default behavior on mobile devices. Re-use the SUGOV_RT_MAX_FREQ sched_feat to control the default behavior. When SUGOV_RT_MAX_FREQ is NOT selected, the uclamp_min value of the RT tasks will be 0. Note, since now we use SUGOV_RT_MAX_FREQ to enforce the default max frequency for RT when uclamp is compiled in; the condition in schedutil_cpu_util() needs to be inverted so that max no longer unconditionally applied when uclamp is compiled in && SUGOV_RT_MAX_FREQ is true. This unconditional application means uclamp values are always ignored which is not what we want when uclamp is compiled in. Bug: 120440300 Signed-off-by: Qais Yousef Change-Id: I3d36f1ebed6ef35a6299af32bbf4462d0353e783 Signed-off-by: Quentin Perret --- kernel/sched/core.c | 12 ++++++++++-- kernel/sched/cpufreq_schedutil.c | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 002e846e7db2..d0154743a3ed 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1157,8 +1157,12 @@ static void __setscheduler_uclamp(struct task_struct *p, continue; /* By default, RT tasks always get 100% boost */ - if (unlikely(rt_task(p) && clamp_id == UCLAMP_MIN)) + if (sched_feat(SUGOV_RT_MAX_FREQ) && + unlikely(rt_task(p) && + clamp_id == UCLAMP_MIN)) { + clamp_value = uclamp_none(UCLAMP_MAX); + } uclamp_se_set(uc_se, clamp_value, false); } @@ -1191,8 +1195,12 @@ static void uclamp_fork(struct task_struct *p) unsigned int clamp_value = uclamp_none(clamp_id); /* By default, RT tasks always get 100% boost */ - if (unlikely(rt_task(p) && clamp_id == UCLAMP_MIN)) + if (sched_feat(SUGOV_RT_MAX_FREQ) && + unlikely(rt_task(p) && + clamp_id == UCLAMP_MIN)) { + clamp_value = uclamp_none(UCLAMP_MAX); + } uclamp_se_set(&p->uclamp_req[clamp_id], clamp_value, false); } diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index d96a55ba7402..4c8ecbf0df69 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -244,7 +244,7 @@ unsigned long schedutil_cpu_util(int cpu, unsigned long util_cfs, unsigned long dl_util, util, irq; struct rq *rq = cpu_rq(cpu); - if ((sched_feat(SUGOV_RT_MAX_FREQ) || !IS_BUILTIN(CONFIG_UCLAMP_TASK)) && + if (sched_feat(SUGOV_RT_MAX_FREQ) && !IS_BUILTIN(CONFIG_UCLAMP_TASK) && type == FREQUENCY_UTIL && rt_rq_is_runnable(&rq->rt)) { return max; }