'How can I add Linux source code global variable?

I face a situation where I need to declare a global variable so every file of Linux source code can reference it. As much as I know, Linux is a Monolithic kernel, so this can be done. So I add the global variable to the init/main.c file. However, when I use extern .. in other files, the compiler says undefined reference. Any help?

Update

The more file can access, the better. To be more concrete, I'm tracing the execution times of certain function, so I define a global variable, everytime the function executes, I'll add one. This is the most straightforward way to meet my demand.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source