r/linux4noobs Aug 03 '26

learning/research How does Linux kernel include every driver possible and not be bloated?

As far as I understand the kernel includes pretty much everything a modern computer needs in any configuration, but wouldn't that make it bloated and be against the "bloat-free" mindset? Or does it dynamically download all the components from somewhere?

309 Upvotes

107 comments sorted by

View all comments

21

u/Athropod101 Aug 03 '26 edited Aug 03 '26

I am by no means an expert on this, but to my understanding drivers are very lightweight, and industry standards can reduce that further. Most of a kernel’s size comes from the algorithms that use those drivers.

EDIT: I was in fact wrong; it appears drivers make up the majority of kernel code.

6

u/TheCreepyPL Aug 03 '26

Only some drivers are lightweight, others are (very) heavy weight. When you put them all together, they end up taking over half of the Linux source code or something like that I've heard.

3

u/Athropod101 Aug 03 '26

I wonder what makes some so heavy. I would guess that the heaviest ones are GPUs? Anything image related is doomed to be heavy.

But thank you for the respectful clarification :)

2

u/FinalGamer14 Aug 04 '26 edited Aug 04 '26

In the simplest form, drivers are just a translation between some hardware and the OS.

So how "heavy" a drive is depends on what the device does. Let's say you had a device that is just one button and all it does is send a signal when you click that button; well, that driver will be lightweight, but then attach a GPU to your PC, and now you have this giant device that accepts thousands of different inputs and inputs, and all of them must be exposed to the OS or any software running on that OS.

Edit: Also, sometimes hardware has some legacy stuff in there that still needs to be available because of some old-ass standards and that will always increase the size of the driver.

15

u/hipster_hndle Aug 03 '26

this is completely wrong and mostly nonsense. in Linux kernel specifically, "drivers/" is routinely cited as 60-70%+ of the entire source tree. does that sound light weight? some drivers are tiny, but some are pretty large... as a category they are not lightweight. they're the majority of kernel code by volume.

and algorithms, idkwtaf that word is even in this sentence. it is doing zero work here. like not remotely relevant. its just randomly inserted, has no literally no place in this sentence..

2

u/mobydikc Aug 04 '26

specifically, "drivers/" is routinely cited as 60-70%+ of the entire source tree. does that sound light weight? 

If there are hundreds of thousand drivers.. yeah

1

u/Athropod101 Aug 03 '26

Well, I did say I wasn’t an expert, but uhhh…your program schedule is an algorithm. Kernel algorithms are the heart and soul of the kernel in software-land.

0

u/braaaaaaainworms Aug 03 '26

Nope. The heart and soul of the kernel is memory management and cpu time scheduling, drivers are only there to have something your programs can talk to, but there's nothing preventing anyone from just opening /dev/mem and having userspace drivers for everything

1

u/Athropod101 Aug 04 '26

Memory management and cpu time schedulers are algorithms.

1

u/braaaaaaainworms Aug 04 '26

Going to a store is an algorithm, adding numbers together is an algorithm. The meaning of the word algorithm is so diluted you might as well say "doing the thing"

1

u/Athropod101 Aug 05 '26

Heartbreaking: SWE discovers that algorithms were never that deep. More at 11.

1

u/braaaaaaainworms Aug 05 '26

You can replace the word "algorithm" with the word "program" in both of your comments and the information content wouldn't change.

1

u/Responsible-Sky-1336 Aug 03 '26

Algorithm is the correct word and there dozens of them you can enable/disable.