From cdbc603fbd2edf4d6abff236b40d843f49cbce8f Mon Sep 17 00:00:00 2001 From: Bruno Meneguele Date: Fri, 21 Feb 2020 17:03:12 -0300 Subject: [PATCH] concepts/initcalls: add module_init macro information While reading about initcalls around the web and kernel source code I found that the information of what happens to __init functions not explicitly set to any initcall list pretty useful. With this patch such information is added. Signed-off-by: Bruno Meneguele --- Concepts/linux-cpu-3.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Concepts/linux-cpu-3.md b/Concepts/linux-cpu-3.md index daf4e34..70c0203 100644 --- a/Concepts/linux-cpu-3.md +++ b/Concepts/linux-cpu-3.md @@ -381,6 +381,20 @@ Besides the `rootfs_initcall` level, there are additional `console_initcall`, `s The main goal of these additional levels is to wait for completion of all modules related initialization routines for a certain level. +Another point worthy of mention is the `module_init(x)` macro, defined at [include/linux/module.h](https://github.com/torvalds/linux/blob/16f73eb02d7e1765ccab3d2018e0bd98eb93d973/include/linux/module.h) as: + +```C +#define module_init(x) __initcall(x); +``` + +If we follow and check what's the definition of `__initcall(x)` at [include/linux/init.h](https://github.com/torvalds/linux/blob/16f73eb02d7e1765ccab3d2018e0bd98eb93d973/include/linux/init.h) we can see that it's being set as an `device_initcall`: + +```C +#define __initcall(fn) device_initcall(fn) +``` + +With that we can conclude that when a function set as `__init` of certain module isn't explicitly added to a specific initcall category, but using `module_init()` macro, it is added to device initcall list by default. + That's all. Conclusion