0

i am using ubuntu 12.04 . If I build monolithic kernels for device drivers i.e driver will have its own kernel as i understand , will it really improves system performance and device performance ? are there any disadvantages ?

3 Answers 3

4

A pedantic note: "monolithic kernel" means something completely different. Linux kernel is always monolithic, regardless of whether some or all of its modules are built as LKMs or compiled directly into the kernel.

http://tldp.org/HOWTO/Module-HOWTO/x73.html#AEN77

When LKMs are loaded into the kernel, there's absolutely no difference in performance compared to built-in modules as LKMs code runs in the same process as the rest of the kernel, there's no inter-process communication or anything.

LKMs are not slower, by the way, than base kernel modules. Calling either one is simply a branch to the memory location where it resides.

However, LKMs can be loaded upon request, so if you take the stock-standard Ubuntu kernel and recompile it with all modules built-in, you'll get a humongous kernel which probably will slow the system down because of using much more RAM for all those unused modules (which possibly will also cause all sorts of conflicts with each other).

On the other hand, if you compile a kernel which is custom-tailored to your particular machine and only has the modules for the actual machine's hardware built in, such kernel will likely to be faster than the stock-standard kernel, especially at boot time. I've been playing with a custom kernel for my EeePC on Arch Linux and can report that it's actually noticeably faster:

  • the kernel can be made very slim, including only features your machine actually uses. The whole kernel-eeepc thing is just 4Mb, which makes it faster to load from disk and it uses less RAM when loaded, leaving more memory for user-space programs.

  • no modules to load means less disk I/O during boot.

  • having hardware drivers built in means no need for hardware probing during boot, which saves time.

  • Built-in hardware drivers eliminate the need in the initial ramdisk, so the kernel can be loaded directly by GRUB.

  • you can disable other kernel features you don't need, which again shrinks the kernel size and make it faster.

The downsides, however, are:

  • Automatic kernel upgrades become useless, you have to build new kernels from source

  • If the machine dies and you plug the disk into another computer the machine probably won't boot.

All in all, this is a fun and educational exercise but not something I would consider doing on a machine which is not too hardware-restricted.

1
  • thanks , you mentioned some Important points to consider.
    – Raja G
    Aug 28, 2012 at 1:19
2

The only advantage I see at that point is the ability to disable module loading (so even if someone gets root/superuser access they can't load a "bad" module).

That being said, it used to be that you got a small performance hike by disabling unused drivers and compiling in loadable modules. As hardware performance increases, these slight improvements become more and more negligible.

4
  • thank you :) . so if i have created large number of mono kernel modules means is it going to be good or bad ?
    – Raja G
    Aug 27, 2012 at 17:53
  • 1
    Monolithic means the module is "built-in" and doesn't really get "loaded" as needed. It's neither "good" nor "bad" really. If you disabled loadable modules, you would not be able to use binary only loadable modules that aren't integrated in to the kernel build process though (virtualbox and vmware come to mind). Aug 27, 2012 at 17:56
  • Ok what if we have more kernel modules ?
    – Raja G
    Aug 27, 2012 at 17:58
  • Generally, you build them all in at once, or leave them as loadables Aug 27, 2012 at 17:59
1

I wanted to chime in here. I used to make only monolithic kernels years ago but the kernel today is pretty advanced using a lot of features. As far as I can tell, it won't let you go 100%. I may be mistaken though.

From what I gather, the kernel will unload modules efficiently allowing your system more memory and resources. For me, I only make things module if it's not important. A USB device, for example, will be a module but my EXT4 is all compiled in. Everything with networking too. In addition, I compile the kernel after I've removed everything that I can and I use some additional methods

First, install all your hardware. It might be a USB device like an iPod or flash drive. Then run this:

make localmodconfig

That will modify the .config to include all your detected hardware and tick it M.

make xconfig

Xconfig will give you the menu to remove things but be careful. I make my kernel a low latency for desktop and I add support for my hardware specifically.

Finally, the additional features of your CPU can be used if GCC is up to date and you use the following:

CONCURRENCY_LEVEL=getconf _NPROCESSORS_ONLN CFLAGS="-march=bdver1 -mtune=bdver1" CXXFLAGS="${CFLAGS}" make-kpkg --initrd --append-to-version=-MyKernelVersionNameHere kernel_image kernel_headers

That will start the kernel building process using all of the available CPUs to build it, PLUS special support for the AMD Zambezi CPU. Change "bdver1" to match your specific CPU and chance MyKernelVersionNameHere to fit your own kernel naming convention.

In the end is it faster? I think YES. I recompiled the kernel, GCC, WINE and I can play most Windows PC games better in Linux than they play in Windows.

1
  • 1
    make localmodconfig is a neat trick, I wasn't aware of that.
    – Sergey
    Aug 28, 2012 at 3:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .