The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Giovanni Gherdovich <ggherdovich@suse.cz>
To: Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	Giovanni Gherdovich <ggherdovich@suse.cz>
Subject: [PATCH 2/2] x86: fix platform info detection in frequency invariance
Date: Fri, 20 May 2022 18:10:22 +0200	[thread overview]
Message-ID: <20220520161022.5972-2-ggherdovich@suse.cz> (raw)
In-Reply-To: <20220520161022.5972-1-ggherdovich@suse.cz>

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@suse.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


  reply	other threads:[~2022-05-20 16:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20 16:10 [PATCH 1/2] x86: Fix return value in frequency invariance setup for XEON_PHI_KNL/KNM Giovanni Gherdovich
2022-05-20 16:10 ` Giovanni Gherdovich [this message]
2022-05-20 16:44   ` [PATCH 2/2] x86: fix platform info detection in frequency invariance Dave Hansen
2022-05-23  9:56     ` Giovanni Gherdovich
2022-05-21 10:02 ` [PATCH 1/2] x86: Fix return value in frequency invariance setup for XEON_PHI_KNL/KNM Peter Zijlstra
2022-05-23  9:57   ` Giovanni Gherdovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220520161022.5972-2-ggherdovich@suse.cz \
    --to=ggherdovich@suse.cz \
    --cc=bp@alien8.de \
    --cc=dan.carpenter@oracle.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox