D.3.6.1 Noting New Grace Periods
Keywords: perfbook_html

###
D.3.6.1 Noting New Grace Periods

The main purpose of Hierarchical RCU is to detect grace periods, and the functions more directly involved in this task are described in this section. Section covers functions that allow CPUs to note that a new grace period has begun, Section covers functions that allow CPUs to note that an existing grace period has ended, Section covers rcu_start_gp(), which starts a new grace period, and Section covers functions involved in reporting CPUs' quiescent states to the RCU core.

Figure: Noting New Grace Periods

Figure shows the code for note_new_gpnum(), which updates state to reflect a new grace period, as well as check_for_new_grace_period(), which is used by CPUs to detect when other CPUs have started a new grace period.

Line 4 of note_new_gpnum() sets the ->qs_pending flag is the current CPU's rcu_data structure to indicate that RCU needs a quiescent state from this CPU, line 5 clears the ->passed_quiesc flag to indicate that this CPU has not yet passed through such a quiescent state, line 6 copies the grace-period number from the global rcu_state structure to this CPU's rcu_data structure so that this CPU will remember that it has already noted the beginning of this new grace period. Finally, lines 7-8 record the time in jiffies at which this CPU will attempt to force holdout CPUs to pass through quiescent states (by invoking force_quiescent_state() on or after that future time), assuming that the grace period does not end beforehand.

Lines 18 and 23 of check_for_new_grace_period() disable and re-enable interrupts, respectively. Line 19 checks to see if there is a new grace period that the current CPU has not yet noted, and, if so, line 20 invokes note_new_gpnum() in order to note the new grace period, and line 21 sets the return value accordingly. Either way, line 24 returns status: non-zero if a new grace period has started, and zero otherwise.

Quick Quiz D.42: Why not just expand note_new_gpnum() inline into check_for_new_grace_period() in Figure ? End Quick Quiz