1

There are many RCU functions that don't have a _bh counterpart.

Examples are:

  • list_entry_rcu()
  • list_for_each_entry_rcu()

Is this because...

  1. they can be called from bottom halves just fine (think list_empty() vs list_empty_rcu())?
    • Does this mean I can use rcu_read_lock() and rcu_read_lock_bh() interchangeably in these cases?
  2. no one has so far needed them (and therefore I's supposed to roll out my own version of them)?

Rule 9 of the RCU checklist says "in which case the matching rcu_dereference() primitive must be used in order to keep lockdep happy". So I guess the second option above is true. But then I find code that reads like this:

rcu_read_lock_bh();
c = __clusterip_config_find(clusterip);

And then, during __clusterip_config_find():

list_for_each_entry_rcu(c, &clusterip_configs, list) {

What is going on!? list_for_each_entry_rcu() uses rcu_dereference_check(), not rcu_dereference_bh_check()...

4

1 回答 1

1

这是真的:

  1. 到目前为止没有人需要它们(因此我应该推出我自己的版本)。

更准确地说,有这么多的 RCU 列表遍历函数,所以一个决定不包括他们所有的_rcu_bh配对,因为很少需要。但见下文。

你不能使用rcu_read_lock()rcu_read_lock_bh互换。但区别rcu_dereferencercu_dereference_check在于注释:它们都扩展为具有不同参数的__rcu_dereference_check()宏调用。c

因此,从处理器的角度来看,实现__clusterip_config_find是正确的,但在启用检查器时可能会产生警告。(当然,每个司机都应该在没有警告的情况下工作)。

于 2015-09-02T18:31:11.950 回答