diff options
Diffstat (limited to 'arch/i386')
-rw-r--r-- | arch/i386/kernel/cpu/amd.c | 12 | ||||
-rw-r--r-- | arch/i386/kernel/cpu/common.c | 36 | ||||
-rw-r--r-- | arch/i386/kernel/cpu/intel.c | 2 | ||||
-rw-r--r-- | arch/i386/kernel/cpu/intel_cacheinfo.c | 2 | ||||
-rw-r--r-- | arch/i386/kernel/cpu/proc.c | 7 | ||||
-rw-r--r-- | arch/i386/kernel/smpboot.c | 73 |
6 files changed, 78 insertions, 54 deletions
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c index 53a1681cd964..e344ef88cfcd 100644 --- a/arch/i386/kernel/cpu/amd.c +++ b/arch/i386/kernel/cpu/amd.c | |||
@@ -206,9 +206,9 @@ static void __init init_amd(struct cpuinfo_x86 *c) | |||
206 | display_cacheinfo(c); | 206 | display_cacheinfo(c); |
207 | 207 | ||
208 | if (cpuid_eax(0x80000000) >= 0x80000008) { | 208 | if (cpuid_eax(0x80000000) >= 0x80000008) { |
209 | c->x86_num_cores = (cpuid_ecx(0x80000008) & 0xff) + 1; | 209 | c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1; |
210 | if (c->x86_num_cores & (c->x86_num_cores - 1)) | 210 | if (c->x86_max_cores & (c->x86_max_cores - 1)) |
211 | c->x86_num_cores = 1; | 211 | c->x86_max_cores = 1; |
212 | } | 212 | } |
213 | 213 | ||
214 | #ifdef CONFIG_X86_HT | 214 | #ifdef CONFIG_X86_HT |
@@ -217,15 +217,15 @@ static void __init init_amd(struct cpuinfo_x86 *c) | |||
217 | * distingush the cores. Assumes number of cores is a power | 217 | * distingush the cores. Assumes number of cores is a power |
218 | * of two. | 218 | * of two. |
219 | */ | 219 | */ |
220 | if (c->x86_num_cores > 1) { | 220 | if (c->x86_max_cores > 1) { |
221 | int cpu = smp_processor_id(); | 221 | int cpu = smp_processor_id(); |
222 | unsigned bits = 0; | 222 | unsigned bits = 0; |
223 | while ((1 << bits) < c->x86_num_cores) | 223 | while ((1 << bits) < c->x86_max_cores) |
224 | bits++; | 224 | bits++; |
225 | cpu_core_id[cpu] = phys_proc_id[cpu] & ((1<<bits)-1); | 225 | cpu_core_id[cpu] = phys_proc_id[cpu] & ((1<<bits)-1); |
226 | phys_proc_id[cpu] >>= bits; | 226 | phys_proc_id[cpu] >>= bits; |
227 | printk(KERN_INFO "CPU %d(%d) -> Core %d\n", | 227 | printk(KERN_INFO "CPU %d(%d) -> Core %d\n", |
228 | cpu, c->x86_num_cores, cpu_core_id[cpu]); | 228 | cpu, c->x86_max_cores, cpu_core_id[cpu]); |
229 | } | 229 | } |
230 | #endif | 230 | #endif |
231 | } | 231 | } |
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c index 35a67dab4a94..4e9c2e99b0a5 100644 --- a/arch/i386/kernel/cpu/common.c +++ b/arch/i386/kernel/cpu/common.c | |||
@@ -335,7 +335,7 @@ void __devinit identify_cpu(struct cpuinfo_x86 *c) | |||
335 | c->x86_model = c->x86_mask = 0; /* So far unknown... */ | 335 | c->x86_model = c->x86_mask = 0; /* So far unknown... */ |
336 | c->x86_vendor_id[0] = '\0'; /* Unset */ | 336 | c->x86_vendor_id[0] = '\0'; /* Unset */ |
337 | c->x86_model_id[0] = '\0'; /* Unset */ | 337 | c->x86_model_id[0] = '\0'; /* Unset */ |
338 | c->x86_num_cores = 1; | 338 | c->x86_max_cores = 1; |
339 | memset(&c->x86_capability, 0, sizeof c->x86_capability); | 339 | memset(&c->x86_capability, 0, sizeof c->x86_capability); |
340 | 340 | ||
341 | if (!have_cpuid_p()) { | 341 | if (!have_cpuid_p()) { |
@@ -446,52 +446,44 @@ void __devinit identify_cpu(struct cpuinfo_x86 *c) | |||
446 | void __devinit detect_ht(struct cpuinfo_x86 *c) | 446 | void __devinit detect_ht(struct cpuinfo_x86 *c) |
447 | { | 447 | { |
448 | u32 eax, ebx, ecx, edx; | 448 | u32 eax, ebx, ecx, edx; |
449 | int index_msb, tmp; | 449 | int index_msb, core_bits; |
450 | int cpu = smp_processor_id(); | 450 | int cpu = smp_processor_id(); |
451 | 451 | ||
452 | cpuid(1, &eax, &ebx, &ecx, &edx); | ||
453 | |||
454 | c->apicid = phys_pkg_id((ebx >> 24) & 0xFF, 0); | ||
455 | |||
452 | if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY)) | 456 | if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY)) |
453 | return; | 457 | return; |
454 | 458 | ||
455 | cpuid(1, &eax, &ebx, &ecx, &edx); | ||
456 | smp_num_siblings = (ebx & 0xff0000) >> 16; | 459 | smp_num_siblings = (ebx & 0xff0000) >> 16; |
457 | 460 | ||
458 | if (smp_num_siblings == 1) { | 461 | if (smp_num_siblings == 1) { |
459 | printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); | 462 | printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); |
460 | } else if (smp_num_siblings > 1 ) { | 463 | } else if (smp_num_siblings > 1 ) { |
461 | index_msb = 31; | ||
462 | 464 | ||
463 | if (smp_num_siblings > NR_CPUS) { | 465 | if (smp_num_siblings > NR_CPUS) { |
464 | printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings); | 466 | printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings); |
465 | smp_num_siblings = 1; | 467 | smp_num_siblings = 1; |
466 | return; | 468 | return; |
467 | } | 469 | } |
468 | tmp = smp_num_siblings; | 470 | |
469 | while ((tmp & 0x80000000 ) == 0) { | 471 | index_msb = get_count_order(smp_num_siblings); |
470 | tmp <<=1 ; | ||
471 | index_msb--; | ||
472 | } | ||
473 | if (smp_num_siblings & (smp_num_siblings - 1)) | ||
474 | index_msb++; | ||
475 | phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb); | 472 | phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb); |
476 | 473 | ||
477 | printk(KERN_INFO "CPU: Physical Processor ID: %d\n", | 474 | printk(KERN_INFO "CPU: Physical Processor ID: %d\n", |
478 | phys_proc_id[cpu]); | 475 | phys_proc_id[cpu]); |
479 | 476 | ||
480 | smp_num_siblings = smp_num_siblings / c->x86_num_cores; | 477 | smp_num_siblings = smp_num_siblings / c->x86_max_cores; |
481 | 478 | ||
482 | tmp = smp_num_siblings; | 479 | index_msb = get_count_order(smp_num_siblings) ; |
483 | index_msb = 31; | ||
484 | while ((tmp & 0x80000000) == 0) { | ||
485 | tmp <<=1 ; | ||
486 | index_msb--; | ||
487 | } | ||
488 | 480 | ||
489 | if (smp_num_siblings & (smp_num_siblings - 1)) | 481 | core_bits = get_count_order(c->x86_max_cores); |
490 | index_msb++; | ||
491 | 482 | ||
492 | cpu_core_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb); | 483 | cpu_core_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb) & |
484 | ((1 << core_bits) - 1); | ||
493 | 485 | ||
494 | if (c->x86_num_cores > 1) | 486 | if (c->x86_max_cores > 1) |
495 | printk(KERN_INFO "CPU: Processor Core ID: %d\n", | 487 | printk(KERN_INFO "CPU: Processor Core ID: %d\n", |
496 | cpu_core_id[cpu]); | 488 | cpu_core_id[cpu]); |
497 | } | 489 | } |
diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c index 43601de0f633..8d603ba28126 100644 --- a/arch/i386/kernel/cpu/intel.c +++ b/arch/i386/kernel/cpu/intel.c | |||
@@ -157,7 +157,7 @@ static void __devinit init_intel(struct cpuinfo_x86 *c) | |||
157 | if ( p ) | 157 | if ( p ) |
158 | strcpy(c->x86_model_id, p); | 158 | strcpy(c->x86_model_id, p); |
159 | 159 | ||
160 | c->x86_num_cores = num_cpu_cores(c); | 160 | c->x86_max_cores = num_cpu_cores(c); |
161 | 161 | ||
162 | detect_ht(c); | 162 | detect_ht(c); |
163 | 163 | ||
diff --git a/arch/i386/kernel/cpu/intel_cacheinfo.c b/arch/i386/kernel/cpu/intel_cacheinfo.c index 4dc42a189ae5..e66d14099564 100644 --- a/arch/i386/kernel/cpu/intel_cacheinfo.c +++ b/arch/i386/kernel/cpu/intel_cacheinfo.c | |||
@@ -307,7 +307,7 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) | |||
307 | #ifdef CONFIG_X86_HT | 307 | #ifdef CONFIG_X86_HT |
308 | else if (num_threads_sharing == smp_num_siblings) | 308 | else if (num_threads_sharing == smp_num_siblings) |
309 | this_leaf->shared_cpu_map = cpu_sibling_map[cpu]; | 309 | this_leaf->shared_cpu_map = cpu_sibling_map[cpu]; |
310 | else if (num_threads_sharing == (c->x86_num_cores * smp_num_siblings)) | 310 | else if (num_threads_sharing == (c->x86_max_cores * smp_num_siblings)) |
311 | this_leaf->shared_cpu_map = cpu_core_map[cpu]; | 311 | this_leaf->shared_cpu_map = cpu_core_map[cpu]; |
312 | else | 312 | else |
313 | printk(KERN_DEBUG "Number of CPUs sharing cache didn't match " | 313 | printk(KERN_DEBUG "Number of CPUs sharing cache didn't match " |
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c index 41b871ecf4b3..e7921315ae9d 100644 --- a/arch/i386/kernel/cpu/proc.c +++ b/arch/i386/kernel/cpu/proc.c | |||
@@ -94,12 +94,11 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
94 | if (c->x86_cache_size >= 0) | 94 | if (c->x86_cache_size >= 0) |
95 | seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); | 95 | seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); |
96 | #ifdef CONFIG_X86_HT | 96 | #ifdef CONFIG_X86_HT |
97 | if (c->x86_num_cores * smp_num_siblings > 1) { | 97 | if (c->x86_max_cores * smp_num_siblings > 1) { |
98 | seq_printf(m, "physical id\t: %d\n", phys_proc_id[n]); | 98 | seq_printf(m, "physical id\t: %d\n", phys_proc_id[n]); |
99 | seq_printf(m, "siblings\t: %d\n", | 99 | seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n])); |
100 | c->x86_num_cores * smp_num_siblings); | ||
101 | seq_printf(m, "core id\t\t: %d\n", cpu_core_id[n]); | 100 | seq_printf(m, "core id\t\t: %d\n", cpu_core_id[n]); |
102 | seq_printf(m, "cpu cores\t: %d\n", c->x86_num_cores); | 101 | seq_printf(m, "cpu cores\t: %d\n", c->booted_cores); |
103 | } | 102 | } |
104 | #endif | 103 | #endif |
105 | 104 | ||
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c index 01b618e73ecd..0a9c64655236 100644 --- a/arch/i386/kernel/smpboot.c +++ b/arch/i386/kernel/smpboot.c | |||
@@ -74,9 +74,11 @@ EXPORT_SYMBOL(phys_proc_id); | |||
74 | int cpu_core_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID}; | 74 | int cpu_core_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID}; |
75 | EXPORT_SYMBOL(cpu_core_id); | 75 | EXPORT_SYMBOL(cpu_core_id); |
76 | 76 | ||
77 | /* representing HT siblings of each logical CPU */ | ||
77 | cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly; | 78 | cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly; |
78 | EXPORT_SYMBOL(cpu_sibling_map); | 79 | EXPORT_SYMBOL(cpu_sibling_map); |
79 | 80 | ||
81 | /* representing HT and core siblings of each logical CPU */ | ||
80 | cpumask_t cpu_core_map[NR_CPUS] __read_mostly; | 82 | cpumask_t cpu_core_map[NR_CPUS] __read_mostly; |
81 | EXPORT_SYMBOL(cpu_core_map); | 83 | EXPORT_SYMBOL(cpu_core_map); |
82 | 84 | ||
@@ -444,35 +446,60 @@ static void __devinit smp_callin(void) | |||
444 | 446 | ||
445 | static int cpucount; | 447 | static int cpucount; |
446 | 448 | ||
449 | /* representing cpus for which sibling maps can be computed */ | ||
450 | static cpumask_t cpu_sibling_setup_map; | ||
451 | |||
447 | static inline void | 452 | static inline void |
448 | set_cpu_sibling_map(int cpu) | 453 | set_cpu_sibling_map(int cpu) |
449 | { | 454 | { |
450 | int i; | 455 | int i; |
456 | struct cpuinfo_x86 *c = cpu_data; | ||
457 | |||
458 | cpu_set(cpu, cpu_sibling_setup_map); | ||
451 | 459 | ||
452 | if (smp_num_siblings > 1) { | 460 | if (smp_num_siblings > 1) { |
453 | for (i = 0; i < NR_CPUS; i++) { | 461 | for_each_cpu_mask(i, cpu_sibling_setup_map) { |
454 | if (!cpu_isset(i, cpu_callout_map)) | 462 | if (phys_proc_id[cpu] == phys_proc_id[i] && |
455 | continue; | 463 | cpu_core_id[cpu] == cpu_core_id[i]) { |
456 | if (cpu_core_id[cpu] == cpu_core_id[i]) { | ||
457 | cpu_set(i, cpu_sibling_map[cpu]); | 464 | cpu_set(i, cpu_sibling_map[cpu]); |
458 | cpu_set(cpu, cpu_sibling_map[i]); | 465 | cpu_set(cpu, cpu_sibling_map[i]); |
466 | cpu_set(i, cpu_core_map[cpu]); | ||
467 | cpu_set(cpu, cpu_core_map[i]); | ||
459 | } | 468 | } |
460 | } | 469 | } |
461 | } else { | 470 | } else { |
462 | cpu_set(cpu, cpu_sibling_map[cpu]); | 471 | cpu_set(cpu, cpu_sibling_map[cpu]); |
463 | } | 472 | } |
464 | 473 | ||
465 | if (current_cpu_data.x86_num_cores > 1) { | 474 | if (current_cpu_data.x86_max_cores == 1) { |
466 | for (i = 0; i < NR_CPUS; i++) { | ||
467 | if (!cpu_isset(i, cpu_callout_map)) | ||
468 | continue; | ||
469 | if (phys_proc_id[cpu] == phys_proc_id[i]) { | ||
470 | cpu_set(i, cpu_core_map[cpu]); | ||
471 | cpu_set(cpu, cpu_core_map[i]); | ||
472 | } | ||
473 | } | ||
474 | } else { | ||
475 | cpu_core_map[cpu] = cpu_sibling_map[cpu]; | 475 | cpu_core_map[cpu] = cpu_sibling_map[cpu]; |
476 | c[cpu].booted_cores = 1; | ||
477 | return; | ||
478 | } | ||
479 | |||
480 | for_each_cpu_mask(i, cpu_sibling_setup_map) { | ||
481 | if (phys_proc_id[cpu] == phys_proc_id[i]) { | ||
482 | cpu_set(i, cpu_core_map[cpu]); | ||
483 | cpu_set(cpu, cpu_core_map[i]); | ||
484 | /* | ||
485 | * Does this new cpu bringup a new core? | ||
486 | */ | ||
487 | if (cpus_weight(cpu_sibling_map[cpu]) == 1) { | ||
488 | /* | ||
489 | * for each core in package, increment | ||
490 | * the booted_cores for this new cpu | ||
491 | */ | ||
492 | if (first_cpu(cpu_sibling_map[i]) == i) | ||
493 | c[cpu].booted_cores++; | ||
494 | /* | ||
495 | * increment the core count for all | ||
496 | * the other cpus in this package | ||
497 | */ | ||
498 | if (i != cpu) | ||
499 | c[i].booted_cores++; | ||
500 | } else if (i != cpu && !c[cpu].booted_cores) | ||
501 | c[cpu].booted_cores = c[i].booted_cores; | ||
502 | } | ||
476 | } | 503 | } |
477 | } | 504 | } |
478 | 505 | ||
@@ -1096,11 +1123,8 @@ static void __init smp_boot_cpus(unsigned int max_cpus) | |||
1096 | 1123 | ||
1097 | current_thread_info()->cpu = 0; | 1124 | current_thread_info()->cpu = 0; |
1098 | smp_tune_scheduling(); | 1125 | smp_tune_scheduling(); |
1099 | cpus_clear(cpu_sibling_map[0]); | ||
1100 | cpu_set(0, cpu_sibling_map[0]); | ||
1101 | 1126 | ||
1102 | cpus_clear(cpu_core_map[0]); | 1127 | set_cpu_sibling_map(0); |
1103 | cpu_set(0, cpu_core_map[0]); | ||
1104 | 1128 | ||
1105 | /* | 1129 | /* |
1106 | * If we couldn't find an SMP configuration at boot time, | 1130 | * If we couldn't find an SMP configuration at boot time, |
@@ -1279,15 +1303,24 @@ static void | |||
1279 | remove_siblinginfo(int cpu) | 1303 | remove_siblinginfo(int cpu) |
1280 | { | 1304 | { |
1281 | int sibling; | 1305 | int sibling; |
1306 | struct cpuinfo_x86 *c = cpu_data; | ||
1282 | 1307 | ||
1308 | for_each_cpu_mask(sibling, cpu_core_map[cpu]) { | ||
1309 | cpu_clear(cpu, cpu_core_map[sibling]); | ||
1310 | /* | ||
1311 | * last thread sibling in this cpu core going down | ||
1312 | */ | ||
1313 | if (cpus_weight(cpu_sibling_map[cpu]) == 1) | ||
1314 | c[sibling].booted_cores--; | ||
1315 | } | ||
1316 | |||
1283 | for_each_cpu_mask(sibling, cpu_sibling_map[cpu]) | 1317 | for_each_cpu_mask(sibling, cpu_sibling_map[cpu]) |
1284 | cpu_clear(cpu, cpu_sibling_map[sibling]); | 1318 | cpu_clear(cpu, cpu_sibling_map[sibling]); |
1285 | for_each_cpu_mask(sibling, cpu_core_map[cpu]) | ||
1286 | cpu_clear(cpu, cpu_core_map[sibling]); | ||
1287 | cpus_clear(cpu_sibling_map[cpu]); | 1319 | cpus_clear(cpu_sibling_map[cpu]); |
1288 | cpus_clear(cpu_core_map[cpu]); | 1320 | cpus_clear(cpu_core_map[cpu]); |
1289 | phys_proc_id[cpu] = BAD_APICID; | 1321 | phys_proc_id[cpu] = BAD_APICID; |
1290 | cpu_core_id[cpu] = BAD_APICID; | 1322 | cpu_core_id[cpu] = BAD_APICID; |
1323 | cpu_clear(cpu, cpu_sibling_setup_map); | ||
1291 | } | 1324 | } |
1292 | 1325 | ||
1293 | int __cpu_disable(void) | 1326 | int __cpu_disable(void) |