_ Read_mostly variable in Linux kernel

Source: Internet
Author: User
Kernel version of The _ read_mostly variable in the Linux kernel: 2.6.14 when reading the socket source code, there is the following sentence (net/socket. c): [plain] staticstructvfsmount * sock_mnt _ read_mostly; I think _ read_mostly is very strange. I have analyzed it in depth...
Kernel version of The _ read_mostly variable in the Linux kernel: 2.6.14 when reading the socket source code, there is the following sentence (net/socket. c): [plain] static struct vfsmount * sock_mnt _ read_mostly; I think _ read_mostly is very strange, so I have gone through the in-depth analysis. The _ read_mostly primitive is defined as being stored in the. data. read_mostly segment. Www.2cto.com [plain] # if defined (CONFIG_X86) | defined (CONFIG_SPARC64) # define _ read_mostly _ attribute _ (_ section __(". data. read_mostly ") # else # define _ read_mostly # endif. we can define the data to be read as _ read_mostly, so that when the Linux kernel is loaded, the data is automatically stored in the Cache to improve the execution efficiency of the entire system. On the other hand, if the platform does not have a Cache, or although there is a Cache, it does not provide an interface for storing data (that is, it does not allow manual data placement in the Cache ), in this way, Data Defined As _ read_mostly cannot be stored in the Linux kernel or even loaded into the system memory for execution. this will cause Linux kernel startup failure. There are two solutions: modify include/asm/cache. in h, _ ready_mostly is defined as: # define _ read_mostly to modify arch/xxx/kernel/vmlinux. s, set. data. the location of the read_mostly segment is in the actual memory space, for example, placed in. after the data segment. In addition, the kernel source code uses CONFIG_X86) and (CONFIG_SPARC64) to determine how to define _ read_mostly. Therefore, this macro is meaningless in arm.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.