D.3.6.2 Noting End of Old Grace Periods

Figure: Noting End of Old Grace Periods
\begin{figure}{ \scriptsize
\begin{verbatim}1 static void
2 rcu_process_gp_e...
...ed_snap;
18 }
19 local_irq_restore(flags);
20 }\end{verbatim}
}\end{figure}

Figure: RCU Callback List
\resizebox{3in}{!}{\includegraphics{appendix/rcuimpl/AdvanceRCUCallbacks}}

Figure [*] shows rcu_process_gp_end(), which is invoked when a CPU suspects that a grace period might have ended (possibly because the CPU in question in fact ended the grace period). If a grace period really has ended, then this function advances the current CPU's RCU callbacks, which are managed as a singly linked list with multiple tail pointers, as shown in Figure [*]. This multiple tail pointer layout, spearheaded by Lai Jiangshan, simplifies list handling [Jia08]. In this figure, the blue box represents one CPU's rcu_data structure, with the six white boxes at the bottom of the diagram representing a list of six RCU callbacks (rcu_head structures). In this list, the first three callbacks have passed through their grace period and are thus waiting to be invoked, the fourth callback (the first on the second line) is waiting for the current grace period to complete, and the last two are waiting for the next grace period. The last two tail pointers reference the last element, so that the final sublist, which would comprise callbacks that had not yet been associated with a specific grace period, is empty.

Lines 8 and 19 of Figure [*] suppress and re-enable interrupts, respectively. Line 9 picks up a snapshot of the rcu_state structure's ->completed field, storing it in the local variable completed_snap. Line 10 checks to see if the current CPU is not yet aware of the end of a grace period, and if it is not aware, lines 11-16 advance this CPU's RCU callbacks by manipulating the tail pointers. Line 17 then records the most recently completed grace period number in this CPU's rcu_data structure in the ->completed field.

Paul E. McKenney 2011-12-16