Skip to contentSkip to conversation

how long does it take to init the scheduler?

DISCUSSION Olaf Hering 2 participants 6 messages May 8, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

the patch below looks wrong to me. Why did you move it to the very end of the boot process, instead to the very end of start_kernel()?

Now drivers will find an empty rootfs. A few of them do want to read files from there. They cant currently use the call_usermodehelper interface because this one checks for system_state. So they have to use sys_open(). But either way, they will not get anything with 2.6.6.

populate_rootfs() should run before do_initcalls().

#date: 2004-04-21
#id: 1.1371.737.7
#tag: via-mm
#time: 07:42:18
#title: Call populate_rootfs later in boot
#who: [email protected][torvalds]
#
# ChangeSet
# 1.1371.737.7 04/04/21 07:42:18 [email protected][torvalds] +1 -0
# [PATCH] Call populate_rootfs later in boot
#
# 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.
#
# init/main.c +10 -11
#
diff -Nru a/init/main.c b/init/main.c
--- a/init/main.c	Wed Apr 28 10:54:47 2004
+++ b/init/main.c	Wed Apr 28 10:54:48 2004
@@ -89,6 +89,7 @@
 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);
@@ -471,7 +472,6 @@
signals_init();
/* rootfs populating might need page-writeback */ page_writeback_init();
- populate_rootfs();
#ifdef CONFIG_PROC_FS
proc_root_init();
#endif
@@ -577,8 +577,6 @@
execve(init_filename, argv_init, envp_init);
}

