Linux 无法“rmmod”模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13847217/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 18:01:59  来源:igfitidea点击:

unable to "rmmod" the module

linuxlinux-kernelkernel-module

提问by Mark

I'm working with a large embedded software (ARM processor, embedded linux 2.6.31, busybox) involving both kernel and user space code. There's a kernel module normally loaded first, and daemon establishing netlink socket with the module.

我正在使用涉及内核和用户空间代码的大型嵌入式软件(ARM 处理器、嵌入式 linux 2.6.31、busybox)。通常首先加载一个内核模块,然后守护进程与该模块建立 netlink 套接字。

The issue here is that after killing the daemon, I'm no longer able to unload the module from the memory:

这里的问题是在杀死守护进程后,我无法再从内存中卸载模块:

% rmmod _module.ko
% rmmod: _module.ko: Resource temporarily unavailable

Analysis has shown that error (return value is -11, i.e. EAGAIN?) is returned by try_stop_module()invoked in syscall delete_module()definition in kernel/module.c. Function try_stop_module() in turn calls stop_machine() and this is where I've stuck, as

分析表明,错误(返回值是-11,即EAGAIN?)是由try_stop_module()中的系统调用delete_module()定义中调用返回的kernel/module.c。函数 try_stop_module() 依次调用 stop_machine() 这就是我卡住的地方,因为

I'm not sure what's exactly happening there. I think the root cause is somewhere in the daemon that opens connections to the module and obviously something else and doesn't correctly close/clean-up on exit (apparently some references/locks are not released?)

我不确定那里到底发生了什么。我认为根本原因是在守护进程中的某个地方打开了与模块的连接,显然还有其他东西并且在退出时没有正确关闭/清理(显然一些引用/锁没有被释放?)

Does anybody have any idea what else to look at and probe?

有没有人知道还有什么可以查看和探索的?

回答by ymn

First of all you should be a superuser to do this. Also you can use rmmod -fbut this option can be extremely dangerous: it has no effect unless CONFIG_MODULE_FORCE_UNLOADwas set when the kernel was compiled. With this option, you can remove modules which are being used, or which are not designed to be removed, or have been marked as unsafe.

首先,您应该是执行此操作的超级用户。您也可以使用,rmmod -f但此选项可能非常危险:除非CONFIG_MODULE_FORCE_UNLOAD在编译内核时设置,否则它无效。使用此选项,您可以删除正在使用的模块,或未设计为删除的模块,或已标记为不安全的模块。

Also read man rmmod.

也读man rmmod

回答by Nandan_G

Check whether all the interfaces related to your module is not 'up'.

检查与您的模块相关的所有接口是否都没有“up”。

if any of the interface which is related to your module is 'up',then rmmod will fail and returns with -11.

如果与您的模块相关的任何接口为“up”,则 rmmod 将失败并返回 -11。

So before calling rmmod, check the active interfaces using 'netcfg' command. then using ifconfig,make your interface down as 'ifconfig <interface_name> down'

因此,在调用 rmmod 之前,请使用“netcfg”命令检查活动接口。然后使用 ifconfig,将您的界面设置为'ifconfig <interface_name> down'

then try to run rmmod <module_name>. it will work!!

然后尝试运行rmmod <module_name>。它会起作用!!

1.netcfg <lists out all interfaces>
2.ifconfig <interface_name> down
3.rmmod <module_name>