RFD: Rework/extending functionality of mdev

Natanael Copa ncopa at alpinelinux.org
Thu Mar 12 09:14:39 UTC 2015


On Thu, 12 Mar 2015 00:15:52 +0100
Harald Becker <ralda at gmx.de> wrote:

> Hi Michael !
> 
> On 11.03.2015 22:44, Michael Conrad wrote:
> > I'm interested in this thread, but there is too much to read.  Can you
> > explain your reason in one concise paragraph?
> 
> One paragraph is a bit to short, my English sucks, but I try to 
> summarize the intention of my approach in compact steps (a bit more than 
> one screen page of text):
> 
> - current kernel hotplug based mdev suffers from parallel start and 
> reading / scanning the conf on each instance
> 
> - the known and proven solution to this is using a netlink reader daemon 
> (long lived daemon which stays active all the time)
> 
> - there are still people who insist staying on the kernel hotplug 
> feature (for whatever reason, so accept we need hotplug + netlink)
> 
> - The third method (scanning sys file system) is the operation of "mdev 
> -s" (initial population of device file system, don't mix with "mdev" w/o 
> parameters), in addition some user take this as semi automatic device 
> management (embedded world)

I disagree here. mdev -s solves a different problem.

there are 2 different problems.

1) handle hotplug events.

   There are only 2 methods for this problem:
      A) using 1 fork per event (eg /sbin/mdev
        in /proc/sys/kernel/hotplug). this is simple but slow.
        
      B) reading hotplug events via netlink using a long lived daemon.
      (like udev does)

   Example situations those 2 methods handles are:
      - user insers usb pen drive.
      - user insert usb NIC
      - user insert web camera

   the hotplug handler should set the proper permissions in /dev/ and
   load the proper drivers (MODALIAS events)

   mdev can handle all this using method (a).

2) do cold plugging. at boot you need configure the devices kernel
   already know about.

   There are atleast 2 different methods for this problem:
       A) scan sysfs and set up found devices.

          mdev -s
          find /sys -name modalias ...

       B) solve problem 1 mentioned above (set up a hotplug handler)
       and then trigger the hotplug events. Now you don't need scan the
       sysfs at all.

What I currently do is:
- for problem 1 (dealing with hotplug events) I use method A.

- for problem 2 (set up devices at boot) I use method A because my
  hotplug handler is slow due to many forks.

What I would like to do is switch to method B for both problem 1 and
method B for problem 2 too. However, I want the long lived daemon
consume less memory and i want be able to use the mdev.conf syntax for
configuring the devices.


> - So how can we have all three methods without duplication of code, plus 
> how can we speed up the kernel hotplug method?

IMHO, there are not 3 methods so the rest of discussion is useless.


-nc


More information about the busybox mailing list