Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
KC7: Compiling directly into a kernel vs. modules
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Frequently Asked Questions
View previous topic :: View next topic  
Author Message
wilburpan
l33t
l33t


Joined: 21 Jan 2003
Posts: 977

PostPosted: Fri Jun 06, 2003 3:05 am    Post subject: KC7: Compiling directly into a kernel vs. modules Reply with quote

Navigation: [Kernel Compilation] [Table of Contents]

Compiling directly into a kernel vs. modules

You have two options for adding functionality to the kernel: building functions into the kernel (making a monolithic kernel) or adding them as modules.

Monolithic kernels:
Building a function into the kernel directly ensures that that function will be available at all times. The downside is that it makes your kernel bigger, increasing boot time, and ultimately using that much more memory to hold the kernel. If you are compiling a kernel to fit on a floppy so that you can boot Linux off a rescue floppy, space will become an issue.

Modules:
Building a function as a module allows that function to be loaded into memory as needed and unloaded when it is no longer needed. This helps keep your kernel small. It is very useful if, say, you are swapping hardware in and out of your system frequently. You could compile support for a variety of, say, sound cards as modules, and your Linux system will theoretically only load the driver that is appropriate for the hardware setup at the time.

Another benefit of building functions as modules is that parameters can be passed to the modules which can be useful in debugging your system if problems occur.

There are some considerations to be made when deciding if a kernel function should be modularized. A small performance penalty is paid as it takes a little time to get the module loaded and unloaded. There are some functions that are needed at boot time and these cannot be compiled as modules -- they need to be present in the kernel so your system can be loaded. For example, ext2/ext3/reiserfs file system support needs to be built into the kernel so that your partitions can be read, as you need to be able to read the filesystem to load modules. In my case, if I have PCMCIA support built into the kernel, then metworking works. If PCMCIA support is modularized, networking fails to start, probably because the PCMCIA support needs to be available very early in the boot process to set up networking.

General approach
The way that I approached kernel building was to see which functions I would need all the time versus the ones that I would only use infrequently. If it was a function that I would be using a lot, I built it directly into the kernel. Otherwise, I compiled it as a module. As I got more comfortable with recompiling the kernel, I started making more functions as modules, and honestly, have not seen that much change in system performance. On the other hand, my hardware setup is pretty static -- my machine is a laptop, and the only hardware option that I have is whether or not I have a USB mouse plugged into it.

[Cribbed from a post I made to another thread]
[edited to incorporate suggested changes. Thanks!]


Last edited by wilburpan on Thu Jun 12, 2003 4:04 pm; edited 2 times in total
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20493

PostPosted: Wed Jul 23, 2003 7:08 pm    Post subject: Reply with quote

Comments on this FAQ can be made in [FAQF] KC7: Compiling directly into a kernel vs. modules


Thanks for the FAQ.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Frequently Asked Questions All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum