Linux-Modules Archive on lore.kernel.org
 help / color / Atom feed
From: Konstantin Kharlamov <hi-angel@yandex.ru>
To: linux-modules@vger.kernel.org
Subject: [RFE] Who's using a module?
Date: Wed, 11 Mar 2020 16:27:24 +0300
Message-ID: <b623f4a2-8b9b-edd9-3546-281155d90d4a@yandex.ru> (raw)

Once in a while there's a need to remove a module (for example because you rebuilt it, or to reload it with different parameters, or whatever…). And then doing `rmmod modulename` and `modprobe -r modulename` gives:

	rmmod: ERROR: Module modulename is in use

If you're lucky, firing up `lsmod | grep modulename` will get you offenders inside "used by" column. But often there's nothing except the count above zero. It is very easy to reproduce if you check `lsmod` output for your graphics driver. I checked it on `i915` and `amdgpu`: when graphics session is opened you can't remove it and `lsmod` doesn't show who's using it.

There's very popular and old question on SO¹ that at the moment has over 55k views, and the only answer that seem to work for people is insanely big and convoluted; it is using a custom kernel driver and kernel tracing capabilities. I guess this amount of research means: no, currently there's no easy way to get who's using a module.

It would be amazing if kernel has capability to figure out who's using a module.

1: https://stackoverflow.com/questions/448999/is-there-a-way-to-figure-out-what-is-using-a-linux-kernel-module

P.S.: please, add me to CC when replying, I'm not subscribed to the list.

             reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 13:27 Konstantin Kharlamov [this message]
2020-03-12  6:53 ` Konstantin Kharlamov
2020-03-13 16:22 ` Lucas De Marchi
2020-03-13 17:29   ` Steven Rostedt
2020-03-16  8:49   ` David Laight
2020-03-16 17:34   ` Jessica Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b623f4a2-8b9b-edd9-3546-281155d90d4a@yandex.ru \
    --to=hi-angel@yandex.ru \
    --cc=linux-modules@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Modules Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-modules/0 linux-modules/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-modules linux-modules/ https://lore.kernel.org/linux-modules \
		linux-modules@vger.kernel.org
	public-inbox-index linux-modules

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-modules


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git