mipadi mipadi - 7 months ago 50
Linux Question

Is there a way to figure out what is using a Linux kernel module?

If I load a kernel module and list the loaded modules with

, I can get the "use count" of the module (number of other modules with a reference to the module). Is there a way to figure out what is using a module, though?

The issue is that a module I am developing insists its use count is 1 and thus I cannot use
to unload it, but its "by" column is empty. This means that every time I want to re-compile and re-load the module, I have to reboot the machine (or, at least, I can't figure out any other way to unload it).


rmmod has a --force parameter. If you know the stuff your module does, and have a kernel configured to support forcing unload, that might work. That's to save you from having to restart until you fixed the problem with the ref-counting), but it won't show you the cause of the load of your module. I think it's not possible to get why the module was loaded in the first place (i.e which exact code-path). Maybe dmesg has logged something useful or you can add some useful logging into your module code.