diff options
Diffstat (limited to 'init/main.c')
-rw-r--r-- | init/main.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/init/main.c b/init/main.c index 3ff8dd0fb512..4ddb53f04f2a 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -125,7 +125,9 @@ static char *ramdisk_execute_command; | |||
125 | 125 | ||
126 | #ifdef CONFIG_SMP | 126 | #ifdef CONFIG_SMP |
127 | /* Setup configured maximum number of CPUs to activate */ | 127 | /* Setup configured maximum number of CPUs to activate */ |
128 | unsigned int __initdata setup_max_cpus = NR_CPUS; | 128 | unsigned int setup_max_cpus = NR_CPUS; |
129 | EXPORT_SYMBOL(setup_max_cpus); | ||
130 | |||
129 | 131 | ||
130 | /* | 132 | /* |
131 | * Setup routine for controlling SMP activation | 133 | * Setup routine for controlling SMP activation |
@@ -422,18 +424,26 @@ static void __init setup_command_line(char *command_line) | |||
422 | * gcc-3.4 accidentally inlines this function, so use noinline. | 424 | * gcc-3.4 accidentally inlines this function, so use noinline. |
423 | */ | 425 | */ |
424 | 426 | ||
427 | static __initdata DECLARE_COMPLETION(kthreadd_done); | ||
428 | |||
425 | static noinline void __init_refok rest_init(void) | 429 | static noinline void __init_refok rest_init(void) |
426 | __releases(kernel_lock) | 430 | __releases(kernel_lock) |
427 | { | 431 | { |
428 | int pid; | 432 | int pid; |
429 | 433 | ||
430 | rcu_scheduler_starting(); | 434 | rcu_scheduler_starting(); |
435 | /* | ||
436 | * We need to spawn init first so that it obtains pid 1, however | ||
437 | * the init task will end up wanting to create kthreads, which, if | ||
438 | * we schedule it before we create kthreadd, will OOPS. | ||
439 | */ | ||
431 | kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); | 440 | kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); |
432 | numa_default_policy(); | 441 | numa_default_policy(); |
433 | pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); | 442 | pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); |
434 | rcu_read_lock(); | 443 | rcu_read_lock(); |
435 | kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns); | 444 | kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns); |
436 | rcu_read_unlock(); | 445 | rcu_read_unlock(); |
446 | complete(&kthreadd_done); | ||
437 | unlock_kernel(); | 447 | unlock_kernel(); |
438 | 448 | ||
439 | /* | 449 | /* |
@@ -856,6 +866,10 @@ static noinline int init_post(void) | |||
856 | 866 | ||
857 | static int __init kernel_init(void * unused) | 867 | static int __init kernel_init(void * unused) |
858 | { | 868 | { |
869 | /* | ||
870 | * Wait until kthreadd is all set-up. | ||
871 | */ | ||
872 | wait_for_completion(&kthreadd_done); | ||
859 | lock_kernel(); | 873 | lock_kernel(); |
860 | 874 | ||
861 | /* | 875 | /* |