On 07/28/2015 06:18 PM, Paolo Bonzini wrote: > > > On 28/07/2015 12:02, Wen Congyang wrote: >> I have a question about rcu: while do we call wait_for_readers() >> twice for 32-bit host? > > Because there is a very small but non-zero probability of the counter > going up by exactly 2^31 periods (periods are stored in bits 1-31 so you > lose one bit) while the thread is sleeping. This detail of the > implementation comes from URCU.
Yes, so you use rcu_gp_ctr ^ RCU_GP_CTR to instead of rcu_gp_ctr + RCU_GP_CTR. The initial value is 1, so rcu_gp_ctr is: 1, 3, 1, 3, ... The rcu_gp_ctr will never be 0. I think calling wait_for_readers() once is enough. Do I miss something? Thanks Wen Congyang > > Paolo >