It is a counter. It can be incremented or decremented by the kernel core API.
It is the responsibility of the modules, when do they increment it. For example, if you have a
somefs module in the kernel, then the awaited behavior is to increment this counter with any mount of a
somefs partition, and decrement it on unmount. On this way,
somefs can guarantee that it won't be removed while there is a mounted
If the module usage counter is non-zero,
rmmod fails on that module. But
rmmod -f not, if forced module removal is compiled into the kernel.
Thus, the important things:
- The increment and decrement of the counter is the responsibility of the modules, there is no sophisticated, generic reference tracking behind it.
- In many cases, it works correctly, but not always. For example, some dirty modules, like
ipv6 works on that way, that it increases the counter to 1 on
insmod and never decreases. Thus, if you compiled
ipv6 as module, you won't be ever able to
rmmod it. Some video card driver works on similar way, because its routines what would deinitialize it, are missing. No such module can be a source of pride for its developers.
- If you can't remove a module because of this, there is no general way to find out, what is exactly used by a module.