The expansion of the initramfs is completely independant of other
boot activities. The original data is already present at boot and the
filesystem is not required until we are ready to start init. It is
therefore reasonable to populate the rootfs asynchronously. Move this
processing to an async call.
This reduces kernel initialisation time (the time from bootloader to
starting userspace) by several 10ths of a second on a selection of test
hardware particularly SMP systems, although UP system also benefit.
Signed-off-by: Surbhi Palande <surbhi.palande@canonical.com>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
static initcall_t __initcall_##fn \
__used __section(.security_initcall.init) = fn
static initcall_t __initcall_##fn \
__used __section(.security_initcall.init) = fn
+extern struct list_head populate_rootfs_domain;
+
struct obs_kernel_param {
const char *str;
int (*setup_func)(char *);
struct obs_kernel_param {
const char *str;
int (*setup_func)(char *);
#include <linux/dirent.h>
#include <linux/syscalls.h>
#include <linux/utime.h>
#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)
static __initdata char *message;
static void __init error(char *x)
-static int __init populate_rootfs(void)
+LIST_HEAD(populate_rootfs_domain);
+
+static void __init async_populate_rootfs(void)
{
char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
if (err)
{
char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
if (err)
initrd_end - initrd_start);
if (!err) {
free_initrd();
initrd_end - initrd_start);
if (!err) {
free_initrd();
} else {
clean_rootfs();
unpack_to_rootfs(__initramfs_start, __initramfs_size);
} else {
clean_rootfs();
unpack_to_rootfs(__initramfs_start, __initramfs_size);
+
+static int __init populate_rootfs(void)
+{
+ async_schedule_domain(async_populate_rootfs, NULL, &populate_rootfs_domain);
+}
+
rootfs_initcall(populate_rootfs);
rootfs_initcall(populate_rootfs);
(void) sys_dup(0);
(void) sys_dup(0);
/*
(void) sys_dup(0);
(void) sys_dup(0);
/*
+ * We need to ensure that the filesystem is ready by this point, wait for
+ * async_populate_rootfs to complete.
+ */
+ async_synchronize_full_domain(&populate_rootfs_domain);
+
+ /*
* check if there is an early userspace init. If yes, let it do all
* the work
*/
* check if there is an early userspace init. If yes, let it do all
* the work
*/