| .. | .. |
|---|
| 78 | 78 | Production-quality implementations of ``rcu_read_lock()`` and |
|---|
| 79 | 79 | ``rcu_read_unlock()`` are extremely lightweight, and in fact have |
|---|
| 80 | 80 | exactly zero overhead in Linux kernels built for production use with |
|---|
| 81 | | -``CONFIG_PREEMPTION=n``. |
|---|
| 81 | +``CONFIG_PREEMPT=n``. |
|---|
| 82 | 82 | |
|---|
| 83 | 83 | This guarantee allows ordering to be enforced with extremely low |
|---|
| 84 | 84 | overhead to readers, for example: |
|---|
| .. | .. |
|---|
| 1182 | 1182 | costs have plummeted. However, as I learned from Matt Mackall's |
|---|
| 1183 | 1183 | `bloatwatch <http://elinux.org/Linux_Tiny-FAQ>`__ efforts, memory |
|---|
| 1184 | 1184 | footprint is critically important on single-CPU systems with |
|---|
| 1185 | | -non-preemptible (``CONFIG_PREEMPTION=n``) kernels, and thus `tiny |
|---|
| 1185 | +non-preemptible (``CONFIG_PREEMPT=n``) kernels, and thus `tiny |
|---|
| 1186 | 1186 | RCU <https://lkml.kernel.org/g/20090113221724.GA15307@linux.vnet.ibm.com>`__ |
|---|
| 1187 | 1187 | was born. Josh Triplett has since taken over the small-memory banner |
|---|
| 1188 | 1188 | with his `Linux kernel tinification <https://tiny.wiki.kernel.org/>`__ |
|---|
| .. | .. |
|---|
| 1498 | 1498 | |
|---|
| 1499 | 1499 | Implementations of RCU for which ``rcu_read_lock()`` and |
|---|
| 1500 | 1500 | ``rcu_read_unlock()`` generate no code, such as Linux-kernel RCU when |
|---|
| 1501 | | -``CONFIG_PREEMPTION=n``, can be nested arbitrarily deeply. After all, there |
|---|
| 1501 | +``CONFIG_PREEMPT=n``, can be nested arbitrarily deeply. After all, there |
|---|
| 1502 | 1502 | is no overhead. Except that if all these instances of |
|---|
| 1503 | 1503 | ``rcu_read_lock()`` and ``rcu_read_unlock()`` are visible to the |
|---|
| 1504 | 1504 | compiler, compilation will eventually fail due to exhausting memory, |
|---|
| .. | .. |
|---|
| 1771 | 1771 | |
|---|
| 1772 | 1772 | However, once the scheduler has spawned its first kthread, this early |
|---|
| 1773 | 1773 | boot trick fails for ``synchronize_rcu()`` (as well as for |
|---|
| 1774 | | -``synchronize_rcu_expedited()``) in ``CONFIG_PREEMPTION=y`` kernels. The |
|---|
| 1774 | +``synchronize_rcu_expedited()``) in ``CONFIG_PREEMPT=y`` kernels. The |
|---|
| 1775 | 1775 | reason is that an RCU read-side critical section might be preempted, |
|---|
| 1776 | 1776 | which means that a subsequent ``synchronize_rcu()`` really does have to |
|---|
| 1777 | 1777 | wait for something, as opposed to simply returning immediately. |
|---|
| .. | .. |
|---|
| 2010 | 2010 | 5 rcu_read_unlock(); |
|---|
| 2011 | 2011 | 6 do_something_with(v, user_v); |
|---|
| 2012 | 2012 | |
|---|
| 2013 | | -If the compiler did make this transformation in a ``CONFIG_PREEMPTION=n`` kernel |
|---|
| 2013 | +If the compiler did make this transformation in a ``CONFIG_PREEMPT=n`` kernel |
|---|
| 2014 | 2014 | build, and if ``get_user()`` did page fault, the result would be a quiescent |
|---|
| 2015 | 2015 | state in the middle of an RCU read-side critical section. This misplaced |
|---|
| 2016 | 2016 | quiescent state could result in line 4 being a use-after-free access, |
|---|
| .. | .. |
|---|
| 2289 | 2289 | |
|---|
| 2290 | 2290 | The Linux kernel is used for real-time workloads, especially in |
|---|
| 2291 | 2291 | conjunction with the `-rt |
|---|
| 2292 | | -patchset <https://wiki.linuxfoundation.org/realtime/>`__. The |
|---|
| 2292 | +patchset <https://rt.wiki.kernel.org/index.php/Main_Page>`__. The |
|---|
| 2293 | 2293 | real-time-latency response requirements are such that the traditional |
|---|
| 2294 | 2294 | approach of disabling preemption across RCU read-side critical sections |
|---|
| 2295 | | -is inappropriate. Kernels built with ``CONFIG_PREEMPTION=y`` therefore use |
|---|
| 2295 | +is inappropriate. Kernels built with ``CONFIG_PREEMPT=y`` therefore use |
|---|
| 2296 | 2296 | an RCU implementation that allows RCU read-side critical sections to be |
|---|
| 2297 | 2297 | preempted. This requirement made its presence known after users made it |
|---|
| 2298 | 2298 | clear that an earlier `real-time |
|---|
| .. | .. |
|---|
| 2414 | 2414 | ``call_rcu_bh()``, ``rcu_barrier_bh()``, and |
|---|
| 2415 | 2415 | ``rcu_read_lock_bh_held()``. However, the update-side APIs are now |
|---|
| 2416 | 2416 | simple wrappers for other RCU flavors, namely RCU-sched in |
|---|
| 2417 | | -CONFIG_PREEMPTION=n kernels and RCU-preempt otherwise. |
|---|
| 2417 | +CONFIG_PREEMPT=n kernels and RCU-preempt otherwise. |
|---|
| 2418 | 2418 | |
|---|
| 2419 | 2419 | Sched Flavor (Historical) |
|---|
| 2420 | 2420 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| .. | .. |
|---|
| 2432 | 2432 | RCU read-side critical section can be a quiescent state. Therefore, |
|---|
| 2433 | 2433 | *RCU-sched* was created, which follows “classic” RCU in that an |
|---|
| 2434 | 2434 | RCU-sched grace period waits for pre-existing interrupt and NMI |
|---|
| 2435 | | -handlers. In kernels built with ``CONFIG_PREEMPTION=n``, the RCU and |
|---|
| 2435 | +handlers. In kernels built with ``CONFIG_PREEMPT=n``, the RCU and |
|---|
| 2436 | 2436 | RCU-sched APIs have identical implementations, while kernels built with |
|---|
| 2437 | | -``CONFIG_PREEMPTION=y`` provide a separate implementation for each. |
|---|
| 2437 | +``CONFIG_PREEMPT=y`` provide a separate implementation for each. |
|---|
| 2438 | 2438 | |
|---|
| 2439 | | -Note well that in ``CONFIG_PREEMPTION=y`` kernels, |
|---|
| 2439 | +Note well that in ``CONFIG_PREEMPT=y`` kernels, |
|---|
| 2440 | 2440 | ``rcu_read_lock_sched()`` and ``rcu_read_unlock_sched()`` disable and |
|---|
| 2441 | 2441 | re-enable preemption, respectively. This means that if there was a |
|---|
| 2442 | 2442 | preemption attempt during the RCU-sched read-side critical section, |
|---|
| .. | .. |
|---|
| 2599 | 2599 | |
|---|
| 2600 | 2600 | The tasks-RCU API is quite compact, consisting only of |
|---|
| 2601 | 2601 | ``call_rcu_tasks()``, ``synchronize_rcu_tasks()``, and |
|---|
| 2602 | | -``rcu_barrier_tasks()``. In ``CONFIG_PREEMPTION=n`` kernels, trampolines |
|---|
| 2602 | +``rcu_barrier_tasks()``. In ``CONFIG_PREEMPT=n`` kernels, trampolines |
|---|
| 2603 | 2603 | cannot be preempted, so these APIs map to ``call_rcu()``, |
|---|
| 2604 | 2604 | ``synchronize_rcu()``, and ``rcu_barrier()``, respectively. In |
|---|
| 2605 | | -``CONFIG_PREEMPTION=y`` kernels, trampolines can be preempted, and these |
|---|
| 2605 | +``CONFIG_PREEMPT=y`` kernels, trampolines can be preempted, and these |
|---|
| 2606 | 2606 | three APIs are therefore implemented by separate functions that check |
|---|
| 2607 | 2607 | for voluntary context switches. |
|---|
| 2608 | 2608 | |
|---|