E.8.1 State Variables for Simplified Dynticks Interface
Keywords: perfbook_html

##
E.8.1 State Variables for Simplified Dynticks Interface

Figure: Variables for Simple Dynticks Interface

Figure shows the new per-CPU state variables. These variables are grouped into structs to allow multiple independent RCU implementations (e.g., rcu and rcu_bh) to conveniently and efficiently share dynticks state. In what follows, they can be thought of as independent per-CPU variables.

The dynticks_nesting, dynticks, and dynticks_snap variables are for the irq code paths, and the dynticks_nmi and dynticks_nmi_snap variables are for the NMI code paths, although the NMI code path will also reference (but not modify) the dynticks_nesting variable. These variables are used as follows:

- dynticks_nesting: This counts the number of reasons that the corresponding CPU should be monitored for RCU read-side critical sections. If the CPU is in dynticks-idle mode, then this counts the irq nesting level, otherwise it is one greater than the irq nesting level.
- dynticks: This counter's value is even if the corresponding CPU is in dynticks-idle mode and there are no irq handlers currently running on that CPU, otherwise the counter's value is odd. In other words, if this counter's value is odd, then the corresponding CPU might be in an RCU read-side critical section.
- dynticks_nmi: This counter's value is odd if the corresponding CPU is in an NMI handler, but only if the NMI arrived while this CPU was in dyntick-idle mode with no irq handlers running. Otherwise, the counter's value will be even.
- dynticks_snap: This will be a snapshot of the dynticks counter, but only if the current RCU grace period has extended for too long a duration.
- dynticks_nmi_snap: This will be a snapshot of the dynticks_nmi counter, but again only if the current RCU grace period has extended for too long a duration.

If both dynticks and dynticks_nmi have taken on an even value during a given time interval, then the corresponding CPU has passed through a quiescent state during that interval.

Quick Quiz E.19: But what happens if an NMI handler starts running before an irq handler completes, and if that NMI handler continues running until a second irq handler starts? End Quick Quiz