From ecccc04d219bdad390bc9ce83156884af5bffdf0 Mon Sep 17 00:00:00 2001 From: Liao Huaping Date: Mon, 11 Mar 2019 18:32:35 +0800 Subject: 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 Signed-off-by: Tao Huang --- init/Kconfig | 5 +++++ init/initramfs.c | 19 +++++++++++++++++++ init/main.c | 4 ++++ 3 files changed, 28 insertions(+) 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 +#include + +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"); -- cgit v1.2.3