__read_mostly變數含義(LINUX)__LINUX

來源:互聯網
上載者:User

__read_mostly原語將定義為存放在.data.read_mostly段中

  include/asm/cache.h

#define __read_mostly __attribute__((__section__(".data.read_mostly")))

    由此可見,我們可以將經常需要被讀取的資料定義為 __read_mostly類型, 這樣Linux核心被載入時,該資料將自動被存放到Cache中,以提高整個系統的執行效率.

   另一方面,如果所在的平台沒有Cache,或者雖然有Cache,但並不提供存放資料的介面,(也就是並不允許人工放置資料在Cache中), 這樣定義為 __read_mostly類型的資料將不能存放在Linux核心中,甚至也不能夠被載入到系統記憶體去執行,將造成Linux 核心啟動失敗.

   解決的方法有兩種:

   修改include/asm/cache.h中的__ready_mostly定義為:

   #define __read_mostly

   或者修改arch/xxx/kernel/vmlinux.S

   修改.data.read_mostly段的位置到實際記憶體空間中去,例如放置在 .data段之後等等

 

  原文地址:   http://blog.chinaunix.net/u2/85263/showart_1743693.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.