diff options
author | Yinghai Lu <yinghai@kernel.org> | 2011-01-21 18:29:44 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-01-26 02:44:49 -0500 |
commit | b3d7336db553d318e7ec042eb50a70d307013339 (patch) | |
tree | 217f1b64c5624c20acc8db9cb77e1d34b8891ac5 | |
parent | 6663050edd9c2e8b1e1f55c09459144d84c045f0 (diff) |
x86: Move llc_shared_map out of cpu_info
cpu_info is already with per_cpu, We can take llc_shared_map out
of cpu_info, and declare it as per_cpu variable directly.
So later referencing could be simple and directly instead of
diving to find cpu_info at first.
Also could make smp_store_cpu_info() much simple to avoid to do
save and restore trick.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Hans Rosenfeld <hans.rosenfeld@amd.com>
Cc: Alok N Kataria <akataria@vmware.com>
Cc: Stephen Hemminger <shemminger@vyatta.com>
Cc: Hans J. Koch <hjk@linutronix.de>
Cc: Tejun Heo <tj@kernel.org>
Cc: Borislav Petkov <borislav.petkov@amd.com>
Cc: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: Robert Richter <robert.richter@amd.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
LKML-Reference: <4D3A16E8.5020608@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-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/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 | 38 |
5 files changed, 21 insertions, 39 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 4c2f63c7fc1b..3597825a3112 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h | |||
@@ -23,6 +23,8 @@ extern unsigned int num_processors; | |||
23 | 23 | ||
24 | DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map); | 24 | DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map); |
25 | DECLARE_PER_CPU(cpumask_var_t, cpu_core_map); | 25 | DECLARE_PER_CPU(cpumask_var_t, cpu_core_map); |
26 | /* cpus sharing the last level cache: */ | ||
27 | DECLARE_PER_CPU(cpumask_var_t, cpu_llc_shared_map); | ||
26 | DECLARE_PER_CPU(u16, cpu_llc_id); | 28 | DECLARE_PER_CPU(u16, cpu_llc_id); |
27 | DECLARE_PER_CPU(int, cpu_number); | 29 | DECLARE_PER_CPU(int, cpu_number); |
28 | 30 | ||
@@ -36,6 +38,11 @@ static inline struct cpumask *cpu_core_mask(int cpu) | |||
36 | return per_cpu(cpu_core_map, cpu); | 38 | return per_cpu(cpu_core_map, cpu); |
37 | } | 39 | } |
38 | 40 | ||
41 | static inline struct cpumask *cpu_llc_shared_mask(int cpu) | ||
42 | { | ||
43 | return per_cpu(cpu_llc_shared_map, cpu); | ||
44 | } | ||
45 | |||
39 | DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); | 46 | DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); |
40 | DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); | 47 | DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); |
41 | 48 | ||
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 0cbe8c0b35ed..d396155f436c 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) |
@@ -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 | ||