public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Unused modules in 2.6.x
@ 2009-02-25 17:52 Alex Buell
  2009-02-25 18:40 ` Michael Tokarev
  2009-02-25 19:28 ` Greg KH
  0 siblings, 2 replies; 7+ messages in thread
From: Alex Buell @ 2009-02-25 17:52 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org

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.


Thanks,
Alex
-- 
http://www.munted.org.uk

Fearsome grindings.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unused modules in 2.6.x
  2009-02-25 17:52 Unused modules in 2.6.x Alex Buell
@ 2009-02-25 18:40 ` Michael Tokarev
  2009-02-26 10:29   ` Alex Buell
  2009-02-25 19:28 ` Greg KH
  1 sibling, 1 reply; 7+ messages in thread
From: Michael Tokarev @ 2009-02-25 18:40 UTC (permalink / raw)
  To: Alex Buell; +Cc: linux-kernel@vger.kernel.org

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.

It's a pure userspace question now.  Well, almost, except of the
single bit which were kept before 2.6  for each module - if it
was loaded with -k flag (auto-unload) or not.

Better question to ask, IMHO, is why network drivers don't gets
referenced properly as all other drivers are.  Because right now
they're unused even if the network interfaces are up-n-running,
and rmmod'ing a seemingly unused module will cause that particular
interface to be removed too...

/mjt

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unused modules in 2.6.x
  2009-02-25 17:52 Unused modules in 2.6.x Alex Buell
  2009-02-25 18:40 ` Michael Tokarev
@ 2009-02-25 19:28 ` Greg KH
  2009-02-26 10:30   ` Alex Buell
  2009-02-28 12:49   ` Stefan Richter
  1 sibling, 2 replies; 7+ messages in thread
From: Greg KH @ 2009-02-25 19:28 UTC (permalink / raw)
  To: Alex Buell; +Cc: linux-kernel@vger.kernel.org

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...)

good luck,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unused modules in 2.6.x
  2009-02-25 18:40 ` Michael Tokarev
@ 2009-02-26 10:29   ` Alex Buell
  2009-02-26 14:48     ` Lennart Sorensen
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Buell @ 2009-02-26 10:29 UTC (permalink / raw)
  To: Michael Tokarev, linux-kernel@vger.kernel.org

On Wed, 25 Feb 2009 21:40:02 +0300, I waved a wand and this message
magically appears in front of Michael Tokarev:

> > 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.  
> 
> It's a pure userspace question now.  Well, almost, except of the
> single bit which were kept before 2.6  for each module - if it
> was loaded with -k flag (auto-unload) or not.

Thanks for that, I'll see if loading modules with -k still works in
2.6.x. 
 
> Better question to ask, IMHO, is why network drivers don't gets
> referenced properly as all other drivers are.  Because right now
> they're unused even if the network interfaces are up-n-running,
> and rmmod'ing a seemingly unused module will cause that particular
> interface to be removed too...

I'd have thought that hotplugging i.e. plug in an USB device in this
case would load the modules as and when required. 

If the interface is up, then it shouldn't have to be unloaded, I think.
I know I could just hack my initrds to remove any modules that I don't
want loaded at bootup but surely... :-D
-- 
http://www.munted.org.uk

Fearsome grindings.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unused modules in 2.6.x
  2009-02-25 19:28 ` Greg KH
@ 2009-02-26 10:30   ` Alex Buell
  2009-02-28 12:49   ` Stefan Richter
  1 sibling, 0 replies; 7+ messages in thread
From: Alex Buell @ 2009-02-26 10:30 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel@vger.kernel.org

On Wed, 25 Feb 2009 11:28:10 -0800, I waved a wand and this message
magically appears in front of Greg KH:

> 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...)

I see, thanks. 
-- 
http://www.munted.org.uk

Fearsome grindings.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unused modules in 2.6.x
  2009-02-26 10:29   ` Alex Buell
@ 2009-02-26 14:48     ` Lennart Sorensen
  0 siblings, 0 replies; 7+ messages in thread
From: Lennart Sorensen @ 2009-02-26 14:48 UTC (permalink / raw)
  To: Alex Buell; +Cc: Michael Tokarev, linux-kernel@vger.kernel.org

On Thu, Feb 26, 2009 at 10:29:39AM +0000, Alex Buell wrote:
> I'd have thought that hotplugging i.e. plug in an USB device in this
> case would load the modules as and when required. 
> 
> If the interface is up, then it shouldn't have to be unloaded, I think.
> I know I could just hack my initrds to remove any modules that I don't
> want loaded at bootup but surely... :-D

So how about if you plug in a usb drive, and the module is loaded to
provide disk access, but you aren't using it right now.  The next module
clean would remove the now unused module, and then when you do want to
use it, there is no longer any way to reach teh device, and since there
is no fixed device node to refer to that would cause the module to be
loaded again, now the device doesn't work.  That would be very annoying.

I think the big problem is that the kernel and the module utils can not
know if a module is actually being used or not since it is more a matter
of 'will it be needed' not 'is it in use right now'.

-- 
Len Sorensen

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unused modules in 2.6.x
  2009-02-25 19:28 ` Greg KH
  2009-02-26 10:30   ` Alex Buell
@ 2009-02-28 12:49   ` Stefan Richter
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Richter @ 2009-02-28 12:49 UTC (permalink / raw)
  To: Greg KH
  Cc: Alex Buell, linux-kernel@vger.kernel.org, Michael Tokarev,
	Lennart Sorensen

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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-28 12:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-25 17:52 Unused modules in 2.6.x Alex Buell
2009-02-25 18:40 ` Michael Tokarev
2009-02-26 10:29   ` Alex Buell
2009-02-26 14:48     ` Lennart Sorensen
2009-02-25 19:28 ` Greg KH
2009-02-26 10:30   ` Alex Buell
2009-02-28 12:49   ` Stefan Richter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox