Commit b54d9db2 authored by Joel Fernandes (Google)'s avatar Joel Fernandes (Google) Committed by Paul E. McKenney
Browse files

doc: rcu: Update Data-Structures for RCU flavor consolidation



This patch updates all Data-Structures document figures and text and
removes some unwanted figures, to reflect the recent work Paul has been
doing with consolidating all flavors of RCU.

Signed-off-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
Cc: <kernel-team@android.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.ibm.com>
parent c9b6f899
Loading
Loading
Loading
Loading
+0 −499
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Creator: fig2dev Version 3.2 Patchlevel 5e -->

<!-- CreationDate: Wed Dec  9 17:26:09 2015 -->

<!-- Magnification: 2.000 -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="5.7in"
   height="6.6in"
   viewBox="-44 -44 6838 7888"
   id="svg2"
   version="1.1"
   inkscape:version="0.48.4 r9939"
   sodipodi:docname="BigTreeClassicRCUBH.fig">
  <metadata
     id="metadata110">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <defs
     id="defs108">
    <marker
       inkscape:stockid="Arrow1Mend"
       orient="auto"
       refY="0.0"
       refX="0.0"
       id="Arrow1Mend"
       style="overflow:visible;">
      <path
         id="path3868"
         d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
         style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;"
         transform="scale(0.4) rotate(180) translate(10,0)" />
    </marker>
    <marker
       inkscape:stockid="Arrow2Mend"
       orient="auto"
       refY="0.0"
       refX="0.0"
       id="Arrow2Mend"
       style="overflow:visible;">
      <path
         id="path3886"
         style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
         d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
         transform="scale(0.6) rotate(180) translate(0,0)" />
    </marker>
  </defs>
  <sodipodi:namedview
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1"
     objecttolerance="10"
     gridtolerance="10"
     guidetolerance="10"
     inkscape:pageopacity="0"
     inkscape:pageshadow="2"
     inkscape:window-width="878"
     inkscape:window-height="1148"
     id="namedview106"
     showgrid="false"
     inkscape:zoom="1.3547758"
     inkscape:cx="256.5"
     inkscape:cy="297"
     inkscape:window-x="45"
     inkscape:window-y="24"
     inkscape:window-maximized="0"
     inkscape:current-layer="g4" />
  <g
     style="stroke-width:.025in; fill:none"
     id="g4">
    <!-- Line: box -->
    <rect
       x="450"
       y="0"
       width="6300"
       height="7350"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#ffffff; "
       id="rect6" />
    <!-- Line: box -->
    <rect
       x="4950"
       y="4950"
       width="1500"
       height="900"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#87cfff; "
       id="rect8" />
    <!-- Line: box -->
    <rect
       x="750"
       y="600"
       width="5700"
       height="3750"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#ffff00; "
       id="rect10" />
    <!-- Line: box -->
    <rect
       x="0"
       y="450"
       width="6300"
       height="7350"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#ffffff; "
       id="rect12" />
    <!-- Line: box -->
    <rect
       x="300"
       y="1050"
       width="5700"
       height="3750"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#ffff00; "
       id="rect14" />
    <!-- Circle -->
    <circle
       cx="2850"
       cy="3900"
       r="76"
       style="fill:#000000;stroke:#000000;stroke-width:14;"
       id="circle16" />
    <!-- Circle -->
    <circle
       cx="3150"
       cy="3900"
       r="76"
       style="fill:#000000;stroke:#000000;stroke-width:14;"
       id="circle18" />
    <!-- Circle -->
    <circle
       cx="3450"
       cy="3900"
       r="76"
       style="fill:#000000;stroke:#000000;stroke-width:14;"
       id="circle20" />
    <!-- Circle -->
    <circle
       cx="1350"
       cy="5100"
       r="76"
       style="fill:#000000;stroke:#000000;stroke-width:14;"
       id="circle22" />
    <!-- Circle -->
    <circle
       cx="1650"
       cy="5100"
       r="76"
       style="fill:#000000;stroke:#000000;stroke-width:14;"
       id="circle24" />
    <!-- Circle -->
    <circle
       cx="1950"
       cy="5100"
       r="76"
       style="fill:#000000;stroke:#000000;stroke-width:14;"
       id="circle26" />
    <!-- Circle -->
    <circle
       cx="4350"
       cy="5100"
       r="76"
       style="fill:#000000;stroke:#000000;stroke-width:14;"
       id="circle28" />
    <!-- Circle -->
    <circle
       cx="4650"
       cy="5100"
       r="76"
       style="fill:#000000;stroke:#000000;stroke-width:14;"
       id="circle30" />
    <!-- Circle -->
    <circle
       cx="4950"
       cy="5100"
       r="76"
       style="fill:#000000;stroke:#000000;stroke-width:14;"
       id="circle32" />
    <!-- Line -->
    <polyline
       points="1350,3450 2350,2590 "
       style="stroke:#00d1d1;stroke-width:30.0045575;stroke-linejoin:miter;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Mend)"
       id="polyline34" />
    <!-- Arrowhead on XXXpoint 1350 3450 - 2444 2510-->
    <!-- Line -->
    <polyline
       points="4950,3450 3948,2590 "
       style="stroke:#00d1d1;stroke-width:30.0045575;stroke-linejoin:miter;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Mend)"
       id="polyline38" />
    <!-- Arrowhead on XXXpoint 4950 3450 - 3854 2510-->
    <!-- Line: box -->
    <rect
       x="750"
       y="3450"
       width="1800"
       height="900"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#ffbfbf; "
       id="rect42" />
    <!-- Line -->
    <polyline
       points="2250,5400 2250,4414 "
       style="stroke:#00d1d1;stroke-width:30.0045575;stroke-linejoin:miter;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Mend)"
       id="polyline44" />
    <!-- Arrowhead on XXXpoint 2250 5400 - 2250 4290-->
    <!-- Line: box -->
    <rect
       x="1500"
       y="5400"
       width="1500"
       height="900"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#87cfff; "
       id="rect48" />
    <!-- Line: box -->
    <rect
       x="300"
       y="6600"
       width="1500"
       height="900"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#87cfff; "
       id="rect50" />
    <!-- Line: box -->
    <rect
       x="3750"
       y="3450"
       width="1800"
       height="900"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#ffbfbf; "
       id="rect52" />
    <!-- Line: box -->
    <rect
       x="4500"
       y="5400"
       width="1500"
       height="900"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#87cfff; "
       id="rect54" />
    <!-- Line: box -->
    <rect
       x="3300"
       y="6600"
       width="1500"
       height="900"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#87cfff; "
       id="rect56" />
    <!-- Line: box -->
    <rect
       x="2250"
       y="1650"
       width="1800"
       height="900"
       rx="0"
       style="stroke:#000000;stroke-width:30; stroke-linejoin:miter; stroke-linecap:butt; fill:#ffbfbf; "
       id="rect58" />
    <!-- Text -->
    <text
       xml:space="preserve"
       x="6450"
       y="300"
       fill="#000000"
       font-family="Helvetica"
       font-style="normal"
       font-weight="normal"
       font-size="192"
       text-anchor="end"
       id="text60">rcu_bh</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="3150"
       y="1950"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text62">struct</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="3150"
       y="2250"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text64">rcu_node</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="1650"
       y="3750"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text66">struct</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="1650"
       y="4050"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text68">rcu_node</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="4650"
       y="4050"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text70">rcu_node</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="4650"
       y="3750"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text72">struct</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="2250"
       y="5700"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text74">struct</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="2250"
       y="6000"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text76">rcu_data</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="1050"
       y="6900"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text78">struct</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="1050"
       y="7200"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text80">rcu_data</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="5250"
       y="5700"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text82">struct</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="5250"
       y="6000"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text84">rcu_data</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="4050"
       y="6900"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text86">struct</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="4050"
       y="7200"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="middle"
       id="text88">rcu_data</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="450"
       y="1350"
       fill="#000000"
       font-family="Courier"
       font-style="normal"
       font-weight="bold"
       font-size="192"
       text-anchor="start"
       id="text90">struct rcu_state</text>
    <!-- Text -->
    <text
       xml:space="preserve"
       x="6000"
       y="750"
       fill="#000000"
       font-family="Helvetica"
       font-style="normal"
       font-weight="normal"
       font-size="192"
       text-anchor="end"
       id="text92">rcu_sched</text>
    <!-- Line -->
    <polyline
       points="5250,5400 5250,4414 "
       style="stroke:#00d1d1;stroke-width:30.0045575;stroke-linejoin:miter;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Mend)"
       id="polyline94" />
    <!-- Arrowhead on XXXpoint 5250 5400 - 5250 4290-->
    <!-- Line -->
    <polyline
       points="4050,6600 4050,4414 "
       style="stroke:#00d1d1;stroke-width:30.0045575;stroke-linejoin:miter;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Mend)"
       id="polyline98" />
    <!-- Arrowhead on XXXpoint 4050 6600 - 4050 4290-->
    <!-- Line -->
    <polyline
       points="1050,6600 1050,4414 "
       style="stroke:#00d1d1;stroke-width:30.0045575;stroke-linejoin:miter;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Mend)"
       id="polyline102" />
    <!-- Arrowhead on XXXpoint 1050 6600 - 1050 4290-->
  </g>
