lsmod는 "사용자" 열에 -2를 표시합니다.

lsmod는 "사용자" 열에 -2를 표시합니다.

커널 4.3.0을 실행하는 Arm 보드(바나나 파이)에서 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
# 

문제는 모듈의 "소비자" 필드를 표시해야 한다는 것입니다. 그렇지 않으면 신경 쓰지 않을 것 같습니다.

답변1

커널 구성( make configmake menuconfig)에서 다음을 활성화해야 합니다 CONFIG_MODULE_UNLOAD.

  • set 을 사용하면 CONFIG_MODULE_UNLOAD참조가 없는 경우에만 모듈을 언로드할 수 있으므로 커널은 참조를 계산합니다.

  • 설정하지 않으면 CONFIG_MODULE_UNLOAD커널은 모듈에 대한 참조 수를 계산할 필요가 없으며 항상 -2태그된 값으로 반환됩니다.

대답은 다음과 같습니다.젠투 포럼에서.

답변2

모듈 참조 카운팅은 에서 찾을 수 있습니다 /sys/module/<module>/refcnt.제거할 수 있는 모듈의 경우. 내장 모듈 또는 해당 모듈이 포함된 커널의 모듈에 CONFIG_MODULE_UNLOAD해당 파일이 없습니다 refcnt.

모듈의 참조 횟수를 확인하려면 lsmod이제 다음을 호출하세요.kmod_module_get_refcnt기능libkmod라이브러리 에서 후자는 refcnt참조 카운트를 읽기 위해 파일을 열려고 시도합니다. 언로드되지 않은 모듈의 경우 해당 파일 작업이 실패하고 설정됩니다.errno(해당 파일이나 디렉터리 없음 ENOENT)(Linux에서는 2) - kmod_module_get_refcnt이를 부정하고 참조 카운트로 반환합니다. lsmod값을 가져와 참조 카운트로 출력합니다.

이것이 lsmod모듈이 설정되지 않은 경우 -2를 표시하는 이유입니다.CONFIG_MODULE_UNLOAD

관련 정보