linux-old/Documentation/kmod.txt
<<
>>
Prefs
   1Kmod: The Kernel Module Loader
   2Kirk Petersen
   3
   4Kmod is a simple replacement for kerneld.  It consists of a 
   5request_module() replacement and a kernel thread called kmod.  When the
   6kernel requests a module, the kmod wakes up and execve()s modprobe,
   7passing it the name that was requested.
   8
   9If you have the /proc filesystem mounted, you can set the path of
  10modprobe (where the kernel looks for it) by doing:
  11
  12        echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
  13
  14To periodically unload unused modules, put something like the following
  15in root's crontab entry:
  16
  17        0-59/5 * * * * /sbin/rmmod -a
  18
  19Kmod only loads modules.  Kerneld could do more (although
  20nothing in the standard kernel used its other features).  If you
  21require features such as request_route, we suggest that you take
  22a similar approach.  A simple request_route function could be called,
  23and a kroute kernel thread could be sent off to do the work.  But
  24we should probably keep this to a minimum.
  25
  26Kerneld also had a mechanism for storing device driver settings.  This
  27can easily be done with modprobe.  When a module is unloaded, modprobe
  28could look at a per-driver-configurable location (/proc/sys/drivers/blah)
  29for device driver settings and save them to a file.  When a module
  30is loaded, simply cat that file back to that location in the proc
  31filesystem.  Or perhaps a script could be a setting in /etc/modules.conf.
  32There are many user-land methods that will work (I prefer using /proc,
  33myself).
  34
  35If kerneld worked, why replace it?
  36
  37- kerneld used SysV IPC, which can now be made into a module.  Besides,
  38  SysV IPC is ugly and should therefore be avoided (well, certainly for
  39  kernel level stuff)
  40
  41- both kmod and kerneld end up doing the same thing (calling modprobe),
  42  so why not skip the middle man?
  43
  44- removing kerneld related stuff from ipc/msg.c made it 40% smaller
  45
  46- kmod reports errors through the normal kernel mechanisms, which avoids
  47  the chicken and egg problem of kerneld and modular Unix domain sockets
  48
  49
  50Keith Owens <kaos@ocs.com.au> December 1999
  51
  52The combination of kmod and modprobe can loop, especially if modprobe uses a
  53system call that requires a module.  If modules.dep does not exist and modprobe
  54was started with the -s option (kmod does this), modprobe tries to syslog() a
  55message.  syslog() needs Unix sockets, if Unix sockets are modular then kmod
  56runs "modprobe -s net-pf-1".  This runs a second copy of modprobe which
  57complains that modules.dep does not exist, tries to use syslog() and starts yet
  58another copy of modprobe.  This is not the only possible kmod/modprobe loop,
  59just the most common.
  60
  61To detect loops caused by "modprobe needs a service which is in a module", kmod
  62limits the number of concurrent kmod issued modprobes.  See MAX_KMOD_CONCURRENT
  63in kernel/kmod.c.  When this limit is exceeded, the kernel issues message "kmod:
  64runaway modprobe loop assumed and stopped".
  65
  66Note for users building a heavily modularised system.  It is a good idea to
  67create modules.dep after installing the modules and before booting a kernel for
  68the first time.  "depmod -ae m.n.p" where m.n.p is the new kernel version.
  69
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.