英文:
Does /proc/modules only list kernel modules that are correctly loaded?
问题
The red hat documentation regarding this file is vague. At first, it states that:
> This file displays a list of all modules loaded into the kernel
但后来在文档中,它说:
> 第三列列出了当前加载的模块实例数量。值为零表示未加载的模块。
所以我的问题是:
-
如果一个模块的第三个值为0,这是否意味着它现在在内核中已经不再加载了?如果是的话,为什么它们仍然都有内核地址?
-
如果 /proc/modules 只显示当前加载的内核模块,那么我如何找到在启动后会自动加载的所有内核模块的列表?
英文:
The red hat documentation regarding this file is vague. At first, it states that:
> This file displays a list of all modules loaded into the kernel
But then later in the doc, it says:
> The third column lists how many instances of the module are currently
> loaded. A value of zero represents an unloaded module.
So my questions are:
-
If the third value for a module is 0, does this mean that it is no longer loaded in the kernel right now? If so, then why do all of them still have a kernel address?
-
If /proc/modules only shows the currently loaded kernel modules, how can I find the list of all the kernel modules that will get loaded automatically after boot?
答案1
得分: 2
根据/kernel/module/procfs.c,这第三个值不是实例的数量,而是模块的引用计数(module_refcount
)。
如果一个模块的引用计数大于0,那么它不能安全卸载(其他模块期望它仍然存在),但如果引用计数为0,该模块可以卸载,但目前仍然加载着。
不知道为什么这个文档记错了。
一个名为systemd-modules-load.service
的systemd服务在启动时加载模块。这里有一些关于它如何工作以及在哪里查找的文档。
然而,对于没有systemd的系统,有一个不同的服务,我相当确定您有其他加载模块的方式。
英文:
1.
According to /kernel/module/procfs.c this third value is not the number of instances, but the reference count of the module (module_refcount
).
If a module has a reference count > 0 than it can't be unload safely (other modules expect it to be there), but if the reference count is 0 the module can be unloaded, but it's still loaded as of now.
Don't know why this documentation got it wrong.
2.
A systemd service called systemd-modules-load.service
loads modules at boot time. here is some documentation that shows how it works and where to look.
However, there is a different service for systems withoud systemd and I'm pretty sure you have some other ways of loading a modules.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论