[Linux programming]__read_mostly variable meaning

Source: Internet
Author: User

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

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.