</svg>
+0 −741

File deleted.

Preview size limit exceeded, changes collapsed.

+319 −515

File changed.

Preview size limit exceeded, changes collapsed.

+8 −41
Original line number Diff line number Diff line
@@ -154,36 +154,9 @@ on that root <tt>rcu_node</tt> structure remains acceptably low.
keeping lock contention under control at all tree levels regardless
of the level of loading on the system.

</p><p>The Linux kernel actually supports multiple flavors of RCU
running concurrently, so RCU builds separate data structures for each
flavor.
For example, for <tt>CONFIG_TREE_RCU=y</tt> kernels, RCU provides
rcu_sched and rcu_bh, as shown below:

</p><p><img src="BigTreeClassicRCUBH.svg" alt="BigTreeClassicRCUBH.svg" width="33%">

</p><p>Energy efficiency is increasingly important, and for that
reason the Linux kernel provides <tt>CONFIG_NO_HZ_IDLE</tt>, which
turns off the scheduling-clock interrupts on idle CPUs, which in
turn allows those CPUs to attain deeper sleep states and to consume
less energy.
CPUs whose scheduling-clock interrupts have been turned off are
said to be in <i>dyntick-idle mode</i>.
RCU must handle dyntick-idle CPUs specially
because RCU would otherwise wake up each CPU on every grace period,
which would defeat the whole purpose of <tt>CONFIG_NO_HZ_IDLE</tt>.
RCU uses the dynticks related fields in the <tt>rcu_data</tt> structure
to track which CPUs are in dyntick idle mode.

