summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init/Kconfig5
-rw-r--r--init/initramfs.c19
-rw-r--r--init/main.c4
3 files changed, 28 insertions, 0 deletions
diff --git a/init/Kconfig b/init/Kconfig
index b72e83288f66..8c62047eeec3 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1380,6 +1380,11 @@ if BLK_DEV_INITRD
source "usr/Kconfig"
+config INITRD_ASYNC
+ bool "Initrd async"
+ help
+ Init ramdisk async, can reduce kernel init time.
+
endif
choice
diff --git a/init/initramfs.c b/init/initramfs.c
index d53138c40639..214c2eaf4373 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -695,4 +695,23 @@ static int __init populate_rootfs(void)
}
return 0;
}
+
+#if IS_BUILTIN(CONFIG_INITRD_ASYNC)
+#include <linux/kthread.h>
+#include <linux/async.h>
+
+static void __init unpack_rootfs_async(void *unused, async_cookie_t cookie)
+{
+ populate_rootfs();
+}
+
+static int __init populate_rootfs_async(void)
+{
+ async_schedule(unpack_rootfs_async, NULL);
+ return 0;
+}
+
+pure_initcall(populate_rootfs_async);
+#else
rootfs_initcall(populate_rootfs);
+#endif
diff --git a/init/main.c b/init/main.c
index ad8ed67e7f4d..a76671330eed 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1044,6 +1044,10 @@ static noinline void __init kernel_init_freeable(void)
do_basic_setup();
+#if IS_BUILTIN(CONFIG_INITRD_ASYNC)
+ async_synchronize_full();
+#endif
+
/* Open the /dev/console on the rootfs, this should never fail */
if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
pr_err("Warning: unable to open an initial console.\n");