Readers pay nothing
Read copy update (RCU) is a synchronization technique optimized for data read far more often than written, like routing tables in the kernel. Readers enter a read side critical section with almost no overhead: no atomic operations, no locks, often just disabling preemption.
How writers update
A writer never mutates shared data in place where readers might see a torn state. Instead:
- It copies the node it wants to change.
- It modifies the copy privately.
- It atomically swaps the pointer so new readers see the new version.
Old readers keep using the old version safely because it still exists.
The grace period
The freed old node cannot be reclaimed until every reader that might hold a reference has left its critical section. The writer waits for a grace period: a span after which all pre existing read side sections are guaranteed to have finished. Only then is the old copy freed. This deferred reclamation is what makes RCU safe without reference counting on the read path.
Key idea
RCU lets readers run with near zero overhead by having writers copy, modify, and swap pointers, deferring reclamation of old versions until a grace period guarantees no reader still references them.