</p><p>Kernels built with <tt>CONFIG_PREEMPT_RCU</tt> support
rcu_preempt in addition to rcu_sched and rcu_bh, as shown below:

</p><p><img src="BigTreePreemptRCUBHdyntick.svg" alt="BigTreePreemptRCUBHdyntick.svg" width="35%">

</p><p>RCU updaters wait for normal grace periods by registering
RCU callbacks, either directly via <tt>call_rcu()</tt> and
friends (namely <tt>call_rcu_bh()</tt> and <tt>call_rcu_sched()</tt>),
there being a separate interface per flavor of RCU)
or indirectly via <tt>synchronize_rcu()</tt> and friends.
RCU callbacks are represented by <tt>rcu_head</tt> structures,
which are queued on <tt>rcu_data</tt> structures while they are
@@ -278,7 +251,7 @@ structures.
The <tt>rcu_state</tt> Structure</a></h3>

<p>The <tt>rcu_state</tt> structure is the base structure that
represents a flavor of RCU.
represents the state of RCU in the system.
This structure forms the interconnection between the
<tt>rcu_node</tt> and <tt>rcu_data</tt> structures,
tracks grace periods, contains the lock used to
@@ -373,7 +346,7 @@ sequence number.
The bottom two bits are the state of the current grace period,
which can be zero for not yet started or one for in progress.
In other words, if the bottom two bits of <tt>-&gt;gp_seq</tt> are
zero, the corresponding flavor of RCU is idle.
zero, then RCU is idle.
Any other value in the bottom two bits indicates that something is broken.
This field is protected by the root <tt>rcu_node</tt> structure's
<tt>-&gt;lock</tt> field.
@@ -403,10 +376,10 @@ as follows:
grace period in jiffies.
It is protected by the root <tt>rcu_node</tt>'s <tt>-&gt;lock</tt>.

<p>The <tt>-&gt;name</tt> field points to the name of the RCU flavor
(for example, &ldquo;rcu_sched&rdquo;), and is constant.
The <tt>-&gt;abbr</tt> field contains a one-character abbreviation,
for example, &ldquo;s&rdquo; for RCU-sched.
<p>The <tt>-&gt;name</tt> and <tt>-&gt;abbr</tt> fields distinguish
between preemptible RCU (&ldquo;rcu_preempt&rdquo; and &ldquo;p&rdquo;)
and non-preemptible RCU (&ldquo;rcu_sched&rdquo; and &ldquo;s&rdquo;).
These fields are used for diagnostic and tracing purposes.

<h3><a name="The rcu_node Structure">
The <tt>rcu_node</tt> Structure</a></h3>
@@ -972,8 +945,7 @@ of <tt>rcu_barrier()</tt>.
<h3><a name="The rcu_data Structure">
The <tt>rcu_data</tt> Structure</a></h3>

<p>The <tt>rcu_data</tt> maintains the per-CPU state for the
corresponding flavor of RCU.
<p>The <tt>rcu_data</tt> maintains the per-CPU state for the RCU subsystem.
The fields in this structure may be accessed only from the corresponding
CPU (and from tracing) unless otherwise stated.
This structure is the
@@ -1030,7 +1002,6 @@ as follows:
  3   bool cpu_no_qs;
  4   bool core_needs_qs;
  5   bool gpwrap;
  6   unsigned long rcu_qs_ctr_snap;
</pre>

<p>The <tt>-&gt;gp_seq</tt> and <tt>-&gt;gp_seq_needed</tt>
@@ -1076,10 +1047,6 @@ CPU has remained idle for so long that the
<tt>gp_seq</tt> counter is in danger of overflow, which
will cause the CPU to disregard the values of its counters on
its next exit from idle.
Finally, the <tt>rcu_qs_ctr_snap</tt> field is used to detect
cases where a given operation has resulted in a quiescent state
for all flavors of RCU, for example, <tt>cond_resched()</tt>
when RCU has indicated a need for quiescent states.

<h5>RCU Callback Handling</h5>

@@ -1387,7 +1354,7 @@ the last part of the array, thus traversing only the leaf
<h3><a name="Summary">
Summary</a></h3>

So each flavor of RCU is represented by an <tt>rcu_state</tt> structure,
So the state of RCU is represented by an <tt>rcu_state</tt> structure,
which contains a combining tree of <tt>rcu_node</tt> and
<tt>rcu_data</tt> structures.
Finally, in <tt>CONFIG_NO_HZ_IDLE</tt> kernels, each CPU's dyntick-idle
+232 −444

File changed.

Preview size limit exceeded, changes collapsed.