I have worked on several boards where there is a rather "aggressive"
external (gpio) watchdog, with timeouts between 250 and 800 ms. Combined
with a rather slow CPU and memory, these boards often fail to make it
through populate_rootfs, since unpacking the initramfs is rather
time-consuming, and we haven't gotten to get the watchdog driver handle
the watchdog. [No, GPIO_WATCHDOG_ARCH_INITCALL doesn't help, at least
not for all cases, probably because the device isn't "discovered" until
mpc83xx_declare_of_platform_devices runs, which is at device_initcall time].
So, those boards currently use some rather ugly patches to make them
boot. I'd like to get rid of those.
I assume there's a good reason populate_rootfs runs between fs_initcall
and device_initcalls - perhaps one of the latter wants some firmware or
do a request_module?
But, would it be possible to throw most of populate_rootfs into a work
item, add some globally visible DECLARE_COMPLETION(initramfs_unpacked)
which is complete_all'ed at the end, and then in the (I assume)
relatively few places that might need to look at the filesystem add a
wait_for_completion(initramfs_unpacked) - including of course right
before the console_on_rootfs() call in kernel_init_freeable() (so also
before we start asking whether there is /init or not).
Rasmus
PS: This is the slowness, .7 seconds to unpack 4MB - it got a bit better
when switching to lz4 compression, but still in the few hundreds of
milliseconds range, which is way too much given the external watchdog's
requirements:
[ 0.047970] Trying to unpack rootfs image as initramfs...
[ 0.768516] Freeing initrd memory: 3972K