On Sun, 08 Mar 2015 16:10:32 +0100 Harald Becker <[email protected]> wrote:
> Hi, > > I'm currently in the phase of thinking about extending the functionality > of mdev. As here are the experts working with this kind of software, I > like to here your ideas before I start hacking the code. ... > 2) I like to use netlink to obtain hotplug information and avoid massive > respawning of mdev as hotplug helper when several events arrive quickly. I am interested in a netlink listener too for 2 reasons: - serialize the events - reduce number of forks for perfomance reasons > That is, I want to auto fork a daemon which just open the netlink > socket. When events arrive it forks again, creating a pipe. The new > instance read mdev.conf, build a table of rules in memory, then read > hotplug operations from the pipe (send by the first instance). When > there are no more events for more then a few seconds, the first instance > closes the pipe and the second instance exits (freeing the used memory). > On next hotplug event a new pipe / second instance is created. I have a simlar idea, but slightly different. I'd like to separate the netlink listener and the event handler. I am thinking of using http://git.r-36.net/nldev/ which basically does the same thing as s6-devd: minimal daemon that listens on netlink and for each event it fork/exec mdev. What I'd like to do is: change mdev to: - be able to read events from stdin. same format as from netlink socket. - set a timeout on stdin (1 sec or so by default). when time out is reached (no event within a sec) then just exit. change nldev to: - have a mdev pipe fd which we forward the kernel events to. - on kernel event if mdev_pipe_fd is -1 then: create pipe, fork and exec mdev with args to have mdev read from stdin (as explained above) else: write the kernel event to the pipe fd - the mdev pipe fd is added to the poll(2) call so we catch POLLHUP to detect mdev timeout. When that happens, set the mdev pipe fd to -1 so we know that it needs to be respawned on next kernel event. The benifits: - the netlink listener who needs to be running all times is very minimal. - when there are many events within short time, (eg coldplugging), we avoid the many forks and gain performance. - when there are no events, mdev will timeout and exit. - busybox mdev does not need set up netlink socket. (less intrusive changes in busybox) Then I'd like to do something similar with modprobe: - add support to read modalias from stdin and have 1 sec timeout. - have nldev to pipe/fork/exec modprobe --stdin on MODALIAS events. That way we can also avoid the many modprobe forks during coldplug. -nc _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
