LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Comprehension question: Are drivers generally compiled as loadable modules? (https://www.linuxquestions.org/questions/linux-kernel-70/comprehension-question-are-drivers-generally-compiled-as-loadable-modules-924552/)

JZL240I-U 01-19-2012 01:47 AM

Comprehension question: Are drivers generally compiled as loadable modules?
 
I recently read that the kernel now exceeds 15 million lines of code, each version adding about 200.000 to 300.000 new lines. By far the most of these lines constitute the sources of drivers.

How is this handled, are those drivers just loadable modules and those statistics just show all available source code? Or does each kernel of an average distro contain all (most) drivers? Can anybody point me to sources to read up on that?

jschiwal 01-19-2012 02:41 AM

Most will probably be for loadable modules. Some is in the kernel proper, but only included if you select that option when building the kernel. Server distributions such as Red Hat may include fewer options. A server is less likely to need the last est hardware drivers. Home users on the other hand want their new wireless device to work.

Remember that many kernel build options can be loadable, or built in. It's up to you when you build your own kernel.

JZL240I-U 01-19-2012 02:57 AM

How is it done? I mean, runs the kernel a hardware scan and decides what to load additionally? Or are all available modules loaded regardless of their being needed or not? How does SuSE handle that, would you know?

jschiwal 01-19-2012 03:49 AM

Firstly, if you don't configure a kernel module, it can't be loaded period. It won't be built as a .ko module either. If it is, the udev system will detect it and the kernel module will be loaded (modprobed). Also look at the documentation for depmod.conf. It or the files in /etc/depmod.d/ determine how modules are loaded. Which options to use, and if it's name is aliased. Sometimes module options are given on the kernel boot line (menu.lst). Some kernel modules are added to the initrd file, so the device can be loaded before the filesystem is loaded.

Things may have changed some under systemd.

JZL240I-U 01-19-2012 04:04 AM

Quote:

Originally Posted by jschiwal (Post 4578617)
Firstly, if you don't configure a kernel module, it can't be loaded period. It won't be built as a .ko module either.

Is it then automatically part of the monolithic kernel, i.e. inbuilt?

Quote:

Originally Posted by jschiwal (Post 4578617)
If it is, the udev system will detect it and the kernel module will be loaded (modprobed).

When requested, i.e. needed by some event in the running system if I understand this right.


Quote:

Originally Posted by jschiwal (Post 4578617)
Also look at the documentation for depmod.conf. It or the files in /etc/depmod.d/ determine how modules are loaded. Which options to use, and if it's name is aliased. Sometimes module options are given on the kernel boot line (menu.lst). Some kernel modules are added to the initrd file, so the device can be loaded before the filesystem is loaded.

Things may have changed some under systemd.

Ahh yes, this makes things more clear. Thank you :).

jschiwal 01-21-2012 11:29 PM

For the first part, I meant when it isn't built into the kernel or built as a module. In that case its code isn't used.

JZL240I-U 01-23-2012 01:20 AM

So this way one can keep the kernel small. Okay, understood. Thanks for your help and explanations jschiwal, they are much appreciated :).


All times are GMT -5. The time now is 06:01 PM.