added code again, which got removed my big merge:-(
[linux-2.6/linux-mips.git] / Documentation / kmod.txt
blob759a300b18cb2dfb9980ca9252c47015bd6d90b7
1 Kmod: The Kernel Module Loader
2 Kirk Petersen
4 Kmod is a simple replacement for kerneld.  It consists of a 
5 request_module() replacement and a kernel thread called kmod.  When the
6 kernel requests a module, the kmod wakes up and execve()s modprobe,
7 passing it the name that was requested.
9 If you have the /proc filesystem mounted, you can set the path of
10 modprobe (where the kernel looks for it) by doing:
12         echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
14 To periodically unload unused modules, put something like the following
15 in root's crontab entry:
17         0-59/5 * * * * /sbin/rmmod -a
19 Kmod only loads modules.  Kerneld could do more (although
20 nothing in the standard kernel used its other features).  If you
21 require features such as request_route, we suggest that you take
22 a similar approach.  A simple request_route function could be called,
23 and a kroute kernel thread could be sent off to do the work.  But
24 we should probably keep this to a minimum.
26 Kerneld also had a mechanism for storing device driver settings.  This
27 can easily be done with modprobe.  When a module is unloaded, modprobe
28 could look at a per-driver-configurable location (/proc/sys/drivers/blah)
29 for device driver settings and save them to a file.  When a module
30 is loaded, simply cat that file back to that location in the proc
31 filesystem.  Or perhaps a script could be a setting in /etc/modules.conf.
32 There are many user-land methods that will work (I prefer using /proc,
33 myself).
35 If kerneld worked, why replace it?
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)
41 - both kmod and kerneld end up doing the same thing (calling modprobe),
42   so why not skip the middle man?
44 - removing kerneld related stuff from ipc/msg.c made it 40% smaller
46 - kmod reports errors through the normal kernel mechanisms, which avoids
47   the chicken and egg problem of kerneld and modular Unix domain sockets