10.3.2.1 RCU is a Reader-Writer Lock Replacement
Keywords: perfbook_html

###
10.3.2.1 RCU is a Reader-Writer Lock Replacement

Perhaps the most common use of RCU within the Linux kernel is as a replacement for reader-writer locking in read-intensive situations. Nevertheless, this use of RCU was not immediately apparent to me at the outset, in fact, I chose to implement something similar to brlock before implementing a general-purpose RCU implementation back in the early 1990s. Each and every one of the uses I envisioned for the proto-brlock primitive was instead implemented using RCU. In fact, it was more than three years before the proto-brlock primitive saw its first use. Boy, did I feel foolish!

The key similarity between RCU and reader-writer locking is that both have read-side critical sections that can execute in parallel. In fact, in some cases, it is possible to mechanically substitute RCU API members for the corresponding reader-writer lock API members. But first, why bother?

Advantages of RCU include performance, deadlock immunity, and realtime latency. There are, of course, limitations to RCU, including the fact that readers and updaters run concurrently, that low-priority RCU readers can block high-priority threads waiting for a grace period to elapse, and that grace-period latencies can extend for many milliseconds. These advantages and limitations are discussed in the following sections.

Subsections

- 10.3.2.1.1 Performance
- 10.3.2.1.2 Deadlock Immunity
- 10.3.2.1.3 Realtime Latency
- 10.3.2.1.4 RCU Readers and Updaters Run Concurrently
- 10.3.2.1.5 Low-Priority RCU Readers Can Block High-Priority Reclaimers
- 10.3.2.1.6 RCU Grace Periods Extend for Many Milliseconds
- 10.3.2.1.7 Comparison of Reader-Writer Locking and RCU Code