-extern void prepare_namespace(void);
-
static int init(void * unused)
{
lock_kernel();
@@ -600,14 +598,15 @@
smp_init();
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

Signature · 3 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG
#1 lore raw
Quoted 7 lines · Olaf Hering

Hi,

the patch below looks wrong to me. Why did you move it to the very end of the boot process, instead to the very end of start_kernel()?

coz I forgot about drivers which want to go opening files in their module_init().

Like this?

init/main.c renamed from init/main.c~populate_rootfs-before-initcalls +7 -1
@@ -660,9 +660,15 @@ static int init(void * unused)
 	fixup_cpu_present_map();
 	smp_init();
 	sched_init_smp();
-	do_basic_setup();
 
+	/*
+	 * Do this before initcalls, because some drivers want to access
+	 * firmware files.
+	 */
 	populate_rootfs();
+
+	do_basic_setup();
+
 	/*
 	 * check if there is an early userspace init.  If yes, let it do all
 	 * the work

_

#2 lore raw
Quoted 5 lines · Andrew Morton
Quoted 4 lines · Olaf Hering

Hi,

Quoted 8 lines
Quoted 3 lines

the patch below looks wrong to me. Why did you move it to the very end of the boot process, instead to the very end of start_kernel()?

coz I forgot about drivers which want to go opening files in their module_init().

Like this?

Yes, but I cant verify it before Monday.

That leads to another question. usermodehelper_init() is now an initcall. all the binfmt stuff is also an initcall. We had a patch (for debugging) that turned init_elf_binfmt() into core_initcall.
Can we change that as well, so one could finally run stuff via the driver hotplug events? init_script_binfmt() should be also core_initcall, so you can run scripts. But I havent looked at the dependencies for the binfmt stuff.

Signature · 3 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG
#3 lore raw
Quoted 8 lines · Olaf Hering

That leads to another question. usermodehelper_init() is now an initcall.
all the binfmt stuff is also an initcall. We had a patch (for debugging) that turned init_elf_binfmt() into core_initcall.
Can we change that as well, so one could finally run stuff via the driver hotplug events? init_script_binfmt() should be also core_initcall, so you can run scripts. But I havent looked at the dependencies for the binfmt stuff.

yes, that's surely OK - those init functions only call register_binfmt() and register_filesystem(), and they merely stick things into a list.

 25-akpm/fs/binfmt_aout.c   |    2 +-
 25-akpm/fs/binfmt_elf.c    |    2 +-
 25-akpm/fs/binfmt_em86.c   |    2 +-
 25-akpm/fs/binfmt_flat.c   |    2 +-
 25-akpm/fs/binfmt_misc.c   |    2 +-
 25-akpm/fs/binfmt_script.c |    2 +-
 25-akpm/fs/binfmt_som.c    |    2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)
fs/binfmt_aout.c renamed from fs/binfmt_aout.c~binfmt-use-core_initcall +1 -1
diff -puN fs/binfmt_aout.c~binfmt-use-core_initcall fs/binfmt_aout.c
@@ -520,6 +520,6 @@ static void __exit exit_aout_binfmt(void
 	unregister_binfmt(&aout_format);
 }
 
-module_init(init_aout_binfmt);
+core_initcall(init_aout_binfmt);
 module_exit(exit_aout_binfmt);
 MODULE_LICENSE("GPL");
fs/binfmt_elf.c renamed from fs/binfmt_elf.c~binfmt-use-core_initcall +1 -1
diff -puN fs/binfmt_elf.c~binfmt-use-core_initcall fs/binfmt_elf.c
@@ -1542,6 +1542,6 @@ static void __exit exit_elf_binfmt(void)
 	unregister_binfmt(&elf_format);
 }
 
-module_init(init_elf_binfmt)
+core_initcall(init_elf_binfmt)
 module_exit(exit_elf_binfmt)
 MODULE_LICENSE("GPL");
fs/binfmt_em86.c renamed from fs/binfmt_em86.c~binfmt-use-core_initcall +1 -1
diff -puN fs/binfmt_em86.c~binfmt-use-core_initcall fs/binfmt_em86.c
@@ -110,6 +110,6 @@ static void __exit exit_em86_binfmt(void
 	unregister_binfmt(&em86_format);
 }
 
-module_init(init_em86_binfmt)
+core_initcall(init_em86_binfmt)
 module_exit(exit_em86_binfmt)
 MODULE_LICENSE("GPL");
fs/binfmt_flat.c renamed from fs/binfmt_flat.c~binfmt-use-core_initcall +1 -1
diff -puN fs/binfmt_flat.c~binfmt-use-core_initcall fs/binfmt_flat.c
@@ -895,7 +895,7 @@ static void __exit exit_flat_binfmt(void
 
 /****************************************************************************/
 
-module_init(init_flat_binfmt);
+core_initcall(init_flat_binfmt);
 module_exit(exit_flat_binfmt);
 
 /****************************************************************************/
fs/binfmt_misc.c renamed from fs/binfmt_misc.c~binfmt-use-core_initcall +1 -1
diff -puN fs/binfmt_misc.c~binfmt-use-core_initcall fs/binfmt_misc.c
@@ -775,6 +775,6 @@ static void __exit exit_misc_binfmt(void
 	unregister_filesystem(&bm_fs_type);
 }
 
-module_init(init_misc_binfmt);
+core_initcall(init_misc_binfmt);
 module_exit(exit_misc_binfmt);
 MODULE_LICENSE("GPL");
fs/binfmt_script.c renamed from fs/binfmt_script.c~binfmt-use-core_initcall +1 -1
diff -puN fs/binfmt_script.c~binfmt-use-core_initcall fs/binfmt_script.c
@@ -111,6 +111,6 @@ static void __exit exit_script_binfmt(vo
 	unregister_binfmt(&script_format);
 }
 
-module_init(init_script_binfmt)
+core_initcall(init_script_binfmt)
 module_exit(exit_script_binfmt)
 MODULE_LICENSE("GPL");
fs/binfmt_som.c renamed from fs/binfmt_som.c~binfmt-use-core_initcall +1 -1
diff -puN fs/binfmt_som.c~binfmt-use-core_initcall fs/binfmt_som.c
@@ -305,5 +305,5 @@ static void __exit exit_som_binfmt(void)
 	unregister_binfmt(&som_format);
 }
 
-module_init(init_som_binfmt);
+core_initcall(init_som_binfmt);
 module_exit(exit_som_binfmt);

_

#4 lore raw
Quoted 3 lines · Andrew Morton

-module_init(init_elf_binfmt)
+core_initcall(init_elf_binfmt)

Sigh. core_initcall() requires a semicolon, but module_init() does not.

fs/binfmt_aout.c renamed from fs/binfmt_aout.c~binfmt-use-core_initcall +1 -1
diff -puN fs/binfmt_aout.c~binfmt-use-core_initcall fs/binfmt_aout.c
@@ -520,6 +520,6 @@ static void __exit exit_aout_binfmt(void
 	unregister_binfmt(&aout_format);
 }
 
-module_init(init_aout_binfmt);
+core_initcall(init_aout_binfmt);
 module_exit(exit_aout_binfmt);
 MODULE_LICENSE("GPL");
