aboutsummaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rw-r--r--init/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/init/main.c b/init/main.c
index 3bdb152f412f..633442f79e90 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 /*
@@ -855,6 +863,10 @@ static noinline int init_post(void)
855 863
856static int __init kernel_init(void * unused) 864static int __init kernel_init(void * unused)
857{ 865{
866 /*
867 * Wait until kthreadd is all set-up.
868 */
869 wait_for_completion(&kthreadd_done);
858 lock_kernel(); 870 lock_kernel();
859 871
860 /* 872 /*