From 30197461c346be6fd021051b7038d6a7b5cc0c6e Mon Sep 17 00:00:00 2001 From: Shaleen Agrawal Date: Mon, 23 Oct 2023 10:45:28 -0700 Subject: [PATCH 1/2] sched/walt: Add flag to determine waltgov status Create a waltgov_disabled flag to indicate if the WALT governor is the active governor. This will be used by the followup patch to determine when to modify capacities. Change-Id: Ic1509efbd123fd471536e75d54efcf6880a81627 Signed-off-by: Shaleen Agrawal --- kernel/sched/walt/cpufreq_walt.c | 4 ++++ kernel/sched/walt/walt.h | 1 + 2 files changed, 5 insertions(+) diff --git a/kernel/sched/walt/cpufreq_walt.c b/kernel/sched/walt/cpufreq_walt.c index e9cb1659ca67..0268e75bdf18 100644 --- a/kernel/sched/walt/cpufreq_walt.c +++ b/kernel/sched/walt/cpufreq_walt.c @@ -1046,6 +1046,7 @@ static void waltgov_tunables_restore(struct cpufreq_policy *policy) tunables->target_load_shift = cached->target_load_shift; } +bool waltgov_disabled = true; static int waltgov_init(struct cpufreq_policy *policy) { struct waltgov_policy *wg_policy; @@ -1164,6 +1165,7 @@ static int waltgov_start(struct cpufreq_policy *policy) waltgov_add_callback(cpu, &wg_cpu->cb, waltgov_update_freq); } + waltgov_disabled = false; return 0; } @@ -1181,6 +1183,8 @@ static void waltgov_stop(struct cpufreq_policy *policy) irq_work_sync(&wg_policy->irq_work); kthread_cancel_work_sync(&wg_policy->work); } + + waltgov_disabled = true; } static void waltgov_limits(struct cpufreq_policy *policy) diff --git a/kernel/sched/walt/walt.h b/kernel/sched/walt/walt.h index ec7a4d17af02..ec5519b8dab1 100644 --- a/kernel/sched/walt/walt.h +++ b/kernel/sched/walt/walt.h @@ -43,6 +43,7 @@ #define MAX_MARGIN_LEVELS (MAX_CLUSTERS - 1) extern bool walt_disabled; +extern bool waltgov_disabled; enum task_event { PUT_PREV_TASK = 0, From 6521efb3c3998ef9b0b96498bdff157563d7c6b4 Mon Sep 17 00:00:00 2001 From: Shaleen Agrawal Date: Mon, 23 Oct 2023 10:50:25 -0700 Subject: [PATCH 2/2] sched/walt: Limit capacity capping to waltgov If userspace changes the governor to a different one than waltgov, ensure that capacities are unnecessarily capped and accurately reflect the current frequency's true capacity. Change-Id: I04c392721a96ff3d03e9438dd3a97777f0d9fd2b Signed-off-by: Shaleen Agrawal --- kernel/sched/walt/walt.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/sched/walt/walt.h b/kernel/sched/walt/walt.h index ec5519b8dab1..1370bca4c8a7 100644 --- a/kernel/sched/walt/walt.h +++ b/kernel/sched/walt/walt.h @@ -1126,11 +1126,14 @@ static inline bool has_internal_freq_limit_changed(struct walt_sched_cluster *cl int i; internal_freq = cluster->walt_internal_freq_limit; - cluster->walt_internal_freq_limit = cluster->max_freq; - for (i = 0; i < MAX_FREQ_CAP; i++) - cluster->walt_internal_freq_limit = min(fmax_cap[i][cluster->id], + + if (likely(!waltgov_disabled)) { + for (i = 0; i < MAX_FREQ_CAP; i++) + cluster->walt_internal_freq_limit = min(fmax_cap[i][cluster->id], cluster->walt_internal_freq_limit); + } + return cluster->walt_internal_freq_limit != internal_freq; }