aboutsummaryrefslogtreecommitdiffstats
path: root/init/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/main.c')
-rw-r--r--init/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/init/main.c b/init/main.c
index e407a05adc29..4ab5124a2952 100644
--- a/init/main.c
+++ b/init/main.c
@@ -422,18 +422,26 @@ static void __init setup_command_line(char *command_line)
422 * gcc-3.4 accidentally inlines this function, so use noinline. 422 * gcc-3.4 accidentally inlines this function, so use noinline.
423 */ 423 */
424 424
425static __initdata DECLARE_COMPLETION(kthreadd_done);
426
425static noinline void __init_refok rest_init(void) 427static noinline void __init_refok rest_init(void)
426 __releases(kernel_lock) 428 __releases(kernel_lock)
427{ 429{
428 int pid; 430 int pid;
429 431
430 rcu_scheduler_starting(); 432 rcu_scheduler_starting();
433 /*
434 * We need to spawn init first so that it obtains pid 1, however
435 * the init task will end up wanting to create kthreads, which, if
436 * we schedule it before we create kthreadd, will OOPS.
437 */
431 kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); 438 kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);
432 numa_default_policy(); 439 numa_default_policy();
433 pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); 440 pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
434 rcu_read_lock(); 441 rcu_read_lock();
435 kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns); 442 kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);
436 rcu_read_unlock(); 443 rcu_read_unlock();
444 complete(&kthreadd_done);
437 unlock_kernel(); 445 unlock_kernel();
438 446
439 /* 447 /*
@@ -849,6 +857,10 @@ static noinline int init_post(void)
849 857
850static int __init kernel_init(void * unused) 858static int __init kernel_init(void * unused)
851{ 859{
860 /*
861 * Wait until kthreadd is all set-up.
862 */
863 wait_for_completion(&kthreadd_done);
852 lock_kernel(); 864 lock_kernel();
853 865
854 /* 866 /*