From 9e864eaf88768194e82e02c35a5b8c80bfd9b8cc Mon Sep 17 00:00:00 2001 From: Quentin Perret Date: Tue, 10 Jul 2018 15:44:09 +0100 Subject: [PATCH 1/2] ANDROID: cpufreq/schedutil: Select frequency using util_avg for RT Schedutil always requests max frequency whenever a RT task is running. Now that we have a better estimate of the utilization of RT runqueues, it is possible to make a less conservative decision and scale frequency according to the needs of the RT tasks. To do so, protect the RT-go-to-max code with a new sched_feature. The sched_feature is disabled by default, hence favoring energy savings as required in mobile environments. Signed-off-by: Quentin Perret Change-Id: Ic9f01c8703d4f843addaa0d684012a422fe9f3b8 Git-commit: c74d264106b150fad8949a985514d127c1e117c5 Git-repo: https://android.googlesource.com/kernel/common/ [satyap@codeaurora.org: fix trivial merge conflicts] Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/sched/cpufreq_schedutil.c | 2 +- kernel/sched/features.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index bfd2ba66d588..5668efdef410 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -307,7 +307,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 (!IS_BUILTIN(CONFIG_UCLAMP_TASK) && + if (!IS_BUILTIN(CONFIG_UCLAMP_TASK) && sched_feat(SUGOV_RT_MAX_FREQ) && type == FREQUENCY_UTIL && rt_rq_is_runnable(&rq->rt)) { return max; } diff --git a/kernel/sched/features.h b/kernel/sched/features.h index 4283e36914f5..9fba55689636 100644 --- a/kernel/sched/features.h +++ b/kernel/sched/features.h @@ -94,3 +94,8 @@ SCHED_FEAT(UTIL_EST, true) * Fast pre-selection of CPU candidates for EAS. */ SCHED_FEAT(FIND_BEST_TARGET, true) + +/* + * Request max frequency from schedutil whenever a RT task is running. + */ +SCHED_FEAT(SUGOV_RT_MAX_FREQ, false) From 09c8865bfcda61b3de19b197b7e828ce9f21208e Mon Sep 17 00:00:00 2001 From: Qais Yousef Date: Thu, 19 Dec 2019 11:24:41 +0000 Subject: [PATCH 2/2] 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. Bug: 120440300 Signed-off-by: Qais Yousef Change-Id: I3d36f1ebed6ef35a6299af32bbf4462d0353e783 Git-commit: f89ff1404286486643a1ae80f1f22946cdb8d0ee Git-repo: https://android.googlesource.com/kernel/common/ Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/sched/core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f68625ec8cf8..6469e436bf7c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1216,8 +1216,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); } @@ -1250,8 +1254,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); }