Is there a reason to do 'udevadm settle' vs allowing it to settle in background?
laserbat opened this issue · 6 comments
From this discussion: rickysarraf/laptop-mode-tools#137
It seems that it would be better to allow udev settle in background while system is booting and use something like udevadm settle -t 0 || exit
for services that absolutely must start after all devices are settled.
Seems like an optimization that makes things less stable.
You should not use udevadm settle
in the background. That forfeits the purpose.. I agree with @Vaelatern that this is an optimization that makes things less stable. Dependent Device Discovery should be done very very early. And for everything asynchronous, you have your init
manager.
@rickysarraf I didn't imply that it should be run in the backgound. What I meant is to skip it at all and leave udevadm settle
in initramfs, to discover essential devices .
After the initramfs step, we have all devices necessary for boot of the system discovered and set up. On my system there are very few udev rules that are included in initramfs. (to compare, rules.d in my rootfs)
After initramfs stage, we then restart udevd and let it detect non-essential devices in the background. Without calls to udevadm settle
blocking the whole boot process for seconds.
And after that, we can use runit default dependency resolution to to start services that depend on having udevd finished loading rules after it has settled everything (i.e. udevadm settle -t 0
produces 0 exit code).
I believe that this optimisation is important, because it can save seconds of boot time spent wasted on detecting steam controllers and applying laptop-mode rules, things that are absolutely not necessary for system boot and shouldn't block the whole process.
I don't want my favorite distro to have noticeably slower boot time than, say, arch linux or debian, just because it unnecessarily runs udevadm settle
twice.
But runit does not provide the same kind of dependency management as systemd.
runit services do not mount filesystems and the early system initialization isn't done in parallel.
The scripts wait for udev to settle in /etc/runit/core-services/02-udev.sh
and then mount filesystems other than root in /etc/runit/core-services/03-filesystems.sh
, some of them which might be crucial to a usable system, /home
as example.
udevadm settle
on a settled machine takes about 0.005
seconds. Before the machine is settled, anything could happen. Older systems solved this by always having devices be well known. We can't.
I think this issue should be closed.
Okay, thank you all for explanations