@@ -1943,56 +1943,27 @@ invoked from a CPU-hotplug notifier.
19431943Scheduler and RCU
19441944~~~~~~~~~~~~~~~~~
19451945
1946- RCU depends on the scheduler, and the scheduler uses RCU to protect some
1947- of its data structures. The preemptible-RCU ``rcu_read_unlock() ``
1948- implementation must therefore be written carefully to avoid deadlocks
1949- involving the scheduler's runqueue and priority-inheritance locks. In
1950- particular, ``rcu_read_unlock() `` must tolerate an interrupt where the
1951- interrupt handler invokes both ``rcu_read_lock() `` and
1952- ``rcu_read_unlock() ``. This possibility requires ``rcu_read_unlock() ``
1953- to use negative nesting levels to avoid destructive recursion via
1954- interrupt handler's use of RCU.
1955-
1956- This scheduler-RCU requirement came as a `complete
1957- surprise <https://lwn.net/Articles/453002/> `__.
1958-
1959- As noted above, RCU makes use of kthreads, and it is necessary to avoid
1960- excessive CPU-time accumulation by these kthreads. This requirement was
1961- no surprise, but RCU's violation of it when running context-switch-heavy
1962- workloads when built with ``CONFIG_NO_HZ_FULL=y `` `did come as a
1963- surprise
1946+ RCU makes use of kthreads, and it is necessary to avoid excessive CPU-time
1947+ accumulation by these kthreads. This requirement was no surprise, but
1948+ RCU's violation of it when running context-switch-heavy workloads when
1949+ built with ``CONFIG_NO_HZ_FULL=y `` `did come as a surprise
19641950[PDF] <http://www.rdrop.com/users/paulmck/scalability/paper/BareMetal.2015.01.15b.pdf> `__.
19651951RCU has made good progress towards meeting this requirement, even for
19661952context-switch-heavy ``CONFIG_NO_HZ_FULL=y `` workloads, but there is
19671953room for further improvement.
19681954
1969- It is forbidden to hold any of scheduler's runqueue or
1970- priority-inheritance spinlocks across an ``rcu_read_unlock() `` unless
1971- interrupts have been disabled across the entire RCU read-side critical
1972- section, that is, up to and including the matching ``rcu_read_lock() ``.
1973- Violating this restriction can result in deadlocks involving these
1974- scheduler spinlocks. There was hope that this restriction might be
1975- lifted when interrupt-disabled calls to ``rcu_read_unlock() `` started
1976- deferring the reporting of the resulting RCU-preempt quiescent state
1977- until the end of the corresponding interrupts-disabled region.
1978- Unfortunately, timely reporting of the corresponding quiescent state to
1979- expedited grace periods requires a call to ``raise_softirq() ``, which
1980- can acquire these scheduler spinlocks. In addition, real-time systems
1981- using RCU priority boosting need this restriction to remain in effect
1982- because deferred quiescent-state reporting would also defer deboosting,
1983- which in turn would degrade real-time latencies.
1984-
1985- In theory, if a given RCU read-side critical section could be guaranteed
1986- to be less than one second in duration, holding a scheduler spinlock
1987- across that critical section's ``rcu_read_unlock() `` would require only
1988- that preemption be disabled across the entire RCU read-side critical
1989- section, not interrupts. Unfortunately, given the possibility of vCPU
1990- preemption, long-running interrupts, and so on, it is not possible in
1991- practice to guarantee that a given RCU read-side critical section will
1992- complete in less than one second. Therefore, as noted above, if
1993- scheduler spinlocks are held across a given call to
1994- ``rcu_read_unlock() ``, interrupts must be disabled across the entire RCU
1995- read-side critical section.
1955+ There is no longer any prohibition against holding any of
1956+ scheduler's runqueue or priority-inheritance spinlocks across an
1957+ ``rcu_read_unlock() ``, even if interrupts and preemption were enabled
1958+ somewhere within the corresponding RCU read-side critical section.
1959+ Therefore, it is now perfectly legal to execute ``rcu_read_lock() ``
1960+ with preemption enabled, acquire one of the scheduler locks, and hold
1961+ that lock across the matching ``rcu_read_unlock() ``.
1962+
1963+ Similarly, the RCU flavor consolidation has removed the need for negative
1964+ nesting. The fact that interrupt-disabled regions of code act as RCU
1965+ read-side critical sections implicitly avoids earlier issues that used
1966+ to result in destructive recursion via interrupt handler's use of RCU.
19961967
19971968Tracing and RCU
19981969~~~~~~~~~~~~~~~
0 commit comments