* module use count & unloading
@ 2003-12-18 15:03 Thomas Koeller
2003-12-18 16:37 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Koeller @ 2003-12-18 15:03 UTC (permalink / raw)
To: linux-kernel
Hi,
I just learned that it is expected behavior for a module
to be in use while having an in-use count of zero, see
http://bugme.osdl.org/show_bug.cgi?id=1693. If this is
so, how am I supposed to know whether a module can safely
be unloaded? It also seems the old 'autoclean / modprobe -k'
functionality from 2.4 is no longer available in 2.6.
In case this has been discussed before, please accept my
apologies. I just wasn't able to locate the information, so
I am posting here. If anyone wants to respond, please CC me
on your reply, since I am not subscribed to this list.
tk
--
Thomas Koeller
thomas@koeller.dyndns.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: module use count & unloading
2003-12-18 15:03 module use count & unloading Thomas Koeller
@ 2003-12-18 16:37 ` Greg KH
2003-12-18 22:03 ` Thomas Koeller
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2003-12-18 16:37 UTC (permalink / raw)
To: Thomas Koeller; +Cc: linux-kernel
On Thu, Dec 18, 2003 at 04:03:11PM +0100, Thomas Koeller wrote:
> Hi,
>
> I just learned that it is expected behavior for a module
> to be in use while having an in-use count of zero, see
> http://bugme.osdl.org/show_bug.cgi?id=1693. If this is
> so, how am I supposed to know whether a module can safely
> be unloaded? It also seems the old 'autoclean / modprobe -k'
> functionality from 2.4 is no longer available in 2.6.
It wasn't safe to do that in 2.4 either. That would easily unload your
USB controller drivers, USB keyboard and USB mouse drivers, as they all
do not increment their in-use count.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: module use count & unloading
2003-12-18 16:37 ` Greg KH
@ 2003-12-18 22:03 ` Thomas Koeller
2003-12-18 22:22 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Koeller @ 2003-12-18 22:03 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
On Thursday 18 December 2003 17:37, Greg KH wrote:
>
> It wasn't safe to do that in 2.4 either. That would easily unload your
> USB controller drivers, USB keyboard and USB mouse drivers, as they all
> do not increment their in-use count.
Thanks for your reply. I am, however, somewhat confused now. If the
in-use count cannot be trusted, then unloading a module is a fundamentally
unsafe operation, and a tool like 'rmmod' should not exist at all. I also
remember that in 2.4 periodic unloading of all unused autoloaded modules
by a cron job used to work just fine. And finally, if module unloading is
inherently unsafe, what is the significance of all this stuff about
forced module unloading and its dangers?
I assumed this was a bug at first and reported it as one, because I could
not make much sense of it. Now that I've been told that this kind of
behavior is actually intended, I still cannot...
tk
--
Thomas Koeller
thomas at koeller dot dyndns dot org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: module use count & unloading
2003-12-18 22:03 ` Thomas Koeller
@ 2003-12-18 22:22 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2003-12-18 22:22 UTC (permalink / raw)
To: Thomas Koeller; +Cc: linux-kernel
On Thu, Dec 18, 2003 at 11:03:04PM +0100, Thomas Koeller wrote:
> On Thursday 18 December 2003 17:37, Greg KH wrote:
> >
> > It wasn't safe to do that in 2.4 either. That would easily unload your
> > USB controller drivers, USB keyboard and USB mouse drivers, as they all
> > do not increment their in-use count.
>
> Thanks for your reply. I am, however, somewhat confused now. If the
> in-use count cannot be trusted, then unloading a module is a fundamentally
> unsafe operation, and a tool like 'rmmod' should not exist at all.
I agree, and so do any other kernel developers who have tried to handle
module cleanup properly :)
Some modules can't mark themselves as "busy" as there really isn't such
a operation for them (like the keyboard driver, when is it busy? When
you are typing?) So they allow themselves to be unloaded at any time if
you want to.
I don't think any distros have the 'rmmod cleanup' cron entry in them
anymore for this very reason. I think that happened around the time 2.2
came out, but it might have been later...
> I also
> remember that in 2.4 periodic unloading of all unused autoloaded modules
> by a cron job used to work just fine. And finally, if module unloading is
> inherently unsafe, what is the significance of all this stuff about
> forced module unloading and its dangers?
module unload is there to help kernel developers. Yes it does seem to
work for 99% of the time for everyone, but there's some fun races in
places that are almost impossible to fix properly. See the various
threads in the lkml archives for more details on this (including Rusty's
proposed fix that we just never unload modules at all, but just mark the
memory as "used" and then load the next version in a different place.)
> I assumed this was a bug at first and reported it as one, because I could
> not make much sense of it. Now that I've been told that this kind of
> behavior is actually intended, I still cannot...
module unloading is tricky. In short, if you can ever help it, don't.
It's there as a convience, and that's about it. There's now a config
option that you have to explictly enable in order to get that "feature",
CONFIG_MODULE_UNLOAD.
Hope this helps clear things up.
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-12-18 22:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-18 15:03 module use count & unloading Thomas Koeller
2003-12-18 16:37 ` Greg KH
2003-12-18 22:03 ` Thomas Koeller
2003-12-18 22:22 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox