Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1808768
  • 博文数量: 272
  • 博客积分: 1272
  • 博客等级: 少尉
  • 技术积分: 1866
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-09 15:51
文章分类

全部博文(272)

文章存档

2016年(16)

2015年(28)

2014年(97)

2013年(59)

2012年(25)

2011年(47)

分类: LINUX

2014-08-19 09:24:09

原文地址:__read_mostly variables 作者:todaygood

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.

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