Linux 如何重新加载修改后的内核模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4646036/
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-05 02:25:23  来源:igfitidea点击:

How to reload modified kernel modules

linuxlinux-kernelkernel-module

提问by apoorv020

How can I instruct the system to reload all kernel modules that have changed? (I am developing a driver with several modules. I want a quick and error-free method to reload all the modules that change.)

如何指示系统重新加载所有已更改的内核模块?(我正在开发具有多个模块的驱动程序。我想要一种快速且无错误的方法来重新加载所有更改的模块。)

采纳答案by Aaron Digulla

There is no simple, error-free way since a bug in the code that adds/removes the driver from the kernel can make it impossible to get rid of a module. In a similar way, a bug in the driver can cause a deadlock in some interrupt handler so the kernel can never unload the module.

没有简单的、无错误的方法,因为在内核中添加/删除驱动程序的代码中的错误可能导致无法摆脱模块。以类似的方式,驱动程序中的错误可能导致某些中断处理程序中的死锁,因此内核永远无法卸载模块。

Also, there is no automatic way to do it since the kernel doesn't check the modules files for changes.

此外,由于内核不会检查模块文件的更改,因此无法自动执行此操作。

All you can do is write a small script that calls rmmodin the correct order to remove the modules and then modprobe's the new versions into the kernel.

您所能做的就是编写一个小脚本,rmmod以正确的顺序调用以删除模块,然后modprobe将新版本放入内核。

回答by Nnaik

Using rmmod to remove the added modules and using modprobe to load the debugged modules again is the only effective solution.

使用 rmmod 删除添加的模块并使用 modprobe 再次加载已调试的模块是唯一有效的解决方案。