Chinaunix首页 | 论坛 | 博客
  • 博客访问: 253006
  • 博文数量: 34
  • 博客积分: 791
  • 博客等级: 军士长
  • 技术积分: 352
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-24 21:45
文章分类

全部博文(34)

文章存档

2015年(2)

2013年(6)

2012年(16)

2011年(8)

2010年(2)

分类: LINUX

2012-06-27 15:52:05

__read_mostly variables

时间 : 2008-08-19  作者:佚名   编辑:本站 点击:  470


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.


‹ Lost in the kernel, sched.h? Linux: VM Swappiness Autoregulation ›
__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.

阅读(904) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~