关于RCU-protected array indexes的探究

关于RCU-protected array indexes的探究

在师兄的驱动代码中看到了几个和rcu index相关的代码在编译的时候报错,原因是现在的linux内核已经废除使用RCU-protected array indexes了。现在建议,用smp_load_acquire对rcu_dereference_index_check进行替换

参加文章内容

Abolition of RCU-protected array indexes

The RCU API has long permitted RCU-protected array indexes, but it turned out that these were used only in one place in x86-specific code. Because x86 has relatively strong total store order (TSO) memory ordering, rcu_dereference_index_check() may be replaced with smp_load_acquire() on x86 with little or no performance penalty. In other words, in the only place using rcu_access_index() and rcu_dereference_index_check(), they were not helping much.

In addition, both rcu_dereference() (and friends) and rcu_dereference_index_check() rely on the compiler to preserve dependencies from those two invocations to any later dereferencing of the returned pointer. Neither the C nor the C++ standard make any sort of dependency-preservation guarantee, and compilers much more aggressively optimize integer expressions than pointer expressions, which means that dependencies carried by integers are more likely to be broken than those carried by pointers. The rules for preventing the compiler from breaking dependencies carried by pointers are complex enough, and so it seemed best to remove integers from the mix.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值