mdev -d can (silently) die with "read: no buffer space available"

Laurent Bercot ska-dietlibc at skarnet.org
Mon Dec 16 00:48:47 UTC 2019


>OTOH udevd seems to use a whooping 128MiB for the netlink socket receive
>buffer. And the ENOBUFS error is exactly what should be returned if the
>receive buffer overflows.

>From experiments I made when writing mdevd (which is a standalone
replacement for mdev), the netlink socket buffer needs to be 
surprisingly
large compared to the total size of events that go through it, about
2 to 3 times the size of events. No, I don't understand it either, and
I didn't go check the netlink code in the kernel to try and figure out
what's going on. But I need 200 kB to comfortably handle a spike of
events that's about 64 kB in total. (mdevd uses a default of 500 kB,
and it's tunable on the command line.)

So, it's not at all a surprise that udev, which doesn't care at all
about small systems, uses 128 MiB. It's so it can coldplug every
supported device in the Linux kernel at the same time, and survive the
spike. XD


>Hmm, adding a stat() for each event that is processed does not seem
>right. In the normal case there will never be a mdev.log...

mdev really should not log to its own file. It should log to stderr and
let its logs be picked up by a dedicated logger, like every other
correctly-written daemon.

--
Laurent



More information about the busybox mailing list