Day66 - Quiescent State Tracking and Tree RCU Overview¶
Overview¶
This lab explores the conceptual difference between a simple reader-counting RCU implementation and the high-level design used by Linux RCU.
The goal is not to implement Linux Tree RCU, but to understand why Linux tracks CPU progress and quiescent states instead of maintaining a global reader counter.
Learning Objectives¶
- Understand the limitation of a global reader counter.
- Understand the concept of a quiescent state.
- Understand grace period completion using progress tracking.
- Understand why Linux RCU scales better on large multi-core systems.
- Understand the motivation behind Tree RCU.
Lab1 - Reader Counter vs Quiescent State Tracking¶
Objective¶
Compare two grace period detection models:
The lab demonstrates how Linux RCU shifts from reader counting to CPU progress tracking.
Model A - Global Reader Counter¶
Design¶
A shared counter tracks active readers:
Reader entry:
Reader exit:
Grace Period Detection¶
Writer waits until:
Pseudo code:
Conceptual Model¶
Reader Enter
↓
reader_count++
↓
Reader Exit
↓
reader_count--
↓
reader_count == 0
↓
Grace Period Complete
Limitation¶
Every reader modifies the same shared variable:
This becomes increasingly expensive as CPU count grows.
Model B - Quiescent State Tracking¶
Design¶
Each reader maintains its own state:
Per-reader tracking:
Reader Flow¶
Reader enters:
Reader exits:
Example:
Grace Period Detection¶
Writer waits until every reader reports:
Pseudo code:
for (;;) {
all_done = true;
for (i = 0; i < READER_NUM; i++) {
if (g_qs_state[i] != QS_REPORTED) {
all_done = false;
break;
}
}
if (all_done)
break;
}
Conceptual Model¶
What Is a Quiescent State?¶
A quiescent state is often misunderstood.
It does not mean:
Instead it means:
Simplified Interpretation¶
Grace Period Starts
↓
CPU progresses
↓
CPU reaches safe point
↓
CPU reports QS
↓
Grace Period progresses
Reader Counting vs Progress Tracking¶
Mini RCU¶
Linux RCU¶
Tree RCU Motivation¶
Tracking a few CPUs is easy.
Example:
However, Linux may run on systems containing:
Checking every CPU individually becomes inefficient.
Hierarchical Tracking¶
Linux aggregates status through multiple layers:
Aggregation¶
Instead of tracking every CPU directly:
Groups report completion upward.
Eventually:
This concept is known as Tree RCU.
Results¶
Model A¶
Grace period completion depends on:
The system counts active readers.
Model B¶
Grace period completion depends on:
The system tracks progress rather than counting readers.
Key Takeaways¶
Model A¶
Model B¶
Most Important Conclusion¶
This shift from reader counting to progress tracking is the foundation of modern Linux RCU implementations.