[PATCH 1/2] Populate rootfs asynchronously for boot performance
Surbhi Palande
surbhi.palande at canonical.com
Mon Dec 7 17:32:06 UTC 2009
populate_rootfs() is called asynchronously to reduce the boot time.
Signed-off-by: Surbhi Palande <surbhi.palande at canonical.com>
---
init/initramfs.c | 15 ++++++++++++---
init/main.c | 7 +++++++
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/init/initramfs.c b/init/initramfs.c
index 4c00edc..aad2c28 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -8,6 +8,7 @@
#include <linux/dirent.h>
#include <linux/syscalls.h>
#include <linux/utime.h>
+#include <linux/async.h>
static __initdata char *message;
static void __init error(char *x)
@@ -565,7 +566,9 @@ static void __init clean_rootfs(void)
}
#endif
-static int __init populate_rootfs(void)
+extern struct list_head rootfs_fn_list;
+
+static void __init async_populate_rootfs(void)
{
char *err = unpack_to_rootfs(__initramfs_start,
__initramfs_end - __initramfs_start);
@@ -579,7 +582,7 @@ static int __init populate_rootfs(void)
initrd_end - initrd_start);
if (!err) {
free_initrd();
- return 0;
+ return;
} else {
clean_rootfs();
unpack_to_rootfs(__initramfs_start,
@@ -603,6 +606,12 @@ static int __init populate_rootfs(void)
free_initrd();
#endif
}
- return 0;
+ return;
}
+
+static int __init populate_rootfs(void)
+{
+ async_schedule_domain(async_populate_rootfs, NULL, &rootfs_fn_list);
+}
+
rootfs_initcall(populate_rootfs);
diff --git a/init/main.c b/init/main.c
index 4051d75..d40ca6f 100644
--- a/init/main.c
+++ b/init/main.c
@@ -752,6 +752,7 @@ int do_one_initcall(initcall_t fn)
extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[];
+LIST_HEAD(rootfs_fn_list);
static void __init do_initcalls(void)
{
@@ -879,6 +880,12 @@ static int __init kernel_init(void * unused)
do_basic_setup();
/*
+ * putting it here to ensure that rootfs is populated by the end of
+ * this call
+ */
+ async_synchronize_full_domain(&rootfs_fn_list);
+
+ /*
* check if there is an early userspace init. If yes, let it do all
* the work
*/
--
1.6.3.3
More information about the kernel-team
mailing list