lsmod在“使用者”列中显示-2


8

这是当我在内核4.3.0上运行的Arm Board(Banana Pi)上运行lsmod时发生的情况

# lsmod
Module                  Size  Used by
async_raid6_recov       1434  -2
async_pq                5548  -2
async_xor               3771  -2
async_memcpy            1665  -2
sha512_generic          8213  -2
rsa_generic             3235  -2
asn1_decoder            2667  -2
mpi                    13730  -2
poly1305_generic        3386  -2
pcbc                    2396  -2
michael_mic             2051  -2
md4                     3536  -2
ghash_generic           1908  -2
gcm                    10511  -2
fcrypt                  8128  -2
echainiv                2110  -2
crypto_user             4316  -2
crc32                   1581  -2
cmac                    2657  -2
chacha20poly1305        6641  -2
chacha20_generic        2902  -2
ccm                     7537  -2
async_tx                1958  -2
asymmetric_keys         3866  -2
arc4                    1882  -2
algif_aead              5293  -2
ablk_helper             1775  -2
cryptd                  7982  -2
dm_crypt               17382  -2
dm_mod                 84208  -2
algif_skcipher          7502  -2
evdev                  10705  -2
nvmem_sunxi_sid         2444  -2
nvmem_core              7792  -2
sg                     23835  -2
sun4i_ts                3948  -2
cpufreq_dt              4349  -2
ohci_platform           4551  -2
ohci_hcd               28715  -2
sun4i_ss               15192  -2
thermal_sys            30747  -2
hwmon                   2571  -2
uio_pdrv_genirq         2949  -2
uio                     7074  -2
#

这是/ proc / modules,以防万一它可以提供任何提示

# cat /proc/modules
async_raid6_recov 1434 - - Live 0xbf140000
async_pq 5548 - - Live 0xbf13b000
async_xor 3771 - - Live 0xbf137000
async_memcpy 1665 - - Live 0xbf133000
sha512_generic 8213 - - Live 0xbf12d000
rsa_generic 3235 - - Live 0xbf129000
asn1_decoder 2667 - - Live 0xbf125000 (P)
mpi 13730 - - Live 0xbf11d000
poly1305_generic 3386 - - Live 0xbf119000
pcbc 2396 - - Live 0xbf115000
michael_mic 2051 - - Live 0xbf111000
md4 3536 - - Live 0xbf10d000
ghash_generic 1908 - - Live 0xbf109000
gcm 10511 - - Live 0xbf102000
fcrypt 8128 - - Live 0xbf0fd000
echainiv 2110 - - Live 0xbf0f9000
crypto_user 4316 - - Live 0xbf0f4000
crc32 1581 - - Live 0xbf0f0000
cmac 2657 - - Live 0xbf0ec000
chacha20poly1305 6641 - - Live 0xbf0e7000
chacha20_generic 2902 - - Live 0xbf0e3000
ccm 7537 - - Live 0xbf0de000
async_tx 1958 - - Live 0xbf0da000
asymmetric_keys 3866 - - Live 0xbf0d6000
arc4 1882 - - Live 0xbf0d2000
algif_aead 5293 - - Live 0xbf0cd000
ablk_helper 1775 - - Live 0xbf0c9000
cryptd 7982 - - Live 0xbf0c3000
dm_crypt 17382 - - Live 0xbf0b9000
dm_mod 84208 - - Live 0xbf099000
algif_skcipher 7502 - - Live 0xbf094000
evdev 10705 - - Live 0xbf08d000
nvmem_sunxi_sid 2444 - - Live 0xbf089000
nvmem_core 7792 - - Live 0xbf083000
sg 23835 - - Live 0xbf078000
sun4i_ts 3948 - - Live 0xbf074000
cpufreq_dt 4349 - - Live 0xbf069000
ohci_platform 4551 - - Live 0xbf064000
ohci_hcd 28715 - - Live 0xbf057000
sun4i_ss 15192 - - Live 0xbf04f000
thermal_sys 30747 - - Live 0xbf040000
hwmon 2571 - - Live 0xbf026000
uio_pdrv_genirq 2949 - - Live 0xbf024000
uio 7074 - - Live 0xbf000000
# 

关键是我需要显示模块的“使用者”字段,否则我不在乎。

Answers:


7

在你的内核配置(make configmake menuconfig等),您需要启用CONFIG_MODULE_UNLOAD

  • CONFIG_MODULE_UNLOAD设置,内核数的引用,因为你可能只如果有对它的引用卸载模块。

  • 如果CONFIG_MODULE_UNLOAD未设置,则内核无需计算对一个模块的引用数量,并且它始终-2作为标记值返回。

这个答案最初来自Gentoo论坛


1

所述模块的引用计数是可用在/sys/module/<module>/refcnt用于可卸载的模块。内置模块或带有的内核上的模块CONFIG_MODULE_UNLOAD没有相应的refcnt文件。

要确定一个模块的引用计数,lsmod时下调用kmod_module_get_refcnt函数libkmod库; 后者尝试打开refcnt文件以读取引用计数。对于未卸载的模块,相应的文件操作失败并设置errnoENOENT(没有这样的文件或目录),在Linux上为2-取反kmod_module_get_refcnt,并将其作为参考计数返回。lsmod将该值作为参考计数输出。

这就是为什么未设置lsmod-2时显示模块的原因CONFIG_MODULE_UNLOAD

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.