diff options
author | Amerigo Wang <amwang@redhat.com> | 2011-03-22 19:34:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-22 20:44:11 -0400 |
commit | 34db18a054c600b6f81787165669dc572fe4de25 (patch) | |
tree | 6a8a0abf4f64ccad677ea2468c3e8465ac4e0c29 /init | |
parent | fa9ee9c4b9885dfdf8eccac19b8b4fc8a7c53288 (diff) |
smp: move smp setup functions to kernel/smp.c
Move setup_nr_cpu_ids(), smp_init() and some other SMP boot parameter
setup functions from init/main.c to kenrel/smp.c, saves some #ifdef
CONFIG_SMP.
Signed-off-by: WANG Cong <amwang@redhat.com>
Cc: Rakib Mullick <rakib.mullick@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tejun Heo <tj@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'init')
-rw-r--r-- | init/main.c | 90 |
1 files changed, 1 insertions, 89 deletions
diff --git a/init/main.c b/init/main.c index 33c37c379e9..3627bb37225 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -129,63 +129,6 @@ static char *static_command_line; | |||
129 | static char *execute_command; | 129 | static char *execute_command; |
130 | static char *ramdisk_execute_command; | 130 | static char *ramdisk_execute_command; |
131 | 131 | ||
132 | #ifdef CONFIG_SMP | ||
133 | /* Setup configured maximum number of CPUs to activate */ | ||
134 | unsigned int setup_max_cpus = NR_CPUS; | ||
135 | EXPORT_SYMBOL(setup_max_cpus); | ||
136 | |||
137 | |||
138 | /* | ||
139 | * Setup routine for controlling SMP activation | ||
140 | * | ||
141 | * Command-line option of "nosmp" or "maxcpus=0" will disable SMP | ||
142 | * activation entirely (the MPS table probe still happens, though). | ||
143 | * | ||
144 | * Command-line option of "maxcpus=<NUM>", where <NUM> is an integer | ||
145 | * greater than 0, limits the maximum number of CPUs activated in | ||
146 | * SMP mode to <NUM>. | ||
147 | */ | ||
148 | |||
149 | void __weak arch_disable_smp_support(void) { } | ||
150 | |||
151 | static int __init nosmp(char *str) | ||
152 | { | ||
153 | setup_max_cpus = 0; | ||
154 | arch_disable_smp_support(); | ||
155 | |||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | early_param("nosmp", nosmp); | ||
160 | |||
161 | /* this is hard limit */ | ||
162 | static int __init nrcpus(char *str) | ||
163 | { | ||
164 | int nr_cpus; | ||
165 | |||
166 | get_option(&str, &nr_cpus); | ||
167 | if (nr_cpus > 0 && nr_cpus < nr_cpu_ids) | ||
168 | nr_cpu_ids = nr_cpus; | ||
169 | |||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | early_param("nr_cpus", nrcpus); | ||
174 | |||
175 | static int __init maxcpus(char *str) | ||
176 | { | ||
177 | get_option(&str, &setup_max_cpus); | ||
178 | if (setup_max_cpus == 0) | ||
179 | arch_disable_smp_support(); | ||
180 | |||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | early_param("maxcpus", maxcpus); | ||
185 | #else | ||
186 | static const unsigned int setup_max_cpus = NR_CPUS; | ||
187 | #endif | ||
188 | |||
189 | /* | 132 | /* |
190 | * If set, this is an indication to the drivers that reset the underlying | 133 | * If set, this is an indication to the drivers that reset the underlying |
191 | * device before going ahead with the initialization otherwise driver might | 134 | * device before going ahead with the initialization otherwise driver might |
@@ -362,7 +305,7 @@ static int __init rdinit_setup(char *str) | |||
362 | __setup("rdinit=", rdinit_setup); | 305 | __setup("rdinit=", rdinit_setup); |
363 | 306 | ||
364 | #ifndef CONFIG_SMP | 307 | #ifndef CONFIG_SMP |
365 | 308 | static const unsigned int setup_max_cpus = NR_CPUS; | |
366 | #ifdef CONFIG_X86_LOCAL_APIC | 309 | #ifdef CONFIG_X86_LOCAL_APIC |
367 | static void __init smp_init(void) | 310 | static void __init smp_init(void) |
368 | { | 311 | { |
@@ -374,37 +317,6 @@ static void __init smp_init(void) | |||
374 | 317 | ||
375 | static inline void setup_nr_cpu_ids(void) { } | 318 | static inline void setup_nr_cpu_ids(void) { } |
376 | static inline void smp_prepare_cpus(unsigned int maxcpus) { } | 319 | static inline void smp_prepare_cpus(unsigned int maxcpus) { } |
377 | |||
378 | #else | ||
379 | |||
380 | /* Setup number of possible processor ids */ | ||
381 | int nr_cpu_ids __read_mostly = NR_CPUS; | ||
382 | EXPORT_SYMBOL(nr_cpu_ids); | ||
383 | |||
384 | /* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */ | ||
385 | static void __init setup_nr_cpu_ids(void) | ||
386 | { | ||
387 | nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1; | ||
388 | } | ||
389 | |||
390 | /* Called by boot processor to activate the rest. */ | ||
391 | static void __init smp_init(void) | ||
392 | { | ||
393 | unsigned int cpu; | ||
394 | |||
395 | /* FIXME: This should be done in userspace --RR */ | ||
396 | for_each_present_cpu(cpu) { | ||
397 | if (num_online_cpus() >= setup_max_cpus) | ||
398 | break; | ||
399 | if (!cpu_online(cpu)) | ||
400 | cpu_up(cpu); | ||
401 | } | ||
402 | |||
403 | /* Any cleanup work */ | ||
404 | printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus()); | ||
405 | smp_cpus_done(setup_max_cpus); | ||
406 | } | ||
407 | |||
408 | #endif | 320 | #endif |
409 | 321 | ||
410 | /* | 322 | /* |