Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4566195
  • 博文数量: 385
  • 博客积分: 21208
  • 博客等级: 上将
  • 技术积分: 4393
  • 用 户 组: 普通用户
  • 注册时间: 2006-09-30 13:40
文章分类

全部博文(385)

文章存档

2015年(1)

2014年(3)

2012年(16)

2011年(42)

2010年(1)

2009年(2)

2008年(34)

2007年(188)

2006年(110)

分类: LINUX

2008-08-17 10:27:56

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.

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.

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