Message ID | 1260207127-7736-2-git-send-email-surbhi.palande@canonical.com |
---|---|
State | Rejected |
Headers | show |
On Mon, Dec 07, 2009 at 07:32:06PM +0200, Surbhi Palande wrote: > populate_rootfs() is called asynchronously to reduce the boot time. > > Signed-off-by: Surbhi Palande <surbhi.palande@canonical.com> > --- > init/initramfs.c | 15 ++++++++++++--- > init/main.c | 7 +++++++ > 2 files changed, 19 insertions(+), 3 deletions(-) > > diff --git a/init/initramfs.c b/init/initramfs.c > index 4c00edc..aad2c28 100644 > --- a/init/initramfs.c > +++ b/init/initramfs.c > @@ -8,6 +8,7 @@ > #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) > @@ -565,7 +566,9 @@ static void __init clean_rootfs(void) > } > #endif > > -static int __init populate_rootfs(void) > +extern struct list_head rootfs_fn_list; Externs are frowned upon heavily in .c files, as it is possible to get an undetected type missmatch leading to unexpected behaviour. You should move the extern to a header that these two files both include, there is likely something already. Also I would rather see the declaration here in this file as its the primary consumer of it. I also think the name is a bit wierd, as its not a function list? If anything its an async_t list, but you are not meant to know that, its an opaque type. populate_rootfs_domain or something seems more sensible to my eye. > + > +static void __init async_populate_rootfs(void) > { > char *err = unpack_to_rootfs(__initramfs_start, > __initramfs_end - __initramfs_start); > @@ -579,7 +582,7 @@ static int __init populate_rootfs(void) > initrd_end - initrd_start); > if (!err) { > free_initrd(); > - return 0; > + return; > } else { > clean_rootfs(); > unpack_to_rootfs(__initramfs_start, > @@ -603,6 +606,12 @@ static int __init populate_rootfs(void) > free_initrd(); > #endif > } > - return 0; > + return; > } > + > +static int __init populate_rootfs(void) > +{ > + async_schedule_domain(async_populate_rootfs, NULL, &rootfs_fn_list); > +} > + > rootfs_initcall(populate_rootfs); > diff --git a/init/main.c b/init/main.c > index 4051d75..d40ca6f 100644 > --- a/init/main.c > +++ b/init/main.c > @@ -752,6 +752,7 @@ int do_one_initcall(initcall_t fn) > > > extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[]; > +LIST_HEAD(rootfs_fn_list); > > static void __init do_initcalls(void) > { > @@ -879,6 +880,12 @@ static int __init kernel_init(void * unused) > do_basic_setup(); > > /* > + * putting it here to ensure that rootfs is populated by the end of putting it here? /* * We need to ensure the filesystem is ready by this point, wait for * async_populate_rootfs to complete. */ > + * this call > + */ > + async_synchronize_full_domain(&rootfs_fn_list); > + > + /* > * check if there is an early userspace init. If yes, let it do all > * the work > */ -apw
diff --git a/init/initramfs.c b/init/initramfs.c index 4c00edc..aad2c28 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -8,6 +8,7 @@ #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) @@ -565,7 +566,9 @@ static void __init clean_rootfs(void) } #endif -static int __init populate_rootfs(void) +extern struct list_head rootfs_fn_list; + +static void __init async_populate_rootfs(void) { char *err = unpack_to_rootfs(__initramfs_start, __initramfs_end - __initramfs_start); @@ -579,7 +582,7 @@ static int __init populate_rootfs(void) initrd_end - initrd_start); if (!err) { free_initrd(); - return 0; + return; } else { clean_rootfs(); unpack_to_rootfs(__initramfs_start, @@ -603,6 +606,12 @@ static int __init populate_rootfs(void) free_initrd(); #endif } - return 0; + return; } + +static int __init populate_rootfs(void) +{ + async_schedule_domain(async_populate_rootfs, NULL, &rootfs_fn_list); +} + rootfs_initcall(populate_rootfs); diff --git a/init/main.c b/init/main.c index 4051d75..d40ca6f 100644 --- a/init/main.c +++ b/init/main.c @@ -752,6 +752,7 @@ int do_one_initcall(initcall_t fn) extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[]; +LIST_HEAD(rootfs_fn_list); static void __init do_initcalls(void) { @@ -879,6 +880,12 @@ static int __init kernel_init(void * unused) do_basic_setup(); /* + * putting it here to ensure that rootfs is populated by the end of + * this call + */ + async_synchronize_full_domain(&rootfs_fn_list); + + /* * check if there is an early userspace init. If yes, let it do all * the work */
populate_rootfs() is called asynchronously to reduce the boot time. Signed-off-by: Surbhi Palande <surbhi.palande@canonical.com> --- init/initramfs.c | 15 ++++++++++++--- init/main.c | 7 +++++++ 2 files changed, 19 insertions(+), 3 deletions(-)