Skip to content

x86/cpu: Rework topology evaluation

Thomas Gleixner lkml 6 versions – Applied

Status from this message: The following commit has been merged into the x86/apic branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest19 patches 5 repliesApplied
  2. v519 patches 24 repliesApplied
  3. v441 patches 21 repliesApplied
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v340 patches45 repliesApplied
v238 patches32 repliesSuperseded
v129 patches10 repliesSuperseded

Changes in v6 from the cover letter

- Fix the AMD leaf 0x8000008 parsing
- Update to generated CPUID leaf structures
- Address review comments (coding style, comments, changelogs, boot_cpu_has())

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/19x86/cpu: Provide cpuid_read() et al.arch/x86/include/asm/cpuid.h+36 -02 replies
1/19x86/cpu: Provide cpuid_read() et al.arch/x86/include/asm/cpuid.h+36 -02 replies
2/19x86/cpu: Provide cpu_init/parse_topology()arch/x86/include/asm/topology.h arch/x86/kernel/cpu/Makefile arch/x86/kernel/cpu/common.c +4 more+296 -180 replies
3/19x86/cpu: Add legacy topology parserarch/x86/kernel/cpu/common.c arch/x86/kernel/cpu/topology.h arch/x86/kernel/cpu/topology_common.c+51 -10 replies
4/19x86/cpu: Use common topology code for Centaur and Zhaoxinarch/x86/kernel/cpu/centaur.c arch/x86/kernel/cpu/topology_common.c arch/x86/kernel/cpu/zhaoxin.c+8 -110 replies
5/19x86/cpu: Move __max_die_per_package to common.carch/x86/kernel/cpu/common.c arch/x86/kernel/cpu/topology.c+3 -30 replies
6/19x86/cpu: Provide a sane leaf 0xb/0x1f parserarch/x86/kernel/cpu/Makefile arch/x86/kernel/cpu/topology.h arch/x86/kernel/cpu/topology_ext.c+143 -10 replies
7/19x86/cpu: Use common topology code for Intelarch/x86/kernel/cpu/common.c arch/x86/kernel/cpu/cpu.h arch/x86/kernel/cpu/intel.c +2 more+4 -1170 replies
8/19x86/cpu/amd: Provide a separate accessor for Node IDarch/x86/events/amd/core.c arch/x86/include/asm/processor.h arch/x86/include/asm/topology.h +6 more+23 -120 replies
9/19x86/cpu: Provide an AMD/HYGON specific topology parserarch/x86/include/asm/topology.h arch/x86/kernel/cpu/Makefile arch/x86/kernel/cpu/amd.c +6 more+215 -70 replies
10/19x86/smpboot: Teach it about topo.amd_node_idarch/x86/kernel/smpboot.c+8 -40 replies
11/19x86/cpu: Use common topology code for AMDarch/x86/include/asm/processor.h arch/x86/kernel/cpu/amd.c arch/x86/kernel/cpu/mce/inject.c +1 more+5 -1510 replies
12/19x86/cpu: Use common topology code for HYGONarch/x86/kernel/cpu/common.c arch/x86/kernel/cpu/cpu.h arch/x86/kernel/cpu/hygon.c +2 more+4 -1540 replies
13/19x86/mm/numa: Use core domain size on AMDarch/x86/include/asm/topology.h arch/x86/mm/amdtopology.c+21 -190 replies
14/19x86/cpu: Make topology_amd_node_id() use the actual node infoarch/x86/include/asm/topology.h arch/x86/kernel/cpu/topology_common.c+4 -70 replies
15/19x86/cpu: Remove topology.carch/x86/kernel/cpu/Makefile arch/x86/kernel/cpu/topology.c+1 -1430 replies
16/19x86/cpu: Remove x86_coreid_bitsarch/x86/include/asm/processor.h arch/x86/kernel/cpu/common.c+0 -30 replies
17/19x86/apic: Remove unused phys_pkg_id() callbackarch/x86/include/asm/apic.h arch/x86/kernel/apic/apic_flat_64.c arch/x86/kernel/apic/apic_noop.c +9 more+0 -680 replies
18/19x86/xen/smp_pv: Remove cpudata fiddlingarch/x86/xen/smp_pv.c+0 -30 replies
19/19x86/apic/uv: Remove the private leaf 0xb parserarch/x86/include/asm/topology.h arch/x86/kernel/apic/x2apic_uv_x.c+14 -430 replies

Reviews trailers per patch

3 of 20 patches have a Reviewed-by or Acked-by.

PatchJuergen GrossSohil MehtaMichael KelleyPeter Zijlstra (Intel)Zhang RuiWang WendyK Prateek Nayak
SeriesT-b
1/19T-b T-b T-b T-b T-b T-b T-b A-b T-b A-b T-b T-b T-b T-b
1/19T-b T-b T-b T-b T-b T-b T-b A-b T-b A-b T-b T-b T-b T-b
2/19T-b T-b T-b T-b A-b T-b T-b
3/19T-b T-b T-b T-b T-b
4/19T-b T-b T-b T-b T-b
5/19T-b T-b T-b T-b T-b
6/19T-b T-b T-b T-b T-b
7/19T-b T-b T-b T-b T-b
8/19T-b T-b T-b T-b T-b
9/19T-b T-b T-b T-b T-b
10/19T-b T-b T-b T-b T-b
11/19T-b T-b T-b T-b T-b
12/19T-b T-b T-b T-b T-b
13/19T-b T-b T-b T-b T-b
14/19T-b T-b T-b T-b T-b
15/19T-b T-b T-b T-b T-b
16/19T-b T-b T-b T-b T-b
17/19T-b T-b T-b T-b T-b
18/19T-b T-b T-b T-b T-b
19/19T-b T-b T-b T-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 7 reviewers.

