From 7be803f0d5dc9185cca8405175135b62417af9ab Mon Sep 17 00:00:00 2001 From: Liao Huaping Date: Mon, 11 Mar 2019 18:32:35 +0800 Subject: [PATCH] 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 cd402972fc2f..5acb8ec84bf6 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1310,6 +1310,11 @@ if BLK_DEV_INITRD source "usr/Kconfig" +config INITRD_ASYNC + bool "Initrd async" + help + Init ramdisk async, can reduce kernel init time. + endif config BOOT_CONFIG diff --git a/init/initramfs.c b/init/initramfs.c index 55b74d7e5260..46429e8ffe27 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -639,4 +639,23 @@ done: flush_delayed_fput(); 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 e8633b6d5752..04a07c2633a2 100644 --- a/init/main.c +++ b/init/main.c @@ -1550,6 +1550,10 @@ static noinline void __init kernel_init_freeable(void) kunit_run_all_tests(); +#if IS_BUILTIN(CONFIG_INITRD_ASYNC) + async_synchronize_full(); +#endif + console_on_rootfs(); /*