Linux kernel try_模块_get()中的内核分页请求失败

Linux kernel try_模块_get()中的内核分页请求失败,linux-kernel,Linux Kernel,以下代码在我的一个linux内核模块中失败 printk("This module: %p\n",THIS_MODULE); DEBUG_USE_COUNT(p); printk("This module refcount: %d\n", module_refcount(THIS_MODULE)); DEBUG_USE_COUNT(p); if (!try_module_get(THIS_MODULE)) { printk_stderr("can't get module\n");

以下代码在我的一个linux内核模块中失败

printk("This module: %p\n",THIS_MODULE);
DEBUG_USE_COUNT(p);
printk("This module refcount: %d\n", module_refcount(THIS_MODULE));
DEBUG_USE_COUNT(p);
if (!try_module_get(THIS_MODULE)) {
    printk_stderr("can't get module\n");
    return -EFAULT;
}
代码本身在通常的环境中工作,但当我试图在从另一个模块中调用的函数中执行它时,它失败并出现分页错误。(另一个模块在初始化过程中被传递到相关函数的指针) 知道为什么模块不能增加从另一个模块调用的引用计数吗? 是否有任何特殊限制适用于尝试\u get \u模块调用

[ 7888.065029] BUG: unable to handle kernel paging request at fa69206
8
[ 7888.067470] IP: [<f926a2b6>] _ZL18open_station_sharePKcP23__camac_
kernel_open_argP4file+0x84/0x8ec [camac_k0607_lsi6] //function in question, calling try_module_get()
[ 7888.069014] Call Trace:
[ 7888.069014]  [<c10ac2b7>] ? __kmalloc+0x104/0x110
[ 7888.069014]  [<c12518f5>] ? printk+0xe/0x11
[ 7888.069014]  [<f90fae79>] ? T.633+0x46/0x4b [camac_mx]
[ 7888.069014]  [<f90fb07e>] ? camac_mx_ioctl+0x200/0x228 [camac_mx] //function of another module that calls the one in question
[ 7888.069014]  [<c10ba415>] ? vfs_ioctl+0x58/0x72
[ 7888.069014]  [<c10ba966>] ? do_vfs_ioctl+0x492/0x4d6
[ 7888.069014]  [<c109007b>] ? shmem_parse_options+0x167/0x281
[ 7888.069014]  [<c10ae69e>] ? fd_install+0x1b/0x38
[ 7888.069014]  [<c10ae88b>] ? do_sys_open+0xc8/0xdd
[ 7888.069014]  [<c10ba9ee>] ? sys_ioctl+0x44/0x64
[ 7888.069014]  [<c100305b>] ? sysenter_do_call+0x12/0x28
[7888.065029]错误:无法处理fa69206上的内核分页请求
8.
[7888.067470]IP:[]ZL18open\U车站\U sharePKcP23\U camac_
kernel_open_argP4file+0x84/0x8ec[camac_k0607_lsi6]//有问题的函数,调用try_module_get()
[7888.069014]呼叫跟踪:
[ 7888.069014]  [] ? __kmalloc+0x104/0x110
[ 7888.069014]  [] ? printk+0xe/0x11
[ 7888.069014]  [] ? T.633+0x46/0x4b[camac_mx]
[ 7888.069014]  [] ? camac_mx_ioctl+0x200/0x228[camac_mx]//调用相关模块的另一个模块的函数
[ 7888.069014]  [] ? vfs_ioctl+0x58/0x72
[ 7888.069014]  [] ? do_vfs_ioctl+0x492/0x4d6
[ 7888.069014]  [] ? shmem_解析_选项+0x167/0x281
[ 7888.069014]  [] ? fd_安装+0x1b/0x38
[ 7888.069014]  [] ? 系统是否打开+0xc8/0xdd
[ 7888.069014]  [] ? 系统ioctl+0x44/0x64
[ 7888.069014]  [] ? sysenter\u do\u call+0x12/0x28

如果有人解释打印堆栈顶部的垃圾,我也会很高兴。跨模块调用中不应有任何函数。堆栈上的前三个函数对我来说毫无意义。

如果特定的源文件被编译到内核中而不是作为模块的一部分,并且模块refcount不喜欢得到NULL,那么该模块可能会计算为NULL


也不推荐在内核模块中使用C++,因为它可能干扰所有的事情(考虑异常和所有这些)。我想,ZL18OpenStUnjSypPkCP23的一个正确的地址和一个CAMAC KNELL OPENARQ4FILE(是内核中的C++)的解析器会有帮助。