1. Definition
The __read_mostly primitive defines the variable to be stored in the . data.read_mostly segment, and the prototype is defined in include/asm/cache.h:
#define __read_mostly __attribute__ ((__section__ (". data.read_mostly"))
2. Role
Because __read_mostl modified variables are placed in the . data.read_mostly segment, we can define the data that is often needed to be read as a __read_mostly type, so When the Linux kernel is loaded , the data is automatically stored in the cache to improve the overall system execution efficiency .
however , if the platform does not have a cache, or if there is a cache, but does not provide the interface to hold the data(that is, it is not allowed to manually place the data in the Cache ), it is defined as __ Data of the read_mostly type will not be stored in the Linux kernel or even be loaded into the system memory for execution.
If the data can not be stored in the Linux kernel, and can not even be loaded into the system memory to execute, the result is very serious, will cause the Linux kernel boot failure.
[Linux programming]__read_mostly variable meaning