Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the linux kernel maintain the vast amount of config options?

This question is about configuration maintenance and testing.

When used wrongly, #ifdef, #ifndef, #elseif, #elif, #else, #endif preprocessor instructions do not only diminish the readability and maintainability of C-code, but they also increase the risk of regression bugs (e.g. when a specific build configuration has not been tested for a certain period of time).

I wonder how the linux kernel is able to maintain the tremendous amount of config options without running into a complete maintenance hell?

I understand that this is necessary to be flexible for all kinds of different hardware, but the sheer number of config options looks really frightening to me as an application developer.

Which of the following statements would you consider as true?

  • Most vendors only use a set of standard configurations for their targeted platform, so that most of the possible config combinations are neither tested nor used
  • A very strict coding guideline exists that allows the introduction of new #ifdef's only for clearly separable pieces of code, where it makes sense to disable a feature (and the right people in charge to make these decisions)
  • There are so many testers for every new kernel release that the configuration related bugs get fixed in time, since most of them are likely to be only build regressions
like image 573
Mike76 Avatar asked Dec 03 '16 15:12

Mike76


1 Answers

I am working myself directly with the Linux kernel and "Das u-boot". By far, I don't have enough experience but I will give it a shot.

As far as I can tell, the config file that you are talking about is actually composed by multiple files, from most general things like CPU arhitecture and alike, to very detailed things like RAM frequency and that sort of things.

Yes, it is very and I mean very frightening, but as you said, with very good (at least decent documentation) the project must go on. Also, you must realize the huge number of people working on all the stuff that is in there. Surelly, there isn't anyone who can consider himself a real connoisseur of everything.

Not 100% sure, but I think you are right about most vendors use at least some standard configuration. For example, imagine that most smartphones have about the same general HW arhitecture (CPU, GPU, RAM, etc) so no need to customize absolutely everything.

Also yes, the main code is full of

#ifdef, #ifndef, #elseif, #elif, #else, #endif

and this obviously has it advantages and drawbacks. But that is one of the beautiful things about C (and C++ also), it allows to control everything. Quit empowering sometimes, sometimes a real nightmare.

Nothing to add about testing :)

like image 82
Alexandru Dascălu Avatar answered Sep 22 '22 20:09

Alexandru Dascălu