diff options
author | Liao Huaping <huaping.liao@rock-chips.com> | 2019-03-11 18:32:35 +0800 |
---|---|---|
committer | Tao Huang <huangtao@rock-chips.com> | 2019-03-19 14:06:04 +0800 |
commit | ecccc04d219bdad390bc9ce83156884af5bffdf0 (patch) | |
tree | 2a9bb2ed9e74fa1e96ffe23281ba84d8856e9ac3 | |
parent | 5c64ed8c2aec0da9a170e17eed68326aeff6c302 (diff) |
init: support init ramfs async
If enable ramfs function, init ramfs async,
can reduce kernel init time.
Change-Id: I95d8ca6d8b9c4e9c738c635c5ee56391cbbe7c16
Signed-off-by: Liao Huaping <huaping.liao@rock-chips.com>
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
-rw-r--r-- | init/Kconfig | 5 | ||||
-rw-r--r-- | init/initramfs.c | 19 | ||||
-rw-r--r-- | init/main.c | 4 |
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"); |