⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kmod.txt

📁 嵌入式系统设计与实验教材二源码linux内核移植与编译
💻 TXT
字号:
Kmod: The Kernel Module LoaderKirk PetersenKmod is a simple replacement for kerneld.  It consists of a request_module() replacement and a kernel thread called kmod.  When thekernel requests a module, the kmod wakes up and execve()s modprobe,passing it the name that was requested.If you have the /proc filesystem mounted, you can set the path ofmodprobe (where the kernel looks for it) by doing:	echo "/sbin/modprobe" > /proc/sys/kernel/modprobeTo periodically unload unused modules, put something like the followingin root's crontab entry:	0-59/5 * * * * /sbin/rmmod -aKmod only loads modules.  Kerneld could do more (althoughnothing in the standard kernel used its other features).  If yourequire features such as request_route, we suggest that you takea similar approach.  A simple request_route function could be called,and a kroute kernel thread could be sent off to do the work.  Butwe should probably keep this to a minimum.Kerneld also had a mechanism for storing device driver settings.  Thiscan easily be done with modprobe.  When a module is unloaded, modprobecould look at a per-driver-configurable location (/proc/sys/drivers/blah)for device driver settings and save them to a file.  When a moduleis loaded, simply cat that file back to that location in the procfilesystem.  Or perhaps a script could be a setting in /etc/modules.conf.There are many user-land methods that will work (I prefer using /proc,myself).If kerneld worked, why replace it?- kerneld used SysV IPC, which can now be made into a module.  Besides,  SysV IPC is ugly and should therefore be avoided (well, certainly for  kernel level stuff)- both kmod and kerneld end up doing the same thing (calling modprobe),  so why not skip the middle man?- removing kerneld related stuff from ipc/msg.c made it 40% smaller- kmod reports errors through the normal kernel mechanisms, which avoids  the chicken and egg problem of kerneld and modular Unix domain socketsKeith Owens <kaos@ocs.com.au> December 1999The combination of kmod and modprobe can loop, especially if modprobe uses asystem call that requires a module.  If modules.dep does not exist and modprobewas started with the -s option (kmod does this), modprobe tries to syslog() amessage.  syslog() needs Unix sockets, if Unix sockets are modular then kmodruns "modprobe -s net-pf-1".  This runs a second copy of modprobe whichcomplains that modules.dep does not exist, tries to use syslog() and starts yetanother copy of modprobe.  This is not the only possible kmod/modprobe loop,just the most common.To detect loops caused by "modprobe needs a service which is in a module", kmodlimits the number of concurrent kmod issued modprobes.  See MAX_KMOD_CONCURRENTin kernel/kmod.c.  When this limit is exceeded, the kernel issues message "kmod:runaway modprobe loop assumed and stopped".Note for users building a heavily modularised system.  It is a good idea tocreate modules.dep after installing the modules and before booting a kernel forthe first time.  "depmod -ae m.n.p" where m.n.p is the new kernel version.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -