0001 =================================================
0002 A Tour Through TREE_RCU's Expedited Grace Periods
0003 =================================================
0004
0005 Introduction
0006 ============
0007
0008 This document describes RCU's expedited grace periods.
0009 Unlike RCU's normal grace periods, which accept long latencies to attain
0010 high efficiency and minimal disturbance, expedited grace periods accept
0011 lower efficiency and significant disturbance to attain shorter latencies.
0012
0013 There are two flavors of RCU (RCU-preempt and RCU-sched), with an earlier
0014 third RCU-bh flavor having been implemented in terms of the other two.
0015 Each of the two implementations is covered in its own section.
0016
0017 Expedited Grace Period Design
0018 =============================
0019
0020 The expedited RCU grace periods cannot be accused of being subtle,
0021 given that they for all intents and purposes hammer every CPU that
0022 has not yet provided a quiescent state for the current expedited
0023 grace period.
0024 The one saving grace is that the hammer has grown a bit smaller
0025 over time: The old call to ``try_stop_cpus()`` has been
0026 replaced with a set of calls to ``smp_call_function_single()``,
0027 each of which results in an IPI to the target CPU.
0028 The corresponding handler function checks the CPU's state, motivating
0029 a faster quiescent state where possible, and triggering a report
0030 of that quiescent state.
0031 As always for RCU, once everything has spent some time in a quiescent
0032 state, the expedited grace period has completed.
0033
0034 The details of the ``smp_call_function_single()`` handler's
0035 operation depend on the RCU flavor, as described in the following
0036 sections.
0037
0038 RCU-preempt Expedited Grace Periods
0039 ===================================
0040
0041 ``CONFIG_PREEMPTION=y`` kernels implement RCU-preempt.
0042 The overall flow of the handling of a given CPU by an RCU-preempt
0043 expedited grace period is shown in the following diagram:
0044
0045 .. kernel-figure:: ExpRCUFlow.svg
0046
0047 The solid arrows denote direct action, for example, a function call.
0048 The dotted arrows denote indirect action, for example, an IPI
0049 or a state that is reached after some time.
0050
0051 If a given CPU is offline or idle, ``synchronize_rcu_expedited()``
0052 will ignore it because idle and offline CPUs are already residing
0053 in quiescent states.
0054 Otherwise, the expedited grace period will use
0055 ``smp_call_function_single()`` to send the CPU an IPI, which
0056 is handled by ``rcu_exp_handler()``.
0057
0058 However, because this is preemptible RCU, ``rcu_exp_handler()``
0059 can check to see if the CPU is currently running in an RCU read-side
0060 critical section.
0061 If not, the handler can immediately report a quiescent state.
0062 Otherwise, it sets flags so that the outermost ``rcu_read_unlock()``
0063 invocation will provide the needed quiescent-state report.
0064 This flag-setting avoids the previous forced preemption of all
0065 CPUs that might have RCU read-side critical sections.
0066 In addition, this flag-setting is done so as to avoid increasing
0067 the overhead of the common-case fastpath through the scheduler.
0068
0069 Again because this is preemptible RCU, an RCU read-side critical section
0070 can be preempted.
0071 When that happens, RCU will enqueue the task, which will the continue to
0072 block the current expedited grace period until it resumes and finds its
0073 outermost ``rcu_read_unlock()``.
0074 The CPU will report a quiescent state just after enqueuing the task because
0075 the CPU is no longer blocking the grace period.
0076 It is instead the preempted task doing the blocking.
0077 The list of blocked tasks is managed by ``rcu_preempt_ctxt_queue()``,
0078 which is called from ``rcu_preempt_note_context_switch()``, which
0079 in turn is called from ``rcu_note_context_switch()``, which in
0080 turn is called from the scheduler.
0081
0082
0083 +-----------------------------------------------------------------------+
0084 | **Quick Quiz**: |
0085 +-----------------------------------------------------------------------+
0086 | Why not just have the expedited grace period check the state of all |
0087 | the CPUs? After all, that would avoid all those real-time-unfriendly |
0088 | IPIs. |
0089 +-----------------------------------------------------------------------+
0090 | **Answer**: |
0091 +-----------------------------------------------------------------------+
0092 | Because we want the RCU read-side critical sections to run fast, |
0093 | which means no memory barriers. Therefore, it is not possible to |
0094 | safely check the state from some other CPU. And even if it was |
0095 | possible to safely check the state, it would still be necessary to |
0096 | IPI the CPU to safely interact with the upcoming |
0097 | ``rcu_read_unlock()`` invocation, which means that the remote state |
0098 | testing would not help the worst-case latency that real-time |
0099 | applications care about. |
0100 | |
0101 | One way to prevent your real-time application from getting hit with |
0102 | these IPIs is to build your kernel with ``CONFIG_NO_HZ_FULL=y``. RCU |
0103 | would then perceive the CPU running your application as being idle, |
0104 | and it would be able to safely detect that state without needing to |
0105 | IPI the CPU. |
0106 +-----------------------------------------------------------------------+
0107
0108 Please note that this is just the overall flow: Additional complications
0109 can arise due to races with CPUs going idle or offline, among other
0110 things.
0111
0112 RCU-sched Expedited Grace Periods
0113 ---------------------------------
0114
0115 ``CONFIG_PREEMPTION=n`` kernels implement RCU-sched. The overall flow of
0116 the handling of a given CPU by an RCU-sched expedited grace period is
0117 shown in the following diagram:
0118
0119 .. kernel-figure:: ExpSchedFlow.svg
0120
0121 As with RCU-preempt, RCU-sched's ``synchronize_rcu_expedited()`` ignores
0122 offline and idle CPUs, again because they are in remotely detectable
0123 quiescent states. However, because the ``rcu_read_lock_sched()`` and
0124 ``rcu_read_unlock_sched()`` leave no trace of their invocation, in
0125 general it is not possible to tell whether or not the current CPU is in
0126 an RCU read-side critical section. The best that RCU-sched's
0127 ``rcu_exp_handler()`` can do is to check for idle, on the off-chance
0128 that the CPU went idle while the IPI was in flight. If the CPU is idle,
0129 then ``rcu_exp_handler()`` reports the quiescent state.
0130
0131 Otherwise, the handler forces a future context switch by setting the
0132 NEED_RESCHED flag of the current task's thread flag and the CPU preempt
0133 counter. At the time of the context switch, the CPU reports the
0134 quiescent state. Should the CPU go offline first, it will report the
0135 quiescent state at that time.
0136
0137 Expedited Grace Period and CPU Hotplug
0138 --------------------------------------
0139
0140 The expedited nature of expedited grace periods require a much tighter
0141 interaction with CPU hotplug operations than is required for normal
0142 grace periods. In addition, attempting to IPI offline CPUs will result
0143 in splats, but failing to IPI online CPUs can result in too-short grace
0144 periods. Neither option is acceptable in production kernels.
0145
0146 The interaction between expedited grace periods and CPU hotplug
0147 operations is carried out at several levels:
0148
0149 #. The number of CPUs that have ever been online is tracked by the
0150 ``rcu_state`` structure's ``->ncpus`` field. The ``rcu_state``
0151 structure's ``->ncpus_snap`` field tracks the number of CPUs that
0152 have ever been online at the beginning of an RCU expedited grace
0153 period. Note that this number never decreases, at least in the
0154 absence of a time machine.
0155 #. The identities of the CPUs that have ever been online is tracked by
0156 the ``rcu_node`` structure's ``->expmaskinitnext`` field. The
0157 ``rcu_node`` structure's ``->expmaskinit`` field tracks the
0158 identities of the CPUs that were online at least once at the
0159 beginning of the most recent RCU expedited grace period. The
0160 ``rcu_state`` structure's ``->ncpus`` and ``->ncpus_snap`` fields are
0161 used to detect when new CPUs have come online for the first time,
0162 that is, when the ``rcu_node`` structure's ``->expmaskinitnext``
0163 field has changed since the beginning of the last RCU expedited grace
0164 period, which triggers an update of each ``rcu_node`` structure's
0165 ``->expmaskinit`` field from its ``->expmaskinitnext`` field.
0166 #. Each ``rcu_node`` structure's ``->expmaskinit`` field is used to
0167 initialize that structure's ``->expmask`` at the beginning of each
0168 RCU expedited grace period. This means that only those CPUs that have
0169 been online at least once will be considered for a given grace
0170 period.
0171 #. Any CPU that goes offline will clear its bit in its leaf ``rcu_node``
0172 structure's ``->qsmaskinitnext`` field, so any CPU with that bit
0173 clear can safely be ignored. However, it is possible for a CPU coming
0174 online or going offline to have this bit set for some time while
0175 ``cpu_online`` returns ``false``.
0176 #. For each non-idle CPU that RCU believes is currently online, the
0177 grace period invokes ``smp_call_function_single()``. If this
0178 succeeds, the CPU was fully online. Failure indicates that the CPU is
0179 in the process of coming online or going offline, in which case it is
0180 necessary to wait for a short time period and try again. The purpose
0181 of this wait (or series of waits, as the case may be) is to permit a
0182 concurrent CPU-hotplug operation to complete.
0183 #. In the case of RCU-sched, one of the last acts of an outgoing CPU is
0184 to invoke ``rcu_report_dead()``, which reports a quiescent state for
0185 that CPU. However, this is likely paranoia-induced redundancy.
0186
0187 +-----------------------------------------------------------------------+
0188 | **Quick Quiz**: |
0189 +-----------------------------------------------------------------------+
0190 | Why all the dancing around with multiple counters and masks tracking |
0191 | CPUs that were once online? Why not just have a single set of masks |
0192 | tracking the currently online CPUs and be done with it? |
0193 +-----------------------------------------------------------------------+
0194 | **Answer**: |
0195 +-----------------------------------------------------------------------+
0196 | Maintaining single set of masks tracking the online CPUs *sounds* |
0197 | easier, at least until you try working out all the race conditions |
0198 | between grace-period initialization and CPU-hotplug operations. For |
0199 | example, suppose initialization is progressing down the tree while a |
0200 | CPU-offline operation is progressing up the tree. This situation can |
0201 | result in bits set at the top of the tree that have no counterparts |
0202 | at the bottom of the tree. Those bits will never be cleared, which |
0203 | will result in grace-period hangs. In short, that way lies madness, |
0204 | to say nothing of a great many bugs, hangs, and deadlocks. |
0205 | In contrast, the current multi-mask multi-counter scheme ensures that |
0206 | grace-period initialization will always see consistent masks up and |
0207 | down the tree, which brings significant simplifications over the |
0208 | single-mask method. |
0209 | |
0210 | This is an instance of `deferring work in order to avoid |
0211 | synchronization <http://www.cs.columbia.edu/~library/TR-repository/re |
0212 | ports/reports-1992/cucs-039-92.ps.gz>`__. |
0213 | Lazily recording CPU-hotplug events at the beginning of the next |
0214 | grace period greatly simplifies maintenance of the CPU-tracking |
0215 | bitmasks in the ``rcu_node`` tree. |
0216 +-----------------------------------------------------------------------+
0217
0218 Expedited Grace Period Refinements
0219 ----------------------------------
0220
0221 Idle-CPU Checks
0222 ~~~~~~~~~~~~~~~
0223
0224 Each expedited grace period checks for idle CPUs when initially forming
0225 the mask of CPUs to be IPIed and again just before IPIing a CPU (both
0226 checks are carried out by ``sync_rcu_exp_select_cpus()``). If the CPU is
0227 idle at any time between those two times, the CPU will not be IPIed.
0228 Instead, the task pushing the grace period forward will include the idle
0229 CPUs in the mask passed to ``rcu_report_exp_cpu_mult()``.
0230
0231 For RCU-sched, there is an additional check: If the IPI has interrupted
0232 the idle loop, then ``rcu_exp_handler()`` invokes
0233 ``rcu_report_exp_rdp()`` to report the corresponding quiescent state.
0234
0235 For RCU-preempt, there is no specific check for idle in the IPI handler
0236 (``rcu_exp_handler()``), but because RCU read-side critical sections are
0237 not permitted within the idle loop, if ``rcu_exp_handler()`` sees that
0238 the CPU is within RCU read-side critical section, the CPU cannot
0239 possibly be idle. Otherwise, ``rcu_exp_handler()`` invokes
0240 ``rcu_report_exp_rdp()`` to report the corresponding quiescent state,
0241 regardless of whether or not that quiescent state was due to the CPU
0242 being idle.
0243
0244 In summary, RCU expedited grace periods check for idle when building the
0245 bitmask of CPUs that must be IPIed, just before sending each IPI, and
0246 (either explicitly or implicitly) within the IPI handler.
0247
0248 Batching via Sequence Counter
0249 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0250
0251 If each grace-period request was carried out separately, expedited grace
0252 periods would have abysmal scalability and problematic high-load
0253 characteristics. Because each grace-period operation can serve an
0254 unlimited number of updates, it is important to *batch* requests, so
0255 that a single expedited grace-period operation will cover all requests
0256 in the corresponding batch.
0257
0258 This batching is controlled by a sequence counter named
0259 ``->expedited_sequence`` in the ``rcu_state`` structure. This counter
0260 has an odd value when there is an expedited grace period in progress and
0261 an even value otherwise, so that dividing the counter value by two gives
0262 the number of completed grace periods. During any given update request,
0263 the counter must transition from even to odd and then back to even, thus
0264 indicating that a grace period has elapsed. Therefore, if the initial
0265 value of the counter is ``s``, the updater must wait until the counter
0266 reaches at least the value ``(s+3)&~0x1``. This counter is managed by
0267 the following access functions:
0268
0269 #. ``rcu_exp_gp_seq_start()``, which marks the start of an expedited
0270 grace period.
0271 #. ``rcu_exp_gp_seq_end()``, which marks the end of an expedited grace
0272 period.
0273 #. ``rcu_exp_gp_seq_snap()``, which obtains a snapshot of the counter.
0274 #. ``rcu_exp_gp_seq_done()``, which returns ``true`` if a full expedited
0275 grace period has elapsed since the corresponding call to
0276 ``rcu_exp_gp_seq_snap()``.
0277
0278 Again, only one request in a given batch need actually carry out a
0279 grace-period operation, which means there must be an efficient way to
0280 identify which of many concurrent reqeusts will initiate the grace
0281 period, and that there be an efficient way for the remaining requests to
0282 wait for that grace period to complete. However, that is the topic of
0283 the next section.
0284
0285 Funnel Locking and Wait/Wakeup
0286 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0287
0288 The natural way to sort out which of a batch of updaters will initiate
0289 the expedited grace period is to use the ``rcu_node`` combining tree, as
0290 implemented by the ``exp_funnel_lock()`` function. The first updater
0291 corresponding to a given grace period arriving at a given ``rcu_node``
0292 structure records its desired grace-period sequence number in the
0293 ``->exp_seq_rq`` field and moves up to the next level in the tree.
0294 Otherwise, if the ``->exp_seq_rq`` field already contains the sequence
0295 number for the desired grace period or some later one, the updater
0296 blocks on one of four wait queues in the ``->exp_wq[]`` array, using the
0297 second-from-bottom and third-from bottom bits as an index. An
0298 ``->exp_lock`` field in the ``rcu_node`` structure synchronizes access
0299 to these fields.
0300
0301 An empty ``rcu_node`` tree is shown in the following diagram, with the
0302 white cells representing the ``->exp_seq_rq`` field and the red cells
0303 representing the elements of the ``->exp_wq[]`` array.
0304
0305 .. kernel-figure:: Funnel0.svg
0306
0307 The next diagram shows the situation after the arrival of Task A and
0308 Task B at the leftmost and rightmost leaf ``rcu_node`` structures,
0309 respectively. The current value of the ``rcu_state`` structure's
0310 ``->expedited_sequence`` field is zero, so adding three and clearing the
0311 bottom bit results in the value two, which both tasks record in the
0312 ``->exp_seq_rq`` field of their respective ``rcu_node`` structures:
0313
0314 .. kernel-figure:: Funnel1.svg
0315
0316 Each of Tasks A and B will move up to the root ``rcu_node`` structure.
0317 Suppose that Task A wins, recording its desired grace-period sequence
0318 number and resulting in the state shown below:
0319
0320 .. kernel-figure:: Funnel2.svg
0321
0322 Task A now advances to initiate a new grace period, while Task B moves
0323 up to the root ``rcu_node`` structure, and, seeing that its desired
0324 sequence number is already recorded, blocks on ``->exp_wq[1]``.
0325
0326 +-----------------------------------------------------------------------+
0327 | **Quick Quiz**: |
0328 +-----------------------------------------------------------------------+
0329 | Why ``->exp_wq[1]``? Given that the value of these tasks' desired |
0330 | sequence number is two, so shouldn't they instead block on |
0331 | ``->exp_wq[2]``? |
0332 +-----------------------------------------------------------------------+
0333 | **Answer**: |
0334 +-----------------------------------------------------------------------+
0335 | No. |
0336 | Recall that the bottom bit of the desired sequence number indicates |
0337 | whether or not a grace period is currently in progress. It is |
0338 | therefore necessary to shift the sequence number right one bit |
0339 | position to obtain the number of the grace period. This results in |
0340 | ``->exp_wq[1]``. |
0341 +-----------------------------------------------------------------------+
0342
0343 If Tasks C and D also arrive at this point, they will compute the same
0344 desired grace-period sequence number, and see that both leaf
0345 ``rcu_node`` structures already have that value recorded. They will
0346 therefore block on their respective ``rcu_node`` structures'
0347 ``->exp_wq[1]`` fields, as shown below:
0348
0349 .. kernel-figure:: Funnel3.svg
0350
0351 Task A now acquires the ``rcu_state`` structure's ``->exp_mutex`` and
0352 initiates the grace period, which increments ``->expedited_sequence``.
0353 Therefore, if Tasks E and F arrive, they will compute a desired sequence
0354 number of 4 and will record this value as shown below:
0355
0356 .. kernel-figure:: Funnel4.svg
0357
0358 Tasks E and F will propagate up the ``rcu_node`` combining tree, with
0359 Task F blocking on the root ``rcu_node`` structure and Task E wait for
0360 Task A to finish so that it can start the next grace period. The
0361 resulting state is as shown below:
0362
0363 .. kernel-figure:: Funnel5.svg
0364
0365 Once the grace period completes, Task A starts waking up the tasks
0366 waiting for this grace period to complete, increments the
0367 ``->expedited_sequence``, acquires the ``->exp_wake_mutex`` and then
0368 releases the ``->exp_mutex``. This results in the following state:
0369
0370 .. kernel-figure:: Funnel6.svg
0371
0372 Task E can then acquire ``->exp_mutex`` and increment
0373 ``->expedited_sequence`` to the value three. If new tasks G and H arrive
0374 and moves up the combining tree at the same time, the state will be as
0375 follows:
0376
0377 .. kernel-figure:: Funnel7.svg
0378
0379 Note that three of the root ``rcu_node`` structure's waitqueues are now
0380 occupied. However, at some point, Task A will wake up the tasks blocked
0381 on the ``->exp_wq`` waitqueues, resulting in the following state:
0382
0383 .. kernel-figure:: Funnel8.svg
0384
0385 Execution will continue with Tasks E and H completing their grace
0386 periods and carrying out their wakeups.
0387
0388 +-----------------------------------------------------------------------+
0389 | **Quick Quiz**: |
0390 +-----------------------------------------------------------------------+
0391 | What happens if Task A takes so long to do its wakeups that Task E's |
0392 | grace period completes? |
0393 +-----------------------------------------------------------------------+
0394 | **Answer**: |
0395 +-----------------------------------------------------------------------+
0396 | Then Task E will block on the ``->exp_wake_mutex``, which will also |
0397 | prevent it from releasing ``->exp_mutex``, which in turn will prevent |
0398 | the next grace period from starting. This last is important in |
0399 | preventing overflow of the ``->exp_wq[]`` array. |
0400 +-----------------------------------------------------------------------+
0401
0402 Use of Workqueues
0403 ~~~~~~~~~~~~~~~~~
0404
0405 In earlier implementations, the task requesting the expedited grace
0406 period also drove it to completion. This straightforward approach had
0407 the disadvantage of needing to account for POSIX signals sent to user
0408 tasks, so more recent implemementations use the Linux kernel's
0409 workqueues (see Documentation/core-api/workqueue.rst).
0410
0411 The requesting task still does counter snapshotting and funnel-lock
0412 processing, but the task reaching the top of the funnel lock does a
0413 ``schedule_work()`` (from ``_synchronize_rcu_expedited()`` so that a
0414 workqueue kthread does the actual grace-period processing. Because
0415 workqueue kthreads do not accept POSIX signals, grace-period-wait
0416 processing need not allow for POSIX signals. In addition, this approach
0417 allows wakeups for the previous expedited grace period to be overlapped
0418 with processing for the next expedited grace period. Because there are
0419 only four sets of waitqueues, it is necessary to ensure that the
0420 previous grace period's wakeups complete before the next grace period's
0421 wakeups start. This is handled by having the ``->exp_mutex`` guard
0422 expedited grace-period processing and the ``->exp_wake_mutex`` guard
0423 wakeups. The key point is that the ``->exp_mutex`` is not released until
0424 the first wakeup is complete, which means that the ``->exp_wake_mutex``
0425 has already been acquired at that point. This approach ensures that the
0426 previous grace period's wakeups can be carried out while the current
0427 grace period is in process, but that these wakeups will complete before
0428 the next grace period starts. This means that only three waitqueues are
0429 required, guaranteeing that the four that are provided are sufficient.
0430
0431 Stall Warnings
0432 ~~~~~~~~~~~~~~
0433
0434 Expediting grace periods does nothing to speed things up when RCU
0435 readers take too long, and therefore expedited grace periods check for
0436 stalls just as normal grace periods do.
0437
0438 +-----------------------------------------------------------------------+
0439 | **Quick Quiz**: |
0440 +-----------------------------------------------------------------------+
0441 | But why not just let the normal grace-period machinery detect the |
0442 | stalls, given that a given reader must block both normal and |
0443 | expedited grace periods? |
0444 +-----------------------------------------------------------------------+
0445 | **Answer**: |
0446 +-----------------------------------------------------------------------+
0447 | Because it is quite possible that at a given time there is no normal |
0448 | grace period in progress, in which case the normal grace period |
0449 | cannot emit a stall warning. |
0450 +-----------------------------------------------------------------------+
0451
0452 The ``synchronize_sched_expedited_wait()`` function loops waiting for
0453 the expedited grace period to end, but with a timeout set to the current
0454 RCU CPU stall-warning time. If this time is exceeded, any CPUs or
0455 ``rcu_node`` structures blocking the current grace period are printed.
0456 Each stall warning results in another pass through the loop, but the
0457 second and subsequent passes use longer stall times.
0458
0459 Mid-boot operation
0460 ~~~~~~~~~~~~~~~~~~
0461
0462 The use of workqueues has the advantage that the expedited grace-period
0463 code need not worry about POSIX signals. Unfortunately, it has the
0464 corresponding disadvantage that workqueues cannot be used until they are
0465 initialized, which does not happen until some time after the scheduler
0466 spawns the first task. Given that there are parts of the kernel that
0467 really do want to execute grace periods during this mid-boot “dead
0468 zone”, expedited grace periods must do something else during thie time.
0469
0470 What they do is to fall back to the old practice of requiring that the
0471 requesting task drive the expedited grace period, as was the case before
0472 the use of workqueues. However, the requesting task is only required to
0473 drive the grace period during the mid-boot dead zone. Before mid-boot, a
0474 synchronous grace period is a no-op. Some time after mid-boot,
0475 workqueues are used.
0476
0477 Non-expedited non-SRCU synchronous grace periods must also operate
0478 normally during mid-boot. This is handled by causing non-expedited grace
0479 periods to take the expedited code path during mid-boot.
0480
0481 The current code assumes that there are no POSIX signals during the
0482 mid-boot dead zone. However, if an overwhelming need for POSIX signals
0483 somehow arises, appropriate adjustments can be made to the expedited
0484 stall-warning code. One such adjustment would reinstate the
0485 pre-workqueue stall-warning checks, but only during the mid-boot dead
0486 zone.
0487
0488 With this refinement, synchronous grace periods can now be used from
0489 task context pretty much any time during the life of the kernel. That
0490 is, aside from some points in the suspend, hibernate, or shutdown code
0491 path.
0492
0493 Summary
0494 ~~~~~~~
0495
0496 Expedited grace periods use a sequence-number approach to promote
0497 batching, so that a single grace-period operation can serve numerous
0498 requests. A funnel lock is used to efficiently identify the one task out
0499 of a concurrent group that will request the grace period. All members of
0500 the group will block on waitqueues provided in the ``rcu_node``
0501 structure. The actual grace-period processing is carried out by a
0502 workqueue.
0503
0504 CPU-hotplug operations are noted lazily in order to prevent the need for
0505 tight synchronization between expedited grace periods and CPU-hotplug
0506 operations. The dyntick-idle counters are used to avoid sending IPIs to
0507 idle CPUs, at least in the common case. RCU-preempt and RCU-sched use
0508 different IPI handlers and different code to respond to the state
0509 changes carried out by those handlers, but otherwise use common code.
0510
0511 Quiescent states are tracked using the ``rcu_node`` tree, and once all
0512 necessary quiescent states have been reported, all tasks waiting on this
0513 expedited grace period are awakened. A pair of mutexes are used to allow
0514 one grace period's wakeups to proceed concurrently with the next grace
0515 period's processing.
0516
0517 This combination of mechanisms allows expedited grace periods to run
0518 reasonably efficiently. However, for non-time-critical tasks, normal
0519 grace periods should be used instead because their longer duration
0520 permits much higher degrees of batching, and thus much lower per-request
0521 overheads.