LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 04-26-2009, 02:40 AM   #1
riddler313
LQ Newbie
 
Registered: Apr 2009
Posts: 9

Rep: Reputation: 0
kernel module on demand loading


Hi!

I was just wondering why my distribution loads so many kernel modules and starts several kernel threads on boot automatically when there is no devices or software that actually needs them. This seems like a waste of resources. Shouldn't it work more like when attaching a device or launching a sofware that needs a specific kernel functionality that is not compiled in the kernel, udev/kernel loads the specific driver and after the device/software is removed it automatically unloads the module/removes the thread?

BTW, does anyone know a site that describes what all those kernel threads like kstop/kintegrityd/cqueue/kmmcd/ecryptfs-kthread etc. are supposed to do?
 
Old 04-27-2009, 03:46 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
In fact, it more or less works this way. Try connecting/disconnecting a camera etc. The thing is that a standard PC has a long list of hardware and the list of modules for that hardware is also long. There are also per-processor kernel threads, so if you have a multi-core machine, the number of threads may be also high, but they're usually idle.
 
Old 04-27-2009, 07:10 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
A "stock" distro usually makes heavy use of kernel-modules because otherwise you have to custom-configure a kernel ... which is not what most of their users would know how to do or would want to do. (They're basically accustomed to "the Windows experience.")

So, a lot of hardware detection goes on. A lot of modules get loaded, most of whom promptly unload themselves.

You see, the distro writer has no way to know in-advance just what your system's hardware might consist of. In the Windows world, computer manufacturers take care of that chore for you, and they pre-install an "OEM" version of Windows which is properly configured for their hardware. Linux distros generally do not have that luxury.

Certainly, if you know what you are doing you can customize Linux tremendously and thus make it boot much more quickly. (My system boots in under 15 seconds, and I last rebooted it several months ago.) But distro writers want their systems to "somehow boot, on anything." An entirely different set of technical objectives.
 
Old 04-28-2009, 10:21 AM   #4
riddler313
LQ Newbie
 
Registered: Apr 2009
Posts: 9

Original Poster
Rep: Reputation: 0
What I find interesting is that although my system only has jfs filesystems mounted, the pdflush kernel threads are running just because they are compiled in the kernel. Linux should be "intelligent" enough to remove these threads when no ext2/ext3 volumes are mounted regardles of compiled in ext2/ext3 filesystem support.
 
Old 04-28-2009, 09:20 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Actually, this design-decision on the part of the driver writer might well be perfectly justifiable. Here's why...

Perhaps, just a few moments from now, you're going to plug in a USB device that's formatted with this filesystem. The driver needs to be prepared to handle it. As long as the driver is loaded (which, only in the case of a compiled-in driver, is "forever"), it must be prepared to do its job.

If, as it happens, "the driver has no job to do," then using-up a slot or two in the kernel's process-table really costs nothing at all. (Kernel processes don't even consume virtual memory.) It really does become a "who cares" decision. In this way, the choices made by the design team are, in fact, entirely reasonable.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with module auto-loading (load on demand) in kernel 2.6.7 (2.6.x too) Cyb3rPr0 Linux - Software 4 07-02-2004 12:57 AM
startup module loading by kernel, need help asc3ndant Linux - General 1 07-10-2003 07:38 AM
kernel 2.5.65 and module loading m0rl0ck Linux - Software 4 03-21-2003 01:18 AM
Kernel 2.5.49 module loading problem m0rl0ck Linux - Software 3 11-27-2002 05:28 PM
Loading 8139too kernel module gdc34 Linux - Networking 4 08-04-2002 05:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 10:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration