Documentation updates for v5.5
Subsystems (2)
Paul E. McKenney
maintainercover Documentation updates for v5.5
Hello!
This series provides documentation updates:
1-2. Revert a pair of documentation updates conflicting with later
ReST-ification, courtesy of Joel Fernandes.
3. Convert some RCU articles to ReST, courtesy of Mauro Carvalho
Chehab.
4-5. ReST adjustments, courtesy of Joel Fernandes.
6-7. Reapply the reverted pair of updates, but in ReST form,
courtesy of Joel Fernandes.
8. Update list_for_each_entry_rcu() documentation, courtesy of
Joel Fernandes.
9. Rename rcu_node_context_switch() to rcu_note_context_switch(),
courtesy of Sebastian Andrzej Siewior.
Thanx, Paul
------------------------------------------------------------------------
/Documentation/RCU/Design/Requirements/Requirements.html | 3330 ---------- Documentation/RCU/Design/Data-Structures/Data-Structures.html | 1391 ---- Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.html | 668 -- Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Diagram.html | 9 Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.html | 704 -- b/Documentation/RCU/Design/Data-Structures/Data-Structures.rst | 1163 +++ b/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst | 521 + b/Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst | 644 + b/Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg | 2 b/Documentation/RCU/Design/Memory-Ordering/TreeRCU-qs.svg | 2 b/Documentation/RCU/Design/Requirements/Requirements.html | 73 b/Documentation/RCU/Design/Requirements/Requirements.rst | 2808 ++++++++ b/Documentation/RCU/index.rst | 7 b/Documentation/RCU/lockdep.txt | 18 b/Documentation/RCU/whatisRCU.txt | 14 15 files changed, 5108 insertions(+), 6246 deletions(-)
[email protected]
maintainerPATCH 1/9 Revert docs from "rcu: Restore barrier() to rcu_read_lock() and rcu_read_unlock()"
From: "Joel Fernandes (Google)" <[email protected]>
This reverts docs from commit d6b9cd7dc8e041ee83cb1362fce59a3cdb1f2709.
--- .../RCU/Design/Requirements/Requirements.html | 71 ---------------------- 1 file changed, 71 deletions(-)
Documentation/RCU/Design/Requirements/Requirements.html +0 -71
@@ -2129,8 +2129,6 @@ Some of the relevant points of interest are as follows: <li> <a href="#Hotplug CPU">Hotplug CPU</a>. <li> <a href="#Scheduler and RCU">Scheduler and RCU</a>. <li> <a href="#Tracing and RCU">Tracing and RCU</a>. -<li> <a href="#Accesses to User Memory and RCU"> -Accesses to User Memory and RCU</a>. <li> <a href="#Energy Efficiency">Energy Efficiency</a>. <li> <a href="#Scheduling-Clock Interrupts and RCU"> Scheduling-Clock Interrupts and RCU</a>.
@@ -2523,75 +2521,6 @@ cannot be used. The tracing folks both located the requirement and provided the needed fix, so this surprise requirement was relatively painless. -<h3><a name="Accesses to User Memory and RCU"> -Accesses to User Memory and RCU</a></h3> - -<p> -The kernel needs to access user-space memory, for example, to access -data referenced by system-call parameters. -The <tt>get_user()</tt> macro does this job. - -<p> -However, user-space memory might well be paged out, which means -that <tt>get_user()</tt> might well page-fault and thus block while -waiting for the resulting I/O to complete. -It would be a very bad thing for the compiler to reorder -a <tt>get_user()</tt> invocation into an RCU read-side critical -section. -For example, suppose that the source code looked like this: - -<blockquote> -<pre> - 1 rcu_read_lock(); - 2 p = rcu_dereference(gp); - 3 v = p->value; - 4 rcu_read_unlock(); - 5 get_user(user_v, user_p); - 6 do_something_with(v, user_v); -</pre> -</blockquote> - -<p> -The compiler must not be permitted to transform this source code into -the following: - -<blockquote> -<pre> - 1 rcu_read_lock(); - 2 p = rcu_dereference(gp); - 3 get_user(user_v, user_p); // BUG: POSSIBLE PAGE FAULT!!! - 4 v = p->value; - 5 rcu_read_unlock(); - 6 do_something_with(v, user_v); -</pre> -</blockquote> - -<p> -If the compiler did make this transformation in a -<tt>CONFIG_PREEMPT=n</tt> kernel build, and if <tt>get_user()</tt> did -page fault, the result would be a quiescent state in the middle -of an RCU read-side critical section. -This misplaced quiescent state could result in line 4 being -a use-after-free access, which could be bad for your kernel's -actuarial statistics. -Similar examples can be constructed with the call to <tt>get_user()</tt> -preceding the <tt>rcu_read_lock()</tt>. - -<p> -Unfortunately, <tt>get_user()</tt> doesn't have any particular -ordering properties, and in some architectures the underlying <tt>asm</tt> -isn't even marked <tt>volatile</tt>. -And even if it was marked <tt>volatile</tt>, the above access to -<tt>p->value</tt> is not volatile, so the compiler would not have any -reason to keep those two accesses in order. - -<p> -Therefore, the Linux-kernel definitions of <tt>rcu_read_lock()</tt> -and <tt>rcu_read_unlock()</tt> must act as compiler barriers, -at least for outermost instances of <tt>rcu_read_lock()</tt> and -<tt>rcu_read_unlock()</tt> within a nested set of RCU read-side critical -sections. - <h3><a name="Energy Efficiency">Energy Efficiency</a></h3> <p>
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 2/9 Revert docs from "treewide: Rename rcu_dereference_raw_notrace() to _check()"
In reply to Paul E. McKenneyFrom: "Joel Fernandes (Google)" <[email protected]>
This reverts docs from commit 355e9972da81e803bbb825b76106ae9b358caf8e.
--- Documentation/RCU/Design/Requirements/Requirements.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/RCU/Design/Requirements/Requirements.html +1 -1
@@ -2512,7 +2512,7 @@ disabled across the entire RCU read-side critical section. <p> It is possible to use tracing on RCU code, but tracing itself uses RCU. -For this reason, <tt>rcu_dereference_raw_check()</tt> +For this reason, <tt>rcu_dereference_raw_notrace()</tt> is provided for use by tracing, which avoids the destructive recursion that could otherwise ensue. This API is also used by virtualization in some architectures,
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 4/9 docs: rcu: Correct links referring to titles
In reply to Paul E. McKenneyFrom: "Joel Fernandes (Google)" <[email protected]>
Mauro's auto conversion broken these links, fix them.
--- .../Memory-Ordering/Tree-RCU-Memory-Ordering.rst | 17 ++-- .../RCU/Design/Requirements/Requirements.rst | 90 ++++++++++------------ 2 files changed, 47 insertions(+), 60 deletions(-)
Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst +8 -9
@@ -230,15 +230,14 @@ Tree RCU Grace Period Memory Ordering Components Tree RCU's grace-period memory-ordering guarantee is provided by a number of RCU components: -#. `Callback Registry <#Callback%20Registry>`__ -#. `Grace-Period Initialization <#Grace-Period%20Initialization>`__ -#. `Self-Reported Quiescent - States <#Self-Reported%20Quiescent%20States>`__ -#. `Dynamic Tick Interface <#Dynamic%20Tick%20Interface>`__ -#. `CPU-Hotplug Interface <#CPU-Hotplug%20Interface>`__ -#. `Forcing Quiescent States <Forcing%20Quiescent%20States>`__ -#. `Grace-Period Cleanup <Grace-Period%20Cleanup>`__ -#. `Callback Invocation <Callback%20Invocation>`__ +#. `Callback Registry`_ +#. `Grace-Period Initialization`_ +#. `Self-Reported Quiescent States`_ +#. `Dynamic Tick Interface`_ +#. `CPU-Hotplug Interface`_ +#. `Forcing Quiescent States`_ +#. `Grace-Period Cleanup`_ +#. `Callback Invocation`_ Each of the following section looks at the corresponding component in detail.
Documentation/RCU/Design/Requirements/Requirements.rst +39 -51
126 lines not on this page · raw message
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 5/9 docs: rcu: Increase toctree to 3
In reply to Paul E. McKenneyFrom: "Joel Fernandes (Google)" <[email protected]>
These documents are long and have various sections. Provide a good toc nesting level.
--- Documentation/RCU/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/RCU/index.rst +1 -1
@@ -5,7 +5,7 @@ RCU concepts ============ .. toctree:: - :maxdepth: 1 + :maxdepth: 3 rcu listRCU
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 6/9 Restore docs "treewide: Rename rcu_dereference_raw_notrace() to _check()"
In reply to Paul E. McKenneyFrom: "Joel Fernandes (Google)" <[email protected]>
This restores docs back in ReST format.
--- Documentation/RCU/Design/Requirements/Requirements.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/RCU/Design/Requirements/Requirements.rst +1 -1
@@ -1997,7 +1997,7 @@ Tracing and RCU ~~~~~~~~~~~~~~~ It is possible to use tracing on RCU code, but tracing itself uses RCU. -For this reason, ``rcu_dereference_raw_notrace()`` is provided for use +For this reason, ``rcu_dereference_raw_check()`` is provided for use by tracing, which avoids the destructive recursion that could otherwise ensue. This API is also used by virtualization in some architectures, where RCU readers execute in environments in which tracing cannot be
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 7/9 Restore docs "rcu: Restore barrier() to rcu_read_lock() and rcu_read_unlock()"
In reply to Paul E. McKenneyFrom: "Joel Fernandes (Google)" <[email protected]>
This restores docs back in ReST format.
--- .../RCU/Design/Requirements/Requirements.rst | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+)
Documentation/RCU/Design/Requirements/Requirements.rst +54 -0
@@ -1691,6 +1691,7 @@ follows: #. `Hotplug CPU`_ #. `Scheduler and RCU`_ #. `Tracing and RCU`_ +#. `Accesses to User Memory and RCU`_ #. `Energy Efficiency`_ #. `Scheduling-Clock Interrupts and RCU`_ #. `Memory Efficiency`_
@@ -2004,6 +2005,59 @@ where RCU readers execute in environments in which tracing cannot be used. The tracing folks both located the requirement and provided the needed fix, so this surprise requirement was relatively painless. +Accesses to User Memory and RCU +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The kernel needs to access user-space memory, for example, to access data +referenced by system-call parameters. The ``get_user()`` macro does this job. + +However, user-space memory might well be paged out, which means that +``get_user()`` might well page-fault and thus block while waiting for the +resulting I/O to complete. It would be a very bad thing for the compiler to +reorder a ``get_user()`` invocation into an RCU read-side critical section. + +For example, suppose that the source code looked like this: + + :: + + 1 rcu_read_lock(); + 2 p = rcu_dereference(gp); + 3 v = p->value; + 4 rcu_read_unlock(); + 5 get_user(user_v, user_p); + 6 do_something_with(v, user_v); + +The compiler must not be permitted to transform this source code into +the following: + + :: + + 1 rcu_read_lock(); + 2 p = rcu_dereference(gp); + 3 get_user(user_v, user_p); // BUG: POSSIBLE PAGE FAULT!!! + 4 v = p->value; + 5 rcu_read_unlock(); + 6 do_something_with(v, user_v); + +If the compiler did make this transformation in a ``CONFIG_PREEMPT=n`` kernel +build, and if ``get_user()`` did page fault, the result would be a quiescent +state in the middle of an RCU read-side critical section. This misplaced +quiescent state could result in line 4 being a use-after-free access, +which could be bad for your kernel's actuarial statistics. Similar examples +can be constructed with the call to ``get_user()`` preceding the +``rcu_read_lock()``. + +Unfortunately, ``get_user()`` doesn't have any particular ordering properties, +and in some architectures the underlying ``asm`` isn't even marked +``volatile``. And even if it was marked ``volatile``, the above access to +``p->value`` is not volatile, so the compiler would not have any reason to keep +those two accesses in order. + +Therefore, the Linux-kernel definitions of ``rcu_read_lock()`` and +``rcu_read_unlock()`` must act as compiler barriers, at least for outermost +instances of ``rcu_read_lock()`` and ``rcu_read_unlock()`` within a nested set +of RCU read-side critical sections. + Energy Efficiency ~~~~~~~~~~~~~~~~~
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 8/9 doc: Update list_for_each_entry_rcu() documentation
In reply to Paul E. McKenneyFrom: "Joel Fernandes (Google)" <[email protected]>
This commit updates the documentation with information about usage of lockdep with list_for_each_entry_rcu().
--- Documentation/RCU/lockdep.txt | 18 ++++++++++++++---- Documentation/RCU/whatisRCU.txt | 10 +++++++++- 2 files changed, 23 insertions(+), 5 deletions(-)
Documentation/RCU/lockdep.txt +14 -4
@@ -96,7 +96,17 @@ other flavors of rcu_dereference(). On the other hand, it is illegal to use rcu_dereference_protected() if either the RCU-protected pointer or the RCU-protected data that it points to can change concurrently. -There are currently only "universal" versions of the rcu_assign_pointer() -and RCU list-/tree-traversal primitives, which do not (yet) check for -being in an RCU read-side critical section. In the future, separate -versions of these primitives might be created. +Like rcu_dereference(), when lockdep is enabled, RCU list and hlist +traversal primitives check for being called from within an RCU read-side +critical section. However, a lockdep expression can be passed to them +as a additional optional argument. With this lockdep expression, these +traversal primitives will complain only if the lockdep expression is +false and they are called from outside any RCU read-side critical section. + +For example, the workqueue for_each_pwq() macro is intended to be used +either within an RCU read-side critical section or with wq->mutex held. +It is thus implemented as follows: + + #define for_each_pwq(pwq, wq) + list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node, + lock_is_held(&(wq->mutex).dep_map))
Documentation/RCU/whatisRCU.txt +9 -1
@@ -290,7 +290,7 @@ rcu_dereference() at any time, including immediately after the rcu_dereference(). And, again like rcu_assign_pointer(), rcu_dereference() is typically used indirectly, via the _rcu list-manipulation - primitives, such as list_for_each_entry_rcu(). + primitives, such as list_for_each_entry_rcu() [2]. [1] The variant rcu_dereference_protected() can be used outside of an RCU read-side critical section as long as the usage is
@@ -305,6 +305,14 @@ rcu_dereference() a lockdep splat is emitted. See Documentation/RCU/Design/Requirements/Requirements.rst and the API's code comments for more details and example usage. + [2] If the list_for_each_entry_rcu() instance might be used by + update-side code as well as by RCU readers, then an additional + lockdep expression can be added to its list of arguments. + For example, given an additional "lock_is_held(&mylock)" argument, + the RCU lockdep code would complain only if this instance was + invoked outside of an RCU read-side critical section and without + the protection of mylock. + The following diagram shows how each API communicates among the reader, updater, and reclaimer.
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 9/9 Documentation: Rename rcu_node_context_switch() to rcu_note_context_switch()
In reply to Paul E. McKenneyFrom: Sebastian Andrzej Siewior <[email protected]>
While Paul was explaining some RCU magic I noticed a typo in rcu_note_context_switch(). As a result, this commit replaces rcu_node_context_switch() with rcu_note_context_switch().
--- Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst | 2 +- Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg | 2 +- Documentation/RCU/Design/Memory-Ordering/TreeRCU-qs.svg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst +1 -1
@@ -423,7 +423,7 @@ wait on. +-----------------------------------------------------------------------+ If the CPU does a context switch, a quiescent state will be noted by -``rcu_node_context_switch()`` on the left. On the other hand, if the CPU +``rcu_note_context_switch()`` on the left. On the other hand, if the CPU takes a scheduler-clock interrupt while executing in usermode, a quiescent state will be noted by ``rcu_sched_clock_irq()`` on the right. Either way, the passage through a quiescent state will be noted in a
Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg +1 -1
@@ -3880,7 +3880,7 @@ font-style="normal" y="-4418.6582" x="3745.7725" - xml:space="preserve">rcu_node_context_switch()</text> + xml:space="preserve">rcu_note_context_switch()</text> </g> <g transform="translate(1881.1886,54048.57)"
Documentation/RCU/Design/Memory-Ordering/TreeRCU-qs.svg +1 -1
@@ -753,7 +753,7 @@ font-style="normal" y="-4418.6582" x="3745.7725" - xml:space="preserve">rcu_node_context_switch()</text> + xml:space="preserve">rcu_note_context_switch()</text> </g> <g transform="translate(3131.2648,-585.6713)"
Signature · 1 line
2.9.5