Day66 - RCU Quiescent State and Tree RCU Overview¶
Topic¶
Linux Kernel RCU internals.
This session focused on understanding how Linux RCU scales beyond the simple global reader counter model used in educational implementations.
Goals¶
- Understand why a global reader counter does not scale.
- Understand the meaning of a quiescent state.
- Understand how Linux RCU tracks CPU progress instead of counting readers.
- Understand grace period detection at a high level.
- Understand the motivation behind Tree RCU.
Completed Labs¶
Lab1 - Quiescent State Tracking Simulation¶
Implemented two grace period models.
Model A - Global Reader Counter¶
Used a shared atomic counter:
Grace period completion:
This model matches the simplified Mini RCU implementation used in previous labs.
Model B - Quiescent State Tracking¶
Used per-thread state tracking:
Each reader reports a quiescent state after leaving its read-side critical section.
Grace period completion:
This model demonstrates the fundamental idea behind Linux RCU internals.
Key Understanding¶
A global reader counter is easy to understand:
However, this design does not scale on large multi-core systems because every reader must modify the same shared counter.
Linux RCU avoids this design.
Instead, Linux tracks whether each CPU has progressed through a safe point where it can no longer hold a reader from the beginning of the grace period.
Quiescent State¶
A quiescent state does not mean:
Instead, it means:
Conceptually:
When all relevant CPUs become safe, the grace period can complete.
Reader Counter vs CPU Progress Tracking¶
Educational Mini RCU:
Linux RCU:
This is the most important conceptual difference between the two approaches.
Tree RCU Motivation¶
Tracking a small number of CPUs is simple:
However, modern systems may contain:
Scanning every CPU for every grace period would become expensive.
Linux solves this using a hierarchical tracking structure:
This design is known as Tree RCU.
Tree RCU allows grace period status to be aggregated efficiently across large CPU counts.
Lab Observations¶
Model A demonstrated:
Model B demonstrated:
Although the lab used threads instead of CPUs, it clearly showed the conceptual shift from reader counting to progress tracking.
Summary¶
Day66 completed the introduction to Linux RCU internals.
The most important conclusion is:
Grace period detection is based on quiescent state reporting rather than a global reader counter.
Next¶
Synchronization series wrap-up:
- Linux Synchronization Topic Summary
- Linux Synchronization API Reference
Future topics:
- Workqueue
- Kernel Thread
- Completion
- Notifier Chain