Skip to content

Commit 1b3108f

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/cpu/amd: Make the CPUID 0x80000008 parser correct
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: f7fb3b2 ("x86/cpu: Provide an AMD/HYGON specific topology parser") Reported-by: "kernelci.org bot" <[email protected]> Reported-by: Laura Nao <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Laura Nao <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4f51173 commit 1b3108f

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

arch/x86/kernel/cpu/topology_amd.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,21 @@ static bool parse_8000_0008(struct topo_scan *tscan)
2929
if (!sft)
3030
sft = get_count_order(ecx.cpu_nthreads + 1);
3131

32-
topology_set_dom(tscan, TOPO_SMT_DOMAIN, sft, ecx.cpu_nthreads + 1);
32+
/*
33+
* cpu_nthreads describes the number of threads in the package
34+
* sft is the number of APIC ID bits per package
35+
*
36+
* As the number of actual threads per core is not described in
37+
* this leaf, just set the CORE domain shift and let the later
38+
* parsers set SMT shift. Assume one thread per core by default
39+
* which is correct if there are no other CPUID leafs to parse.
40+
*/
41+
topology_update_dom(tscan, TOPO_SMT_DOMAIN, 0, 1);
42+
topology_set_dom(tscan, TOPO_CORE_DOMAIN, sft, ecx.cpu_nthreads + 1);
3343
return true;
3444
}
3545

36-
static void store_node(struct topo_scan *tscan, unsigned int nr_nodes, u16 node_id)
46+
static void store_node(struct topo_scan *tscan, u16 nr_nodes, u16 node_id)
3747
{
3848
/*
3949
* Starting with Fam 17h the DIE domain could probably be used to
@@ -73,12 +83,14 @@ static bool parse_8000_001e(struct topo_scan *tscan, bool has_0xb)
7383
tscan->c->topo.initial_apicid = leaf.ext_apic_id;
7484

7585
/*
76-
* If leaf 0xb is available, then SMT shift is set already. If not
77-
* take it from ecx.threads_per_core and use topo_update_dom() -
78-
* topology_set_dom() would propagate and overwrite the already
79-
* propagated CORE level.
86+
* If leaf 0xb is available, then the domain shifts are set
87+
* already and nothing to do here.
8088
*/
8189
if (!has_0xb) {
90+
/*
91+
* Leaf 0x80000008 set the CORE domain shift already.
92+
* Update the SMT domain, but do not propagate it.
93+
*/
8294
unsigned int nthreads = leaf.core_nthreads + 1;
8395

8496
topology_update_dom(tscan, TOPO_SMT_DOMAIN, get_count_order(nthreads), nthreads);

0 commit comments

Comments
 (0)