2
下面的代碼失敗在我的Linux內核模塊內核傳呼請求try_module_get失敗()
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;
}
本身工作在通常環境中的代碼之一,但是當我嘗試從調用的函數來執行它在另一個模塊中,它會因分頁錯誤而失敗。 (另一個模塊在初始化期間傳遞指向正在討論的函數的指針) 任何想法爲什麼模塊不能增加從另一個模塊調用的引用計數? 是否有任何適用於try_get_module調用的特殊限制?
[ 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
我也將是巨大的,如果有人介紹了在印刷堆棧的頂部垃圾。跨模塊調用中不應該有任何功能。堆棧中的三大功能對我來說毫無意義。
你或許應該發佈更多細節。我猜源和_ZL18open_station_sharePKcP23__camac_ kernel_open_argP4file的正確地址的拆裝(是C++內核?)會有所幫助。 – ninjalj 2010-11-06 15:20:05