RCU Kernel Implementation
In our last session, we learned how to use RCU API as a synchronization mechanism using a sample driver. Please visit the last session if you missed. In this blog, we will be going through Kernel Implementation of RCU API. The below diagram depicts the overall RCU API used for synchronization. rcu_read_lock() - The kernel implementation is as follows - static inline void rcu_read_lock(void) { __rcu_read_lock(); __acquire(RCU); rcu_lock_acquire(&rcu_lock_map); rcu_lockdep_assert(rcu_is_watching(), "rcu_read_lock() used illegally while idle"); } Basically the above function disables the preemption on the particular cpu on which it is running. So that no other process can preempt this process and the process completes its execution without interruption. After holding rcu_read_lock() it is illegal for the process to explicitly call sleep. rcu_read_unlock()- static inline void rcu_read_unlock