[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220520161022.5972-2-ggherdovich@suse.cz>
Date: Fri, 20 May 2022 18:10:22 +0200
From: Giovanni Gherdovich <ggherdovich@...e.cz>
To: Borislav Petkov <bp@...en8.de>, Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>
Cc: "Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
Dan Carpenter <dan.carpenter@...cle.com>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
x86@...nel.org, linux-kernel@...r.kernel.org,
Giovanni Gherdovich <ggherdovich@...e.cz>
Subject: [PATCH 2/2] x86: fix platform info detection in frequency invariance
Once the microarchitecture is recognized (via x86_match_cpu()), a failure
in setting base_freq/turbo_freq should result in bailing out from frequency
invariance, not in trying the next microarchitecture. This is because the
call to core_set_max_freq_ratio() isn't guarded by x86_match_cpu(). The
call to core_set_max_freq_ratio() should happen if no more specific
microarch matched, but not in case of prior errors.
Initializing base_freq=0 and turbo_freq=0 gives a mean for later code to
check if setup failed.
Fixes: db441bd9f630 ("x86, sched: Move check for CPU type to caller function")
Signed-off-by: Giovanni Gherdovich <ggherdovich@...e.cz>
---
arch/x86/kernel/smpboot.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 225a3c31297c..d0a692ea8294 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -2044,23 +2044,26 @@ static bool core_set_max_freq_ratio(u64 *base_freq, u64 *turbo_freq)
static bool intel_set_max_freq_ratio(void)
{
- u64 base_freq, turbo_freq;
+ u64 base_freq = 0, turbo_freq = 0;
u64 turbo_ratio;
if (slv_set_max_freq_ratio(&base_freq, &turbo_freq))
goto out;
- if (x86_match_cpu(has_glm_turbo_ratio_limits) &&
- skx_set_max_freq_ratio(&base_freq, &turbo_freq, 1))
+ if (x86_match_cpu(has_glm_turbo_ratio_limits)) {
+ skx_set_max_freq_ratio(&base_freq, &turbo_freq, 1);
goto out;
+ }
- if (x86_match_cpu(has_knl_turbo_ratio_limits) &&
- knl_set_max_freq_ratio(&base_freq, &turbo_freq, 1))
+ if (x86_match_cpu(has_knl_turbo_ratio_limits)) {
+ knl_set_max_freq_ratio(&base_freq, &turbo_freq, 1);
goto out;
+ }
- if (x86_match_cpu(has_skx_turbo_ratio_limits) &&
- skx_set_max_freq_ratio(&base_freq, &turbo_freq, 4))
+ if (x86_match_cpu(has_skx_turbo_ratio_limits)) {
+ skx_set_max_freq_ratio(&base_freq, &turbo_freq, 4);
goto out;
+ }
if (core_set_max_freq_ratio(&base_freq, &turbo_freq))
goto out;
--
2.31.1
Powered by blists - more mailing lists