aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlauber Costa <gcosta@redhat.com>2008-03-03 12:12:42 -0500
committerIngo Molnar <mingo@elte.hu>2008-04-17 11:40:53 -0400
commit68a1c3f8cd893f5c3c1396fec5be7d8acac4fc93 (patch)
tree9e68b2943f67912535b649a45a659ee1fc076aa2
parent7b1292e2371e3ae2ac69fbb899d539ddc7b53a27 (diff)
x86: move prefill_possible_map to common file
this patches moves prefill_possible_map() to smpboot.c Right now it is x86_64-specific, but nothing intrinsically prevents it to be used by i386 Signed-off-by: Glauber Costa <gcosta@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/Makefile2
-rw-r--r--arch/x86/kernel/smpboot.c53
-rw-r--r--arch/x86/kernel/smpboot_64.c51
-rw-r--r--include/asm-x86/smp.h1
-rw-r--r--include/asm-x86/smp_64.h1
5 files changed, 55 insertions, 53 deletions
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index df10327182d4..4c68bfc6df1d 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -46,7 +46,7 @@ obj-$(CONFIG_MICROCODE) += microcode.o
46obj-$(CONFIG_PCI) += early-quirks.o 46obj-$(CONFIG_PCI) += early-quirks.o
47apm-y := apm_32.o 47apm-y := apm_32.o
48obj-$(CONFIG_APM) += apm.o 48obj-$(CONFIG_APM) += apm.o
49obj-$(CONFIG_X86_SMP) += smp_$(BITS).o smpboot_$(BITS).o tsc_sync.o 49obj-$(CONFIG_X86_SMP) += smp_$(BITS).o smpboot_$(BITS).o smpboot.o tsc_sync.o
50obj-$(CONFIG_X86_32_SMP) += smpcommon_32.o 50obj-$(CONFIG_X86_32_SMP) += smpcommon_32.o
51obj-$(CONFIG_X86_64_SMP) += smp_64.o smpboot_64.o tsc_sync.o 51obj-$(CONFIG_X86_64_SMP) += smp_64.o smpboot_64.o tsc_sync.o
52obj-$(CONFIG_X86_TRAMPOLINE) += trampoline_$(BITS).o 52obj-$(CONFIG_X86_TRAMPOLINE) += trampoline_$(BITS).o
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
new file mode 100644
index 000000000000..bffe10861390
--- /dev/null
+++ b/arch/x86/kernel/smpboot.c
@@ -0,0 +1,53 @@
1#include <linux/init.h>
2#include <linux/smp.h>
3
4#ifdef CONFIG_HOTPLUG_CPU
5
6int additional_cpus __initdata = -1;
7
8static __init int setup_additional_cpus(char *s)
9{
10 return s && get_option(&s, &additional_cpus) ? 0 : -EINVAL;
11}
12early_param("additional_cpus", setup_additional_cpus);
13
14/*
15 * cpu_possible_map should be static, it cannot change as cpu's
16 * are onlined, or offlined. The reason is per-cpu data-structures
17 * are allocated by some modules at init time, and dont expect to
18 * do this dynamically on cpu arrival/departure.
19 * cpu_present_map on the other hand can change dynamically.
20 * In case when cpu_hotplug is not compiled, then we resort to current
21 * behaviour, which is cpu_possible == cpu_present.
22 * - Ashok Raj
23 *
24 * Three ways to find out the number of additional hotplug CPUs:
25 * - If the BIOS specified disabled CPUs in ACPI/mptables use that.
26 * - The user can overwrite it with additional_cpus=NUM
27 * - Otherwise don't reserve additional CPUs.
28 * We do this because additional CPUs waste a lot of memory.
29 * -AK
30 */
31__init void prefill_possible_map(void)
32{
33 int i;
34 int possible;
35
36 if (additional_cpus == -1) {
37 if (disabled_cpus > 0)
38 additional_cpus = disabled_cpus;
39 else
40 additional_cpus = 0;
41 }
42 possible = num_processors + additional_cpus;
43 if (possible > NR_CPUS)
44 possible = NR_CPUS;
45
46 printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n",
47 possible, max_t(int, possible - num_processors, 0));
48
49 for (i = 0; i < possible; i++)
50 cpu_set(i, cpu_possible_map);
51}
52#endif
53
diff --git a/arch/x86/kernel/smpboot_64.c b/arch/x86/kernel/smpboot_64.c
index fd0d3a93b995..953b0ff72b65 100644
--- a/arch/x86/kernel/smpboot_64.c
+++ b/arch/x86/kernel/smpboot_64.c
@@ -749,51 +749,6 @@ static __init void disable_smp(void)
749 cpu_set(0, per_cpu(cpu_core_map, 0)); 749 cpu_set(0, per_cpu(cpu_core_map, 0));
750} 750}
751 751
752#ifdef CONFIG_HOTPLUG_CPU
753
754int additional_cpus __initdata = -1;
755
756/*
757 * cpu_possible_map should be static, it cannot change as cpu's
758 * are onlined, or offlined. The reason is per-cpu data-structures
759 * are allocated by some modules at init time, and dont expect to
760 * do this dynamically on cpu arrival/departure.
761 * cpu_present_map on the other hand can change dynamically.
762 * In case when cpu_hotplug is not compiled, then we resort to current
763 * behaviour, which is cpu_possible == cpu_present.
764 * - Ashok Raj
765 *
766 * Three ways to find out the number of additional hotplug CPUs:
767 * - If the BIOS specified disabled CPUs in ACPI/mptables use that.
768 * - The user can overwrite it with additional_cpus=NUM
769 * - Otherwise don't reserve additional CPUs.
770 * We do this because additional CPUs waste a lot of memory.
771 * -AK
772 */
773__init void prefill_possible_map(void)
774{
775 int i;
776 int possible;
777
778 if (additional_cpus == -1) {
779 if (disabled_cpus > 0)
780 additional_cpus = disabled_cpus;
781 else
782 additional_cpus = 0;
783 }
784 possible = num_processors + additional_cpus;
785 if (possible > NR_CPUS)
786 possible = NR_CPUS;
787
788 printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n",
789 possible,
790 max_t(int, possible - num_processors, 0));
791
792 for (i = 0; i < possible; i++)
793 cpu_set(i, cpu_possible_map);
794}
795#endif
796
797/* 752/*
798 * Various sanity checks. 753 * Various sanity checks.
799 */ 754 */
@@ -1087,12 +1042,6 @@ void __cpu_die(unsigned int cpu)
1087 printk(KERN_ERR "CPU %u didn't die...\n", cpu); 1042 printk(KERN_ERR "CPU %u didn't die...\n", cpu);
1088} 1043}
1089 1044
1090static __init int setup_additional_cpus(char *s)
1091{
1092 return s && get_option(&s, &additional_cpus) ? 0 : -EINVAL;
1093}
1094early_param("additional_cpus", setup_additional_cpus);
1095
1096#else /* ... !CONFIG_HOTPLUG_CPU */ 1045#else /* ... !CONFIG_HOTPLUG_CPU */
1097 1046
1098int __cpu_disable(void) 1047int __cpu_disable(void)
diff --git a/include/asm-x86/smp.h b/include/asm-x86/smp.h
index be8a511fdb1d..28cb1f8bb47e 100644
--- a/include/asm-x86/smp.h
+++ b/include/asm-x86/smp.h
@@ -63,6 +63,7 @@ void native_smp_cpus_done(unsigned int max_cpus);
63int native_cpu_up(unsigned int cpunum); 63int native_cpu_up(unsigned int cpunum);
64 64
65extern unsigned disabled_cpus; 65extern unsigned disabled_cpus;
66extern void prefill_possible_map(void);
66#endif 67#endif
67 68
68#ifdef CONFIG_X86_32 69#ifdef CONFIG_X86_32
diff --git a/include/asm-x86/smp_64.h b/include/asm-x86/smp_64.h
index c7a00caa6ec6..e5bc1be70827 100644
--- a/include/asm-x86/smp_64.h
+++ b/include/asm-x86/smp_64.h
@@ -43,7 +43,6 @@ static inline int cpu_present_to_apicid(int mps_cpu)
43 43
44extern int __cpu_disable(void); 44extern int __cpu_disable(void);
45extern void __cpu_die(unsigned int cpu); 45extern void __cpu_die(unsigned int cpu);
46extern void prefill_possible_map(void);
47 46
48#define raw_smp_processor_id() read_pda(cpunumber) 47#define raw_smp_processor_id() read_pda(cpunumber)
49#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) 48#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)