Patchwork [2/2] async_populate_rootfs: move rootfs init earlier

login
register
mail settings
Submitter Bryan Wu
Date Feb. 5, 2010, 1:41 a.m.
Message ID <1265334066-15161-3-git-send-email-bryan.wu@canonical.com>
Download mbox | patch
Permalink /patch/44587/
State Accepted
Delegated to: Andy Whitcroft
Headers show

Comments

Bryan Wu - Feb. 5, 2010, 1:41 a.m.
From: Andy Whitcroft <apw@canonical.com>

Check to see if the machine has more than one active CPU, if it does
then it is worth starting the decode of the rootfs earlier.

Signed-off-by: Andy Whitcroft <apw@canonical.com>

[cherry-pick from a7baa7164fdf25b2819798ee2238a3cc7b4ada75 for backporting]
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
---
 include/asm-generic/vmlinux.lds.h |    1 +
 include/linux/init.h              |    1 +
 init/initramfs.c                  |   15 ++++++++++++++-
 3 files changed, 16 insertions(+), 1 deletions(-)

Patch

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 6ad76bf..45e2d65 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -587,6 +587,7 @@ 
   	*(.initcall0s.init)						\
   	*(.initcall1.init)						\
   	*(.initcall1s.init)						\
+	*(.initcallearlyrootfs.init)					\
   	*(.initcall2.init)						\
   	*(.initcall2s.init)						\
   	*(.initcall3.init)						\
diff --git a/include/linux/init.h b/include/linux/init.h
index 5a33056..33d7ac8 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -186,6 +186,7 @@  extern void (*late_time_init)(void);
 
 #define core_initcall(fn)		__define_initcall("1",fn,1)
 #define core_initcall_sync(fn)		__define_initcall("1s",fn,1s)
+#define earlyrootfs_initcall(fn)	__define_initcall("earlyrootfs",fn,rootfs)
 #define postcore_initcall(fn)		__define_initcall("2",fn,2)
 #define postcore_initcall_sync(fn)	__define_initcall("2s",fn,2s)
 #define arch_initcall(fn)		__define_initcall("3",fn,3)
diff --git a/init/initramfs.c b/init/initramfs.c
index b8f9e3c..d9e6e81 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -609,9 +609,22 @@  static void __init async_populate_rootfs(void)
 	return;
 }
 
+static int __initdata rootfs_populated;
+
+static int __init populate_rootfs_early(void)
+{
+	if (num_online_cpus() > 1) {
+		rootfs_populated = 1;
+		async_schedule_domain(async_populate_rootfs, NULL,
+						&populate_rootfs_domain);
+	}
+}
 static int __init populate_rootfs(void)
 {
-	async_schedule_domain(async_populate_rootfs, NULL, &populate_rootfs_domain);
+	if (!rootfs_populated)
+		async_schedule_domain(async_populate_rootfs, NULL,
+						&populate_rootfs_domain);
 }
 
+earlyrootfs_initcall(populate_rootfs_early);
 rootfs_initcall(populate_rootfs);