clinux-kernelrcu

Does using list_for_each_entry() in rcu reader side critical section cause problems?


In the Linux kernel, list_for_each_entry_rcu() is used to traverse rcu protected list in reader side critical section. What happens if list_for_each_entry() is used instead? Does it cause problems?


Solution

  • In some architectures CPUs can look through the next pointer early. Specially in case of ALPHA and SPARC CPUs. Hence list_for_each_entry_rcu() is needed which essentially put memory barriers to limit this behavior. However in writer side we can avoid list_for_each_entry_rcu() and use list_for_each_entry().