Skip to content

Commit 95f3d39

Browse files
committed
x86/cpu/topology: Provide detect_extended_topology_early()
To support force disabling of SMT it's required to know the number of thread siblings early. detect_extended_topology() cannot be called before the APIC driver is selected, so split out the part which initializes smp_num_siblings. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Acked-by: Ingo Molnar <[email protected]>
1 parent 545401f commit 95f3d39

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

arch/x86/kernel/cpu/cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ extern void init_intel_cacheinfo(struct cpuinfo_x86 *c);
5555
extern void init_amd_cacheinfo(struct cpuinfo_x86 *c);
5656

5757
extern void detect_num_cpu_cores(struct cpuinfo_x86 *c);
58+
extern int detect_extended_topology_early(struct cpuinfo_x86 *c);
5859
extern int detect_extended_topology(struct cpuinfo_x86 *c);
5960
extern int detect_ht_early(struct cpuinfo_x86 *c);
6061
extern void detect_ht(struct cpuinfo_x86 *c);

arch/x86/kernel/cpu/topology.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,10 @@
2222
#define BITS_SHIFT_NEXT_LEVEL(eax) ((eax) & 0x1f)
2323
#define LEVEL_MAX_SIBLINGS(ebx) ((ebx) & 0xffff)
2424

25-
/*
26-
* Check for extended topology enumeration cpuid leaf 0xb and if it
27-
* exists, use it for populating initial_apicid and cpu topology
28-
* detection.
29-
*/
30-
int detect_extended_topology(struct cpuinfo_x86 *c)
25+
int detect_extended_topology_early(struct cpuinfo_x86 *c)
3126
{
3227
#ifdef CONFIG_SMP
33-
unsigned int eax, ebx, ecx, edx, sub_index;
34-
unsigned int ht_mask_width, core_plus_mask_width;
35-
unsigned int core_select_mask, core_level_siblings;
28+
unsigned int eax, ebx, ecx, edx;
3629

3730
if (c->cpuid_level < 0xb)
3831
return -1;
@@ -51,10 +44,30 @@ int detect_extended_topology(struct cpuinfo_x86 *c)
5144
* initial apic id, which also represents 32-bit extended x2apic id.
5245
*/
5346
c->initial_apicid = edx;
47+
smp_num_siblings = LEVEL_MAX_SIBLINGS(ebx);
48+
#endif
49+
return 0;
50+
}
51+
52+
/*
53+
* Check for extended topology enumeration cpuid leaf 0xb and if it
54+
* exists, use it for populating initial_apicid and cpu topology
55+
* detection.
56+
*/
57+
int detect_extended_topology(struct cpuinfo_x86 *c)
58+
{
59+
#ifdef CONFIG_SMP
60+
unsigned int eax, ebx, ecx, edx, sub_index;
61+
unsigned int ht_mask_width, core_plus_mask_width;
62+
unsigned int core_select_mask, core_level_siblings;
63+
64+
if (detect_extended_topology_early(c) < 0)
65+
return -1;
5466

5567
/*
5668
* Populate HT related information from sub-leaf level 0.
5769
*/
70+
cpuid_count(0xb, SMT_LEVEL, &eax, &ebx, &ecx, &edx);
5871
core_level_siblings = smp_num_siblings = LEVEL_MAX_SIBLINGS(ebx);
5972
core_plus_mask_width = ht_mask_width = BITS_SHIFT_NEXT_LEVEL(eax);
6073

0 commit comments

Comments
 (0)