Some usages of RCU in the kernel code
Posted Jan 6, 2008 19:04 UTC (Sun) by PaulMcKenney
In reply to: Some usages of RCU in the kernel code
Parent article: What is RCU, Fundamentally?
The reason that kernel/kprobes.c does not use
synchronize_rcu() is that it instead uses
synchronize_sched(). The read-side primitives corresponding to
local_irq_save()/local_irq_restore() -- in short, any primitive that disables and re-enables preemption, including entry to hardware irq/exception handlers. The third article in this series will cover these and other nuances of the RCU API.
The reason that
__list_add_rcu() does not use
rcu_dereference() is that
__list_add_rcu() is an update-side primitive, and therefore must be protected by appropriate locking. This means that the list cannot change while the lock is held, and this in turn means that the memory barriers implied by lock acquisition suffice. That said, it is permissible (but again, not necessary) to use
rcu_dereference() in update-side code -- in fact, in some situations, doing so promotes code reuse and in some cases readability.
The discussion of Figure 2 in this article and its bibliography is a good place to start on Alpha's memory ordering. I am not all that familiar with value-speculation compiler-optimization research, but one place to start might be here.
to post comments)