Read-copy update (RCU) is one of the synchronization mechanism of the linux kernel, which supports concurrency between a single updater and multiple readers.

Updates are into “removal” and “reclamation” phases

  • removal, remove references to items within a data structure. Can run concurrently with readers.
    • It is safe because modern CPUs guarantee that readers will not see a partially updated reference
  • reclamation, free the data items. This phase must not start until readers no longer hold references to those data items.

The sequence is the following:

  • remove pointers to a data structure so that subsequent readers cannot gain a reference to it
  • wait for all existing readers to complete their RCU read-side critical sections (grace period). In this period, readers always read the old version.
  • at this point, it can be safely reclaimed

See also

References