aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/RCU/Design/Data-Structures/Data-Structures.html207
-rw-r--r--Documentation/RCU/Design/Data-Structures/nxtlist.svg34
2 files changed, 156 insertions, 85 deletions
diff --git a/Documentation/RCU/Design/Data-Structures/Data-Structures.html b/Documentation/RCU/Design/Data-Structures/Data-Structures.html
index d583c653a703..2ab38ee420c5 100644
--- a/Documentation/RCU/Design/Data-Structures/Data-Structures.html
+++ b/Documentation/RCU/Design/Data-Structures/Data-Structures.html
@@ -19,6 +19,8 @@ to each other.
19 The <tt>rcu_state</tt> Structure</a> 19 The <tt>rcu_state</tt> Structure</a>
20<li> <a href="#The rcu_node Structure"> 20<li> <a href="#The rcu_node Structure">
21 The <tt>rcu_node</tt> Structure</a> 21 The <tt>rcu_node</tt> Structure</a>
22<li> <a href="#The rcu_segcblist Structure">
23 The <tt>rcu_segcblist</tt> Structure</a>
22<li> <a href="#The rcu_data Structure"> 24<li> <a href="#The rcu_data Structure">
23 The <tt>rcu_data</tt> Structure</a> 25 The <tt>rcu_data</tt> Structure</a>
24<li> <a href="#The rcu_dynticks Structure"> 26<li> <a href="#The rcu_dynticks Structure">
@@ -841,6 +843,134 @@ for lockdep lock-class names.
841Finally, lines&nbsp;64-66 produce an error if the maximum number of 843Finally, lines&nbsp;64-66 produce an error if the maximum number of
842CPUs is too large for the specified fanout. 844CPUs is too large for the specified fanout.
843 845
846<h3><a name="The rcu_segcblist Structure">
847The <tt>rcu_segcblist</tt> Structure</a></h3>
848
849The <tt>rcu_segcblist</tt> structure maintains a segmented list of
850callbacks as follows:
851
852<pre>
853 1 #define RCU_DONE_TAIL 0
854 2 #define RCU_WAIT_TAIL 1
855 3 #define RCU_NEXT_READY_TAIL 2
856 4 #define RCU_NEXT_TAIL 3
857 5 #define RCU_CBLIST_NSEGS 4
858 6
859 7 struct rcu_segcblist {
860 8 struct rcu_head *head;
861 9 struct rcu_head **tails[RCU_CBLIST_NSEGS];
86210 unsigned long gp_seq[RCU_CBLIST_NSEGS];
86311 long len;
86412 long len_lazy;
86513 };
866</pre>
867
868<p>
869The segments are as follows:
870
871<ol>
872<li> <tt>RCU_DONE_TAIL</tt>: Callbacks whose grace periods have elapsed.
873 These callbacks are ready to be invoked.
874<li> <tt>RCU_WAIT_TAIL</tt>: Callbacks that are waiting for the
875 current grace period.
876 Note that different CPUs can have different ideas about which
877 grace period is current, hence the <tt>-&gt;gp_seq</tt> field.
878<li> <tt>RCU_NEXT_READY_TAIL</tt>: Callbacks waiting for the next
879 grace period to start.
880<li> <tt>RCU_NEXT_TAIL</tt>: Callbacks that have not yet been
881 associated with a grace period.
882</ol>
883
884<p>
885The <tt>-&gt;head</tt> pointer references the first callback or
886is <tt>NULL</tt> if the list contains no callbacks (which is
887<i>not</i> the same as being empty).
888Each element of the <tt>-&gt;tails[]</tt> array references the
889<tt>-&gt;next</tt> pointer of the last callback in the corresponding
890segment of the list, or the list's <tt>-&gt;head</tt> pointer if
891that segment and all previous segments are empty.
892If the corresponding segment is empty but some previous segment is
893not empty, then the array element is identical to its predecessor.
894Older callbacks are closer to the head of the list, and new callbacks
895are added at the tail.
896This relationship between the <tt>-&gt;head</tt> pointer, the
897<tt>-&gt;tails[]</tt> array, and the callbacks is shown in this
898diagram:
899
900</p><p><img src="nxtlist.svg" alt="nxtlist.svg" width="40%">
901
902</p><p>In this figure, the <tt>-&gt;head</tt> pointer references the
903first
904RCU callback in the list.
905The <tt>-&gt;tails[RCU_DONE_TAIL]</tt> array element references
906the <tt>-&gt;head</tt> pointer itself, indicating that none
907of the callbacks is ready to invoke.
908The <tt>-&gt;tails[RCU_WAIT_TAIL]</tt> array element references callback
909CB&nbsp;2's <tt>-&gt;next</tt> pointer, which indicates that
910CB&nbsp;1 and CB&nbsp;2 are both waiting on the current grace period,
911give or take possible disagreements about exactly which grace period
912is the current one.
913The <tt>-&gt;tails[RCU_NEXT_READY_TAIL]</tt> array element
914references the same RCU callback that <tt>-&gt;tails[RCU_WAIT_TAIL]</tt>
915does, which indicates that there are no callbacks waiting on the next
916RCU grace period.
917The <tt>-&gt;tails[RCU_NEXT_TAIL]</tt> array element references
918CB&nbsp;4's <tt>-&gt;next</tt> pointer, indicating that all the
919remaining RCU callbacks have not yet been assigned to an RCU grace
920period.
921Note that the <tt>-&gt;tails[RCU_NEXT_TAIL]</tt> array element
922always references the last RCU callback's <tt>-&gt;next</tt> pointer
923unless the callback list is empty, in which case it references
924the <tt>-&gt;head</tt> pointer.
925
926<p>
927There is one additional important special case for the
928<tt>-&gt;tails[RCU_NEXT_TAIL]</tt> array element: It can be <tt>NULL</tt>
929when this list is <i>disabled</i>.
930Lists are disabled when the corresponding CPU is offline or when
931the corresponding CPU's callbacks are offloaded to a kthread,
932both of which are described elsewhere.
933
934</p><p>CPUs advance their callbacks from the
935<tt>RCU_NEXT_TAIL</tt> to the <tt>RCU_NEXT_READY_TAIL</tt> to the
936<tt>RCU_WAIT_TAIL</tt> to the <tt>RCU_DONE_TAIL</tt> list segments
937as grace periods advance.
938
939</p><p>The <tt>-&gt;gp_seq[]</tt> array records grace-period
940numbers corresponding to the list segments.
941This is what allows different CPUs to have different ideas as to
942which is the current grace period while still avoiding premature
943invocation of their callbacks.
944In particular, this allows CPUs that go idle for extended periods
945to determine which of their callbacks are ready to be invoked after
946reawakening.
947
948</p><p>The <tt>-&gt;len</tt> counter contains the number of
949callbacks in <tt>-&gt;head</tt>, and the
950<tt>-&gt;len_lazy</tt> contains the number of those callbacks that
951are known to only free memory, and whose invocation can therefore
952be safely deferred.
953
954<p><b>Important note</b>: It is the <tt>-&gt;len</tt> field that
955determines whether or not there are callbacks associated with
956this <tt>rcu_segcblist</tt> structure, <i>not</i> the <tt>-&gt;head</tt>
957pointer.
958The reason for this is that all the ready-to-invoke callbacks
959(that is, those in the <tt>RCU_DONE_TAIL</tt> segment) are extracted
960all at once at callback-invocation time.
961If callback invocation must be postponed, for example, because a
962high-priority process just woke up on this CPU, then the remaining
963callbacks are placed back on the <tt>RCU_DONE_TAIL</tt> segment.
964Either way, the <tt>-&gt;len</tt> and <tt>-&gt;len_lazy</tt> counts
965are adjusted after the corresponding callbacks have been invoked, and so
966again it is the <tt>-&gt;len</tt> count that accurately reflects whether
967or not there are callbacks associated with this <tt>rcu_segcblist</tt>
968structure.
969Of course, off-CPU sampling of the <tt>-&gt;len</tt> count requires
970the use of appropriate synchronization, for example, memory barriers.
971This synchronization can be a bit subtle, particularly in the case
972of <tt>rcu_barrier()</tt>.
973
844<h3><a name="The rcu_data Structure"> 974<h3><a name="The rcu_data Structure">
845The <tt>rcu_data</tt> Structure</a></h3> 975The <tt>rcu_data</tt> Structure</a></h3>
846 976
@@ -983,62 +1113,18 @@ choice.
983as follows: 1113as follows:
984 1114
985<pre> 1115<pre>
986 1 struct rcu_head *nxtlist; 1116 1 struct rcu_segcblist cblist;
987 2 struct rcu_head **nxttail[RCU_NEXT_SIZE]; 1117 2 long qlen_last_fqs_check;
988 3 unsigned long nxtcompleted[RCU_NEXT_SIZE]; 1118 3 unsigned long n_cbs_invoked;
989 4 long qlen_lazy; 1119 4 unsigned long n_nocbs_invoked;
990 5 long qlen; 1120 5 unsigned long n_cbs_orphaned;
991 6 long qlen_last_fqs_check; 1121 6 unsigned long n_cbs_adopted;
992 7 unsigned long n_force_qs_snap; 1122 7 unsigned long n_force_qs_snap;
993 8 unsigned long n_cbs_invoked; 1123 8 long blimit;
994 9 unsigned long n_cbs_orphaned;
99510 unsigned long n_cbs_adopted;
99611 long blimit;
997</pre> 1124</pre>
998 1125
999<p>The <tt>-&gt;nxtlist</tt> pointer and the 1126<p>The <tt>-&gt;cblist</tt> structure is the segmented callback list
1000<tt>-&gt;nxttail[]</tt> array form a four-segment list with 1127described earlier.
1001older callbacks near the head and newer ones near the tail.
1002Each segment contains callbacks with the corresponding relationship
1003to the current grace period.
1004The pointer out of the end of each of the four segments is referenced
1005by the element of the <tt>-&gt;nxttail[]</tt> array indexed by
1006<tt>RCU_DONE_TAIL</tt> (for callbacks handled by a prior grace period),
1007<tt>RCU_WAIT_TAIL</tt> (for callbacks waiting on the current grace period),
1008<tt>RCU_NEXT_READY_TAIL</tt> (for callbacks that will wait on the next
1009grace period), and
1010<tt>RCU_NEXT_TAIL</tt> (for callbacks that are not yet associated
1011with a specific grace period)
1012respectively, as shown in the following figure.
1013
1014</p><p><img src="nxtlist.svg" alt="nxtlist.svg" width="40%">
1015
1016</p><p>In this figure, the <tt>-&gt;nxtlist</tt> pointer references the
1017first
1018RCU callback in the list.
1019The <tt>-&gt;nxttail[RCU_DONE_TAIL]</tt> array element references
1020the <tt>-&gt;nxtlist</tt> pointer itself, indicating that none
1021of the callbacks is ready to invoke.
1022The <tt>-&gt;nxttail[RCU_WAIT_TAIL]</tt> array element references callback
1023CB&nbsp;2's <tt>-&gt;next</tt> pointer, which indicates that
1024CB&nbsp;1 and CB&nbsp;2 are both waiting on the current grace period.
1025The <tt>-&gt;nxttail[RCU_NEXT_READY_TAIL]</tt> array element
1026references the same RCU callback that <tt>-&gt;nxttail[RCU_WAIT_TAIL]</tt>
1027does, which indicates that there are no callbacks waiting on the next
1028RCU grace period.
1029The <tt>-&gt;nxttail[RCU_NEXT_TAIL]</tt> array element references
1030CB&nbsp;4's <tt>-&gt;next</tt> pointer, indicating that all the
1031remaining RCU callbacks have not yet been assigned to an RCU grace
1032period.
1033Note that the <tt>-&gt;nxttail[RCU_NEXT_TAIL]</tt> array element
1034always references the last RCU callback's <tt>-&gt;next</tt> pointer
1035unless the callback list is empty, in which case it references
1036the <tt>-&gt;nxtlist</tt> pointer.
1037
1038</p><p>CPUs advance their callbacks from the
1039<tt>RCU_NEXT_TAIL</tt> to the <tt>RCU_NEXT_READY_TAIL</tt> to the
1040<tt>RCU_WAIT_TAIL</tt> to the <tt>RCU_DONE_TAIL</tt> list segments
1041as grace periods advance.
1042The CPU advances the callbacks in its <tt>rcu_data</tt> structure 1128The CPU advances the callbacks in its <tt>rcu_data</tt> structure
1043whenever it notices that another RCU grace period has completed. 1129whenever it notices that another RCU grace period has completed.
1044The CPU detects the completion of an RCU grace period by noticing 1130The CPU detects the completion of an RCU grace period by noticing
@@ -1049,16 +1135,7 @@ Recall that each <tt>rcu_node</tt> structure's
1049<tt>-&gt;completed</tt> field is updated at the end of each 1135<tt>-&gt;completed</tt> field is updated at the end of each
1050grace period. 1136grace period.
1051 1137
1052</p><p>The <tt>-&gt;nxtcompleted[]</tt> array records grace-period 1138<p>
1053numbers corresponding to the list segments.
1054This allows CPUs that go idle for extended periods to determine
1055which of their callbacks are ready to be invoked after reawakening.
1056
1057</p><p>The <tt>-&gt;qlen</tt> counter contains the number of
1058callbacks in <tt>-&gt;nxtlist</tt>, and the
1059<tt>-&gt;qlen_lazy</tt> contains the number of those callbacks that
1060are known to only free memory, and whose invocation can therefore
1061be safely deferred.
1062The <tt>-&gt;qlen_last_fqs_check</tt> and 1139The <tt>-&gt;qlen_last_fqs_check</tt> and
1063<tt>-&gt;n_force_qs_snap</tt> coordinate the forcing of quiescent 1140<tt>-&gt;n_force_qs_snap</tt> coordinate the forcing of quiescent
1064states from <tt>call_rcu()</tt> and friends when callback 1141states from <tt>call_rcu()</tt> and friends when callback
@@ -1069,6 +1146,10 @@ lists grow excessively long.
1069fields count the number of callbacks invoked, 1146fields count the number of callbacks invoked,
1070sent to other CPUs when this CPU goes offline, 1147sent to other CPUs when this CPU goes offline,
1071and received from other CPUs when those other CPUs go offline. 1148and received from other CPUs when those other CPUs go offline.
1149The <tt>-&gt;n_nocbs_invoked</tt> is used when the CPU's callbacks
1150are offloaded to a kthread.
1151
1152<p>
1072Finally, the <tt>-&gt;blimit</tt> counter is the maximum number of 1153Finally, the <tt>-&gt;blimit</tt> counter is the maximum number of
1073RCU callbacks that may be invoked at a given time. 1154RCU callbacks that may be invoked at a given time.
1074 1155
diff --git a/Documentation/RCU/Design/Data-Structures/nxtlist.svg b/Documentation/RCU/Design/Data-Structures/nxtlist.svg
index abc4cc73a097..0223e79c38e0 100644
--- a/Documentation/RCU/Design/Data-Structures/nxtlist.svg
+++ b/Documentation/RCU/Design/Data-Structures/nxtlist.svg
@@ -19,7 +19,7 @@
19 id="svg2" 19 id="svg2"
20 version="1.1" 20 version="1.1"
21 inkscape:version="0.48.4 r9939" 21 inkscape:version="0.48.4 r9939"
22 sodipodi:docname="nxtlist.fig"> 22 sodipodi:docname="segcblist.svg">
23 <metadata 23 <metadata
24 id="metadata94"> 24 id="metadata94">
25 <rdf:RDF> 25 <rdf:RDF>
@@ -28,7 +28,7 @@
28 <dc:format>image/svg+xml</dc:format> 28 <dc:format>image/svg+xml</dc:format>
29 <dc:type 29 <dc:type
30 rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> 30 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
31 <dc:title></dc:title> 31 <dc:title />
32 </cc:Work> 32 </cc:Work>
33 </rdf:RDF> 33 </rdf:RDF>
34 </metadata> 34 </metadata>
@@ -241,61 +241,51 @@
241 xml:space="preserve" 241 xml:space="preserve"
242 x="225" 242 x="225"
243 y="675" 243 y="675"
244 fill="#000000"
245 font-family="Courier"
246 font-style="normal" 244 font-style="normal"
247 font-weight="bold" 245 font-weight="bold"
248 font-size="324" 246 font-size="324"
249 text-anchor="start" 247 id="text64"
250 id="text64">nxtlist</text> 248 style="font-size:324px;font-style:normal;font-weight:bold;text-anchor:start;fill:#000000;font-family:Courier">-&gt;head</text>
251 <!-- Text --> 249 <!-- Text -->
252 <text 250 <text
253 xml:space="preserve" 251 xml:space="preserve"
254 x="225" 252 x="225"
255 y="1800" 253 y="1800"
256 fill="#000000"
257 font-family="Courier"
258 font-style="normal" 254 font-style="normal"
259 font-weight="bold" 255 font-weight="bold"
260 font-size="324" 256 font-size="324"
261 text-anchor="start" 257 id="text66"
262 id="text66">nxttail[RCU_DONE_TAIL]</text> 258 style="font-size:324px;font-style:normal;font-weight:bold;text-anchor:start;fill:#000000;font-family:Courier">-&gt;tails[RCU_DONE_TAIL]</text>
263 <!-- Text --> 259 <!-- Text -->
264 <text 260 <text
265 xml:space="preserve" 261 xml:space="preserve"
266 x="225" 262 x="225"
267 y="2925" 263 y="2925"
268 fill="#000000"
269 font-family="Courier"
270 font-style="normal" 264 font-style="normal"
271 font-weight="bold" 265 font-weight="bold"
272 font-size="324" 266 font-size="324"
273 text-anchor="start" 267 id="text68"
274 id="text68">nxttail[RCU_WAIT_TAIL]</text> 268 style="font-size:324px;font-style:normal;font-weight:bold;text-anchor:start;fill:#000000;font-family:Courier">-&gt;tails[RCU_WAIT_TAIL]</text>
275 <!-- Text --> 269 <!-- Text -->
276 <text 270 <text
277 xml:space="preserve" 271 xml:space="preserve"
278 x="225" 272 x="225"
279 y="4050" 273 y="4050"
280 fill="#000000"
281 font-family="Courier"
282 font-style="normal" 274 font-style="normal"
283 font-weight="bold" 275 font-weight="bold"
284 font-size="324" 276 font-size="324"
285 text-anchor="start" 277 id="text70"
286 id="text70">nxttail[RCU_NEXT_READY_TAIL]</text> 278 style="font-size:324px;font-style:normal;font-weight:bold;text-anchor:start;fill:#000000;font-family:Courier">-&gt;tails[RCU_NEXT_READY_TAIL]</text>
287 <!-- Text --> 279 <!-- Text -->
288 <text 280 <text
289 xml:space="preserve" 281 xml:space="preserve"
290 x="225" 282 x="225"
291 y="5175" 283 y="5175"
292 fill="#000000"
293 font-family="Courier"
294 font-style="normal" 284 font-style="normal"
295 font-weight="bold" 285 font-weight="bold"
296 font-size="324" 286 font-size="324"
297 text-anchor="start" 287 id="text72"
298 id="text72">nxttail[RCU_NEXT_TAIL]</text> 288 style="font-size:324px;font-style:normal;font-weight:bold;text-anchor:start;fill:#000000;font-family:Courier">-&gt;tails[RCU_NEXT_TAIL]</text>
299 <!-- Text --> 289 <!-- Text -->
300 <text 290 <text
301 xml:space="preserve" 291 xml:space="preserve"