用户并发访问

发布于 2024-10-02 11:43:32 字数 40 浏览 0 评论 0原文

我正在尝试找出在 SMP 系统上删除模块的问题 有什么好的解释吗?

I'm trying to find out about the problems of removing a module on an SMP system
Any good explanations?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心奴独伤 2024-10-09 11:43:32

通常遇到的问题是系统上某处存在对正在运行的模块的一些引用。这可以是任何东西,从被持有的锁,某种正在运行的回调 - 使用符号的另一个模块等等。

内核内部有广泛的引用计数系统,应该用来帮助您确保这种情况永远不会发生。将使用您的模块的事物(或模块的某些方面)将保存相关的引用计数。当此计数非零时,内核将阻止您的表单执行“rmmod”。您可以在“lsmod”输出中看到所有已加载模块的引用计数。

学习它们并明智地使用它们。

这些问题并不是“SMP”特有的,而是任何内核模块特有的。例如,如果您的模块是字符驱动程序,并且有人打开了您的设备,您不希望在有人在其上打开文件描述符时卸载您的驱动程序 - 或者更糟糕 - read() 上有一个进程阻塞等待答复。在许多情况下 - 像这样 - 内核本身将为您保存引用。在这种情况下,打开驱动程序的进程将在驱动程序的模块上保存 refcnt。

The problems generally encountered is that there is some reference to the module in-flight somewhere on the system. This can be anything from a lock being held, some sort of callback in-flight - another module using a symbol, etc etc etc.

There are extensive reference counting systems inside the kernel which should be used to assist you in making sure this never occurs. Things that would use your module - or aspects of your module - would hold pertiant reference counts. The kernel will prevent your form doing an "rmmod" when this count is nonzero. You can see the reference count of all loaded modules in the "lsmod" outut.

Learn them and use them wisely.

These issues aren't really specific to "SMP" - but any kernel module. For example, if your module was a character driver, and someone opened your device, you wouldn't want your driver to unload while someone had a file descriptor opened on it - or worse yet - there was a process blocking on a read() awaiting a response. In many cases - like this - the kernel itself will hold references for you. In this case, a process opening a driver will hold a refcnt on the driver's module.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文