热门关键字:  ubuntu  分区  函数  Fedora  linux系统进程

当前位置 :| 主页>Linux教程>内核研究>

__read_mostly variables

来源: 作者: 时间:2008-08-18 Tag: 点击:

I want to know what is __read_mostly variable and its use when used in the linux kernel sources and i want to know that whether it can be used in normal c programs.

__read_mostly variables are

January 4, 2008 - 2:24pm
Anonymous (not verified)

__read_mostly variables are grouped together in the final executable. This is thought to improve performance because it improves access time to those variables in SMP systems. This is because with reads only all processors on system can cache copies of those variables safely; however if a write occurs, one processor assumes ownership of that general memory area and this is a very expensive operation. This is referred to as cacheline bouncing, as each processor in turn assumes ownership of the cache line (= the memory area which contains the variable) in order to do their writes.

The unfortunate downside of __read_mostly variables is that the not-read-mostly variables, that is, "write_mostly"-variables are also clustered together and this may exacerbate the cacheline bouncing for them. This can have performance penalty too.

Look up the way __read_mostly is defined and copy the definition. It is likely some GCC attribute.


最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册