diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-15 22:00:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-15 22:00:53 -0400 |
commit | 502f4d4f74219749a9758b9bbc27fb665b2e83ab (patch) | |
tree | 78076e71ea6e455354913005f04b53cff124553f | |
parent | da849abeb86ddaa093b0935fde595e8e4dd21ffc (diff) | |
parent | e5fea868e6c04343e501176a373d568c1c0094aa (diff) |
Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
x86: Fix and clean up generic_processor_info()
x86: Don't copy per_cpu cpuinfo for BSP two times
x86: Move llc_shared_map out of cpu_info
-rw-r--r-- | arch/x86/include/asm/processor.h | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/smp.h | 7 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic.c | 39 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/intel_cacheinfo.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mcheck/mce_amd.c | 7 | ||||
-rw-r--r-- | arch/x86/kernel/smpboot.c | 44 |
6 files changed, 44 insertions, 61 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 45636cefa186..4c25ab48257b 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -94,10 +94,6 @@ struct cpuinfo_x86 { | |||
94 | int x86_cache_alignment; /* In bytes */ | 94 | int x86_cache_alignment; /* In bytes */ |
95 | int x86_power; | 95 | int x86_power; |
96 | unsigned long loops_per_jiffy; | 96 | unsigned long loops_per_jiffy; |
97 | #ifdef CONFIG_SMP | ||
98 | /* cpus sharing the last level cache: */ | ||
99 | cpumask_var_t llc_shared_map; | ||
100 | #endif | ||
101 | /* cpuid returned max cores value: */ | 97 | /* cpuid returned max cores value: */ |
102 | u16 x86_max_cores; | 98 | u16 x86_max_cores; |
103 | u16 apicid; | 99 | u16 apicid; |
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index c1bbfa89a0e2..99fa8b47381e 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h | |||
@@ -33,6 +33,8 @@ static inline bool cpu_has_ht_siblings(void) | |||
33 | 33 | ||
34 | DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map); | 34 | DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map); |
35 | DECLARE_PER_CPU(cpumask_var_t, cpu_core_map); | 35 | DECLARE_PER_CPU(cpumask_var_t, cpu_core_map); |
36 | /* cpus sharing the last level cache: */ | ||
37 | DECLARE_PER_CPU(cpumask_var_t, cpu_llc_shared_map); | ||
36 | DECLARE_PER_CPU(u16, cpu_llc_id); | 38 | DECLARE_PER_CPU(u16, cpu_llc_id); |
37 | DECLARE_PER_CPU(int, cpu_number); | 39 | DECLARE_PER_CPU(int, cpu_number); |
38 | 40 | ||
@@ -46,6 +48,11 @@ static inline struct cpumask *cpu_core_mask(int cpu) | |||
46 | return per_cpu(cpu_core_map, cpu); | 48 | return per_cpu(cpu_core_map, cpu); |
47 | } | 49 | } |
48 | 50 | ||
51 | static inline struct cpumask *cpu_llc_shared_mask(int cpu) | ||
52 | { | ||
53 | return per_cpu(cpu_llc_shared_map, cpu); | ||
54 | } | ||
55 | |||
49 | DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); | 56 | DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); |
50 | DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); | 57 | DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); |
51 | 58 | ||
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 76b96d74978a..3606feb7d67c 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c | |||
@@ -1930,17 +1930,6 @@ void __cpuinit generic_processor_info(int apicid, int version) | |||
1930 | { | 1930 | { |
1931 | int cpu; | 1931 | int cpu; |
1932 | 1932 | ||
1933 | /* | ||
1934 | * Validate version | ||
1935 | */ | ||
1936 | if (version == 0x0) { | ||
1937 | pr_warning("BIOS bug, APIC version is 0 for CPU#%d! " | ||
1938 | "fixing up to 0x10. (tell your hw vendor)\n", | ||
1939 | version); | ||
1940 | version = 0x10; | ||
1941 | } | ||
1942 | apic_version[apicid] = version; | ||
1943 | |||
1944 | if (num_processors >= nr_cpu_ids) { | 1933 | if (num_processors >= nr_cpu_ids) { |
1945 | int max = nr_cpu_ids; | 1934 | int max = nr_cpu_ids; |
1946 | int thiscpu = max + disabled_cpus; | 1935 | int thiscpu = max + disabled_cpus; |
@@ -1954,22 +1943,34 @@ void __cpuinit generic_processor_info(int apicid, int version) | |||
1954 | } | 1943 | } |
1955 | 1944 | ||
1956 | num_processors++; | 1945 | num_processors++; |
1957 | cpu = cpumask_next_zero(-1, cpu_present_mask); | ||
1958 | |||
1959 | if (version != apic_version[boot_cpu_physical_apicid]) | ||
1960 | WARN_ONCE(1, | ||
1961 | "ACPI: apic version mismatch, bootcpu: %x cpu %d: %x\n", | ||
1962 | apic_version[boot_cpu_physical_apicid], cpu, version); | ||
1963 | |||
1964 | physid_set(apicid, phys_cpu_present_map); | ||
1965 | if (apicid == boot_cpu_physical_apicid) { | 1946 | if (apicid == boot_cpu_physical_apicid) { |
1966 | /* | 1947 | /* |
1967 | * x86_bios_cpu_apicid is required to have processors listed | 1948 | * x86_bios_cpu_apicid is required to have processors listed |
1968 | * in same order as logical cpu numbers. Hence the first | 1949 | * in same order as logical cpu numbers. Hence the first |
1969 | * entry is BSP, and so on. | 1950 | * entry is BSP, and so on. |
1951 | * boot_cpu_init() already hold bit 0 in cpu_present_mask | ||
1952 | * for BSP. | ||
1970 | */ | 1953 | */ |
1971 | cpu = 0; | 1954 | cpu = 0; |
1955 | } else | ||
1956 | cpu = cpumask_next_zero(-1, cpu_present_mask); | ||
1957 | |||
1958 | /* | ||
1959 | * Validate version | ||
1960 | */ | ||
1961 | if (version == 0x0) { | ||
1962 | pr_warning("BIOS bug: APIC version is 0 for CPU %d/0x%x, fixing up to 0x10\n", | ||
1963 | cpu, apicid); | ||
1964 | version = 0x10; | ||
1972 | } | 1965 | } |
1966 | apic_version[apicid] = version; | ||
1967 | |||
1968 | if (version != apic_version[boot_cpu_physical_apicid]) { | ||
1969 | pr_warning("BIOS bug: APIC version mismatch, boot CPU: %x, CPU %d: version %x\n", | ||
1970 | apic_version[boot_cpu_physical_apicid], cpu, version); | ||
1971 | } | ||
1972 | |||
1973 | physid_set(apicid, phys_cpu_present_map); | ||
1973 | if (apicid > max_physical_apicid) | 1974 | if (apicid > max_physical_apicid) |
1974 | max_physical_apicid = apicid; | 1975 | max_physical_apicid = apicid; |
1975 | 1976 | ||
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c index ec2c19a7b8ef..5419a263ebd1 100644 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c | |||
@@ -732,11 +732,11 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) | |||
732 | struct cpuinfo_x86 *c = &cpu_data(cpu); | 732 | struct cpuinfo_x86 *c = &cpu_data(cpu); |
733 | 733 | ||
734 | if ((index == 3) && (c->x86_vendor == X86_VENDOR_AMD)) { | 734 | if ((index == 3) && (c->x86_vendor == X86_VENDOR_AMD)) { |
735 | for_each_cpu(i, c->llc_shared_map) { | 735 | for_each_cpu(i, cpu_llc_shared_mask(cpu)) { |
736 | if (!per_cpu(ici_cpuid4_info, i)) | 736 | if (!per_cpu(ici_cpuid4_info, i)) |
737 | continue; | 737 | continue; |
738 | this_leaf = CPUID4_INFO_IDX(i, index); | 738 | this_leaf = CPUID4_INFO_IDX(i, index); |
739 | for_each_cpu(sibling, c->llc_shared_map) { | 739 | for_each_cpu(sibling, cpu_llc_shared_mask(cpu)) { |
740 | if (!cpu_online(sibling)) | 740 | if (!cpu_online(sibling)) |
741 | continue; | 741 | continue; |
742 | set_bit(sibling, this_leaf->shared_cpu_map); | 742 | set_bit(sibling, this_leaf->shared_cpu_map); |
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index 5bf2fac52aca..167f97b5596e 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c | |||
@@ -527,15 +527,12 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) | |||
527 | int i, err = 0; | 527 | int i, err = 0; |
528 | struct threshold_bank *b = NULL; | 528 | struct threshold_bank *b = NULL; |
529 | char name[32]; | 529 | char name[32]; |
530 | #ifdef CONFIG_SMP | ||
531 | struct cpuinfo_x86 *c = &cpu_data(cpu); | ||
532 | #endif | ||
533 | 530 | ||
534 | sprintf(name, "threshold_bank%i", bank); | 531 | sprintf(name, "threshold_bank%i", bank); |
535 | 532 | ||
536 | #ifdef CONFIG_SMP | 533 | #ifdef CONFIG_SMP |
537 | if (cpu_data(cpu).cpu_core_id && shared_bank[bank]) { /* symlink */ | 534 | if (cpu_data(cpu).cpu_core_id && shared_bank[bank]) { /* symlink */ |
538 | i = cpumask_first(c->llc_shared_map); | 535 | i = cpumask_first(cpu_llc_shared_mask(cpu)); |
539 | 536 | ||
540 | /* first core not up yet */ | 537 | /* first core not up yet */ |
541 | if (cpu_data(i).cpu_core_id) | 538 | if (cpu_data(i).cpu_core_id) |
@@ -555,7 +552,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) | |||
555 | if (err) | 552 | if (err) |
556 | goto out; | 553 | goto out; |
557 | 554 | ||
558 | cpumask_copy(b->cpus, c->llc_shared_map); | 555 | cpumask_copy(b->cpus, cpu_llc_shared_mask(cpu)); |
559 | per_cpu(threshold_banks, cpu)[bank] = b; | 556 | per_cpu(threshold_banks, cpu)[bank] = b; |
560 | 557 | ||
561 | goto out; | 558 | goto out; |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 08776a953487..e2865df242bc 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -130,6 +130,8 @@ EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); | |||
130 | DEFINE_PER_CPU(cpumask_var_t, cpu_core_map); | 130 | DEFINE_PER_CPU(cpumask_var_t, cpu_core_map); |
131 | EXPORT_PER_CPU_SYMBOL(cpu_core_map); | 131 | EXPORT_PER_CPU_SYMBOL(cpu_core_map); |
132 | 132 | ||
133 | DEFINE_PER_CPU(cpumask_var_t, cpu_llc_shared_map); | ||
134 | |||
133 | /* Per CPU bogomips and other parameters */ | 135 | /* Per CPU bogomips and other parameters */ |
134 | DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info); | 136 | DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info); |
135 | EXPORT_PER_CPU_SYMBOL(cpu_info); | 137 | EXPORT_PER_CPU_SYMBOL(cpu_info); |
@@ -355,23 +357,6 @@ notrace static void __cpuinit start_secondary(void *unused) | |||
355 | cpu_idle(); | 357 | cpu_idle(); |
356 | } | 358 | } |
357 | 359 | ||
358 | #ifdef CONFIG_CPUMASK_OFFSTACK | ||
359 | /* In this case, llc_shared_map is a pointer to a cpumask. */ | ||
360 | static inline void copy_cpuinfo_x86(struct cpuinfo_x86 *dst, | ||
361 | const struct cpuinfo_x86 *src) | ||
362 | { | ||
363 | struct cpumask *llc = dst->llc_shared_map; | ||
364 | *dst = *src; | ||
365 | dst->llc_shared_map = llc; | ||
366 | } | ||
367 | #else | ||
368 | static inline void copy_cpuinfo_x86(struct cpuinfo_x86 *dst, | ||
369 | const struct cpuinfo_x86 *src) | ||
370 | { | ||
371 | *dst = *src; | ||
372 | } | ||
373 | #endif /* CONFIG_CPUMASK_OFFSTACK */ | ||
374 | |||
375 | /* | 360 | /* |
376 | * The bootstrap kernel entry code has set these up. Save them for | 361 | * The bootstrap kernel entry code has set these up. Save them for |
377 | * a given CPU | 362 | * a given CPU |
@@ -381,7 +366,7 @@ void __cpuinit smp_store_cpu_info(int id) | |||
381 | { | 366 | { |
382 | struct cpuinfo_x86 *c = &cpu_data(id); | 367 | struct cpuinfo_x86 *c = &cpu_data(id); |
383 | 368 | ||
384 | copy_cpuinfo_x86(c, &boot_cpu_data); | 369 | *c = boot_cpu_data; |
385 | c->cpu_index = id; | 370 | c->cpu_index = id; |
386 | if (id != 0) | 371 | if (id != 0) |
387 | identify_secondary_cpu(c); | 372 | identify_secondary_cpu(c); |
@@ -389,15 +374,12 @@ void __cpuinit smp_store_cpu_info(int id) | |||
389 | 374 | ||
390 | static void __cpuinit link_thread_siblings(int cpu1, int cpu2) | 375 | static void __cpuinit link_thread_siblings(int cpu1, int cpu2) |
391 | { | 376 | { |
392 | struct cpuinfo_x86 *c1 = &cpu_data(cpu1); | ||
393 | struct cpuinfo_x86 *c2 = &cpu_data(cpu2); | ||
394 | |||
395 | cpumask_set_cpu(cpu1, cpu_sibling_mask(cpu2)); | 377 | cpumask_set_cpu(cpu1, cpu_sibling_mask(cpu2)); |
396 | cpumask_set_cpu(cpu2, cpu_sibling_mask(cpu1)); | 378 | cpumask_set_cpu(cpu2, cpu_sibling_mask(cpu1)); |
397 | cpumask_set_cpu(cpu1, cpu_core_mask(cpu2)); | 379 | cpumask_set_cpu(cpu1, cpu_core_mask(cpu2)); |
398 | cpumask_set_cpu(cpu2, cpu_core_mask(cpu1)); | 380 | cpumask_set_cpu(cpu2, cpu_core_mask(cpu1)); |
399 | cpumask_set_cpu(cpu1, c2->llc_shared_map); | 381 | cpumask_set_cpu(cpu1, cpu_llc_shared_mask(cpu2)); |
400 | cpumask_set_cpu(cpu2, c1->llc_shared_map); | 382 | cpumask_set_cpu(cpu2, cpu_llc_shared_mask(cpu1)); |
401 | } | 383 | } |
402 | 384 | ||
403 | 385 | ||
@@ -425,7 +407,7 @@ void __cpuinit set_cpu_sibling_map(int cpu) | |||
425 | cpumask_set_cpu(cpu, cpu_sibling_mask(cpu)); | 407 | cpumask_set_cpu(cpu, cpu_sibling_mask(cpu)); |
426 | } | 408 | } |
427 | 409 | ||
428 | cpumask_set_cpu(cpu, c->llc_shared_map); | 410 | cpumask_set_cpu(cpu, cpu_llc_shared_mask(cpu)); |
429 | 411 | ||
430 | if (__this_cpu_read(cpu_info.x86_max_cores) == 1) { | 412 | if (__this_cpu_read(cpu_info.x86_max_cores) == 1) { |
431 | cpumask_copy(cpu_core_mask(cpu), cpu_sibling_mask(cpu)); | 413 | cpumask_copy(cpu_core_mask(cpu), cpu_sibling_mask(cpu)); |
@@ -436,8 +418,8 @@ void __cpuinit set_cpu_sibling_map(int cpu) | |||
436 | for_each_cpu(i, cpu_sibling_setup_mask) { | 418 | for_each_cpu(i, cpu_sibling_setup_mask) { |
437 | if (per_cpu(cpu_llc_id, cpu) != BAD_APICID && | 419 | if (per_cpu(cpu_llc_id, cpu) != BAD_APICID && |
438 | per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) { | 420 | per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) { |
439 | cpumask_set_cpu(i, c->llc_shared_map); | 421 | cpumask_set_cpu(i, cpu_llc_shared_mask(cpu)); |
440 | cpumask_set_cpu(cpu, cpu_data(i).llc_shared_map); | 422 | cpumask_set_cpu(cpu, cpu_llc_shared_mask(i)); |
441 | } | 423 | } |
442 | if (c->phys_proc_id == cpu_data(i).phys_proc_id) { | 424 | if (c->phys_proc_id == cpu_data(i).phys_proc_id) { |
443 | cpumask_set_cpu(i, cpu_core_mask(cpu)); | 425 | cpumask_set_cpu(i, cpu_core_mask(cpu)); |
@@ -476,7 +458,7 @@ const struct cpumask *cpu_coregroup_mask(int cpu) | |||
476 | !(cpu_has(c, X86_FEATURE_AMD_DCM))) | 458 | !(cpu_has(c, X86_FEATURE_AMD_DCM))) |
477 | return cpu_core_mask(cpu); | 459 | return cpu_core_mask(cpu); |
478 | else | 460 | else |
479 | return c->llc_shared_map; | 461 | return cpu_llc_shared_mask(cpu); |
480 | } | 462 | } |
481 | 463 | ||
482 | static void impress_friends(void) | 464 | static void impress_friends(void) |
@@ -1089,13 +1071,13 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) | |||
1089 | 1071 | ||
1090 | preempt_disable(); | 1072 | preempt_disable(); |
1091 | smp_cpu_index_default(); | 1073 | smp_cpu_index_default(); |
1092 | memcpy(__this_cpu_ptr(&cpu_info), &boot_cpu_data, sizeof(cpu_info)); | 1074 | |
1093 | cpumask_copy(cpu_callin_mask, cpumask_of(0)); | ||
1094 | mb(); | ||
1095 | /* | 1075 | /* |
1096 | * Setup boot CPU information | 1076 | * Setup boot CPU information |
1097 | */ | 1077 | */ |
1098 | smp_store_cpu_info(0); /* Final full version of the data */ | 1078 | smp_store_cpu_info(0); /* Final full version of the data */ |
1079 | cpumask_copy(cpu_callin_mask, cpumask_of(0)); | ||
1080 | mb(); | ||
1099 | #ifdef CONFIG_X86_32 | 1081 | #ifdef CONFIG_X86_32 |
1100 | boot_cpu_logical_apicid = logical_smp_processor_id(); | 1082 | boot_cpu_logical_apicid = logical_smp_processor_id(); |
1101 | #endif | 1083 | #endif |
@@ -1103,7 +1085,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) | |||
1103 | for_each_possible_cpu(i) { | 1085 | for_each_possible_cpu(i) { |
1104 | zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL); | 1086 | zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL); |
1105 | zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL); | 1087 | zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL); |
1106 | zalloc_cpumask_var(&cpu_data(i).llc_shared_map, GFP_KERNEL); | 1088 | zalloc_cpumask_var(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL); |
1107 | } | 1089 | } |
1108 | set_cpu_sibling_map(0); | 1090 | set_cpu_sibling_map(0); |
1109 | 1091 | ||