public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Laura Nao <laura.nao@collabora.com>,
	x86@kernel.org, kernel@collabora.com, regressions@leemhuis.info,
	"regressions@lists.linux.dev" <87il0p2era.ffs@tglx>
Subject: [patch 1/2] x86/cpu/amd: Make the CPUID 0x80000008 parser correct
Date: Wed, 10 Apr 2024 21:45:27 +0200 (CEST)	[thread overview]
Message-ID: <20240410194311.535206450@linutronix.de> (raw)
In-Reply-To: 20240410194002.909839385@linutronix.de

CPUID 0x80000008 ECX.cpu_nthreads describes the number of threads in the
package. The parser uses this value to initialize the SMT domain level.

That's wrong because cpu_nthreads does not describe the number of threads
per physical core. So this needs to set the CORE domain level and let the
later parsers set the SMT shift if available.

Preset the SMT domain level with the assumption of one thread per core,
which is correct ifrt here are no other CPUID leafs to parse, and propagate
cpu_nthreads and the core level APIC bitwidth into the CORE domain.

Fixes: f7fb3b2dd92c ("x86/cpu: Provide an AMD/HYGON specific topology parser")
Reported-by: Laura Nao <laura.nao@collabora.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/cpu/topology_amd.c |   24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

--- a/arch/x86/kernel/cpu/topology_amd.c
+++ b/arch/x86/kernel/cpu/topology_amd.c
@@ -29,11 +29,21 @@ static bool parse_8000_0008(struct topo_
 	if (!sft)
 		sft = get_count_order(ecx.cpu_nthreads + 1);
 
-	topology_set_dom(tscan, TOPO_SMT_DOMAIN, sft, ecx.cpu_nthreads + 1);
+	/*
+	 * cpu_nthreads describes the number of threads in the package
+	 * sft is the number of APIC ID bits per package
+	 *
+	 * As the number of actual threads per core is not described in
+	 * this leaf, just set the CORE domain shift and let the later
+	 * parsers set SMT shift. Assume one thread per core by default
+	 * which is correct if there are no other CPUID leafs to parse.
+	 */
+	topology_update_dom(tscan, TOPO_SMT_DOMAIN, 0, 1);
+	topology_set_dom(tscan, TOPO_CORE_DOMAIN, sft, ecx.cpu_nthreads + 1);
 	return true;
 }
 
-static void store_node(struct topo_scan *tscan, unsigned int nr_nodes, u16 node_id)
+static void store_node(struct topo_scan *tscan, u16 nr_nodes, u16 node_id)
 {
 	/*
 	 * Starting with Fam 17h the DIE domain could probably be used to
@@ -73,12 +83,14 @@ static bool parse_8000_001e(struct topo_
 	tscan->c->topo.initial_apicid = leaf.ext_apic_id;
 
 	/*
-	 * If leaf 0xb is available, then SMT shift is set already. If not
-	 * take it from ecx.threads_per_core and use topo_update_dom() -
-	 * topology_set_dom() would propagate and overwrite the already
-	 * propagated CORE level.
+	 * If leaf 0xb is available, then the domain shifts are set
+	 * already and nothing to do here.
 	 */
 	if (!has_0xb) {
+		/*
+		 * Leaf 0x80000008 set the CORE domain shift already.
+		 * Update the SMT domain, but do not propagate it.
+		 */
 		unsigned int nthreads = leaf.core_nthreads + 1;
 
 		topology_update_dom(tscan, TOPO_SMT_DOMAIN, get_count_order(nthreads), nthreads);


  reply	other threads:[~2024-04-10 19:45 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 17:52 [REGRESSION] mainline boot regression on AMD Stoney Ridge Chromebooks Laura Nao
2024-03-28  9:44 ` Laura Nao
2024-03-28 11:50   ` Laura Nao
2024-04-04  8:24     ` Linux regression tracking (Thorsten Leemhuis)
2024-04-04  9:26       ` Laura Nao
2024-04-04 13:01       ` Thomas Gleixner
2024-04-04 13:05         ` Thomas Gleixner
2024-04-04 15:23           ` Laura Nao
2024-04-04 16:14             ` Thomas Gleixner
2024-04-04 18:06               ` Thomas Gleixner
2024-04-04 19:14                 ` Thomas Gleixner
2024-04-04 20:05                   ` Thomas Gleixner
2024-04-05  8:14                     ` Laura Nao
2024-04-05  8:42                       ` Thomas Gleixner
2024-04-05 10:32                         ` Laura Nao
2024-04-05 13:38                           ` Thomas Gleixner
2024-04-05 13:58                             ` Laura Nao
2024-04-05 14:59                               ` Thomas Gleixner
2024-04-08  8:20                                 ` Thomas Gleixner
2024-04-08 11:06                                   ` Laura Nao
2024-04-08 14:19                                     ` Thomas Gleixner
2024-04-09 10:07                                       ` Laura Nao
2024-04-09 12:25                                         ` Thomas Gleixner
2024-04-10  8:15                                           ` Laura Nao
2024-04-10 13:57                                             ` Thomas Gleixner
2024-04-10 16:11                                               ` Laura Nao
2024-04-10 19:34                                                 ` Thomas Gleixner
2024-04-10 19:45                                                   ` [patch 0/2] x86/cpu/amd: Fixup the topology rework fallout Thomas Gleixner
2024-04-10 19:45                                                     ` Thomas Gleixner [this message]
2024-04-11 12:45                                                       ` [tip: x86/urgent] x86/cpu/amd: Make the CPUID 0x80000008 parser correct tip-bot2 for Thomas Gleixner
2024-04-12 10:12                                                       ` tip-bot2 for Thomas Gleixner
2024-04-10 19:45                                                     ` [patch 2/2] x86/cpu/amd: Make the NODEID_MSR union actually work Thomas Gleixner
2024-04-11 12:45                                                       ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2024-04-12 10:12                                                       ` tip-bot2 for Thomas Gleixner
2024-04-11 11:27                                                     ` [patch 0/2] x86/cpu/amd: Fixup the topology rework fallout Laura Nao
2024-04-11 11:37                                                       ` Linux regression tracking (Thorsten Leemhuis)
2024-04-11 12:14                                                         ` Thomas Gleixner

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=20240410194311.535206450@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=87il0p2era.ffs@tglx \
    --cc=kernel@collabora.com \
    --cc=laura.nao@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=regressions@leemhuis.info \
    --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