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

