FS#12706 - [initscripts] A better default in rc.sysinit for a faster boot

Attached to Project: Arch Linux
Opened by Vahid Hamidullah (vh22) - Wednesday, 07 January 2009, 23:11 GMT
Last edited by Thomas Bächler (brain0) - Wednesday, 11 November 2009, 18:09 GMT
Task Type Feature Request
Category Packages: Core
Status Closed
Assigned To Tobias Powalowski (tpowa)
Aaron Griffin (phrakture)
Thomas Bächler (brain0)
Architecture All
Severity Low
Priority Normal
Reported Version None
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 6
Private No

Details

Recently I've been playing around with getting Arch to boot as fast as possible. Most of the changes I made make the boot process specific to my machine (turning off autodetect, loading modules manually...etc). But there was one change that I believe introduced no instability and I wonder why its not included by default.

In /etc/rc.sysinit starting on line 119 of a vanilla file

Code:

/sbin/udevadm trigger
/sbin/udevadm settle

These lines occur many lines after the udev daemon has been loaded. My question is why not move the trigger line to right after the udev deamon is loaded and run it in the background by default?

So the settle line stays in the same spot it is, but move the trigger line up and make make it run in the background:
(line 77)
Code:

/sbin/udevd --daemon
/sbin/udevadm trigger &

This sped my system up by about 5 seconds and there doesn't seem to be any instability ( I don't see why there would be). So is it possible this could be made the default?
This task depends upon

