populate_rootfs() is called rather early - before we've called init_idle().

But populate_rootfs() does file I/O, which involves calls to cond_resched(),
and downing of semaphores, etc.  If it scheules, the scheduler emits
scheduling-while-atomic warnings and sometimes oopses.

So run populate_rootfs() later, after the scheduler is all set up.


---

 25-akpm/init/main.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff -puN init/main.c~populate-rootfs-later init/main.c
--- 25/init/main.c~populate-rootfs-later	2004-04-15 18:03:02.838445296 -0700
+++ 25-akpm/init/main.c	2004-04-15 18:05:21.643343744 -0700
@@ -88,6 +88,7 @@ extern void radix_tree_init(void);
 extern void free_initmem(void);
 extern void populate_rootfs(void);
 extern void driver_init(void);
+extern void prepare_namespace(void);
 
 #ifdef CONFIG_TC
 extern void tc_init(void);
@@ -514,7 +515,6 @@ asmlinkage void __init start_kernel(void
 	signals_init();
 	/* rootfs populating might need page-writeback */
 	page_writeback_init();
-	populate_rootfs();
 #ifdef CONFIG_PROC_FS
 	proc_root_init();
 #endif
@@ -619,8 +619,6 @@ static void run_init_process(char *init_
 	execve(init_filename, argv_init, envp_init);
 }
 
-extern void prepare_namespace(void);
-
 static int init(void * unused)
 {
 	lock_kernel();
@@ -643,14 +641,15 @@ static int init(void * unused)
 	sched_init_smp();
 	do_basic_setup();
 
-       /*
-        * check if there is an early userspace init, if yes
-        * let it do all the work
-        */
-       if (sys_access("/init", 0) == 0)
-               execute_command = "/init";
-       else
-	prepare_namespace();
+	populate_rootfs();
+	/*
+	 * check if there is an early userspace init.  If yes, let it do all
+	 * the work
+	 */
+	if (sys_access("/init", 0) == 0)
+		execute_command = "/init";
+	else
+		prepare_namespace();
 
 	/*
 	 * Ok, we have completed the initial bootup, and

_