rcu_read_unlock()¶
Purpose¶
rcu_read_unlock() marks the end of an RCU read-side critical section.
After this call returns, the current execution context is no longer considered an active RCU reader.
Prototype¶
Header¶
Usage Pattern¶
Behavior¶
rcu_read_unlock() informs the RCU subsystem that the current reader has completed access to RCU-protected objects.
Once all readers that existed before a grace period have exited their read-side critical sections:
and deferred object reclamation may proceed.
Reader Lifetime¶
Conceptually:
The object must remain valid throughout the entire read-side critical section.
Important Rules¶
- Always pair with
rcu_read_lock(). - Do not access RCU-protected objects after calling
rcu_read_unlock(). - Do not free RCU-protected objects directly from reader code.
- Reader code should not perform object reclamation.
Common Mistake¶
Incorrect:
The object is accessed after leaving the RCU read-side critical section.
Correct:
Relationship to Grace Period¶
RCU writers often wait for readers to complete:
The grace period cannot complete until all existing readers have executed: