mdev race conditions
Bernard Blackham
bernard at largestprime.net
Tue Jun 3 14:44:26 UTC 2008
Hi,
When I switched from udev+udevd to mdev, booting was much faster and it
shaved a decent amount from the total image size. However, I've recently
noticed device nodes sometimes disappearing on boot. The specific
scenario is:
1. /dev/ttyS1 exists as a device node in the filesystem on boot - prior
to the actual device existing, and prior to mdev being called.
2. echo /bin/mdev > /proc/sys/kernel/hotplug
3. a module is loaded that provides ttyS1
When this module is loaded, most of the time the existing ttyS1 remains.
Sometimes however, it is unlinked from the filesystem and is never seen
again (until mdev -s is run, or next boot, maybe).
I pointed my hotplug to a script to log what mdev was being called as,
and found that when the module is loaded, there is actually a remove
event emitted followed by an add event. As there is no locking with
mdev, sometimes mdev runs the remove after the add and thus the device
node goes missing.
udev seems to have gotten around this using a daemon that serialises
events based on the sequence number provided by the kernel.
Is there a lightweight way that mdev can do this or another way to work
around this problem? I'd also prefer not to have a udevd running 24/7
unnecessarily, as I imagine most low-memory systems would.
Perhaps something like an on-demand udevd that exists during the flurry
of uevents from the kernel, waits for things to settle, and then
processes things in order and exits?
I can't think of a clean way to do this reliably though.
Regards,
Bernard.
More information about the busybox
mailing list