LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-16-2004, 03:02 PM   #1
itzfritz
Member
 
Registered: Oct 2004
Location: Babylon, New York
Distribution: debian lenny, ubuntu intrepid
Posts: 70

Rep: Reputation: 15
Compiling as modules: useful always?


Hi,

Should I maximize the amount of code that I compile as a module?
Is it a better use of resources to compile say my ethernet card's driver as a module or should something so often-used go into the kernel?


Thanks!
-Mike
 
Old 11-17-2004, 08:12 PM   #2
gypsy_rabbi
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
I'm not at all a kernel-hacker, so take all this with a grain of salt.

Kernel modules are most useful for flexibility:
  • For instance, if you're building a kernel that might run on many different systems (say for a bootdisk), then you want to build a flexible kernel and package different sets of modules in different initrds. You plug in the pieces you need at runtime as and when you need them.
  • You can also unload them when you're done with them. That's a somewhat uncommon situation: in regular desktop use, for example, you're probably not going to unload your ethernet card driver after you load it in. But in special circumstances that can happen, and when it does, modules will save you some memory (the base kernel stays in memory; modules don't).
  • This also means you can upgrade your hardware without rebuilding your kernel or rebooting your system. Which is really cool but again, it doesn't happen every day.
The disadvantages are:
  • When you build the kernel, you could end up with all this crud lying around that you don't really need (for instance, building a PCMCIA module when you only really need the EtherExpress Pro/100 module).
  • Security risk: if modules can be loaded, malicious modules can be loaded. If you have a streamlined monolithic kernel that doesn't allow any later additions then you're that much safer. Just as when you're hardening a server you want to put in stuff you need, get rid of stuff you don't need, and then lock it down; you don't want to put in stuff just because you *might* use it someday. I think some rootkits are deployed as loadable kernel modules.
  • In a few (rare) instances there can be a performance hit.
TLDP has a page on kernel modules: http://www.tldp.org/HOWTO/Module-HOWTO/

Bottom line: if you're a regular home user it doesn't matter either way and you're probably better off with the flexibility of modules. If you have a stable box and you're not going to keep adding or removing hardware and you want a somewhat tighter system, a monolithic kernel is a good idea. If you're developing/playing with lots of toys, modules are a good idea.

GR


(Of course, all this is for a kernel that was originally meant to be monolithic, like Linux. For a fundamentally modular/microkernel system like the Hurd, you can't live without modules. They also have some really cool ideas like "translators" (ie. modules) that can be attached to any file, but then they have an OS that has been coming out "next year" for 20 years now.)
 
Old 11-17-2004, 08:57 PM   #3
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Additionally, one thing that speaks for using modules for certain kernel features is that you can pass options to them as you load them. For instance some sound cards are very tricky and their drivers need a *lot* of parameters passed to them in order to work. If you configure your kernel with the driver built in you will need to pass the options at boot-time, and if it takes twenty tries to get it working you'll be really unhappy rebooting a 21st time in order to see if it works. When having the driver compiled as a module you can try specifying the different parameters on the command line until you get it right. When you do get it right, simply add them to your distribution's means of module parameter passing (nowadays mostly meaning your modprobe.conf file).

I have had a lot of tricky hardware (mostly sound chips in laptops) and having the driver statically compiled in the kernel is a real pain when configuring.

Håkan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
compiling modules DBabo Linux - Software 8 07-29-2004 07:55 AM
after compiling 2.6.3 modules... c0rderr0y Linux - Newbie 1 02-23-2004 03:48 AM
Modules not Compiling BlakeB395 Linux - Software 0 02-08-2004 04:06 AM
modules don't seem to be compiling thrice Slackware 3 11-20-2003 11:37 PM
compiling apache modules e1000 Linux - Newbie 1 11-17-2003 01:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:21 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