Booting Debian in 14 seconds (Debian-administration)
Inspired by this work, and because I have the same laptop, I decided to try to reproduce their results. So far I have not come very close to their 5 seconds, but I have made some significant improvements compared to the default boot time for Debian on that machine; this article describes what I've done."
Posted Nov 11, 2008 20:58 UTC (Tue)
by rvfh (guest, #31018)
[Link] (12 responses)
This being said, 2.6.27 solved the standby on my Amilo Xi 2428, and I only use that these days. Takes only a few seconds to be exactly as I'd left it. Suspend-to-disk was already reliable and I use that if I need to switch off the power. This is not the case of all computers though...
Posted Nov 11, 2008 22:07 UTC (Tue)
by dlang (guest, #313)
[Link] (4 responses)
Posted Nov 12, 2008 8:27 UTC (Wed)
by pjm (guest, #2080)
[Link] (3 responses)
I don't speak for the original poster, but a few reasons I've heard are:
Posted Nov 12, 2008 8:54 UTC (Wed)
by rvfh (guest, #31018)
[Link] (2 responses)
Some drivers also have little issues which can be solved by removing then re-adding then, but I agree that it's a bug.
Last but not least, removing the module is sometimes the only way to put the corresponding device in low-power mode.
Posted Nov 12, 2008 11:00 UTC (Wed)
by dlang (guest, #313)
[Link] (1 responses)
the ioports is a variation of the issue above (and very unlikly to be needed on modern hardware)
the suspend problem is valid
I didn't think that it was possible to load a module multiple times, are you sure this is possible?
for hardware that you don't have you don't want to compile the drivers in, but that's not what is being talked about here. what's being talked about is making it so that the kernel you boot has drivers compiled in for all the hardware in your machine. other things can be compiled as modules and used by the hotplug system as needed. the thing that we are trying to avoid is the overhead in the coldplug case.
for things that you are developing, or out-of-tree drivers you may not want to or be able to compile them in. but again, that's not the situation that is being addressed here, and compiling in the drivers for the hardware that your system _does_ have doesn't prevent you from compiling other drivers as modules.
all these articles have included having many modules available for USB devices, but it still makes a significant difference in the boot time of the systems.
Posted Nov 12, 2008 11:58 UTC (Wed)
by baruchb (subscriber, #6054)
[Link]
The first few paragraphs of the Documentation/kernel-parameters.txt document look quite clear to me.
Posted Nov 11, 2008 23:00 UTC (Tue)
by endecotp (guest, #36428)
[Link] (6 responses)
That sounds like an excellent idea. It would give a lot of flexibility to users of distribution kernels who would otherwise need to compile a kernel from source. Are there any experts reading this who know how practical it is?
Posted Nov 11, 2008 23:16 UTC (Tue)
by dlang (guest, #313)
[Link] (4 responses)
1. no time wasted probing to see if the module should be loaded (especially for the 90% of the modules that end up not being loaded)
2. things that the kernel can be compiled to do because it knows everything is there (for example async scsi inititalization)
3. optimizations the compiler can make on non-modular code (for example, modules waste 1/2 page or ram per module, all calls to module code are more expensive 'far' calls as the compiler can't know where in memory the module code will be loaded)
pre-linking seperatly compiled modules may save some time for #1, but won't help #2 and #3. and even for #1 you could probably achieve very similar results by just deleting the unneeded modules
Posted Nov 12, 2008 12:28 UTC (Wed)
by AnswerGuy (guest, #1256)
[Link] (3 responses)
I know for sure #1 is based on an invalid assumption for a large number of cases. Many drivers (particularly for things like USB, fibre channel, firewire, etc.) don't perform any probing during kernel initialization. They probe for device presence when there is an attempt to access the device (or, in some cases, for a hotplug event).
I would suspect that this is true of most of the drivers that one would see loaded via kmod. When user space opens a device (or invokes the entry points for binfmt or network protocols, etc) then kmod dispatches a copy of modprobe to load the module and any probing and device initialization must happen at that time. However, even if that module is statically linked into the kernel the probing and initialization is (usually? always?) deferred until the first access.
No attempt to access means no time wasted on such initialization.
I also strongly suspect that #3 is bogus because it's not at all clear how often any statically linked module's exported functionality could be accessed by any means other than the same calling conventions that have already been established. I think it's going to be a far call dispatched through a table regardless of whether the code is statically or dynamically linked. (It's not like some of the optimizations you might get from different types of linking for user space code). In any event I also rather strongly suspect that the difference between the calling types (specifically for device drivers and other bits of functionality that can be modules) isn't going to make any appreciable difference in overall performance. (Most of the time spent in any sort of I/O is time that the CPU was waiting for DMA from the device(s), for example. Any calling and stack handling overhead should be down well under the 1% (line noise) threshold).
In any event you'd have to show me measurements and a detailed description of your methodology before I'd give these claims any credence.
Posted Nov 12, 2008 14:04 UTC (Wed)
by endecotp (guest, #36428)
[Link]
I can't think of any hardware that I have that works this way. Everything seems to load the necessary modules during hotpluging or coldpluging. Can you give some examples?
Posted Nov 12, 2008 16:00 UTC (Wed)
by willy (subscriber, #9762)
[Link] (1 responses)
I'm sorry, you're wrong. Drivers that can optionally be modules mark their entry point with module_init(). If compiled as a module, this code is executed at module load time; if it's built it, it's executed as part of do_initcalls() (see init/main.c in the kernel source tree).
You may be confused by some of the asynchronous discovery code; the scsi core spawns a thread for each host and does the lengthy device discovery in that thread. This cuts down boot time substantially on machines with lots of scsi (including fibrechannel).
Claiming that drivers only check for device presence when there's an attempt to access the device is just wrong, though. Sorry.
Posted Nov 12, 2008 16:05 UTC (Wed)
by rvfh (guest, #31018)
[Link]
Indeed.
I seem to remember that the devfs system provided module loading when the device was accessed, but that's been dead for a while now. Maybe the poster thought it had been preserved?
Posted Nov 12, 2008 13:50 UTC (Wed)
by njh (subscriber, #4425)
[Link]
Doing something similar in Linux would presumably involve teaching GRUB
Posted Nov 11, 2008 21:08 UTC (Tue)
by mjthayer (guest, #39183)
[Link] (8 responses)
Posted Nov 11, 2008 22:56 UTC (Tue)
by endecotp (guest, #36428)
[Link] (7 responses)
As for improvements that don't sacrifice portability, I agree; for example, it would be interesting to study why udevd seems to take so long at boot. Is it the shear number of modprobe and mknod calls that it makes? Or does modprobe constantly have to re-load configuration files every time it is started?
Posted Nov 12, 2008 7:13 UTC (Wed)
by aleXXX (subscriber, #2742)
[Link] (6 responses)
Alex
Posted Nov 12, 2008 8:22 UTC (Wed)
by mjthayer (guest, #39183)
[Link] (4 responses)
Posted Nov 12, 2008 9:02 UTC (Wed)
by rvfh (guest, #31018)
[Link] (3 responses)
Posted Nov 12, 2008 9:22 UTC (Wed)
by mjthayer (guest, #39183)
[Link] (2 responses)
Posted Nov 12, 2008 10:21 UTC (Wed)
by rvfh (guest, #31018)
[Link] (1 responses)
You're right, and my stuff won't work because it requires access to the grub dir, which requires a running system... Maybe we could change the kernel to ignore the initrd if root as specified in the How much time does it actually save to skip the initrd BTW? Is it worth it?
Posted Nov 12, 2008 10:31 UTC (Wed)
by mjthayer (guest, #39183)
[Link]
Posted Nov 12, 2008 9:06 UTC (Wed)
by endecotp (guest, #36428)
[Link]
Posted Nov 12, 2008 9:36 UTC (Wed)
by pjm (guest, #2080)
[Link]
Note that both this and the previous “five second boot” are actually measured from when Linux loads, not from power on. According to the article, that adds about another 10 seconds (or 4 seconds when merely rebooting). That can be greatly reduced by switching to CoreBoot (né LinuxBIOS). Google search for ‘coreboot eee’ for some info on progress on this for Eee machines, or choose hardware already supported by CoreBoot.
Configuring a kernel with built-in drivers
- rather than recompiling a kernel with some modules built-in, I think it would be nice to see if there is not a way to link existing modules into the existing kernel binary. Something like file.ko -> file.o, then 'ld bzImage file.o'... Note that some things are better left as modules.
- it would be nice to have the SATA support built into the kernel anyway, thus not requiring an initrd in most cases, as most computers need it.
- USB gets initialised in its own time, and some initrds wait for it to be ready in case the root fs was on it. Getting rid of the initrd might get rid of this often useless delay
Configuring a kernel with built-in drivers
Reasons for preferring modules?
Reasons for preferring modules?
Reasons for preferring modules?
Reasons for preferring modules?
> command line (although the documentation on how to do this is very
> poor)
Configuring a kernel with built-in drivers
> it would be nice to see if there is not a way to link existing modules
> into the existing kernel binary. Something like file.ko -> file.o, then
> 'ld bzImage file.o'
Configuring a kernel with built-in drivers
Bzzzzt!
Bzzzzt!
> then kmod dispatches a copy of modprobe to load the module and any
> probing and device initialization must happen at that time
Bzzzzt!
> of cases. Many drivers (particularly for things like USB, fibre channel,
> firewire, etc.) don't perform any probing during kernel initialization.
> They probe for device presence when there is an attempt to access the
> device (or, in some cases, for a hotplug event).
devfs is dead
Configuring a kernel with built-in drivers
kernel before booting the kernel - this is often used in the FreeBSD
world to make boot-critical device drivers or filesystems available
to the GENERIC kernel (addressing the same sort of problem for which a
modular Linux installation would typically use an initrd).
about Linux modules. I notice that GRUB actually has a "module" command
for loading modules when it is working with an OS kernel that uses the
Multiboot Specification (such as Hurd) ...
Booting Debian in 14 seconds (Debian-administration)
Booting Debian in 14 seconds (Debian-administration)
Booting Debian in 14 seconds (Debian-administration)
hardware configuration hasn't changed so there should be some way to
reuse the previous results.
Maybe some boot parameter could be used which would force automatic
detection again ? (so you can select "Boot with hardware detection" from
grub when you changed something in your machine)
Booting Debian in 14 seconds (Debian-administration)
I suppose this could easily be made automatic:
Booting Debian in 14 seconds (Debian-administration)
if (last boot ok) [Ubuntu have apparently introduced such a flag now]
try usual boot
if (fails)
flag last boot no ok
reboot
else
try default boot [with initrd, whatever]
if (fails)
Houston, we have a problem.
Booting Debian in 14 seconds (Debian-administration)
Booting Debian in 14 seconds (Debian-administration)
root= argument is accessible? That would require a new kernel command line option though, like initrd=?, and to make sure that what the initrd used to do is also done without it.Booting Debian in 14 seconds (Debian-administration)
Booting Debian in 14 seconds (Debian-administration)
Plus BIOS time