Read the v6 thread

Cover letter [patch V6 00/19] x86/cpu: Rework topology evaluation

This is a follow up on V5 of this work:

https://lore.kernel.org/all/[email protected]

and contains only the not yet applied part which reworks the CPUID parsing. This is also preparatory work for the general overhaul of APIC ID enumeration and management.

Changes vs. V5:

- Fix the AMD leaf 0x8000008 parsing
- Update to generated CPUID leaf structures
- Address review comments (coding style, comments, changelogs, boot_cpu_has())

This applies on Linus tree and is available from git:

git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git topo-cpuid-v6

Delta patch to V5 appended.

Thanks,

tglx
---

arch/x86/include/asm/processor.h +0 -2
index a45346ad552b..de1648ee2b9e 100644
@@ -705,12 +705,10 @@ static inline u32 per_cpu_l2c_id(unsigned int cpu)
 }
 
 #ifdef CONFIG_CPU_SUP_AMD
-extern u32 amd_get_nodes_per_socket(void);
 extern u32 amd_get_highest_perf(void);
 extern void amd_clear_divider(void);
 extern void amd_check_microcode(void);
 #else
-static inline u32 amd_get_nodes_per_socket(void)	{ return 0; }
 static inline u32 amd_get_highest_perf(void)		{ return 0; }
 static inline void amd_clear_divider(void)		{ }
 static inline void amd_check_microcode(void)		{ }
arch/x86/kernel/cpu/topology.h +2 -2
index 0d1ebb3a56e7..2a3c838b6044 100644
@@ -7,10 +7,10 @@ struct topo_scan {
 	unsigned int		dom_shifts[TOPO_MAX_DOMAIN];
 	unsigned int		dom_ncpus[TOPO_MAX_DOMAIN];
 
-	// Legacy CPUID[1]:EBX[23:16] number of logical processors
+	/* Legacy CPUID[1]:EBX[23:16] number of logical processors */
 	unsigned int		ebx1_nproc_shift;
 
-	// AMD specific node ID which cannot be mapped into APIC space.
+	/* AMD specific node ID which cannot be mapped into APIC space. */
 	u16			amd_nodes_per_pkg;
 	u16			amd_node_id;
 };
arch/x86/kernel/cpu/topology_amd.c +25 -24

99 lines not on this page · raw message

arch/x86/kernel/cpu/topology_common.c +3 -3
index 5ff862db5a3a..afea34d59598 100644
@@ -26,7 +26,7 @@ void topology_set_dom(struct topo_scan *tscan, enum x86_topology_domains dom,
 	}
 }
 
-static unsigned int parse_num_cores(struct cpuinfo_x86 *c)
+static unsigned int __maybe_unused parse_num_cores_legacy(struct cpuinfo_x86 *c)
 {
 	struct {
 		u32	cache_type	:  5,
@@ -49,7 +49,7 @@ static void parse_legacy(struct topo_scan *tscan)
 	unsigned int cores, core_shift, smt_shift = 0;
 	struct cpuinfo_x86 *c = tscan->c;
 
-	cores = parse_num_cores(c);
+	cores = parse_num_cores_legacy(c);
 	core_shift = get_count_order(cores);
 
 	if (cpu_has(c, X86_FEATURE_HT)) {
@@ -97,7 +97,7 @@ static void parse_topology(struct topo_scan *tscan, bool early)
 	c->topo = topo_defaults;
 
 	if (fake_topology(tscan))
-	    return;
+		return;
 
 	/* Preset Initial APIC ID from CPUID leaf 1 */
 	cpuid_leaf_reg(1, CPUID_EBX, &ebx);
arch/x86/kernel/cpu/topology_ext.c +1 -1
index b9b37296d9cd..e477228cd5b2 100644
@@ -110,7 +110,7 @@ static bool parse_topology_leaf(struct topo_scan *tscan, u32 leaf)
 	if (!tscan->dom_shifts[TOPO_SMT_DOMAIN] && tscan->dom_ncpus[TOPO_SMT_DOMAIN] > 1) {
 		unsigned int sft = get_count_order(tscan->dom_ncpus[TOPO_SMT_DOMAIN]);
 
-		pr_warn_once(FW_BUG "CPUID leaf 0x%x subleaf 0 has shift level 0 but %u CPUs\n",
+		pr_warn_once(FW_BUG "CPUID leaf 0x%x subleaf 0 has shift level 0 but %u CPUs. Fixing it up.\n",
 			     leaf, tscan->dom_ncpus[TOPO_SMT_DOMAIN]);
 		topology_update_dom(tscan, TOPO_SMT_DOMAIN, sft, tscan->dom_ncpus[TOPO_SMT_DOMAIN]);
 	}
arch/x86/kernel/smpboot.c +1 -1
index 2634f8f82867..9cdb056c37b5 100644
@@ -513,7 +513,7 @@ static bool match_die(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
 	if (c->topo.pkg_id != o->topo.pkg_id || c->topo.die_id != o->topo.die_id)
 		return false;
 
-	if (boot_cpu_has(X86_FEATURE_TOPOEXT) && topology_amd_nodes_per_pkg() > 1)
+	if (cpu_feature_enabled(X86_FEATURE_TOPOEXT) && topology_amd_nodes_per_pkg() > 1)
 		return c->topo.amd_node_id == o->topo.amd_node_id;
 
 	return true;