I'm in the middle of reading the whole Linux 5.0.7 source code, and I've noticed something strange. I'll refer to linux as the parent directory here, correct me if the community uses some other naming convention in the literature.

In the file linux/include/asm-generic/param.h, the value CONFIG_HZ is used. The value is not defined in the previous lines, and the only included file is uapi/asm-generic/param.h. I believe this refers to linux/include/uapi/asm-generic/param.h, again, correct me if I'm wrong.

In that file, no such value as CONFIG_HZ is ever defined. Now, in your average C program, this would cause a bug. We have 3 options here:

  • I misunderstood something and linux/include/asm-generic/param.h actually includes another file where the value IS defined.
  • This is a bug, and I am a genius for discovering it (least likely option).
  • There is some "magic" going on, like some macros that Linux defines before, or some files the kernel includes before including linux/include/asm-generic/param.h where the value is defined, so that when linux/include/asm-generic/param.h is called the value is already defined. In this case, please point me to what this file is.

If none of these is true, what is the reason why this is a correct C program?


Like other CONFIG_ values, CONFIG_HZ is a configuration setting; you’ll find it in kernel/Kconfig.hz, along with various arch-specific overrides in other Kconfig files. Its value is determined during the build and stored in a generated configuration file, include/generated/autoconf.h.

  • And I suppose include/generated/autoconf.h is included in the kernel's execution flow before linux/include/asm-generic/param.h? – memememe Apr 11 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.