Closed by  Thomas Bächler (brain0)
Wednesday, 11 November 2009, 18:09 GMT
Reason for closing:  Implemented
Comment by Bill (QuimaxW) - Sunday, 11 January 2009, 14:00 GMT
Nice work! On my system, this shaved the UDev processing time from ~7000ms to 164ms and everythin is still functioning properly.
Comment by Gavin Bisesi (Daenyth) - Saturday, 21 March 2009, 14:39 GMT
Status? I'd like to see this implemented.
Comment by JM (fijam) - Saturday, 21 March 2009, 16:43 GMT
Does this decrease total boot time or just makes udev processing appear to be faster?
Comment by Vahid Hamidullah (vh22) - Saturday, 21 March 2009, 16:50 GMT
Well udev processing time definitely gets faster of course, but as far as total boot time, it appears people get mixed results. The best way is to just try it yourself I guess.
Comment by Tobias Powalowski (tpowa) - Sunday, 31 May 2009, 14:36 GMT
the problem which might happen, is things are not finished and boot process just goes on.
New .30 will introduce fastboot patches which will make module loading even more asynchrous.
Comment by Vahid Hamidullah (vh22) - Sunday, 31 May 2009, 22:11 GMT
I don't know anything about the .30 patches or how module loading changed in the new kernel, but the boot process should not go on if things aren't finished. The settle command is left in the foreground so the whole boot process should basically block until settle is done, or at least that is my understanding of it.
Comment by kujub (kujub) - Thursday, 25 June 2009, 14:19 GMT
+1
But may I suggest to do the trigger in an separate stat_busy stat_done section. This is because initscripts-extras-fbsplash (AUR) hooks into stat_done after stat_busy "Starting UDev Daemon" doing
/sbin/udevadm trigger --subsystem-match=tty --subsystem-match=graphics
/sbin/udevadm settle
to be able to start the Fbsplash daemon. (See  FS#14808  for discussion on this.) This normally takes around 100 ms to settle because only a few events are triggered at this point by now. When triggering all right after starting udev the advantage gets lost when fbsplash is installed.

Suggested PATCH:
--- etc/rc.sysinit.orig 2009-03-10 22:10:02.000000000 +0100
+++ etc/rc.sysinit 2009-06-25 15:54:10.000000000 +0200
@@ -70,6 +70,13 @@
status "Using static /dev filesystem" true
fi

+# Trigger udev uevents
+if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then
+ stat_busy "Triggering UDev uevents"
+ /sbin/udevadm trigger &
+ stat_done
+fi
+
# Load modules from the MODULES array defined in rc.conf
if ! [ "$load_modules" = "off" ]; then
if [ -f /proc/modules ]; then
@@ -101,11 +108,10 @@
fi
fi

-# run udev uevents
+# Wait for udev uevents
if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then
- stat_busy "Loading UDev uevents"
+ stat_busy "Waiting for UDev uevents to be processed"
udevstart="$(/bin/date +%s%0N)"
- /sbin/udevadm trigger
/sbin/udevadm settle
stat_done
udevend="$(/bin/date +%s%0N)"
Comment by Aaron Griffin (phrakture) - Friday, 26 June 2009, 17:49 GMT
I like this a lot, and can't believe I didn't notice it before.

Patch in git here for testing: http://projects.archlinux.org/?p=initscripts.git;a=commit;h=fb1177118b663da6b45021cb0ebdb40741047bac
Comment by Thomas Bächler (brain0) - Friday, 26 June 2009, 18:03 GMT
We had a reason for waiting with the triggering until we processed our own MODULES array: If we want to load modules in a certain order (audio, hard disk controllers, etc) we will destroy that order by moving uevent triggering before our module loading.

Most of those ordering problems can be solved differently though: For hard drives, we have UUIDs, for audio we can set index=N options in modprobe configuration files. Just saying that we must be careful here!
Comment by Aaron Griffin (phrakture) - Friday, 26 June 2009, 18:24 GMT
Hmm that is a good catch. I am on the fence about whether or not this is a good enough reason to back out the change.

If we do go forward with this, we will probably need an announcement
Comment by kujub (kujub) - Friday, 26 June 2009, 22:40 GMT
Just and idea. Maybe we could avoid triggering critical subsystems early doing
/sbin/udevadm trigger --subsystem-nomatch=subsytem [...]
and then later
/sbin/udevadm trigger --subsystem-match=subsytem [...] ?
Comment by Thomas Bächler (brain0) - Friday, 26 June 2009, 22:51 GMT
I guess we could, but somehow I don't like it. I guess that whole "loading modules in the right order" is stupid anyway, there's better ways to solve those problems.
Comment by Aaron Griffin (phrakture) - Friday, 26 June 2009, 22:56 GMT
I agree. Order-dependent modules seems awfully oldschool to me
Comment by Thomas Bächler (brain0) - Friday, 26 June 2009, 22:59 GMT
Okay, we have:

hard drives: UUIDs, labels
network cards: udev rules based on the MAC address
sound cards: index=? module parameter

Anything else that used to be problematic with changing module ordering?
Comment by kujub (kujub) - Saturday, 27 June 2009, 09:04 GMT
I don't really now, but I could think of any kind of devices depending on the users needs. I think the most clean solution would be getting this together with the modular rc.sysinit aka SIMs from  FS#14569 . This way the user could simply move the trigger to the late point if needed.
Comment by Roman Kyrylych (Romashka) - Sunday, 28 June 2009, 14:36 GMT
> Anything else that used to be problematic with changing module ordering?
big "maybe": multiple videocards? but there is pciid in xorg.conf
Comment by kujub (kujub) - Sunday, 12 July 2009, 10:59 GMT
Now since I updated the kernel to 2.6.30, snd-hda-intel steals the beeps from pcspkr. (The module loaded at least gets the beeps.) To get around this I have to load snd-hda-intel before the udev stuff. I modified the patch to get steps as follows:
- Load modules from the MODULES array defined in rc.conf
- Trigger udev uevents
- Load modules from a new MODULES2 array defined in rc.conf
- Load standard ACPI modules
- Wait for udev uevents
This way we would only load the ACPI modules and those from the new array MODULES2 concurrent to udev and could keep any critical stuff in MODULES. Looks like so here:
MODULES=(!floppy snd-hda-intel)
MODULES2=(fuse acpi-cpufreq cpufreq_ondemand cpufreq_powersave)
Comment by Roman Kyrylych (Romashka) - Wednesday, 05 August 2009, 16:13 GMT Comment by Aaron Griffin (phrakture) - Wednesday, 05 August 2009, 17:13 GMT
Kurt, can you please provide a patch against git: http://projects.archlinux.org/?p=initscripts.git
Comment by kujub (kujub) - Wednesday, 05 August 2009, 21:13 GMT
Patch against git. (Untested though because I use a custom rc.d script to work around the problem now.)
Comment by Aaron Griffin (phrakture) - Wednesday, 05 August 2009, 21:19 GMT
Hmm, the only thing left to implement is the MODULES/MODULES2 thing. I'm not too sure I want to do this. Can you give me specific examples as to what problems this solves?
Comment by kujub (kujub) - Wednesday, 05 August 2009, 21:41 GMT
The only one I know about is the snd-hda-intel pc-beep against pcspkr race. I don't know if more modules loading order problems exist that can't be solved by other means. (As said above, I can live without the patch. Just reloading pcspkr does the trick.)
Comment by Aaron Griffin (phrakture) - Wednesday, 05 August 2009, 21:58 GMT
Well, wouldn't specifying those modules in order in the existing MODULES line solve this? Even if udev loads one or both, a reload of both modules would solve it, right? Or do you mean an actual unload/load?

More to the point though, this seems a bit like a work around for module bugs to me than anything else. I'm sure there's a way, with module params, to tell snd-hda-intel to not touch the pcspkr
Comment by Roman Kyrylych (Romashka) - Thursday, 06 August 2009, 07:41 GMT
I don't like the MODULES2 idea.
The PC speaker beep problem is something not worth to add extra var.
See the bottom of this section: http://wiki.archlinux.org/index.php/ALSA#Set_the_default_sound_card
that appeared after http://bugs.archlinux.org/task/12454
Another PC beep related problem was described in this thread: http://www.archlinux.org/pipermail/arch-general/2009-July/006678.html
but it cannot be solved my modules loading order.

I am not aware of any other (not PC speaker related) problems that might warrant adding MODULES2.
brain0 already listed solutions for hard drives and network cards above (http://bugs.archlinux.org/task/12706#comment45987)
Comment by kujub (kujub) - Thursday, 06 August 2009, 08:45 GMT
@Aaron: I really meant unloading and loading again. I agree it's a bug in snd-hda-intel - discussed that on tha ALSA devel list 6 weeks abo. Result was something like: "If you don't like the behavior of snd-hda-intel change the config and build your own kernel." The module option you describe was my expectation too, but there is no such.

@Roman:
modinfo snd-pcsp
modinfo: could not find module snd-pcsp

Because I already found another workaround, my vote on this is now: +-0
Comment by Roman Kyrylych (Romashka) - Thursday, 06 August 2009, 09:27 GMT
@Kurt: I believe ALSA devs referred to the option that was mentioned in this thread: http://www.archlinux.org/pipermail/arch-general/2009-July/006678.html
as for module name - probably it was changed :-/
Comment by kujub (kujub) - Thursday, 06 August 2009, 10:31 GMT
@Roman: I agree to yout 1st point.
2nd point: http://bugs.archlinux.org/task/14958 says it was removed.
grep CONFIG_SND_PCSP /var/abs/core/kernel26/config
# CONFIG_SND_PCSP is not set
I think this is kind of a ALSA sound card driver for the PC speaker. But what I talk about here is the PC beep (console bell or sound from beep binary) which can go thru snd-hda-intel to the stereo jacks since 2.6.30 instead of thru pcspkr to the built in speaker. snd-hda-intel is actually stealing the functionality from module pcspkr.
Comment by Roman Kyrylych (Romashka) - Thursday, 06 August 2009, 13:13 GMT
yes, this is because of CONFIG_SND_HDA_INPUT_BEEP=y in our kernel (btw, it produced a VERY annoying sound, but this is now fixed by upstream)
Comment by Roman Kyrylych (Romashka) - Thursday, 06 August 2009, 13:15 GMT
Anyway, we've got a little offtopic here,
I think the report can be closed as Implemented now.
Comment by Roman Kyrylych (Romashka) - Thursday, 06 August 2009, 13:33 GMT
@brain0: regarding http://bugs.archlinux.org/task/12706#comment45987
input devices were mentioned in http://bugs.archlinux.org/task/15828

Also problems with blacklisting were mentioned in http://bugs.archlinux.org/task/15829
not sure what this has to do with the patch applied.
Comment by kujub (kujub) - Thursday, 06 August 2009, 13:46 GMT
For me the beep sound from ALSA was ok. But I can not hear it if my speakers are switched off. ;-/
I agree the report can be closed since fixing weird kernel bugs isn't really the primary scope of initscripts. :-)
Comment by Gavin Bisesi (Daenyth) - Wednesday, 11 November 2009, 15:49 GMT
What's the status on this? Implemented?

Loading...