fs/binfmt_elf.c renamed from fs/binfmt_elf.c~binfmt-use-core_initcall +2 -2
diff -puN fs/binfmt_elf.c~binfmt-use-core_initcall fs/binfmt_elf.c
@@ -1542,6 +1542,6 @@ static void __exit exit_elf_binfmt(void)
 	unregister_binfmt(&elf_format);
 }
 
-module_init(init_elf_binfmt)
-module_exit(exit_elf_binfmt)
+core_initcall(init_elf_binfmt);
+module_exit(exit_elf_binfmt);
 MODULE_LICENSE("GPL");
fs/binfmt_em86.c renamed from fs/binfmt_em86.c~binfmt-use-core_initcall +2 -2
diff -puN fs/binfmt_em86.c~binfmt-use-core_initcall fs/binfmt_em86.c
@@ -110,6 +110,6 @@ static void __exit exit_em86_binfmt(void
 	unregister_binfmt(&em86_format);
 }
 
-module_init(init_em86_binfmt)
-module_exit(exit_em86_binfmt)
+core_initcall(init_em86_binfmt);
+module_exit(exit_em86_binfmt);
 MODULE_LICENSE("GPL");
fs/binfmt_flat.c renamed from fs/binfmt_flat.c~binfmt-use-core_initcall +1 -1
diff -puN fs/binfmt_flat.c~binfmt-use-core_initcall fs/binfmt_flat.c
@@ -895,7 +895,7 @@ static void __exit exit_flat_binfmt(void
 
 /****************************************************************************/
 
-module_init(init_flat_binfmt);
+core_initcall(init_flat_binfmt);
 module_exit(exit_flat_binfmt);
 
 /****************************************************************************/
fs/binfmt_misc.c renamed from fs/binfmt_misc.c~binfmt-use-core_initcall +1 -1
diff -puN fs/binfmt_misc.c~binfmt-use-core_initcall fs/binfmt_misc.c
@@ -775,6 +775,6 @@ static void __exit exit_misc_binfmt(void
 	unregister_filesystem(&bm_fs_type);
 }
 
-module_init(init_misc_binfmt);
+core_initcall(init_misc_binfmt);
 module_exit(exit_misc_binfmt);
 MODULE_LICENSE("GPL");
fs/binfmt_script.c renamed from fs/binfmt_script.c~binfmt-use-core_initcall +2 -2
diff -puN fs/binfmt_script.c~binfmt-use-core_initcall fs/binfmt_script.c
@@ -111,6 +111,6 @@ static void __exit exit_script_binfmt(vo
 	unregister_binfmt(&script_format);
 }
 
-module_init(init_script_binfmt)
-module_exit(exit_script_binfmt)
+core_initcall(init_script_binfmt);
+module_exit(exit_script_binfmt);
 MODULE_LICENSE("GPL");
fs/binfmt_som.c renamed from fs/binfmt_som.c~binfmt-use-core_initcall +1 -1
diff -puN fs/binfmt_som.c~binfmt-use-core_initcall fs/binfmt_som.c
@@ -305,5 +305,5 @@ static void __exit exit_som_binfmt(void)
 	unregister_binfmt(&som_format);
 }
 
-module_init(init_som_binfmt);
+core_initcall(init_som_binfmt);
 module_exit(exit_som_binfmt);

_

#5 lore raw
In reply to Olaf Hering
Quoted 8 lines · Olaf Hering

That leads to another question. usermodehelper_init() is now an initcall.
all the binfmt stuff is also an initcall. We had a patch (for debugging) that turned init_elf_binfmt() into core_initcall.
Can we change that as well, so one could finally run stuff via the driver hotplug events? init_script_binfmt() should be also core_initcall, so you can run scripts. But I havent looked at the dependencies for the binfmt stuff.

We may as well make usermodehelper_init() core_initcall as well, to make sure its services are avaialble to all the other initcall levels.

kernel/kmod.c renamed from kernel/kmod.c~usermodehelper_init-use-core_initcall +1 -1
diff -puN kernel/kmod.c~usermodehelper_init-use-core_initcall kernel/kmod.c
@@ -269,4 +269,4 @@ static __init int usermodehelper_init(vo
 	BUG_ON(!khelper_wq);
 	return 0;
 }
-__initcall(usermodehelper_init);
+core_initcall(usermodehelper_init);

_