When I try to rmmod a module I get the error message "Error: Module in use" , lsmod | grep <module name>
shows the count.
Is there a way that would tell me which processes are using this particular kernel module/driver?
To list all currently loaded modules in Linux, we can use the lsmod (list modules) command which reads the contents of /proc/modules like this.
In the case of pid, you can use: pid = task_pid_nr(current); to get the current task's pid. here is the comment taken from include/linux/sched.
Use the lsmod command to see what kernel modules are currently loaded. This is a list of the kernel module drivers which are currently loaded, as produced by the lsmod command.
Instead, use the modprobe command followed by the kernel module name. modprobe attempts to load the module from /lib/modules/<kernel-version>/kernel/drivers/ . This command will automatically check for module dependencies and load those drivers first before loading the specified module.
lsof /dev/ might help you to find the dependent process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With