Messages in this thread | | | Date | Sat, 28 Feb 2009 13:49:26 +0100 | From | Stefan Richter <> | Subject | Re: Unused modules in 2.6.x |
| |
Greg KH wrote: > On Wed, Feb 25, 2009 at 05:52:49PM +0000, Alex Buell wrote: >> Hi, >> >> Perhaps I missed something when the 2.6.x kernels got started a few >> years back, but why is it not possible for unused modules to be >> automatically unloaded anymore i.e with rmmod -a? I remember being able >> to do that with the 2.2.x and 2.4.x series a long time ago. > > Because if you do that, lots of modules that were being "used" by the > system would get unloaded (usb host controllers, network drivers, etc.) > > So it makes sense not to do that anymore. See the linux-kernel archives > about 6 years ago for details if you are curious about this historical > issue (hint, it could burn you very badly even in 2.2 and 2.4...)
Alex,
the "use count" tracks how many sites in the kernel might be using symbols in a module (call functions of a module etc.). The "use count" does *not* track anything higher-level than that, e.g. (as pointed out by Lennart) "this module might soon come in handy to start accessing some hardware" or (as pointed out by Michael) "this module provides functionality for one of the links in a currently active IO path".
So, the meaning of Greg's "could burn you" in kernel 2.6 is basically: Unloading of seemingly unused modules won't crash the kernel (occasional driver bugs excepted) but it might switch off kernel functionality which you still intended to use.
But why don't we count "this module provides functionality for one of the links in a currently active IO path" too, generally?¹ Because for the kernel, "user requests to unbind this driver from that device" is merely yet another kind of a family of events like "user plugged out that cable", "user ejected this card", "user sent a shutdown request to that peer" etc.
------ ¹) Only in very simple cases is "is part of an IO path" indistinguishable from "another kernel site uses symbols of this module"; and there are very rare exceptional cases in which we do count "is part of an IO path" explicitly for specific reasons. -- Stefan Richter -=====-==--= --=- ===-- http://arcgraph.de/sr/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |