如何使用find_module?
如何使用linux内核的find_module()
函数? 文档说“必须持有 module_mutex”。
- 这是否意味着我应该获得 之前我的模块代码中的锁 寻找指向另一个的指针?
- 当该互斥体被锁定时 非模块内核代码?
上下文
我正在调试一组协同工作的内核模块。
模块A调用模块B的函数。在模块A的函数C中的某个时刻,模块B的使用计数无效。我确定这不会发生在模块 B 的功能。我想从 C 调试模块 B 的使用计数。为此,我将使用 find_module() 获取指向 B 的指针。
How to use linux kernel's find_module()
function?
The documentation says "must hold module_mutex".
- Does that mean that I should acquire
a lock in my module code before
searching for a pointer to another? - When this mutex is locked by
non-module kernel code?
Context
I'm debugging a set of kernel modules working together.
Module A call functions of module B. At some point in function C of module A a use count of module B goes invalid. I've determined that this is not happening in function of module B. I'd like to debug use count of module B from C. To do this I'm going to use find_module() to obtain a pointer to B.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议在代码中采取更多的防御措施:
module_mutex 是由内核在模块的各种操作中获取的。所有这些都位于 /kernel/module.c 中,并且是:
I would suggest being a little more defensive in your code:
module_mutex is acquired by the kernel in various operations on modules. All of them are in /kernel/module.c and are:
1)是的。在调用
find_module()
之前在模块中获取module_mutex
2) 它不在模块代码之外使用
示例:
1) Yes. Get
module_mutex
in your module before callingfind_module()
2) It's not used outside the module code
Example: