You do know that most of the kernel code is in the form of modules, and is loaded on-demand? Only the core code needed for initialization, memory management, disk management, process scheduling, interrupts etc. has to absolutely be in memory at all times, and that portion doesn't take up much memory (although the data structures used might take up a bit more, it's nothing compared to userspace memory usage).
Don't forget all the code that's for handling various architectures (looks like about 2M lines), and which will actually be entirely compiled out for every arch other than the one you need.
15
u/[deleted] Nov 07 '18
You do know that most of the kernel code is in the form of modules, and is loaded on-demand? Only the core code needed for initialization, memory management, disk management, process scheduling, interrupts etc. has to absolutely be in memory at all times, and that portion doesn't take up much memory (although the data structures used might take up a bit more, it's nothing compared to userspace memory usage).