€•Œsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ>/translations/zh_CN/RCU/Design/Data-Structures/Data-Structures”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ>/translations/zh_TW/RCU/Design/Data-Structures/Data-Structures”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ>/translations/it_IT/RCU/Design/Data-Structures/Data-Structures”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ>/translations/ja_JP/RCU/Design/Data-Structures/Data-Structures”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ>/translations/ko_KR/RCU/Design/Data-Structures/Data-Structures”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ>/translations/pt_BR/RCU/Design/Data-Structures/Data-Structures”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ>/translations/sp_SP/RCU/Design/Data-Structures/Data-Structures”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒ3A Tour Through TREE_RCU's Data Structures [LWN.net]”h]”hŒ5A Tour Through TREE_RCU’s Data Structures [LWN.net]”…”�”}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒX/var/lib/git/docbuild/linux/Documentation/RCU/Design/Data-Structures/Data-Structures.rst”h´KubhŒ paragraph”“”)�”}”(hŒDecember 18, 2016”h]”hŒDecember 18, 2016”…”�”}”(hhÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubhÌ)�”}”(hŒ0This article was contributed by Paul E. McKenney”h]”hŒ0This article was contributed by Paul E. McKenney”…”�”}”(hhÛh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubh¶)�”}”(hhh]”(h»)�”}”(hŒ Introduction”h]”hŒ Introduction”…”�”}”(hhìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhhéh²hh³hÊh´K ubhÌ)�”}”(hŒYThis document describes RCU's major data structures and their relationship to each other.”h]”hŒ[This document describes RCU’s major data structures and their relationship to each other.”…”�”}”(hhúh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K hhéh²hubeh}”(h]”Œ introduction”ah ]”h"]”Œ introduction”ah$]”h&]”uh1hµhh·h²hh³hÊh´K ubh¶)�”}”(hhh]”(h»)�”}”(hŒData-Structure Relationships”h]”hŒData-Structure Relationships”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´KubhÌ)�”}”(hX…RCU is for all intents and purposes a large state machine, and its data structures maintain the state in such a way as to allow RCU readers to execute extremely quickly, while also processing the RCU grace periods requested by updaters in an efficient and extremely scalable fashion. The efficiency and scalability of RCU updaters is provided primarily by a combining tree, as shown below:”h]”hX…RCU is for all intents and purposes a large state machine, and its data structures maintain the state in such a way as to allow RCU readers to execute extremely quickly, while also processing the RCU grace periods requested by updaters in an efficient and extremely scalable fashion. The efficiency and scalability of RCU updaters is provided primarily by a combining tree, as shown below:”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khjh²hubŒkfigure”Œ kernel_figure”“”)�”}”(hhh]”hŒfigure”“”)�”}”(hhh]”hŒimage”“”)�”}”(hŒ).. kernel-figure:: BigTreeClassicRCU.svg ”h]”h}”(h]”h ]”h"]”h$]”h&]”Œuri”Œ0RCU/Design/Data-Structures/BigTreeClassicRCU.svg”Œ candidates”}”Œ*”jGsuh1j:hj7h³hÊh´Kubah}”(h]”h ]”h"]”h$]”h&]”uh1j5hj2ubah}”(h]”h ]”h"]”h$]”h&]”uh1j0hjh²hh³hÊh´KubhÌ)�”}”(hX¢This diagram shows an enclosing ``rcu_state`` structure containing a tree of ``rcu_node`` structures. Each leaf node of the ``rcu_node`` tree has up to 16 ``rcu_data`` structures associated with it, so that there are ``NR_CPUS`` number of ``rcu_data`` structures, one for each possible CPU. This structure is adjusted at boot time, if needed, to handle the common case where ``nr_cpu_ids`` is much less than ``NR_CPUs``. For example, a number of Linux distributions set ``NR_CPUs=4096``, which results in a three-level ``rcu_node`` tree. If the actual hardware has only 16 CPUs, RCU will adjust itself at boot time, resulting in an ``rcu_node`` tree with only a single node.”h]”(hŒ This diagram shows an enclosing ”…”�”}”(hjWh²hh³Nh´NubhŒliteral”“”)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hjah²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjWubhŒ structure containing a tree of ”…”�”}”(hjWh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjsh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjWubhŒ# structures. Each leaf node of the ”…”�”}”(hjWh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj…h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjWubhŒ tree has up to 16 ”…”�”}”(hjWh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj—h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjWubhŒ2 structures associated with it, so that there are ”…”�”}”(hjWh²hh³Nh´Nubj`)�”}”(hŒ ``NR_CPUS``”h]”hŒNR_CPUS”…”�”}”(hj©h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjWubhŒ number of ”…”�”}”(hjWh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj»h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjWubhŒ| structures, one for each possible CPU. This structure is adjusted at boot time, if needed, to handle the common case where ”…”�”}”(hjWh²hh³Nh´Nubj`)�”}”(hŒ``nr_cpu_ids``”h]”hŒ nr_cpu_ids”…”�”}”(hjÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjWubhŒ is much less than ”…”�”}”(hjWh²hh³Nh´Nubj`)�”}”(hŒ ``NR_CPUs``”h]”hŒNR_CPUs”…”�”}”(hjßh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjWubhŒ3. For example, a number of Linux distributions set ”…”�”}”(hjWh²hh³Nh´Nubj`)�”}”(hŒ``NR_CPUs=4096``”h]”hŒ NR_CPUs=4096”…”�”}”(hjñh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjWubhŒ!, which results in a three-level ”…”�”}”(hjWh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjWubhŒe tree. If the actual hardware has only 16 CPUs, RCU will adjust itself at boot time, resulting in an ”…”�”}”(hjWh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjWubhŒ tree with only a single node.”…”�”}”(hjWh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khjh²hubhÌ)�”}”(hXÁThe purpose of this combining tree is to allow per-CPU events such as quiescent states, dyntick-idle transitions, and CPU hotplug operations to be processed efficiently and scalably. Quiescent states are recorded by the per-CPU ``rcu_data`` structures, and other events are recorded by the leaf-level ``rcu_node`` structures. All of these events are combined at each level of the tree until finally grace periods are completed at the tree's root ``rcu_node`` structure. A grace period can be completed at the root once every CPU (or, in the case of ``CONFIG_PREEMPT_RCU``, task) has passed through a quiescent state. Once a grace period has completed, record of that fact is propagated back down the tree.”h]”(hŒäThe purpose of this combining tree is to allow per-CPU events such as quiescent states, dyntick-idle transitions, and CPU hotplug operations to be processed efficiently and scalably. Quiescent states are recorded by the per-CPU ”…”�”}”(hj-h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj5h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj-ubhŒ= structures, and other events are recorded by the leaf-level ”…”�”}”(hj-h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjGh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj-ubhŒ‡ structures. All of these events are combined at each level of the tree until finally grace periods are completed at the tree’s root ”…”�”}”(hj-h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj-ubhŒ[ structure. A grace period can be completed at the root once every CPU (or, in the case of ”…”�”}”(hj-h²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_PREEMPT_RCU``”h]”hŒCONFIG_PREEMPT_RCU”…”�”}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj-ubhŒ†, task) has passed through a quiescent state. Once a grace period has completed, record of that fact is propagated back down the tree.”…”�”}”(hj-h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K&hjh²hubhÌ)�”}”(hŒ±As can be seen from the diagram, on a 64-bit system a two-level tree with 64 leaves can accommodate 1,024 CPUs, with a fanout of 64 at the root and a fanout of 16 at the leaves.”h]”hŒ±As can be seen from the diagram, on a 64-bit system a two-level tree with 64 leaves can accommodate 1,024 CPUs, with a fanout of 64 at the root and a fanout of 16 at the leaves.”…”�”}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K6hjh²hubhŒtable”“”)�”}”(hhh]”hŒtgroup”“”)�”}”(hhh]”(hŒcolspec”“”)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”KGuh1j›hj˜ubhŒtbody”“”)�”}”(hhh]”(hŒrow”“”)�”}”(hhh]”hŒentry”“”)�”}”(hhh]”hÌ)�”}”(hŒ**Quick Quiz**:”h]”(hŒstrong”“”)�”}”(hŒ**Quick Quiz**”h]”hŒ Quick Quiz”…”�”}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhj¶ubhŒ:”…”�”}”(hj¶h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K;hj³ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj®ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj©ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ+Why isn't the fanout at the leaves also 64?”h]”hŒ-Why isn’t the fanout at the leaves also 64?”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K=hjãubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjàubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj©ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ **Answer**:”h]”(j»)�”}”(hŒ **Answer**”h]”hŒAnswer”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjubhŒ:”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K?hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj©ubj­)�”}”(hhh]”j²)�”}”(hhh]”(hÌ)�”}”(hX|Because there are more types of events that affect the leaf-level ``rcu_node`` structures than further up the tree. Therefore, if the leaf ``rcu_node`` structures have fanout of 64, the contention on these structures' ``->structures`` becomes excessive. Experimentation on a wide variety of systems has shown that a fanout of 16 works well for the leaves of the ``rcu_node`` tree.”h]”(hŒBBecause there are more types of events that affect the leaf-level ”…”�”}”(hj4h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj<h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj4ubhŒ= structures than further up the tree. Therefore, if the leaf ”…”�”}”(hj4h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjNh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj4ubhŒE structures have fanout of 64, the contention on these structures’ ”…”�”}”(hj4h²hh³Nh´Nubj`)�”}”(hŒ``->structures``”h]”hŒ ->structures”…”�”}”(hj`h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj4ubhŒ€ becomes excessive. Experimentation on a wide variety of systems has shown that a fanout of 16 works well for the leaves of the ”…”�”}”(hj4h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj4ubhŒ tree.”…”�”}”(hj4h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KAhj1ubhÌ)�”}”(hXäOf course, further experience with systems having hundreds or thousands of CPUs may demonstrate that the fanout for the non-leaf ``rcu_node`` structures must also be reduced. Such reduction can be easily carried out when and if it proves necessary. In the meantime, if you are using such a system and running into contention problems on the non-leaf ``rcu_node`` structures, you may use the ``CONFIG_RCU_FANOUT`` kernel configuration parameter to reduce the non-leaf fanout as needed.”h]”(hŒ�Of course, further experience with systems having hundreds or thousands of CPUs may demonstrate that the fanout for the non-leaf ”…”�”}”(hjŠh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj’h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjŠubhŒÑ structures must also be reduced. Such reduction can be easily carried out when and if it proves necessary. In the meantime, if you are using such a system and running into contention problems on the non-leaf ”…”�”}”(hjŠh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj¤h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjŠubhŒ structures, you may use the ”…”�”}”(hjŠh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_RCU_FANOUT``”h]”hŒCONFIG_RCU_FANOUT”…”�”}”(hj¶h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjŠubhŒH kernel configuration parameter to reduce the non-leaf fanout as needed.”…”�”}”(hjŠh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KHhj1ubhÌ)�”}”(hŒðKernels built for systems with strong NUMA characteristics might also need to adjust ``CONFIG_RCU_FANOUT`` so that the domains of the ``rcu_node`` structures align with hardware boundaries. However, there has thus far been no need for this.”h]”(hŒUKernels built for systems with strong NUMA characteristics might also need to adjust ”…”�”}”(hjÎh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_RCU_FANOUT``”h]”hŒCONFIG_RCU_FANOUT”…”�”}”(hjÖh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÎubhŒ so that the domains of the ”…”�”}”(hjÎh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjèh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÎubhŒ^ structures align with hardware boundaries. However, there has thus far been no need for this.”…”�”}”(hjÎh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KQhj1ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j±hj.ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj©ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j§hj˜ubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j–hj“ubah}”(h]”h ]”h"]”h$]”h&]”uh1j‘hjh²hh³hÊh´NubhÌ)�”}”(hXIf your system has more than 1,024 CPUs (or more than 512 CPUs on a 32-bit system), then RCU will automatically add more levels to the tree. For example, if you are crazy enough to build a 64-bit system with 65,536 CPUs, RCU would configure the ``rcu_node`` tree as follows:”h]”(hŒõIf your system has more than 1,024 CPUs (or more than 512 CPUs on a 32-bit system), then RCU will automatically add more levels to the tree. For example, if you are crazy enough to build a 64-bit system with 65,536 CPUs, RCU would configure the ”…”�”}”(hjh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjubhŒ tree as follows:”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KWhjh²hubj1)�”}”(hhh]”j6)�”}”(hhh]”j;)�”}”(hŒ*.. kernel-figure:: HugeTreeClassicRCU.svg ”h]”h}”(h]”h ]”h"]”h$]”h&]”Œuri”Œ1RCU/Design/Data-Structures/HugeTreeClassicRCU.svg”jH}”jJjPsuh1j:hjBh³hÊh´Kubah}”(h]”h ]”h"]”h$]”h&]”uh1j5hj?ubah}”(h]”h ]”h"]”h$]”h&]”uh1j0hjh²hh³hÊh´K]ubhÌ)�”}”(hX—RCU currently permits up to a four-level tree, which on a 64-bit system accommodates up to 4,194,304 CPUs, though only a mere 524,288 CPUs for 32-bit systems. On the other hand, you can set both ``CONFIG_RCU_FANOUT`` and ``CONFIG_RCU_FANOUT_LEAF`` to be as small as 2, which would result in a 16-CPU test using a 4-level tree. This can be useful for testing large-system capabilities on small test machines.”h]”(hŒÃRCU currently permits up to a four-level tree, which on a 64-bit system accommodates up to 4,194,304 CPUs, though only a mere 524,288 CPUs for 32-bit systems. On the other hand, you can set both ”…”�”}”(hj^h²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_RCU_FANOUT``”h]”hŒCONFIG_RCU_FANOUT”…”�”}”(hjfh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj^ubhŒ and ”…”�”}”(hj^h²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_RCU_FANOUT_LEAF``”h]”hŒCONFIG_RCU_FANOUT_LEAF”…”�”}”(hjxh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj^ubhŒ  to be as small as 2, which would result in a 16-CPU test using a 4-level tree. This can be useful for testing large-system capabilities on small test machines.”…”�”}”(hj^h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K^hjh²hubhÌ)�”}”(hXðThis multi-level combining tree allows us to get most of the performance and scalability benefits of partitioning, even though RCU grace-period detection is inherently a global operation. The trick here is that only the last CPU to report a quiescent state into a given ``rcu_node`` structure need advance to the ``rcu_node`` structure at the next level up the tree. This means that at the leaf-level ``rcu_node`` structure, only one access out of sixteen will progress up the tree. For the internal ``rcu_node`` structures, the situation is even more extreme: Only one access out of sixty-four will progress up the tree. Because the vast majority of the CPUs do not progress up the tree, the lock contention remains roughly constant up the tree. No matter how many CPUs there are in the system, at most 64 quiescent-state reports per grace period will progress all the way to the root ``rcu_node`` structure, thus ensuring that the lock contention on that root ``rcu_node`` structure remains acceptably low.”h]”(hXThis multi-level combining tree allows us to get most of the performance and scalability benefits of partitioning, even though RCU grace-period detection is inherently a global operation. The trick here is that only the last CPU to report a quiescent state into a given ”…”�”}”(hj�h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj�ubhŒ structure need advance to the ”…”�”}”(hj�h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjªh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj�ubhŒL structure at the next level up the tree. This means that at the leaf-level ”…”�”}”(hj�h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj�ubhŒW structure, only one access out of sixteen will progress up the tree. For the internal ”…”�”}”(hj�h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj�ubhXv structures, the situation is even more extreme: Only one access out of sixty-four will progress up the tree. Because the vast majority of the CPUs do not progress up the tree, the lock contention remains roughly constant up the tree. No matter how many CPUs there are in the system, at most 64 quiescent-state reports per grace period will progress all the way to the root ”…”�”}”(hj�h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjàh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj�ubhŒ@ structure, thus ensuring that the lock contention on that root ”…”�”}”(hj�h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjòh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj�ubhŒ" structure remains acceptably low.”…”�”}”(hj�h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kehjh²hubhÌ)�”}”(hŒ¨In effect, the combining tree acts like a big shock absorber, keeping lock contention under control at all tree levels regardless of the level of loading on the system.”h]”hŒ¨In effect, the combining tree acts like a big shock absorber, keeping lock contention under control at all tree levels regardless of the level of loading on the system.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kuhjh²hubhÌ)�”}”(hX]RCU updaters wait for normal grace periods by registering RCU callbacks, either directly via ``call_rcu()`` or indirectly via ``synchronize_rcu()`` and friends. RCU callbacks are represented by ``rcu_head`` structures, which are queued on ``rcu_data`` structures while they are waiting for a grace period to elapse, as shown in the following figure:”h]”(hŒ]RCU updaters wait for normal grace periods by registering RCU callbacks, either directly via ”…”�”}”(hjh²hh³Nh´Nubj`)�”}”(hŒ``call_rcu()``”h]”hŒ call_rcu()”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjubhŒ or indirectly via ”…”�”}”(hjh²hh³Nh´Nubj`)�”}”(hŒ``synchronize_rcu()``”h]”hŒsynchronize_rcu()”…”�”}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjubhŒ/ and friends. RCU callbacks are represented by ”…”�”}”(hjh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_head``”h]”hŒrcu_head”…”�”}”(hjDh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjubhŒ! structures, which are queued on ”…”�”}”(hjh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjubhŒb structures while they are waiting for a grace period to elapse, as shown in the following figure:”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kyhjh²hubj1)�”}”(hhh]”j6)�”}”(hhh]”j;)�”}”(hŒ4.. kernel-figure:: BigTreePreemptRCUBHdyntickCB.svg ”h]”h}”(h]”h ]”h"]”h$]”h&]”Œuri”Œ;RCU/Design/Data-Structures/BigTreePreemptRCUBHdyntickCB.svg”jH}”jJjsuh1j:hjqh³hÊh´Kubah}”(h]”h ]”h"]”h$]”h&]”uh1j5hjnubah}”(h]”h ]”h"]”h$]”h&]”uh1j0hjh²hh³hÊh´K�ubhÌ)�”}”(hŒ²This figure shows how ``TREE_RCU``'s and ``PREEMPT_RCU``'s major data structures are related. Lesser data structures will be introduced with the algorithms that make use of them.”h]”(hŒThis figure shows how ”…”�”}”(hj�h²hh³Nh´Nubj`)�”}”(hŒ ``TREE_RCU``”h]”hŒTREE_RCU”…”�”}”(hj•h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj�ubhŒ ’s and ”…”�”}”(hj�h²hh³Nh´Nubj`)�”}”(hŒ``PREEMPT_RCU``”h]”hŒ PREEMPT_RCU”…”�”}”(hj§h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj�ubhŒ|’s major data structures are related. Lesser data structures will be introduced with the algorithms that make use of them.”…”�”}”(hj�h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K‚hjh²hubhÌ)�”}”(hŒVNote that each of the data structures in the above figure has its own synchronization:”h]”hŒVNote that each of the data structures in the above figure has its own synchronization:”…”�”}”(hj¿h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K†hjh²hubhŒenumerated_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒŒEach ``rcu_state`` structures has a lock and a mutex, and some fields are protected by the corresponding root ``rcu_node`` structure's lock.”h]”hÌ)�”}”(hŒŒEach ``rcu_state`` structures has a lock and a mutex, and some fields are protected by the corresponding root ``rcu_node`` structure's lock.”h]”(hŒEach ”…”�”}”(hjØh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hjàh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjØubhŒ\ structures has a lock and a mutex, and some fields are protected by the corresponding root ”…”�”}”(hjØh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjòh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjØubhŒ structure’s lock.”…”�”}”(hjØh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K‰hjÔubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhjÏh²hh³hÊh´NubjÓ)�”}”(hŒ+Each ``rcu_node`` structure has a spinlock.”h]”hÌ)�”}”(hjh]”(hŒEach ”…”�”}”(hjh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjubhŒ structure has a spinlock.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K‹hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhjÏh²hh³hÊh´NubjÓ)�”}”(hŒwThe fields in ``rcu_data`` are private to the corresponding CPU, although a few can be read and written by other CPUs. ”h]”hÌ)�”}”(hŒvThe fields in ``rcu_data`` are private to the corresponding CPU, although a few can be read and written by other CPUs.”h]”(hŒThe fields in ”…”�”}”(hj=h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjEh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj=ubhŒ\ are private to the corresponding CPU, although a few can be read and written by other CPUs.”…”�”}”(hj=h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KŒhj9ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhjÏh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ.”uh1jÍhjh²hh³hÊh´K‰ubhÌ)�”}”(hX)It is important to note that different data structures can have very different ideas about the state of RCU at any given time. For but one example, awareness of the start or end of a given RCU grace period propagates slowly through the data structures. This slow propagation is absolutely necessary for RCU to have good read-side performance. If this balkanized implementation seems foreign to you, one useful trick is to consider each instance of these data structures to be a different person, each having the usual slightly different view of reality.”h]”hX)It is important to note that different data structures can have very different ideas about the state of RCU at any given time. For but one example, awareness of the start or end of a given RCU grace period propagates slowly through the data structures. This slow propagation is absolutely necessary for RCU to have good read-side performance. If this balkanized implementation seems foreign to you, one useful trick is to consider each instance of these data structures to be a different person, each having the usual slightly different view of reality.”…”�”}”(hjnh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K�hjh²hubhÌ)�”}”(hŒ@The general role of each of these data structures is as follows:”h]”hŒ@The general role of each of these data structures is as follows:”…”�”}”(hj|h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K˜hjh²hubjÎ)�”}”(hhh]”(jÓ)�”}”(hXp``rcu_state``: This structure forms the interconnection between the ``rcu_node`` and ``rcu_data`` structures, tracks grace periods, serves as short-term repository for callbacks orphaned by CPU-hotplug events, maintains ``rcu_barrier()`` state, tracks expedited grace-period state, and maintains state used to force quiescent states when grace periods extend too long,”h]”hÌ)�”}”(hXp``rcu_state``: This structure forms the interconnection between the ``rcu_node`` and ``rcu_data`` structures, tracks grace periods, serves as short-term repository for callbacks orphaned by CPU-hotplug events, maintains ``rcu_barrier()`` state, tracks expedited grace-period state, and maintains state used to force quiescent states when grace periods extend too long,”h]”(j`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj•h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj‘ubhŒ7: This structure forms the interconnection between the ”…”�”}”(hj‘h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj§h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj‘ubhŒ and ”…”�”}”(hj‘h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj‘ubhŒ{ structures, tracks grace periods, serves as short-term repository for callbacks orphaned by CPU-hotplug events, maintains ”…”�”}”(hj‘h²hh³Nh´Nubj`)�”}”(hŒ``rcu_barrier()``”h]”hŒ rcu_barrier()”…”�”}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj‘ubhŒƒ state, tracks expedited grace-period state, and maintains state used to force quiescent states when grace periods extend too long,”…”�”}”(hj‘h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kšhj�ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhjŠh²hh³hÊh´NubjÓ)�”}”(hX5``rcu_node``: This structure forms the combining tree that propagates quiescent-state information from the leaves to the root, and also propagates grace-period information from the root to the leaves. It provides local copies of the grace-period state in order to allow this information to be accessed in a synchronized manner without suffering the scalability limitations that would otherwise be imposed by global locking. In ``CONFIG_PREEMPT_RCU`` kernels, it manages the lists of tasks that have blocked while in their current RCU read-side critical section. In ``CONFIG_PREEMPT_RCU`` with ``CONFIG_RCU_BOOST``, it manages the per-\ ``rcu_node`` priority-boosting kernel threads (kthreads) and state. Finally, it records CPU-hotplug state in order to determine which CPUs should be ignored during a given grace period.”h]”hÌ)�”}”(hX5``rcu_node``: This structure forms the combining tree that propagates quiescent-state information from the leaves to the root, and also propagates grace-period information from the root to the leaves. It provides local copies of the grace-period state in order to allow this information to be accessed in a synchronized manner without suffering the scalability limitations that would otherwise be imposed by global locking. In ``CONFIG_PREEMPT_RCU`` kernels, it manages the lists of tasks that have blocked while in their current RCU read-side critical section. In ``CONFIG_PREEMPT_RCU`` with ``CONFIG_RCU_BOOST``, it manages the per-\ ``rcu_node`` priority-boosting kernel threads (kthreads) and state. Finally, it records CPU-hotplug state in order to determine which CPUs should be ignored during a given grace period.”h]”(j`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjñh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjíubhXŸ: This structure forms the combining tree that propagates quiescent-state information from the leaves to the root, and also propagates grace-period information from the root to the leaves. It provides local copies of the grace-period state in order to allow this information to be accessed in a synchronized manner without suffering the scalability limitations that would otherwise be imposed by global locking. In ”…”�”}”(hjíh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_PREEMPT_RCU``”h]”hŒCONFIG_PREEMPT_RCU”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjíubhŒt kernels, it manages the lists of tasks that have blocked while in their current RCU read-side critical section. In ”…”�”}”(hjíh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_PREEMPT_RCU``”h]”hŒCONFIG_PREEMPT_RCU”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjíubhŒ with ”…”�”}”(hjíh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_RCU_BOOST``”h]”hŒCONFIG_RCU_BOOST”…”�”}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjíubhŒ, it manages the per- ”…”�”}”(hjíh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj9h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjíubhŒ­ priority-boosting kernel threads (kthreads) and state. Finally, it records CPU-hotplug state in order to determine which CPUs should be ignored during a given grace period.”…”�”}”(hjíh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K hjéubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhjŠh²hh³hÊh´NubjÓ)�”}”(hX3``rcu_data``: This per-CPU structure is the focus of quiescent-state detection and RCU callback queuing. It also tracks its relationship to the corresponding leaf ``rcu_node`` structure to allow more-efficient propagation of quiescent states up the ``rcu_node`` combining tree. Like the ``rcu_node`` structure, it provides a local copy of the grace-period information to allow for-free synchronized access to this information from the corresponding CPU. Finally, this structure records past dyntick-idle state for the corresponding CPU and also tracks statistics.”h]”hÌ)�”}”(hX3``rcu_data``: This per-CPU structure is the focus of quiescent-state detection and RCU callback queuing. It also tracks its relationship to the corresponding leaf ``rcu_node`` structure to allow more-efficient propagation of quiescent states up the ``rcu_node`` combining tree. Like the ``rcu_node`` structure, it provides a local copy of the grace-period information to allow for-free synchronized access to this information from the corresponding CPU. Finally, this structure records past dyntick-idle state for the corresponding CPU and also tracks statistics.”h]”(j`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj_h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj[ubhŒ—: This per-CPU structure is the focus of quiescent-state detection and RCU callback queuing. It also tracks its relationship to the corresponding leaf ”…”�”}”(hj[h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjqh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj[ubhŒJ structure to allow more-efficient propagation of quiescent states up the ”…”�”}”(hj[h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj[ubhŒ combining tree. Like the ”…”�”}”(hj[h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj•h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj[ubhX structure, it provides a local copy of the grace-period information to allow for-free synchronized access to this information from the corresponding CPU. Finally, this structure records past dyntick-idle state for the corresponding CPU and also tracks statistics.”…”�”}”(hj[h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K­hjWubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhjŠh²hh³hÊh´NubjÓ)�”}”(hŒÎ``rcu_head``: This structure represents RCU callbacks, and is the only structure allocated and managed by RCU users. The ``rcu_head`` structure is normally embedded within the RCU-protected data structure. ”h]”hÌ)�”}”(hŒÍ``rcu_head``: This structure represents RCU callbacks, and is the only structure allocated and managed by RCU users. The ``rcu_head`` structure is normally embedded within the RCU-protected data structure.”h]”(j`)�”}”(hŒ ``rcu_head``”h]”hŒrcu_head”…”�”}”(hj»h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj·ubhŒm: This structure represents RCU callbacks, and is the only structure allocated and managed by RCU users. The ”…”�”}”(hj·h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_head``”h]”hŒrcu_head”…”�”}”(hjÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj·ubhŒH structure is normally embedded within the RCU-protected data structure.”…”�”}”(hj·h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¶hj³ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhjŠh²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jijjjkhjljmuh1jÍhjh²hh³hÊh´KšubhÌ)�”}”(hŒñIf all you wanted from this article was a general notion of how RCU's data structures are related, you are done. Otherwise, each of the following sections give more details on the ``rcu_state``, ``rcu_node`` and ``rcu_data`` data structures.”h]”(hŒ¶If all you wanted from this article was a general notion of how RCU’s data structures are related, you are done. Otherwise, each of the following sections give more details on the ”…”�”}”(hjñh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjñubhŒ, ”…”�”}”(hjñh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjñubhŒ and ”…”�”}”(hjñh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjñubhŒ data structures.”…”�”}”(hjñh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K»hjh²hubh¶)�”}”(hhh]”(h»)�”}”(hŒThe ``rcu_state`` Structure”h]”(hŒThe ”…”�”}”(hj8h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj8ubhŒ Structure”…”�”}”(hj8h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hºhj5h²hh³hÊh´KÁubhÌ)�”}”(hXlThe ``rcu_state`` structure is the base structure that represents the state of RCU in the system. This structure forms the interconnection between the ``rcu_node`` and ``rcu_data`` structures, tracks grace periods, contains the lock used to synchronize with CPU-hotplug events, and maintains state used to force quiescent states when grace periods extend too long,”h]”(hŒThe ”…”�”}”(hjXh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj`h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjXubhŒ† structure is the base structure that represents the state of RCU in the system. This structure forms the interconnection between the ”…”�”}”(hjXh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjXubhŒ and ”…”�”}”(hjXh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj„h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjXubhŒ¸ structures, tracks grace periods, contains the lock used to synchronize with CPU-hotplug events, and maintains state used to force quiescent states when grace periods extend too long,”…”�”}”(hjXh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÃhj5h²hubhÌ)�”}”(hŒµA few of the ``rcu_state`` structure's fields are discussed, singly and in groups, in the following sections. The more specialized fields are covered in the discussion of their use.”h]”(hŒ A few of the ”…”�”}”(hjœh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj¤h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjœubhŒ� structure’s fields are discussed, singly and in groups, in the following sections. The more specialized fields are covered in the discussion of their use.”…”�”}”(hjœh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÊhj5h²hubh¶)�”}”(hhh]”(h»)�”}”(hŒ0Relationship to rcu_node and rcu_data Structures”h]”hŒ0Relationship to rcu_node and rcu_data Structures”…”�”}”(hj¿h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj¼h²hh³hÊh´KÏubhÌ)�”}”(hŒCThis portion of the ``rcu_state`` structure is declared as follows:”h]”(hŒThis portion of the ”…”�”}”(hjÍh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÍubhŒ" structure is declared as follows:”…”�”}”(hjÍh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÑhj¼h²hubhŒ literal_block”“”)�”}”(hŒy1 struct rcu_node node[NUM_RCU_NODES]; 2 struct rcu_node *level[NUM_RCU_LVLS + 1]; 3 struct rcu_data __percpu *rda;”h]”hŒy1 struct rcu_node node[NUM_RCU_NODES]; 2 struct rcu_node *level[NUM_RCU_LVLS + 1]; 3 struct rcu_data __percpu *rda;”…”�”}”hjïsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1jíh³hÊh´KÕhj¼h²hubj’)�”}”(hhh]”j—)�”}”(hhh]”(jœ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”KGuh1j›hj ubj¨)�”}”(hhh]”(j­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ**Quick Quiz**:”h]”(j»)�”}”(hŒ**Quick Quiz**”h]”hŒ Quick Quiz”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhj ubhŒ:”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÚhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒzWait a minute! You said that the ``rcu_node`` structures formed a tree, but they are declared as a flat array! What gives?”h]”(hŒ!Wait a minute! You said that the ”…”�”}”(hjF h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjN h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjF ubhŒM structures formed a tree, but they are declared as a flat array! What gives?”…”�”}”(hjF h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÜhjC ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj@ ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ **Answer**:”h]”(j»)�”}”(hŒ **Answer**”h]”hŒAnswer”…”�”}”(hj| h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjx ubhŒ:”…”�”}”(hjx h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kßhju ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjr ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hXThe tree is laid out in the array. The first node In the array is the head, the next set of nodes in the array are children of the head node, and so on until the last set of nodes in the array are the leaves. See the following diagrams to see how this works.”h]”hXThe tree is laid out in the array. The first node In the array is the head, the next set of nodes in the array are children of the head node, and so on until the last set of nodes in the array are the leaves. See the following diagrams to see how this works.”…”�”}”(hj¦ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Káhj£ ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj  ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j§hj ubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j–hjÿubah}”(h]”h ]”h"]”h$]”h&]”uh1j‘hj¼h²hh³hÊh´NubhÌ)�”}”(hŒ_The ``rcu_node`` tree is embedded into the ``->node[]`` array as shown in the following figure:”h]”(hŒThe ”…”�”}”(hjÓ h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjÛ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÓ ubhŒ tree is embedded into the ”…”�”}”(hjÓ h²hh³Nh´Nubj`)�”}”(hŒ ``->node[]``”h]”hŒ->node[]”…”�”}”(hjí h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÓ ubhŒ( array as shown in the following figure:”…”�”}”(hjÓ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kèhj¼h²hubj1)�”}”(hhh]”j6)�”}”(hhh]”j;)�”}”(hŒ#.. kernel-figure:: TreeMapping.svg ”h]”h}”(h]”h ]”h"]”h$]”h&]”Œuri”Œ*RCU/Design/Data-Structures/TreeMapping.svg”jH}”jJj suh1j:hj h³hÊh´Kubah}”(h]”h ]”h"]”h$]”h&]”uh1j5hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1j0hj¼h²hh³hÊh´KìubhÌ)�”}”(hXOne interesting consequence of this mapping is that a breadth-first traversal of the tree is implemented as a simple linear scan of the array, which is in fact what the ``rcu_for_each_node_breadth_first()`` macro does. This macro is used at the beginning and ends of grace periods.”h]”(hŒ©One interesting consequence of this mapping is that a breadth-first traversal of the tree is implemented as a simple linear scan of the array, which is in fact what the ”…”�”}”(hj$ h²hh³Nh´Nubj`)�”}”(hŒ%``rcu_for_each_node_breadth_first()``”h]”hŒ!rcu_for_each_node_breadth_first()”…”�”}”(hj, h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj$ ubhŒK macro does. This macro is used at the beginning and ends of grace periods.”…”�”}”(hj$ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kíhj¼h²hubhÌ)�”}”(hŒ”Each entry of the ``->level`` array references the first ``rcu_node`` structure on the corresponding level of the tree, for example, as shown below:”h]”(hŒEach entry of the ”…”�”}”(hjD h²hh³Nh´Nubj`)�”}”(hŒ ``->level``”h]”hŒ->level”…”�”}”(hjL h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjD ubhŒ array references the first ”…”�”}”(hjD h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj^ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjD ubhŒO structure on the corresponding level of the tree, for example, as shown below:”…”�”}”(hjD h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kóhj¼h²hubj1)�”}”(hhh]”j6)�”}”(hhh]”j;)�”}”(hŒ(.. kernel-figure:: TreeMappingLevel.svg ”h]”h}”(h]”h ]”h"]”h$]”h&]”Œuri”Œ/RCU/Design/Data-Structures/TreeMappingLevel.svg”jH}”jJj‡ suh1j:hjy h³hÊh´Kubah}”(h]”h ]”h"]”h$]”h&]”uh1j5hjv ubah}”(h]”h ]”h"]”h$]”h&]”uh1j0hj¼h²hh³hÊh´KøubhÌ)�”}”(hŒìThe zero\ :sup:`th` element of the array references the root ``rcu_node`` structure, the first element references the first child of the root ``rcu_node``, and finally the second element references the first leaf ``rcu_node`` structure.”h]”(hŒ The zero ”…”�”}”(hj• h²hh³Nh´NubhŒ superscript”“”)�”}”(hŒ :sup:`th`”h]”hŒth”…”�”}”(hjŸ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j� hj• ubhŒ* element of the array references the root ”…”�”}”(hj• h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj± h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj• ubhŒE structure, the first element references the first child of the root ”…”�”}”(hj• h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjà h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj• ubhŒ;, and finally the second element references the first leaf ”…”�”}”(hj• h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjÕ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj• ubhŒ structure.”…”�”}”(hj• h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kùhj¼h²hubhÌ)�”}”(hŒ†For whatever it is worth, if you draw the tree to be tree-shaped rather than array-shaped, it is easy to draw a planar representation:”h]”hŒ†For whatever it is worth, if you draw the tree to be tree-shaped rather than array-shaped, it is easy to draw a planar representation:”…”�”}”(hjí h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kþhj¼h²hubj1)�”}”(hhh]”j6)�”}”(hhh]”j;)�”}”(hŒ!.. kernel-figure:: TreeLevel.svg ”h]”h}”(h]”h ]”h"]”h$]”h&]”Œuri”Œ(RCU/Design/Data-Structures/TreeLevel.svg”jH}”jJj suh1j:hjþ h³hÊh´Kubah}”(h]”h ]”h"]”h$]”h&]”uh1j5hjû ubah}”(h]”h ]”h"]”h$]”h&]”uh1j0hj¼h²hh³hÊh´MubhÌ)�”}”(hŒlFinally, the ``->rda`` field references a per-CPU pointer to the corresponding CPU's ``rcu_data`` structure.”h]”(hŒ Finally, the ”…”�”}”(hj h²hh³Nh´Nubj`)�”}”(hŒ ``->rda``”h]”hŒ->rda”…”�”}”(hj" h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj ubhŒA field references a per-CPU pointer to the corresponding CPU’s ”…”�”}”(hj h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj4 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj ubhŒ structure.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj¼h²hubhÌ)�”}”(hŒcAll of these fields are constant once initialization is complete, and therefore need no protection.”h]”hŒcAll of these fields are constant once initialization is complete, and therefore need no protection.”…”�”}”(hjL h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj¼h²hubeh}”(h]”Œ0relationship-to-rcu-node-and-rcu-data-structures”ah ]”h"]”Œ0relationship to rcu_node and rcu_data structures”ah$]”h&]”uh1hµhj5h²hh³hÊh´KÏubh¶)�”}”(hhh]”(h»)�”}”(hŒGrace-Period Tracking”h]”hŒGrace-Period Tracking”…”�”}”(hje h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjb h²hh³hÊh´M ubhÌ)�”}”(hŒCThis portion of the ``rcu_state`` structure is declared as follows:”h]”(hŒThis portion of the ”…”�”}”(hjs h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj{ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjs ubhŒ" structure is declared as follows:”…”�”}”(hjs h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M hjb h²hubjî)�”}”(hŒ1 unsigned long gp_seq;”h]”hŒ1 unsigned long gp_seq;”…”�”}”hj“ sbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´Mhjb h²hubhÌ)�”}”(hX×RCU grace periods are numbered, and the ``->gp_seq`` field contains the current grace-period 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 ``->gp_seq`` are 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 ``rcu_node`` structure's ``->lock`` field.”h]”(hŒ(RCU grace periods are numbered, and the ”…”�”}”(hj¡ h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hj© h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¡ ubhŒá field contains the current grace-period 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 ”…”�”}”(hj¡ h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hj» h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¡ ubhŒŒ are 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 ”…”�”}”(hj¡ h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjÍ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¡ ubhŒ structure’s ”…”�”}”(hj¡ h²hh³Nh´Nubj`)�”}”(hŒ ``->lock``”h]”hŒ->lock”…”�”}”(hjß h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¡ ubhŒ field.”…”�”}”(hj¡ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhjb h²hubhÌ)�”}”(hX—There are ``->gp_seq`` fields in the ``rcu_node`` and ``rcu_data`` structures as well. The fields in the ``rcu_state`` structure represent the most current value, and those of the other structures are compared in order to detect the beginnings and ends of grace periods in a distributed fashion. The values flow from ``rcu_state`` to ``rcu_node`` (down the tree from the root to the leaves) to ``rcu_data``.”h]”(hŒ There are ”…”�”}”(hj÷ h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hjÿ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj÷ ubhŒ fields in the ”…”�”}”(hj÷ h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj÷ ubhŒ and ”…”�”}”(hj÷ h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj# h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj÷ ubhŒ' structures as well. The fields in the ”…”�”}”(hj÷ h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj5 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj÷ ubhŒÇ structure represent the most current value, and those of the other structures are compared in order to detect the beginnings and ends of grace periods in a distributed fashion. The values flow from ”…”�”}”(hj÷ h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hjG h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj÷ ubhŒ to ”…”�”}”(hj÷ h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjY h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj÷ ubhŒ0 (down the tree from the root to the leaves) to ”…”�”}”(hj÷ h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjk h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj÷ ubhŒ.”…”�”}”(hj÷ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhjb h²hubj’)�”}”(hhh]”j—)�”}”(hhh]”(jœ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”KGuh1j›hj† ubj¨)�”}”(hhh]”(j­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ**Quick Quiz**:”h]”(j»)�”}”(hŒ**Quick Quiz**”h]”hŒ Quick Quiz”…”�”}”(hj  h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjœ ubhŒ:”…”�”}”(hjœ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M"hj™ ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj– ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj“ ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒúGiven that the root rcu_node structure has a gp_seq field, why does RCU maintain a separate gp_seq in the rcu_state structure? Why not just use the root rcu_node's gp_seq as the official record and update it directly when starting a new grace period?”h]”hŒüGiven that the root rcu_node structure has a gp_seq field, why does RCU maintain a separate gp_seq in the rcu_state structure? Why not just use the root rcu_node’s gp_seq as the official record and update it directly when starting a new grace period?”…”�”}”(hjÊ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M$hjÇ ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjÄ ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj“ ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ **Answer**:”h]”(j»)�”}”(hŒ **Answer**”h]”hŒAnswer”…”�”}”(hjî h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjê ubhŒ:”…”�”}”(hjê h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M)hjç ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjä ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj“ ubj­)�”}”(hhh]”j²)�”}”(hhh]”(hÌ)�”}”(hŒ On single-node RCU trees (where the root node is also a leaf), updating the root node's gp_seq immediately would create unnecessary lock contention. Here's why:”h]”hŒ¤On single-node RCU trees (where the root node is also a leaf), updating the root node’s gp_seq immediately would create unnecessary lock contention. Here’s why:”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M+hj ubhÌ)�”}”(hŒ=If we did rcu_seq_start() directly on the root node's gp_seq:”h]”hŒ?If we did rcu_seq_start() directly on the root node’s gp_seq:”…”�”}”(hj& h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M/hj ubjÎ)�”}”(hhh]”(jÓ)�”}”(hŒ†All CPUs would immediately see their node's gp_seq from their rdp's gp_seq, in rcu_pending(). They would all then invoke the RCU-core.”h]”hÌ)�”}”(hŒ†All CPUs would immediately see their node's gp_seq from their rdp's gp_seq, in rcu_pending(). They would all then invoke the RCU-core.”h]”hŒŠAll CPUs would immediately see their node’s gp_seq from their rdp’s gp_seq, in rcu_pending(). They would all then invoke the RCU-core.”…”�”}”(hj; h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M1hj7 ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj4 ubjÓ)�”}”(hŒ?Which calls note_gp_changes() and try to acquire the node lock.”h]”hÌ)�”}”(hjQ h]”hŒ?Which calls note_gp_changes() and try to acquire the node lock.”…”�”}”(hjS h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M3hjO ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj4 ubjÓ)�”}”(hŒFBut rnp->qsmask isn't initialized yet (happens later in rcu_gp_init())”h]”hÌ)�”}”(hŒFBut rnp->qsmask isn't initialized yet (happens later in rcu_gp_init())”h]”hŒHBut rnp->qsmask isn’t initialized yet (happens later in rcu_gp_init())”…”�”}”(hjj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M4hjf ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj4 ubjÓ)�”}”(hŒ˜So each CPU would acquire the lock, find it can't determine if it needs to report quiescent state (no qsmask), update rdp->gp_seq, and release the lock.”h]”hÌ)�”}”(hŒ˜So each CPU would acquire the lock, find it can't determine if it needs to report quiescent state (no qsmask), update rdp->gp_seq, and release the lock.”h]”hŒšSo each CPU would acquire the lock, find it can’t determine if it needs to report quiescent state (no qsmask), update rdp->gp_seq, and release the lock.”…”�”}”(hj‚ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M6hj~ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj4 ubjÓ)�”}”(hŒ@Result: Lots of lock acquisitions with no grace period progress ”h]”hÌ)�”}”(hŒ?Result: Lots of lock acquisitions with no grace period progress”h]”hŒ?Result: Lots of lock acquisitions with no grace period progress”…”�”}”(hjš h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M9hj– ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj4 ubeh}”(h]”h ]”h"]”h$]”h&]”jijjjkhjljmuh1jÍhj ubhÌ)�”}”(hX>By having a separate rcu_state.gp_seq, we can increment the official grace period counter without immediately affecting what CPUs see in their nodes. The hierarchical propagation in rcu_gp_init() then updates the root node's gp_seq and qsmask together under the same lock acquisition, avoiding this useless contention.”h]”hX@By having a separate rcu_state.gp_seq, we can increment the official grace period counter without immediately affecting what CPUs see in their nodes. The hierarchical propagation in rcu_gp_init() then updates the root node’s gp_seq and qsmask together under the same lock acquisition, avoiding this useless contention.”…”�”}”(hj´ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M;hj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j±hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj“ ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j§hj† ubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j–hjƒ ubah}”(h]”h ]”h"]”h$]”h&]”uh1j‘hjb h²hh³hÊh´Nubeh}”(h]”Œgrace-period-tracking”ah ]”h"]”h$]”Œgrace-period tracking”ah&]”uh1hµhj5h²hh³hÊh´M Œ referenced”Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ Miscellaneous”h]”hŒ Miscellaneous”…”�”}”(hjí h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjê h²hh³hÊh´MCubhÌ)�”}”(hŒCThis portion of the ``rcu_state`` structure is declared as follows:”h]”(hŒThis portion of the ”…”�”}”(hjû h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjû ubhŒ" structure is declared as follows:”…”�”}”(hjû h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MEhjê h²hubjî)�”}”(hŒ81 unsigned long gp_max; 2 char abbr; 3 char *name;”h]”hŒ81 unsigned long gp_max; 2 char abbr; 3 char *name;”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´MIhjê h²hubhÌ)�”}”(hŒ‰The ``->gp_max`` field tracks the duration of the longest grace period in jiffies. It is protected by the root ``rcu_node``'s ``->lock``.”h]”(hŒThe ”…”�”}”(hj)h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_max``”h]”hŒ->gp_max”…”�”}”(hj1h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj)ubhŒ_ field tracks the duration of the longest grace period in jiffies. It is protected by the root ”…”�”}”(hj)h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjCh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj)ubhŒ’s ”…”�”}”(hj)h²hh³Nh´Nubj`)�”}”(hŒ ``->lock``”h]”hŒ->lock”…”�”}”(hjUh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj)ubhŒ.”…”�”}”(hj)h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MMhjê h²hubhÌ)�”}”(hŒÚThe ``->name`` and ``->abbr`` fields distinguish between preemptible RCU (“rcu_preemptâ€� and “pâ€�) and non-preemptible RCU (“rcu_schedâ€� and “sâ€�). These fields are used for diagnostic and tracing purposes.”h]”(hŒThe ”…”�”}”(hjmh²hh³Nh´Nubj`)�”}”(hŒ ``->name``”h]”hŒ->name”…”�”}”(hjuh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjmubhŒ and ”…”�”}”(hjmh²hh³Nh´Nubj`)�”}”(hŒ ``->abbr``”h]”hŒ->abbr”…”�”}”(hj‡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjmubhŒ½ fields distinguish between preemptible RCU (“rcu_preemptâ€� and “pâ€�) and non-preemptible RCU (“rcu_schedâ€� and “sâ€�). These fields are used for diagnostic and tracing purposes.”…”�”}”(hjmh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MPhjê h²hubeh}”(h]”Œ miscellaneous”ah ]”h"]”Œ miscellaneous”ah$]”h&]”uh1hµhj5h²hh³hÊh´MCubeh}”(h]”Œthe-rcu-state-structure”ah ]”h"]”Œthe rcu_state structure”ah$]”h&]”uh1hµhjh²hh³hÊh´KÁubh¶)�”}”(hhh]”(h»)�”}”(hŒThe ``rcu_node`` Structure”h]”(hŒThe ”…”�”}”(hj²h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjºh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj²ubhŒ Structure”…”�”}”(hj²h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hºhj¯h²hh³hÊh´MUubhÌ)�”}”(hXAThe ``rcu_node`` structures form the combining tree that propagates quiescent-state information from the leaves to the root and also that propagates grace-period information from the root down to the leaves. They provides local copies of the grace-period state in order to allow this information to be accessed in a synchronized manner without suffering the scalability limitations that would otherwise be imposed by global locking. In ``CONFIG_PREEMPT_RCU`` kernels, they manage the lists of tasks that have blocked while in their current RCU read-side critical section. In ``CONFIG_PREEMPT_RCU`` with ``CONFIG_RCU_BOOST``, they manage the per-\ ``rcu_node`` priority-boosting kernel threads (kthreads) and state. Finally, they record CPU-hotplug state in order to determine which CPUs should be ignored during a given grace period.”h]”(hŒThe ”…”�”}”(hjÒh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjÚh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒubhX¤ structures form the combining tree that propagates quiescent-state information from the leaves to the root and also that propagates grace-period information from the root down to the leaves. They provides local copies of the grace-period state in order to allow this information to be accessed in a synchronized manner without suffering the scalability limitations that would otherwise be imposed by global locking. In ”…”�”}”(hjÒh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_PREEMPT_RCU``”h]”hŒCONFIG_PREEMPT_RCU”…”�”}”(hjìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒubhŒu kernels, they manage the lists of tasks that have blocked while in their current RCU read-side critical section. In ”…”�”}”(hjÒh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_PREEMPT_RCU``”h]”hŒCONFIG_PREEMPT_RCU”…”�”}”(hjþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒubhŒ with ”…”�”}”(hjÒh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_RCU_BOOST``”h]”hŒCONFIG_RCU_BOOST”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒubhŒ, they manage the per- ”…”�”}”(hjÒh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒubhŒ® priority-boosting kernel threads (kthreads) and state. Finally, they record CPU-hotplug state in order to determine which CPUs should be ignored during a given grace period.”…”�”}”(hjÒh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MWhj¯h²hubhÌ)�”}”(hŒcThe ``rcu_node`` structure's fields are discussed, singly and in groups, in the following sections.”h]”(hŒThe ”…”�”}”(hj:h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj:ubhŒU structure’s fields are discussed, singly and in groups, in the following sections.”…”�”}”(hj:h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mdhj¯h²hubh¶)�”}”(hhh]”(h»)�”}”(hŒConnection to Combining Tree”h]”hŒConnection to Combining Tree”…”�”}”(hj]h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjZh²hh³hÊh´MhubhÌ)�”}”(hŒBThis portion of the ``rcu_node`` structure is declared as follows:”h]”(hŒThis portion of the ”…”�”}”(hjkh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjsh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjkubhŒ" structure is declared as follows:”…”�”}”(hjkh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MjhjZh²hubjî)�”}”(hŒr1 struct rcu_node *parent; 2 u8 level; 3 u8 grpnum; 4 unsigned long grpmask; 5 int grplo; 6 int grphi;”h]”hŒr1 struct rcu_node *parent; 2 u8 level; 3 u8 grpnum; 4 unsigned long grpmask; 5 int grplo; 6 int grphi;”…”�”}”hj‹sbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´MnhjZh²hubhÌ)�”}”(hXîThe ``->parent`` pointer references the ``rcu_node`` one level up in the tree, and is ``NULL`` for the root ``rcu_node``. The RCU implementation makes heavy use of this field to push quiescent states up the tree. The ``->level`` field gives the level in the tree, with the root being at level zero, its children at level one, and so on. The ``->grpnum`` field gives this node's position within the children of its parent, so this number can range between 0 and 31 on 32-bit systems and between 0 and 63 on 64-bit systems. The ``->level`` and ``->grpnum`` fields are used only during initialization and for tracing. The ``->grpmask`` field is the bitmask counterpart of ``->grpnum``, and therefore always has exactly one bit set. This mask is used to clear the bit corresponding to this ``rcu_node`` structure in its parent's bitmasks, which are described later. Finally, the ``->grplo`` and ``->grphi`` fields contain the lowest and highest numbered CPU served by this ``rcu_node`` structure, respectively.”h]”(hŒThe ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``->parent``”h]”hŒ->parent”…”�”}”(hj¡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒ pointer references the ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj³h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒ" one level up in the tree, and is ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hjÅh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒ for the root ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj×h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒa. The RCU implementation makes heavy use of this field to push quiescent states up the tree. The ”…”�”•b}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``->level``”h]”hŒ->level”…”�”}”(hjéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒq field gives the level in the tree, with the root being at level zero, its children at level one, and so on. The ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``->grpnum``”h]”hŒ->grpnum”…”�”}”(hjûh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒ¯ field gives this node’s position within the children of its parent, so this number can range between 0 and 31 on 32-bit systems and between 0 and 63 on 64-bit systems. The ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``->level``”h]”hŒ->level”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒ and ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``->grpnum``”h]”hŒ->grpnum”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒA fields are used only during initialization and for tracing. The ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``->grpmask``”h]”hŒ ->grpmask”…”�”}”(hj1h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒ% field is the bitmask counterpart of ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``->grpnum``”h]”hŒ->grpnum”…”�”}”(hjCh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒi, and therefore always has exactly one bit set. This mask is used to clear the bit corresponding to this ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjUh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒO structure in its parent’s bitmasks, which are described later. Finally, the ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``->grplo``”h]”hŒ->grplo”…”�”}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒ and ”…”�”}”hj™sbj`)�”}”(hŒ ``->grphi``”h]”hŒ->grphi”…”�”}”(hjyh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒC fields contain the lowest and highest numbered CPU served by this ”…”�”}”(hj™h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj‹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj™ubhŒ structure, respectively.”…”�”}”(hj™h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MuhjZh²hubhÌ)�”}”(hŒNAll of these fields are constant, and thus do not require any synchronization.”h]”hŒNAll of these fields are constant, and thus do not require any synchronization.”…”�”}”(hj£h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M…hjZh²hubeh}”(h]”Œconnection-to-combining-tree”ah ]”h"]”Œconnection to combining tree”ah$]”h&]”uh1hµhj¯h²hh³hÊh´Mhubh¶)�”}”(hhh]”(h»)�”}”(hŒSynchronization”h]”hŒSynchronization”…”�”}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj¹h²hh³hÊh´M‰ubhÌ)�”}”(hŒ@This field of the ``rcu_node`` structure is declared as follows:”h]”(hŒThis field of the ”…”�”}”(hjÊh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjÒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÊubhŒ" structure is declared as follows:”…”�”}”(hjÊh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M‹hj¹h²hubjî)�”}”(hŒ1 raw_spinlock_t lock;”h]”hŒ1 raw_spinlock_t lock;”…”�”}”hjêsbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´M�hj¹h²hubhÌ)�”}”(hX9This field is used to protect the remaining fields in this structure, unless otherwise stated. That said, all of the fields in this structure can be accessed without locking for tracing purposes. Yes, this can result in confusing traces, but better some tracing confusion than to be heisenbugged out of existence.”h]”hX9This field is used to protect the remaining fields in this structure, unless otherwise stated. That said, all of the fields in this structure can be accessed without locking for tracing purposes. Yes, this can result in confusing traces, but better some tracing confusion than to be heisenbugged out of existence.”…”�”}”(hjøh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M‘hj¹h²hubhŒtarget”“”)�”}”(hŒ.. _grace-period-tracking-1:”h]”h}”(h]”h ]”h"]”h$]”h&]”Œrefid”Œgrace-period-tracking-1”uh1jh´M—hj¹h²hh³hÊubeh}”(h]”Œsynchronization”ah ]”h"]”Œsynchronization”ah$]”h&]”uh1hµhj¯h²hh³hÊh´M‰ubh¶)�”}”(hhh]”(h»)�”}”(hŒGrace-Period Tracking”h]”hŒGrace-Period Tracking”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´MšubhÌ)�”}”(hŒBThis portion of the ``rcu_node`` structure is declared as follows:”h]”(hŒThis portion of the ”…”�”}”(hj-h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj5h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj-ubhŒ" structure is declared as follows:”…”�”}”(hj-h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mœhjh²hubjî)�”}”(hŒ:1 unsigned long gp_seq; 2 unsigned long gp_seq_needed;”h]”hŒ:1 unsigned long gp_seq; 2 unsigned long gp_seq_needed;”…”�”}”hjMsbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´M hjh²hubhÌ)�”}”(hX_The ``rcu_node`` structures' ``->gp_seq`` fields are the counterparts of the field of the same name in the ``rcu_state`` structure. They each may lag up to one step behind their ``rcu_state`` counterpart. If the bottom two bits of a given ``rcu_node`` structure's ``->gp_seq`` field is zero, then this ``rcu_node`` structure believes that RCU is idle.”h]”(hŒThe ”…”�”}”(hj[h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjch²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj[ubhŒ structures’ ”…”�”}”(hj[h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hjuh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj[ubhŒB fields are the counterparts of the field of the same name in the ”…”�”}”(hj[h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj‡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj[ubhŒ: structure. They each may lag up to one step behind their ”…”�”}”(hj[h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj™h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj[ubhŒ0 counterpart. If the bottom two bits of a given ”…”�”}”(hj[h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj«h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj[ubhŒ structure’s ”…”�”}”(hj[h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj[ubhŒ field is zero, then this ”…”�”}”(hj[h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj[ubhŒ% structure believes that RCU is idle.”…”�”}”(hj[h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M£hjh²hubhÌ)�”}”(hŒrThe ``>gp_seq`` field of each ``rcu_node`` structure is updated at the beginning and the end of each grace period.”h]”(hŒThe ”…”�”}”(hjçh²hh³Nh´Nubj`)�”}”(hŒ ``>gp_seq``”h]”hŒ>gp_seq”…”�”}”(hjïh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjçubhŒ field of each ”…”�”}”(hjçh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjçubhŒH structure is updated at the beginning and the end of each grace period.”…”�”}”(hjçh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M©hjh²hubhÌ)�”}”(hX The ``->gp_seq_needed`` fields record the furthest-in-the-future grace period request seen by the corresponding ``rcu_node`` structure. The request is considered fulfilled when the value of the ``->gp_seq`` field equals or exceeds that of the ``->gp_seq_needed`` field.”h]”(hŒThe ”…”�”}”(hjh²hh³Nh´Nubj`)�”}”(hŒ``->gp_seq_needed``”h]”hŒ->gp_seq_needed”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjubhŒY fields record the furthest-in-the-future grace period request seen by the corresponding ”…”�”}”(hjh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj3h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjubhŒF structure. The request is considered fulfilled when the value of the ”…”�”}”(hjh²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hjEh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjubhŒ% field equals or exceeds that of the ”…”�”}”(hjh²hh³Nh´Nubj`)�”}”(hŒ``->gp_seq_needed``”h]”hŒ->gp_seq_needed”…”�”}”(hjWh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjubhŒ field.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¬hjh²hubj’)�”}”(hhh]”j—)�”}”(hhh]”(jœ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”KGuh1j›hjrubj¨)�”}”(hhh]”(j­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ**Quick Quiz**:”h]”(j»)�”}”(hŒ**Quick Quiz**”h]”hŒ Quick Quiz”…”�”}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjˆubhŒ:”…”�”}”(hjˆh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M²hj…ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj‚ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ�Suppose that this ``rcu_node`` structure doesn't see a request for a very long time. Won't wrapping of the ``->gp_seq`` field cause problems?”h]”(hŒSuppose that this ”…”�”}”(hj¶h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj¾h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¶ubhŒQ structure doesn’t see a request for a very long time. Won’t wrapping of the ”…”�”}”(hj¶h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hjÐh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¶ubhŒ field cause problems?”…”�”}”(hj¶h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M´hj³ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj°ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ **Answer**:”h]”(j»)�”}”(hŒ **Answer**”h]”hŒAnswer”…”�”}”(hjþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjúubhŒ:”…”�”}”(hjúh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¸hj÷ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjôubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒþNo, because if the ``->gp_seq_needed`` field lags behind the ``->gp_seq`` field, the ``->gp_seq_needed`` field will be updated at the end of the grace period. Modulo-arithmetic comparisons therefore will always get the correct answer, even with wrapping.”h]”(hŒNo, because if the ”…”�”}”(hj(h²hh³Nh´Nubj`)�”}”(hŒ``->gp_seq_needed``”h]”hŒ->gp_seq_needed”…”�”}”(hj0h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj(ubhŒ field lags behind the ”…”�”}”(hj(h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj(ubhŒ field, the ”…”�”}”(hj(h²hh³Nh´Nubj`)�”}”(hŒ``->gp_seq_needed``”h]”hŒ->gp_seq_needed”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj(ubhŒ– field will be updated at the end of the grace period. Modulo-arithmetic comparisons therefore will always get the correct answer, even with wrapping.”…”�”}”(hj(h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mºhj%ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj"ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j§hjrubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j–hjoubah}”(h]”h ]”h"]”h$]”h&]”uh1j‘hjh²hh³hÊh´Nubeh}”(h]”(jŒid1”eh ]”h"]”Œgrace-period-tracking-1”ah$]”jç ah&]”uh1hµhj¯h²hh³hÊh´Mšjé KŒexpect_referenced_by_name”}”j�jsŒexpect_referenced_by_id”}”jjsubh¶)�”}”(hhh]”(h»)�”}”(hŒQuiescent-State Tracking”h]”hŒQuiescent-State Tracking”…”�”}”(hjšh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj—h²hh³hÊh´MÁubhÌ)�”}”(hŒNThese fields manage the propagation of quiescent states up the combining tree.”h]”hŒNThese fields manage the propagation of quiescent states up the combining tree.”…”�”}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÃhj—h²hubhÌ)�”}”(hŒAThis portion of the ``rcu_node`` structure has fields as follows:”h]”(hŒThis portion of the ”…”�”}”(hj¶h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj¾h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¶ubhŒ! structure has fields as follows:”…”�”}”(hj¶h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÆhj—h²hubjî)�”}”(hŒq1 unsigned long qsmask; 2 unsigned long expmask; 3 unsigned long qsmaskinit; 4 unsigned long expmaskinit;”h]”hŒq1 unsigned long qsmask; 2 unsigned long expmask; 3 unsigned long qsmaskinit; 4 unsigned long expmaskinit;”…”�”}”hjÖsbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´MÊhj—h²hubhÌ)�”}”(hXmThe ``->qsmask`` field tracks which of this ``rcu_node`` structure's children still need to report quiescent states for the current normal grace period. Such children will have a value of 1 in their corresponding bit. Note that the leaf ``rcu_node`` structures should be thought of as having ``rcu_data`` structures as their children. Similarly, the ``->expmask`` field tracks which of this ``rcu_node`` structure's children still need to report quiescent states for the current expedited grace period. An expedited grace period has the same conceptual properties as a normal grace period, but the expedited implementation accepts extreme CPU overhead to obtain much lower grace-period latency, for example, consuming a few tens of microseconds worth of CPU time to reduce grace-period duration from milliseconds to tens of microseconds. The ``->qsmaskinit`` field tracks which of this ``rcu_node`` structure's children cover for at least one online CPU. This mask is used to initialize ``->qsmask``, and ``->expmaskinit`` is used to initialize ``->expmask`` and the beginning of the normal and expedited grace periods, respectively.”h]”(hŒThe ”…”�”}”(hjäh²hh³Nh´Nubj`)�”}”(hŒ ``->qsmask``”h]”hŒ->qsmask”…”�”}”(hjìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjäubhŒ field tracks which of this ”…”�”}”(hjäh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjäubhŒ· structure’s children still need to report quiescent states for the current normal grace period. Such children will have a value of 1 in their corresponding bit. Note that the leaf ”…”�”}”(hjäh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjäubhŒ+ structures should be thought of as having ”…”�”}”(hjäh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjäubhŒ. structures as their children. Similarly, the ”…”�”}”(hjäh²hh³Nh´Nubj`)�”}”(hŒ ``->expmask``”h]”hŒ ->expmask”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjäubhŒ field tracks which of this ”…”�”}”hjäsbj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjäubhX¹ structure’s children still need to report quiescent states for the current expedited grace period. An expedited grace period has the same conceptual properties as a normal grace period, but the expedited implementation accepts extreme CPU overhead to obtain much lower grace-period latency, for example, consuming a few tens of microseconds worth of CPU time to reduce grace-period duration from milliseconds to tens of microseconds. The ”…”�”}”(hjäh²hh³Nh´Nubj`)�”}”(hŒ``->qsmaskinit``”h]”hŒ ->qsmaskinit”…”�”}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjäubhŒ field tracks which of this ”…”�”}”(hjäh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjäubhŒ[ structure’s children cover for at least one online CPU. This mask is used to initialize ”…”�”}”(hjäh²hh³Nh´Nubj`)�”}”(hŒ ``->qsmask``”h]”hŒ->qsmask”…”�”}”(hj|h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjäubhŒ, and ”…”�”}”(hjäh²hh³Nh´Nubj`)�”}”(hŒ``->expmaskinit``”h]”hŒ ->expmaskinit”…”�”}”(hjŽh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjäubhŒ is used to initialize ”…”�”}”(hjäh²hh³Nh´Nubj`)�”}”(hŒ ``->expmask``”h]”hŒ ->expmask”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjäubhŒK and the beginning of the normal and expedited grace periods, respectively.”…”�”}”(hjäh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÏhj—h²hubj’)�”}”(hhh]”j—)�”}”(hhh]”(jœ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”KGuh1j›hj»ubj¨)�”}”(hhh]”(j­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ**Quick Quiz**:”h]”(j»)�”}”(hŒ**Quick Quiz**”h]”hŒ Quick Quiz”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjÑubhŒ:”…”�”}”(hjÑh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MâhjÎubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjËubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÈubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒaWhy are these bitmasks protected by locking? Come on, haven't you heard of atomic instructions???”h]”hŒcWhy are these bitmasks protected by locking? Come on, haven’t you heard of atomic instructions???”…”�”}”(hjÿh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mähjüubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjùubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÈubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ **Answer**:”h]”(j»)�”}”(hŒ **Answer**”h]”hŒAnswer”…”�”}”(hj#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjubhŒ:”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mçhjubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÈubj­)�”}”(hhh]”j²)�”}”(hhh]”(hÌ)�”}”(hŒqLockless grace-period computation! Such a tantalizing possibility! But consider the following sequence of events:”h]”hŒqLockless grace-period computation! Such a tantalizing possibility! But consider the following sequence of events:”…”�”}”(hjMh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MéhjJubjÎ)�”}”(hhh]”(jÓ)�”}”(hŒÔCPU 0 has been in dyntick-idle mode for quite some time. When it wakes up, it notices that the current RCU grace period needs it to report in, so it sets a flag where the scheduling clock interrupt will find it.”h]”hÌ)�”}”(hŒÔCPU 0 has been in dyntick-idle mode for quite some time. When it wakes up, it notices that the current RCU grace period needs it to report in, so it sets a flag where the scheduling clock interrupt will find it.”h]”hŒÔCPU 0 has been in dyntick-idle mode for quite some time. When it wakes up, it notices that the current RCU grace period needs it to report in, so it sets a flag where the scheduling clock interrupt will find it.”…”�”}”(hjbh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mìhj^ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj[ubjÓ)�”}”(hŒ Meanwhile, CPU 1 is running ``force_quiescent_state()``, and notices that CPU 0 has been in dyntick idle mode, which qualifies as an extended quiescent state.”h]”hÌ)�”}”(hŒ Meanwhile, CPU 1 is running ``force_quiescent_state()``, and notices that CPU 0 has been in dyntick idle mode, which qualifies as an extended quiescent state.”h]”(hŒMeanwhile, CPU 1 is running ”…”�”}”(hjzh²hh³Nh´Nubj`)�”}”(hŒ``force_quiescent_state()``”h]”hŒforce_quiescent_state()”…”�”}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjzubhŒh, and notices that CPU 0 has been in dyntick idle mode, which qualifies as an extended quiescent state.”…”�”}”(hjzh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mðhjvubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj[ubjÓ)�”}”(hŒ±CPU 0's scheduling clock interrupt fires in the middle of an RCU read-side critical section, and notices that the RCU core needs something, so commences RCU softirq processing.”h]”hÌ)�”}”(hŒ±CPU 0's scheduling clock interrupt fires in the middle of an RCU read-side critical section, and notices that the RCU core needs something, so commences RCU softirq processing.”h]”hŒ³CPU 0’s scheduling clock interrupt fires in the middle of an RCU read-side critical section, and notices that the RCU core needs something, so commences RCU softirq processing.”…”�”}”(hj¤h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Móhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj[ubjÓ)�”}”(hŒqCPU 0's softirq handler executes and is just about ready to report its quiescent state up the ``rcu_node`` tree.”h]”hÌ)�”}”(hŒqCPU 0's softirq handler executes and is just about ready to report its quiescent state up the ``rcu_node`` tree.”h]”(hŒaCPU 0’s softirq handler executes and is just about ready to report its quiescent state up the ”…”�”}”(hj¼h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjÄh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¼ubhŒ tree.”…”�”}”(hj¼h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Möhj¸ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj[ubjÓ)�”}”(hŒ]But CPU 1 beats it to the punch, completing the current grace period and starting a new one.”h]”hÌ)�”}”(hŒ]But CPU 1 beats it to the punch, completing the current grace period and starting a new one.”h]”hŒ]But CPU 1 beats it to the punch, completing the current grace period and starting a new one.”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Møhjâubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj[ubjÓ)�”}”(hŒ´CPU 0 now reports its quiescent state for the wrong grace period. That grace period might now end before the RCU read-side critical section. If that happens, disaster will ensue. ”h]”hÌ)�”}”(hŒ³CPU 0 now reports its quiescent state for the wrong grace period. That grace period might now end before the RCU read-side critical section. If that happens, disaster will ensue.”h]”hŒ³CPU 0 now reports its quiescent state for the wrong grace period. That grace period might now end before the RCU read-side critical section. If that happens, disaster will ensue.”…”�”}”(hjþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Múhjúubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj[ubeh}”(h]”h ]”h"]”h$]”h&]”jijjjkhjljmuh1jÍhjJubhÌ)�”}”(hŒ”So the locking is absolutely required in order to coordinate clearing of the bits with updating of the grace-period sequence number in ``->gp_seq``.”h]”(hŒ‡So the locking is absolutely required in order to coordinate clearing of the bits with updating of the grace-period sequence number in ”…”�”}”(hjh²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjubhŒ.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MþhjJubeh}”(h]”h ]”h"]”h$]”h&]”uh1j±hjGubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÈubeh}”(h]”h ]”h"]”h$]”h&]”uh1j§hj»ubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j–hj¸ubah}”(h]”h ]”h"]”h$]”h&]”uh1j‘hj—h²hh³hÊh´Nubeh}”(h]”Œquiescent-state-tracking”ah ]”h"]”Œquiescent-state tracking”ah$]”h&]”uh1hµhj¯h²hh³hÊh´MÁubh¶)�”}”(hhh]”(h»)�”}”(hŒBlocked-Task Management”h]”hŒBlocked-Task Management”…”�”}”(hjbh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj_h²hh³hÊh´MubhÌ)�”}”(hXQ``PREEMPT_RCU`` allows tasks to be preempted in the midst of their RCU read-side critical sections, and these tasks must be tracked explicitly. The details of exactly why and how they are tracked will be covered in a separate article on RCU read-side processing. For now, it is enough to know that the ``rcu_node`` structure tracks them.”h]”(j`)�”}”(hŒ``PREEMPT_RCU``”h]”hŒ PREEMPT_RCU”…”�”}”(hjth²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjpubhX allows tasks to be preempted in the midst of their RCU read-side critical sections, and these tasks must be tracked explicitly. The details of exactly why and how they are tracked will be covered in a separate article on RCU read-side processing. For now, it is enough to know that the ”…”�”}”(hjph²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj†h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjpubhŒ structure tracks them.”…”�”}”(hjph²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj_h²hubjî)�”}”(hŒ{1 struct list_head blkd_tasks; 2 struct list_head *gp_tasks; 3 struct list_head *exp_tasks; 4 bool wait_blkd_tasks;”h]”hŒ{1 struct list_head blkd_tasks; 2 struct list_head *gp_tasks; 3 struct list_head *exp_tasks; 4 bool wait_blkd_tasks;”…”�”}”hjžsbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´Mhj_h²hubhÌ)�”}”(hX0The ``->blkd_tasks`` field is a list header for the list of blocked and preempted tasks. As tasks undergo context switches within RCU read-side critical sections, their ``task_struct`` structures are enqueued (via the ``task_struct``'s ``->rcu_node_entry`` field) onto the head of the ``->blkd_tasks`` list for the leaf ``rcu_node`` structure corresponding to the CPU on which the outgoing context switch executed. As these tasks later exit their RCU read-side critical sections, they remove themselves from the list. This list is therefore in reverse time order, so that if one of the tasks is blocking the current grace period, all subsequent tasks must also be blocking that same grace period. Therefore, a single pointer into this list suffices to track all tasks blocking a given grace period. That pointer is stored in ``->gp_tasks`` for normal grace periods and in ``->exp_tasks`` for expedited grace periods. These last two fields are ``NULL`` if either there is no grace period in flight or if there are no blocked tasks preventing that grace period from completing. If either of these two pointers is referencing a task that removes itself from the ``->blkd_tasks`` list, then that task must advance the pointer to the next task on the list, or set the pointer to ``NULL`` if there are no subsequent tasks on the list.”h]”(hŒThe ”…”�”}”(hj¬h²hh³Nh´Nubj`)�”}”(hŒ``->blkd_tasks``”h]”hŒ ->blkd_tasks”…”�”}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¬ubhŒ• field is a list header for the list of blocked and preempted tasks. As tasks undergo context switches within RCU read-side critical sections, their ”…”�”}”(hj¬h²hh³Nh´Nubj`)�”}”(hŒ``task_struct``”h]”hŒ task_struct”…”�”}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¬ubhŒ" structures are enqueued (via the ”…”�”}”(hj¬h²hh³Nh´Nubj`)�”}”(hŒ``task_struct``”h]”hŒ task_struct”…”�”}”(hjØh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¬ubhŒ’s ”…”�”}”(hj¬h²hh³Nh´Nubj`)�”}”(hŒ``->rcu_node_entry``”h]”hŒ->rcu_node_entry”…”�”}”(hjêh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¬ubhŒ field) onto the head of the ”…”�”}”(hj¬h²hh³Nh´Nubj`)�”}”(hŒ``->blkd_tasks``”h]”hŒ ->blkd_tasks”…”�”}”(hjüh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¬ubhŒ list for the leaf ”…”�”}”(hj¬h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¬ubhXí structure corresponding to the CPU on which the outgoing context switch executed. As these tasks later exit their RCU read-side critical sections, they remove themselves from the list. This list is therefore in reverse time order, so that if one of the tasks is blocking the current grace period, all subsequent tasks must also be blocking that same grace period. Therefore, a single pointer into this list suffices to track all tasks blocking a given grace period. That pointer is stored in ”…”�”}”(hj¬h²hh³Nh´Nubj`)�”}”(hŒ``->gp_tasks``”h]”hŒ ->gp_tasks”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¬ubhŒ! for normal grace periods and in ”…”�”}”(hj¬h²hh³Nh´Nubj`)�”}”(hŒ``->exp_tasks``”h]”hŒ ->exp_tasks”…”�”}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¬ubhŒ8 for expedited grace periods. These last two fields are ”…”�”}”(hj¬h²hh³Nh´Nubj`)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hjDh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¬ubhŒÐ if either there is no grace period in flight or if there are no blocked tasks preventing that grace period from completing. If either of these two pointers is referencing a task that removes itself from the ”…”�”}”(hj¬h²hh³Nh´Nubj`)�”}”(hŒ``->blkd_tasks``”h]”hŒ ->blkd_tasks”…”�”}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¬ubhŒc list, then that task must advance the pointer to the next task on the list, or set the pointer to ”…”�”}”(hj¬h²hh³Nh´Nubj`)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hjhh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¬ubhŒ. if there are no subsequent tasks on the list.”…”�”}”(hj¬h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj_h²hubhÌ)�”}”(hXàFor example, suppose that tasks T1, T2, and T3 are all hard-affinitied to the largest-numbered CPU in the system. Then if task T1 blocked in an RCU read-side critical section, then an expedited grace period started, then task T2 blocked in an RCU read-side critical section, then a normal grace period started, and finally task 3 blocked in an RCU read-side critical section, then the state of the last leaf ``rcu_node`` structure's blocked-task list would be as shown below:”h]”(hX�For example, suppose that tasks T1, T2, and T3 are all hard-affinitied to the largest-numbered CPU in the system. Then if task T1 blocked in an RCU read-side critical section, then an expedited grace period started, then task T2 blocked in an RCU read-side critical section, then a normal grace period started, and finally task 3 blocked in an RCU read-side critical section, then the state of the last leaf ”…”�”}”(hj€h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj€ubhŒ9 structure’s blocked-task list would be as shown below:”…”�”}”(hj€h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M'hj_h²hubj1)�”}”(hhh]”j6)�”}”(hhh]”j;)�”}”(hŒ!.. kernel-figure:: blkd_task.svg ”h]”h}”(h]”h ]”h"]”h$]”h&]”Œuri”Œ(RCU/Design/Data-Structures/blkd_task.svg”jH}”jJj±suh1j:hj£h³hÊh´Kubah}”(h]”h ]”h"]”h$]”h&]”uh1j5hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1j0hj_h²hh³hÊh´M0ubhÌ)�”}”(hX{Task T1 is blocking both grace periods, task T2 is blocking only the normal grace period, and task T3 is blocking neither grace period. Note that these tasks will not remove themselves from this list immediately upon resuming execution. They will instead remain on the list until they execute the outermost ``rcu_read_unlock()`` that ends their RCU read-side critical section.”h]”(hX6Task T1 is blocking both grace periods, task T2 is blocking only the normal grace period, and task T3 is blocking neither grace period. Note that these tasks will not remove themselves from this list immediately upon resuming execution. They will instead remain on the list until they execute the outermost ”…”�”}”(hj¿h²hh³Nh´Nubj`)�”}”(hŒ``rcu_read_unlock()``”h]”hŒrcu_read_unlock()”…”�”}”(hjÇh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¿ubhŒ0 that ends their RCU read-side critical section.”…”�”}”(hj¿h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M1hj_h²hubhÌ)�”}”(hŒoThe ``->wait_blkd_tasks`` field indicates whether or not the current grace period is waiting on a blocked task.”h]”(hŒThe ”…”�”}”(hjßh²hh³Nh´Nubj`)�”}”(hŒ``->wait_blkd_tasks``”h]”hŒ->wait_blkd_tasks”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjßubhŒV field indicates whether or not the current grace period is waiting on a blocked task.”…”�”}”(hjßh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M8hj_h²hubeh}”(h]”Œblocked-task-management”ah ]”h"]”Œblocked-task management”ah$]”h&]”uh1hµhj¯h²hh³hÊh´Mubh¶)�”}”(hhh]”(h»)�”}”(hŒSizing the ``rcu_node`` Array”h]”(hŒ Sizing the ”…”�”}”(hj h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj ubhŒ Array”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´M<ubhÌ)�”}”(hŒVThe ``rcu_node`` array is sized via a series of C-preprocessor expressions as follows:”h]”(hŒThe ”…”�”}”(hj*h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj*ubhŒF array is sized via a series of C-preprocessor expressions as follows:”…”�”}”(hj*h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M>hjh²hubjî)�”}”(hXð 1 #ifdef CONFIG_RCU_FANOUT 2 #define RCU_FANOUT CONFIG_RCU_FANOUT 3 #else 4 # ifdef CONFIG_64BIT 5 # define RCU_FANOUT 64 6 # else 7 # define RCU_FANOUT 32 8 # endif 9 #endif 10 11 #ifdef CONFIG_RCU_FANOUT_LEAF 12 #define RCU_FANOUT_LEAF CONFIG_RCU_FANOUT_LEAF 13 #else 14 # ifdef CONFIG_64BIT 15 # define RCU_FANOUT_LEAF 64 16 # else 17 # define RCU_FANOUT_LEAF 32 18 # endif 19 #endif 20 21 #define RCU_FANOUT_1 (RCU_FANOUT_LEAF) 22 #define RCU_FANOUT_2 (RCU_FANOUT_1 * RCU_FANOUT) 23 #define RCU_FANOUT_3 (RCU_FANOUT_2 * RCU_FANOUT) 24 #define RCU_FANOUT_4 (RCU_FANOUT_3 * RCU_FANOUT) 25 26 #if NR_CPUS <= RCU_FANOUT_1 27 # define RCU_NUM_LVLS 1 28 # define NUM_RCU_LVL_0 1 29 # define NUM_RCU_NODES NUM_RCU_LVL_0 30 # define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0 } 31 # define RCU_NODE_NAME_INIT { "rcu_node_0" } 32 # define RCU_FQS_NAME_INIT { "rcu_node_fqs_0" } 33 # define RCU_EXP_NAME_INIT { "rcu_node_exp_0" } 34 #elif NR_CPUS <= RCU_FANOUT_2 35 # define RCU_NUM_LVLS 2 36 # define NUM_RCU_LVL_0 1 37 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 38 # define NUM_RCU_NODES (NUM_RCU_LVL_0 + NUM_RCU_LVL_1) 39 # define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0, NUM_RCU_LVL_1 } 40 # define RCU_NODE_NAME_INIT { "rcu_node_0", "rcu_node_1" } 41 # define RCU_FQS_NAME_INIT { "rcu_node_fqs_0", "rcu_node_fqs_1" } 42 # define RCU_EXP_NAME_INIT { "rcu_node_exp_0", "rcu_node_exp_1" } 43 #elif NR_CPUS <= RCU_FANOUT_3 44 # define RCU_NUM_LVLS 3 45 # define NUM_RCU_LVL_0 1 46 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) 47 # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 48 # define NUM_RCU_NODES (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2) 49 # define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0, NUM_RCU_LVL_1, NUM_RCU_LVL_2 } 50 # define RCU_NODE_NAME_INIT { "rcu_node_0", "rcu_node_1", "rcu_node_2" } 51 # define RCU_FQS_NAME_INIT { "rcu_node_fqs_0", "rcu_node_fqs_1", "rcu_node_fqs_2" } 52 # define RCU_EXP_NAME_INIT { "rcu_node_exp_0", "rcu_node_exp_1", "rcu_node_exp_2" } 53 #elif NR_CPUS <= RCU_FANOUT_4 54 # define RCU_NUM_LVLS 4 55 # define NUM_RCU_LVL_0 1 56 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_3) 57 # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) 58 # define NUM_RCU_LVL_3 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 59 # define NUM_RCU_NODES (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3) 60 # define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0, NUM_RCU_LVL_1, NUM_RCU_LVL_2, NUM_RCU_LVL_3 } 61 # define RCU_NODE_NAME_INIT { "rcu_node_0", "rcu_node_1", "rcu_node_2", "rcu_node_3" } 62 # define RCU_FQS_NAME_INIT { "rcu_node_fqs_0", "rcu_node_fqs_1", "rcu_node_fqs_2", "rcu_node_fqs_3" } 63 # define RCU_EXP_NAME_INIT { "rcu_node_exp_0", "rcu_node_exp_1", "rcu_node_exp_2", "rcu_node_exp_3" } 64 #else 65 # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" 66 #endif”h]”hXð 1 #ifdef CONFIG_RCU_FANOUT 2 #define RCU_FANOUT CONFIG_RCU_FANOUT 3 #else 4 # ifdef CONFIG_64BIT 5 # define RCU_FANOUT 64 6 # else 7 # define RCU_FANOUT 32 8 # endif 9 #endif 10 11 #ifdef CONFIG_RCU_FANOUT_LEAF 12 #define RCU_FANOUT_LEAF CONFIG_RCU_FANOUT_LEAF 13 #else 14 # ifdef CONFIG_64BIT 15 # define RCU_FANOUT_LEAF 64 16 # else 17 # define RCU_FANOUT_LEAF 32 18 # endif 19 #endif 20 21 #define RCU_FANOUT_1 (RCU_FANOUT_LEAF) 22 #define RCU_FANOUT_2 (RCU_FANOUT_1 * RCU_FANOUT) 23 #define RCU_FANOUT_3 (RCU_FANOUT_2 * RCU_FANOUT) 24 #define RCU_FANOUT_4 (RCU_FANOUT_3 * RCU_FANOUT) 25 26 #if NR_CPUS <= RCU_FANOUT_1 27 # define RCU_NUM_LVLS 1 28 # define NUM_RCU_LVL_0 1 29 # define NUM_RCU_NODES NUM_RCU_LVL_0 30 # define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0 } 31 # define RCU_NODE_NAME_INIT { "rcu_node_0" } 32 # define RCU_FQS_NAME_INIT { "rcu_node_fqs_0" } 33 # define RCU_EXP_NAME_INIT { "rcu_node_exp_0" } 34 #elif NR_CPUS <= RCU_FANOUT_2 35 # define RCU_NUM_LVLS 2 36 # define NUM_RCU_LVL_0 1 37 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 38 # define NUM_RCU_NODES (NUM_RCU_LVL_0 + NUM_RCU_LVL_1) 39 # define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0, NUM_RCU_LVL_1 } 40 # define RCU_NODE_NAME_INIT { "rcu_node_0", "rcu_node_1" } 41 # define RCU_FQS_NAME_INIT { "rcu_node_fqs_0", "rcu_node_fqs_1" } 42 # define RCU_EXP_NAME_INIT { "rcu_node_exp_0", "rcu_node_exp_1" } 43 #elif NR_CPUS <= RCU_FANOUT_3 44 # define RCU_NUM_LVLS 3 45 # define NUM_RCU_LVL_0 1 46 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) 47 # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 48 # define NUM_RCU_NODES (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2) 49 # define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0, NUM_RCU_LVL_1, NUM_RCU_LVL_2 } 50 # define RCU_NODE_NAME_INIT { "rcu_node_0", "rcu_node_1", "rcu_node_2" } 51 # define RCU_FQS_NAME_INIT { "rcu_node_fqs_0", "rcu_node_fqs_1", "rcu_node_fqs_2" } 52 # define RCU_EXP_NAME_INIT { "rcu_node_exp_0", "rcu_node_exp_1", "rcu_node_exp_2" } 53 #elif NR_CPUS <= RCU_FANOUT_4 54 # define RCU_NUM_LVLS 4 55 # define NUM_RCU_LVL_0 1 56 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_3) 57 # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) 58 # define NUM_RCU_LVL_3 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 59 # define NUM_RCU_NODES (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3) 60 # define NUM_RCU_LVL_INIT { NUM_RCU_LVL_0, NUM_RCU_LVL_1, NUM_RCU_LVL_2, NUM_RCU_LVL_3 } 61 # define RCU_NODE_NAME_INIT { "rcu_node_0", "rcu_node_1", "rcu_node_2", "rcu_node_3" } 62 # define RCU_FQS_NAME_INIT { "rcu_node_fqs_0", "rcu_node_fqs_1", "rcu_node_fqs_2", "rcu_node_fqs_3" } 63 # define RCU_EXP_NAME_INIT { "rcu_node_exp_0", "rcu_node_exp_1", "rcu_node_exp_2", "rcu_node_exp_3" } 64 #else 65 # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" 66 #endif”…”�”}”hjJsbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´MChjh²hubhÌ)�”}”(hXKThe maximum number of levels in the ``rcu_node`` structure is currently limited to four, as specified by lines 21-24 and the structure of the subsequent “ifâ€� statement. For 32-bit systems, this allows 16*32*32*32=524,288 CPUs, which should be sufficient for the next few years at least. For 64-bit systems, 16*64*64*64=4,194,304 CPUs is allowed, which should see us through the next decade or so. This four-level tree also allows kernels built with ``CONFIG_RCU_FANOUT=8`` to support up to 4096 CPUs, which might be useful in very large systems having eight CPUs per socket (but please note that no one has yet shown any measurable performance degradation due to misaligned socket and ``rcu_node`` boundaries). In addition, building kernels with a full four levels of ``rcu_node`` tree permits better testing of RCU's combining-tree code.”h]”(hŒ$The maximum number of levels in the ”…”�”}”(hjXh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj`h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjXubhX– structure is currently limited to four, as specified by lines 21-24 and the structure of the subsequent “ifâ€� statement. For 32-bit systems, this allows 16*32*32*32=524,288 CPUs, which should be sufficient for the next few years at least. For 64-bit systems, 16*64*64*64=4,194,304 CPUs is allowed, which should see us through the next decade or so. This four-level tree also allows kernels built with ”…”�”}”(hjXh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_RCU_FANOUT=8``”h]”hŒCONFIG_RCU_FANOUT=8”…”�”}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjXubhŒÕ to support up to 4096 CPUs, which might be useful in very large systems having eight CPUs per socket (but please note that no one has yet shown any measurable performance degradation due to misaligned socket and ”…”�”}”(hjXh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj„h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjXubhŒG boundaries). In addition, building kernels with a full four levels of ”…”�”}”(hjXh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj–h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjXubhŒ< tree permits better testing of RCU’s combining-tree code.”…”�”}”(hjXh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M†hjh²hubhÌ)�”}”(hXThe ``RCU_FANOUT`` symbol controls how many children are permitted at each non-leaf level of the ``rcu_node`` tree. If the ``CONFIG_RCU_FANOUT`` Kconfig option is not specified, it is set based on the word size of the system, which is also the Kconfig default.”h]”(hŒThe ”…”�”}”(hj®h²hh³Nh´Nubj`)�”}”(hŒ``RCU_FANOUT``”h]”hŒ RCU_FANOUT”…”�”}”(hj¶h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj®ubhŒO symbol controls how many children are permitted at each non-leaf level of the ”…”�”}”(hj®h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjÈh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj®ubhŒ tree. If the ”…”�”}”(hj®h²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_RCU_FANOUT``”h]”hŒCONFIG_RCU_FANOUT”…”�”}”(hjÚh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj®ubhŒt Kconfig option is not specified, it is set based on the word size of the system, which is also the Kconfig default.”…”�”}”(hj®h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M”hjh²hubhÌ)�”}”(hX£The ``RCU_FANOUT_LEAF`` symbol controls how many CPUs are handled by each leaf ``rcu_node`` structure. Experience has shown that allowing a given leaf ``rcu_node`` structure to handle 64 CPUs, as permitted by the number of bits in the ``->qsmask`` field on a 64-bit system, results in excessive contention for the leaf ``rcu_node`` structures' ``->lock`` fields. The number of CPUs per leaf ``rcu_node`` structure is therefore limited to 16 given the default value of ``CONFIG_RCU_FANOUT_LEAF``. If ``CONFIG_RCU_FANOUT_LEAF`` is unspecified, the value selected is based on the word size of the system, just as for ``CONFIG_RCU_FANOUT``. Lines 11-19 perform this computation.”h]”(hŒThe ”…”�”}”(hjòh²hh³Nh´Nubj`)�”}”(hŒ``RCU_FANOUT_LEAF``”h]”hŒRCU_FANOUT_LEAF”…”�”}”(hjúh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjòubhŒ8 symbol controls how many CPUs are handled by each leaf ”…”�”}”(hjòh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjòubhŒ< structure. Experience has shown that allowing a given leaf ”…”�”}”(hjòh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjòubhŒH structure to handle 64 CPUs, as permitted by the number of bits in the ”…”�”}”(hjòh²hh³Nh´Nubj`)�”}”(hŒ ``->qsmask``”h]”hŒ->qsmask”…”�”}”(hj0h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjòubhŒH field on a 64-bit system, results in excessive contention for the leaf ”…”�”}”(hjòh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjòubhŒ structures’ ”…”�”}”(hjòh²hh³Nh´Nubj`)�”}”(hŒ ``->lock``”h]”hŒ->lock”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjòubhŒ% fields. The number of CPUs per leaf ”…”�”}”(hjòh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjfh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjòubhŒA structure is therefore limited to 16 given the default value of ”…”�”}”(hjòh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_RCU_FANOUT_LEAF``”h]”hŒCONFIG_RCU_FANOUT_LEAF”…”�”}”(hjxh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjòubhŒ. If ”…”�”}”(hjòh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_RCU_FANOUT_LEAF``”h]”hŒCONFIG_RCU_FANOUT_LEAF”…”�”}”(hjŠh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjòubhŒY is unspecified, the value selected is based on the word size of the system, just as for ”…”�”}”(hjòh²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_RCU_FANOUT``”h]”hŒCONFIG_RCU_FANOUT”…”�”}”(hjœh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjòubhŒ(. Lines 11-19 perform this computation.”…”�”}”(hjòh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M™hjh²hubhÌ)�”}”(hX¨Lines 21-24 compute the maximum number of CPUs supported by a single-level (which contains a single ``rcu_node`` structure), two-level, three-level, and four-level ``rcu_node`` tree, respectively, given the fanout specified by ``RCU_FANOUT`` and ``RCU_FANOUT_LEAF``. These numbers of CPUs are retained in the ``RCU_FANOUT_1``, ``RCU_FANOUT_2``, ``RCU_FANOUT_3``, and ``RCU_FANOUT_4`` C-preprocessor variables, respectively.”h]”(hŒeLines 21-24 compute the maximum number of CPUs supported by a single-level (which contains a single ”…”�”}”(hj´h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj´ubhŒ4 structure), two-level, three-level, and four-level ”…”�”}”(hj´h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj´ubhŒ3 tree, respectively, given the fanout specified by ”…”�”}”(hj´h²hh³Nh´Nubj`)�”}”(hŒ``RCU_FANOUT``”h]”hŒ RCU_FANOUT”…”�”}”(hjàh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj´ubhŒ and ”…”�”}”(hj´h²hh³Nh´Nubj`)�”}”(hŒ``RCU_FANOUT_LEAF``”h]”hŒRCU_FANOUT_LEAF”…”�”}”(hjòh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj´ubhŒ,. These numbers of CPUs are retained in the ”…”�”}”(hj´h²hh³Nh´Nubj`)�”}”(hŒ``RCU_FANOUT_1``”h]”hŒ RCU_FANOUT_1”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj´ubhŒ, ”…”�”}”(hj´h²hh³Nh´Nubj`)�”}”(hŒ``RCU_FANOUT_2``”h]”hŒ RCU_FANOUT_2”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj´ubhŒ, ”…”�”}”(hj´h²hh³Nh´Nubj`)�”}”(hŒ``RCU_FANOUT_3``”h]”hŒ RCU_FANOUT_3”…”�”}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj´ubhŒ, and ”…”�”}”(hj´h²hh³Nh´Nubj`)�”}”(hŒ``RCU_FANOUT_4``”h]”hŒ RCU_FANOUT_4”…”�”}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj´ubhŒ( C-preprocessor variables, respectively.”…”�”}”(hj´h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¤hjh²hubhÌ)�”}”(hXØThese variables are used to control the C-preprocessor ``#if`` statement spanning lines 26-66 that computes the number of ``rcu_node`` structures required for each level of the tree, as well as the number of levels required. The number of levels is placed in the ``NUM_RCU_LVLS`` C-preprocessor variable by lines 27, 35, 44, and 54. The number of ``rcu_node`` structures for the topmost level of the tree is always exactly one, and this value is unconditionally placed into ``NUM_RCU_LVL_0`` by lines 28, 36, 45, and 55. The rest of the levels (if any) of the ``rcu_node`` tree are computed by dividing the maximum number of CPUs by the fanout supported by the number of levels from the current level down, rounding up. This computation is performed by lines 37, 46-47, and 56-58. Lines 31-33, 40-42, 50-52, and 62-63 create initializers for lockdep lock-class names. Finally, lines 64-66 produce an error if the maximum number of CPUs is too large for the specified fanout.”h]”(hŒ7These variables are used to control the C-preprocessor ”…”�”}”(hjRh²hh³Nh´Nubj`)�”}”(hŒ``#if``”h]”hŒ#if”…”�”}”(hjZh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjRubhŒ= statement spanning lines 26-66 that computes the number of ”…”�”}”(hjRh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjlh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjRubhŒ� structures required for each level of the tree, as well as the number of levels required. The number of levels is placed in the ”…”�”}”(hjRh²hh³Nh´Nubj`)�”}”(hŒ``NUM_RCU_LVLS``”h]”hŒ NUM_RCU_LVLS”…”�”}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjRubhŒF C-preprocessor variable by lines 27, 35, 44, and 54. The number of ”…”�”}”(hjRh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjRubhŒs structures for the topmost level of the tree is always exactly one, and this value is unconditionally placed into ”…”�”}”(hjRh²hh³Nh´Nubj`)�”}”(hŒ``NUM_RCU_LVL_0``”h]”hŒ NUM_RCU_LVL_0”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjRubhŒG by lines 28, 36, 45, and 55. The rest of the levels (if any) of the ”…”�”}”(hjRh²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjRubhX— tree are computed by dividing the maximum number of CPUs by the fanout supported by the number of levels from the current level down, rounding up. This computation is performed by lines 37, 46-47, and 56-58. Lines 31-33, 40-42, 50-52, and 62-63 create initializers for lockdep lock-class names. Finally, lines 64-66 produce an error if the maximum number of CPUs is too large for the specified fanout.”…”�”}”(hjRh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¬hjh²hubeh}”(h]”Œsizing-the-rcu-node-array”ah ]”h"]”Œsizing the rcu_node array”ah$]”h&]”uh1hµhj¯h²hh³hÊh´M<ubeh}”(h]”Œthe-rcu-node-structure”ah ]”h"]”Œthe rcu_node structure”ah$]”h&]”uh1hµhjh²hh³hÊh´MUubh¶)�”}”(hhh]”(h»)�”}”(hŒThe ``rcu_segcblist`` Structure”h]”(hŒThe ”…”�”}”(hjßh²hh³Nh´Nubj`)�”}”(hŒ``rcu_segcblist``”h]”hŒ rcu_segcblist”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjßubhŒ Structure”…”�”}”(hjßh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hºhjÜh²hh³hÊh´M½ubhÌ)�”}”(hŒSThe ``rcu_segcblist`` structure maintains a segmented list of callbacks as follows:”h]”(hŒThe ”…”�”}”(hjÿh²hh³Nh´Nubj`)�”}”(hŒ``rcu_segcblist``”h]”hŒ rcu_segcblist”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÿubhŒ> structure maintains a segmented list of callbacks as follows:”…”�”}”(hjÿh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¿hjÜh²hubjî)�”}”(hXh 1 #define RCU_DONE_TAIL 0 2 #define RCU_WAIT_TAIL 1 3 #define RCU_NEXT_READY_TAIL 2 4 #define RCU_NEXT_TAIL 3 5 #define RCU_CBLIST_NSEGS 4 6 7 struct rcu_segcblist { 8 struct rcu_head *head; 9 struct rcu_head **tails[RCU_CBLIST_NSEGS]; 10 unsigned long gp_seq[RCU_CBLIST_NSEGS]; 11 long len; 12 long len_lazy; 13 };”h]”hXh 1 #define RCU_DONE_TAIL 0 2 #define RCU_WAIT_TAIL 1 3 #define RCU_NEXT_READY_TAIL 2 4 #define RCU_NEXT_TAIL 3 5 #define RCU_CBLIST_NSEGS 4 6 7 struct rcu_segcblist { 8 struct rcu_head *head; 9 struct rcu_head **tails[RCU_CBLIST_NSEGS]; 10 unsigned long gp_seq[RCU_CBLIST_NSEGS]; 11 long len; 12 long len_lazy; 13 };”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´MÄhjÜh²hubhÌ)�”}”(hŒThe segments are as follows:”h]”hŒThe segments are as follows:”…”�”}”(hj-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÒhjÜh²hubjÎ)�”}”(hhh]”(jÓ)�”}”(hŒg``RCU_DONE_TAIL``: Callbacks whose grace periods have elapsed. These callbacks are ready to be invoked.”h]”hÌ)�”}”(hŒg``RCU_DONE_TAIL``: Callbacks whose grace periods have elapsed. These callbacks are ready to be invoked.”h]”(j`)�”}”(hŒ``RCU_DONE_TAIL``”h]”hŒ RCU_DONE_TAIL”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjBubhŒV: Callbacks whose grace periods have elapsed. These callbacks are ready to be invoked.”…”�”}”(hjBh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÔhj>ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj;h²hh³hÊh´NubjÓ)�”}”(hŒÀ``RCU_WAIT_TAIL``: Callbacks that are waiting for the current grace period. Note that different CPUs can have different ideas about which grace period is current, hence the ``->gp_seq`` field.”h]”hÌ)�”}”(hŒÀ``RCU_WAIT_TAIL``: Callbacks that are waiting for the current grace period. Note that different CPUs can have different ideas about which grace period is current, hence the ``->gp_seq`` field.”h]”(j`)�”}”(hŒ``RCU_WAIT_TAIL``”h]”hŒ RCU_WAIT_TAIL”…”�”}”(hjlh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjhubhŒœ: Callbacks that are waiting for the current grace period. Note that different CPUs can have different ideas about which grace period is current, hence the ”…”�”}”(hjhh²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjhubhŒ field.”…”�”}”(hjhh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÖhjdubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj;h²hh³hÊh´NubjÓ)�”}”(hŒN``RCU_NEXT_READY_TAIL``: Callbacks waiting for the next grace period to start.”h]”hÌ)�”}”(hŒN``RCU_NEXT_READY_TAIL``: Callbacks waiting for the next grace period to start.”h]”(j`)�”}”(hŒ``RCU_NEXT_READY_TAIL``”h]”hŒRCU_NEXT_READY_TAIL”…”�”}”(hj¤h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj ubhŒ7: Callbacks waiting for the next grace period to start.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÙhjœubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj;h²hh³hÊh´NubjÓ)�”}”(hŒT``RCU_NEXT_TAIL``: Callbacks that have not yet been associated with a grace period. ”h]”hÌ)�”}”(hŒS``RCU_NEXT_TAIL``: Callbacks that have not yet been associated with a grace period.”h]”(j`)�”}”(hŒ``RCU_NEXT_TAIL``”h]”hŒ RCU_NEXT_TAIL”…”�”}”(hjÊh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÆubhŒB: Callbacks that have not yet been associated with a grace period.”…”�”}”(hjÆh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÛhjÂubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒhj;h²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jijjjkhjljmuh1jÍhjÜh²hh³hÊh´MÔubhÌ)�”}”(hXÈThe ``->head`` pointer references the first callback or is ``NULL`` if the list contains no callbacks (which is *not* the same as being empty). Each element of the ``->tails[]`` array references the ``->next`` pointer of the last callback in the corresponding segment of the list, or the list's ``->head`` pointer if that segment and all previous segments are empty. If the corresponding segment is empty but some previous segment is not empty, then the array element is identical to its predecessor. Older callbacks are closer to the head of the list, and new callbacks are added at the tail. This relationship between the ``->head`` pointer, the ``->tails[]`` array, and the callbacks is shown in this diagram:”h]”(hŒThe ”…”�”}”(hjîh²hh³Nh´Nubj`)�”}”(hŒ ``->head``”h]”hŒ->head”…”�”}”(hjöh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjîubhŒ- pointer references the first callback or is ”…”�”}”(hjîh²hh³Nh´Nubj`)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjîubhŒ- if the list contains no callbacks (which is ”…”�”}”(hjîh²hh³Nh´NubhŒemphasis”“”)�”}”(hŒ*not*”h]”hŒnot”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjîubhŒ/ the same as being empty). Each element of the ”…”�”}”(hjîh²hh³Nh´Nubj`)�”}”(hŒ ``->tails[]``”h]”hŒ ->tails[]”…”�”}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjîubhŒ array references the ”…”�”}”(hjîh²hh³Nh´Nubj`)�”}”(hŒ ``->next``”h]”hŒ->next”…”�”}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjîubhŒX pointer of the last callback in the corresponding segment of the list, or the list’s ”…”�”}”(hjîh²hh³Nh´Nubj`)�”}”(hŒ ``->head``”h]”hŒ->head”…”�”}”(hjRh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjîubhX? pointer if that segment and all previous segments are empty. If the corresponding segment is empty but some previous segment is not empty, then the array element is identical to its predecessor. Older callbacks are closer to the head of the list, and new callbacks are added at the tail. This relationship between the ”…”�”}”(hjîh²hh³Nh´Nubj`)�”}”(hŒ ``->head``”h]”hŒ->head”…”�”}”(hjdh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjîubhŒ pointer, the ”…”�”}”(hjîh²hh³Nh´Nubj`)�”}”(hŒ ``->tails[]``”h]”hŒ ->tails[]”…”�”}”(hjvh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjîubhŒ3 array, and the callbacks is shown in this diagram:”…”�”}”(hjîh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÞhjÜh²hubj1)�”}”(hhh]”j6)�”}”(hhh]”j;)�”}”(hŒ.. kernel-figure:: nxtlist.svg ”h]”h}”(h]”h ]”h"]”h$]”h&]”Œuri”Œ&RCU/Design/Data-Structures/nxtlist.svg”jH}”jJjŸsuh1j:hj‘h³hÊh´Kubah}”(h]”h ]”h"]”h$]”h&]”uh1j5hjŽubah}”(h]”h ]”h"]”h$]”h&]”uh1j0hjÜh²hh³hÊh´MëubhÌ)�”}”(hX=In this figure, the ``->head`` pointer references the first RCU callback in the list. The ``->tails[RCU_DONE_TAIL]`` array element references the ``->head`` pointer itself, indicating that none of the callbacks is ready to invoke. The ``->tails[RCU_WAIT_TAIL]`` array element references callback CB 2's ``->next`` pointer, which indicates that CB 1 and CB 2 are both waiting on the current grace period, give or take possible disagreements about exactly which grace period is the current one. The ``->tails[RCU_NEXT_READY_TAIL]`` array element references the same RCU callback that ``->tails[RCU_WAIT_TAIL]`` does, which indicates that there are no callbacks waiting on the next RCU grace period. The ``->tails[RCU_NEXT_TAIL]`` array element references CB 4's ``->next`` pointer, indicating that all the remaining RCU callbacks have not yet been assigned to an RCU grace period. Note that the ``->tails[RCU_NEXT_TAIL]`` array element always references the last RCU callback's ``->next`` pointer unless the callback list is empty, in which case it references the ``->head`` pointer.”h]”(hŒIn this figure, the ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ ``->head``”h]”hŒ->head”…”�”}”(hjµh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒ< pointer references the first RCU callback in the list. The ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ``->tails[RCU_DONE_TAIL]``”h]”hŒ->tails[RCU_DONE_TAIL]”…”�”}”(hjÇh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒ array element references the ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ ``->head``”h]”hŒ->head”…”�”}”(hjÙh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒO pointer itself, indicating that none of the callbacks is ready to invoke. The ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ``->tails[RCU_WAIT_TAIL]``”h]”hŒ->tails[RCU_WAIT_TAIL]”…”�”}”(hjëh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒ- array element references callback CB 2’s ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ ``->next``”h]”hŒ->next”…”�”}”(hjýh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒº pointer, which indicates that CB 1 and CB 2 are both waiting on the current grace period, give or take possible disagreements about exactly which grace period is the current one. The ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ ``->tails[RCU_NEXT_READY_TAIL]``”h]”hŒ->tails[RCU_NEXT_READY_TAIL]”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒ5 array element references the same RCU callback that ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ``->tails[RCU_WAIT_TAIL]``”h]”hŒ->tails[RCU_WAIT_TAIL]”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒ] does, which indicates that there are no callbacks waiting on the next RCU grace period. The ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ``->tails[RCU_NEXT_TAIL]``”h]”hŒ->tails[RCU_NEXT_TAIL]”…”�”}”(hj3h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒ$ array element references CB 4’s ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ ``->next``”h]”hŒ->next”…”�”}”(hjEh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒ{ pointer, indicating that all the remaining RCU callbacks have not yet been assigned to an RCU grace period. Note that the ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ``->tails[RCU_NEXT_TAIL]``”h]”hŒ->tails[RCU_NEXT_TAIL]”…”�”}”(hjWh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒ; array element always references the last RCU callback’s ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ ``->next``”h]”hŒ->next”…”�”}”(hjih²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒL pointer unless the callback list is empty, in which case it references the ”…”�”}”(hj­h²hh³Nh´Nubj`)�”}”(hŒ ``->head``”h]”hŒ->head”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj­ubhŒ pointer.”…”�”}”(hj­h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MìhjÜh²hubhÌ)�”}”(hX7There is one additional important special case for the ``->tails[RCU_NEXT_TAIL]`` array element: It can be ``NULL`` when this list is *disabled*. Lists are disabled when the corresponding CPU is offline or when the corresponding CPU's callbacks are offloaded to a kthread, both of which are described elsewhere.”h]”(hŒ7There is one additional important special case for the ”…”�”}”(hj“h²hh³Nh´Nubj`)�”}”(hŒ``->tails[RCU_NEXT_TAIL]``”h]”hŒ->tails[RCU_NEXT_TAIL]”…”�”}”(hj›h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj“ubhŒ array element: It can be ”…”�”}”(hj“h²hh³Nh´Nubj`)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hj­h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj“ubhŒ when this list is ”…”�”}”(hj“h²hh³Nh´Nubj)�”}”(hŒ *disabled*”h]”hŒdisabled”…”�”}”(hj¿h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj“ubhŒ©. Lists are disabled when the corresponding CPU is offline or when the corresponding CPU’s callbacks are offloaded to a kthread, both of which are described elsewhere.”…”�”}”(hj“h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MýhjÜh²hubhÌ)�”}”(hŒ°CPUs advance their callbacks from the ``RCU_NEXT_TAIL`` to the ``RCU_NEXT_READY_TAIL`` to the ``RCU_WAIT_TAIL`` to the ``RCU_DONE_TAIL`` list segments as grace periods advance.”h]”(hŒ&CPUs advance their callbacks from the ”…”�”}”(hj×h²hh³Nh´Nubj`)�”}”(hŒ``RCU_NEXT_TAIL``”h]”hŒ RCU_NEXT_TAIL”…”�”}”(hjßh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj×ubhŒ to the ”…”�”}”(hj×h²hh³Nh´Nubj`)�”}”(hŒ``RCU_NEXT_READY_TAIL``”h]”hŒRCU_NEXT_READY_TAIL”…”�”}”(hjñh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj×ubhŒ to the ”…”�”}”(hj×h²hh³Nh´Nubj`)�”}”(hŒ``RCU_WAIT_TAIL``”h]”hŒ RCU_WAIT_TAIL”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj×ubhŒ to the ”…”�”}”hj×sbj`)�”}”(hŒ``RCU_DONE_TAIL``”h]”hŒ RCU_DONE_TAIL”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj×ubhŒ( list segments as grace periods advance.”…”�”}”(hj×h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MhjÜh²hubhÌ)�”}”(hX�The ``->gp_seq[]`` array records grace-period numbers corresponding to the list segments. This is what allows different CPUs to have different ideas as to which is the current grace period while still avoiding premature invocation of their callbacks. In particular, this allows CPUs that go idle for extended periods to determine which of their callbacks are ready to be invoked after reawakening.”h]”(hŒThe ”…”�”}”(hj-h²hh³Nh´Nubj`)�”}”(hŒ``->gp_seq[]``”h]”hŒ ->gp_seq[]”…”�”}”(hj5h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj-ubhX{ array records grace-period numbers corresponding to the list segments. This is what allows different CPUs to have different ideas as to which is the current grace period while still avoiding premature invocation of their callbacks. In particular, this allows CPUs that go idle for extended periods to determine which of their callbacks are ready to be invoked after reawakening.”…”�”}”(hj-h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MhjÜh²hubhÌ)�”}”(hŒÞThe ``->len`` counter contains the number of callbacks in ``->head``, and the ``->len_lazy`` contains the number of those callbacks that are known to only free memory, and whose invocation can therefore be safely deferred.”h]”(hŒThe ”…”�”}”(hjMh²hh³Nh´Nubj`)�”}”(hŒ ``->len``”h]”hŒ->len”…”�”}”(hjUh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjMubhŒ- counter contains the number of callbacks in ”…”�”}”(hjMh²hh³Nh´Nubj`)�”}”(hŒ ``->head``”h]”hŒ->head”…”�”}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjMubhŒ , and the ”…”�”}”(hjMh²hh³Nh´Nubj`)�”}”(hŒ``->len_lazy``”h]”hŒ ->len_lazy”…”�”}”(hjyh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjMubhŒ‚ contains the number of those callbacks that are known to only free memory, and whose invocation can therefore be safely deferred.”…”�”•$}”(hjMh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MhjÜh²hubhŒ important”“”)�”}”(hXIt is the ``->len`` field that determines whether or not there are callbacks associated with this ``rcu_segcblist`` structure, *not* the ``->head`` pointer. The reason for this is that all the ready-to-invoke callbacks (that is, those in the ``RCU_DONE_TAIL`` segment) are extracted all at once at callback-invocation time (``rcu_do_batch``), due to which ``->head`` may be set to NULL if there are no not-done callbacks remaining in the ``rcu_segcblist``. If callback invocation must be postponed, for example, because a high-priority process just woke up on this CPU, then the remaining callbacks are placed back on the ``RCU_DONE_TAIL`` segment and ``->head`` once again points to the start of the segment. In short, the head field can briefly be ``NULL`` even though the CPU has callbacks present the entire time. Therefore, it is not appropriate to test the ``->head`` pointer for ``NULL``.”h]”hÌ)�”}”(hXIt is the ``->len`` field that determines whether or not there are callbacks associated with this ``rcu_segcblist`` structure, *not* the ``->head`` pointer. The reason for this is that all the ready-to-invoke callbacks (that is, those in the ``RCU_DONE_TAIL`` segment) are extracted all at once at callback-invocation time (``rcu_do_batch``), due to which ``->head`` may be set to NULL if there are no not-done callbacks remaining in the ``rcu_segcblist``. If callback invocation must be postponed, for example, because a high-priority process just woke up on this CPU, then the remaining callbacks are placed back on the ``RCU_DONE_TAIL`` segment and ``->head`` once again points to the start of the segment. In short, the head field can briefly be ``NULL`` even though the CPU has callbacks present the entire time. Therefore, it is not appropriate to test the ``->head`` pointer for ``NULL``.”h]”(hŒ It is the ”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ ``->len``”h]”hŒ->len”…”�”}”(hjŸh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒO field that determines whether or not there are callbacks associated with this ”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ``rcu_segcblist``”h]”hŒ rcu_segcblist”…”�”}”(hj±h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒ structure, ”…”�”}”(hj—h²hh³Nh´Nubj)�”}”(hŒ*not*”h]”hŒnot”…”�”}”(hjÃh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj—ubhŒ the ”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ ``->head``”h]”hŒ->head”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒ_ pointer. The reason for this is that all the ready-to-invoke callbacks (that is, those in the ”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ``RCU_DONE_TAIL``”h]”hŒ RCU_DONE_TAIL”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒA segment) are extracted all at once at callback-invocation time (”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ``rcu_do_batch``”h]”hŒ rcu_do_batch”…”�”}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒ), due to which ”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ ``->head``”h]”hŒ->head”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒH may be set to NULL if there are no not-done callbacks remaining in the ”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ``rcu_segcblist``”h]”hŒ rcu_segcblist”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒ§. If callback invocation must be postponed, for example, because a high-priority process just woke up on this CPU, then the remaining callbacks are placed back on the ”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ``RCU_DONE_TAIL``”h]”hŒ RCU_DONE_TAIL”…”�”}”(hj/h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒ segment and ”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ ``->head``”h]”hŒ->head”…”�”}”(hjAh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒX once again points to the start of the segment. In short, the head field can briefly be ”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hjSh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒi even though the CPU has callbacks present the entire time. Therefore, it is not appropriate to test the ”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ ``->head``”h]”hŒ->head”…”�”}”(hjeh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒ pointer for ”…”�”}”(hj—h²hh³Nh´Nubj`)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hjwh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj—ubhŒ.”…”�”}”(hj—h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj“ubah}”(h]”h ]”h"]”h$]”h&]”uh1j‘hjÜh²hh³hÊh´NubhÌ)�”}”(hXÍIn contrast, the ``->len`` and ``->len_lazy`` counts are adjusted only after the corresponding callbacks have been invoked. This means that the ``->len`` count is zero only if the ``rcu_segcblist`` structure really is devoid of callbacks. Of course, off-CPU sampling of the ``->len`` count requires careful use of appropriate synchronization, for example, memory barriers. This synchronization can be a bit subtle, particularly in the case of ``rcu_barrier()``.”h]”(hŒIn contrast, the ”…”�”}”(hj•h²hh³Nh´Nubj`)�”}”(hŒ ``->len``”h]”hŒ->len”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj•ubhŒ and ”…”�”}”(hj•h²hh³Nh´Nubj`)�”}”(hŒ``->len_lazy``”h]”hŒ ->len_lazy”…”�”}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj•ubhŒc counts are adjusted only after the corresponding callbacks have been invoked. This means that the ”…”�”}”(hj•h²hh³Nh´Nubj`)�”}”(hŒ ``->len``”h]”hŒ->len”…”�”}”(hjÁh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj•ubhŒ count is zero only if the ”…”�”}”(hj•h²hh³Nh´Nubj`)�”}”(hŒ``rcu_segcblist``”h]”hŒ rcu_segcblist”…”�”}”(hjÓh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj•ubhŒM structure really is devoid of callbacks. Of course, off-CPU sampling of the ”…”�”}”(hj•h²hh³Nh´Nubj`)�”}”(hŒ ``->len``”h]”hŒ->len”…”�”}”(hjåh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj•ubhŒ  count requires careful use of appropriate synchronization, for example, memory barriers. This synchronization can be a bit subtle, particularly in the case of ”…”�”}”(hj•h²hh³Nh´Nubj`)�”}”(hŒ``rcu_barrier()``”h]”hŒ rcu_barrier()”…”�”}”(hj÷h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj•ubhŒ.”…”�”}”(hj•h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M$hjÜh²hubeh}”(h]”Œthe-rcu-segcblist-structure”ah ]”h"]”Œthe rcu_segcblist structure”ah$]”h&]”uh1hµhjh²hh³hÊh´M½ubh¶)�”}”(hhh]”(h»)�”}”(hŒThe ``rcu_data`` Structure”h]”(hŒThe ”…”�”}”(hj h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj" h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj ubhŒ Structure”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hºhj h²hh³hÊh´M-ubhÌ)�”}”(hXÚThe ``rcu_data`` 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 focus of quiescent-state detection and RCU callback queuing. It also tracks its relationship to the corresponding leaf ``rcu_node`` structure to allow more-efficient propagation of quiescent states up the ``rcu_node`` combining tree. Like the ``rcu_node`` structure, it provides a local copy of the grace-period information to allow for-free synchronized access to this information from the corresponding CPU. Finally, this structure records past dyntick-idle state for the corresponding CPU and also tracks statistics.”h]”(hŒThe ”…”�”}”(hj: h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjB h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj: ubhX: 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 focus of quiescent-state detection and RCU callback queuing. It also tracks its relationship to the corresponding leaf ”…”�”}”(hj: h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjT h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj: ubhŒJ structure to allow more-efficient propagation of quiescent states up the ”…”�”}”(hj: h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjf h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj: ubhŒ combining tree. Like the ”…”�”}”(hj: h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjx h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj: ubhX structure, it provides a local copy of the grace-period information to allow for-free synchronized access to this information from the corresponding CPU. Finally, this structure records past dyntick-idle state for the corresponding CPU and also tracks statistics.”…”�”}”(hj: h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M/hj h²hubhÌ)�”}”(hŒcThe ``rcu_data`` structure's fields are discussed, singly and in groups, in the following sections.”h]”(hŒThe ”…”�”}”(hj� h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj˜ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj� ubhŒU structure’s fields are discussed, singly and in groups, in the following sections.”…”�”}”(hj� h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M;hj h²hubh¶)�”}”(hhh]”(h»)�”}”(hŒ#Connection to Other Data Structures”h]”hŒ#Connection to Other Data Structures”…”�”}”(hj³ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj° h²hh³hÊh´M?ubhÌ)�”}”(hŒBThis portion of the ``rcu_data`` structure is declared as follows:”h]”(hŒThis portion of the ”…”�”}”(hjÁ h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjÉ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÁ ubhŒ" structure is declared as follows:”…”�”}”(hjÁ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MAhj° h²hubjî)�”}”(hŒY1 int cpu; 2 struct rcu_node *mynode; 3 unsigned long grpmask; 4 bool beenonline;”h]”hŒY1 int cpu; 2 struct rcu_node *mynode; 3 unsigned long grpmask; 4 bool beenonline;”…”�”}”hjá sbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´MEhj° h²hubhÌ)�”}”(hX*The ``->cpu`` field contains the number of the corresponding CPU and the ``->mynode`` field references the corresponding ``rcu_node`` structure. The ``->mynode`` is used to propagate quiescent states up the combining tree. These two fields are constant and therefore do not require synchronization.”h]”(hŒThe ”…”�”}”(hjï h²hh³Nh´Nubj`)�”}”(hŒ ``->cpu``”h]”hŒ->cpu”…”�”}”(hj÷ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjï ubhŒ< field contains the number of the corresponding CPU and the ”…”�”}”(hjï h²hh³Nh´Nubj`)�”}”(hŒ ``->mynode``”h]”hŒ->mynode”…”�”}”(hj !h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjï ubhŒ$ field references the corresponding ”…”�”}”(hjï h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjï ubhŒ structure. The ”…”�”}”(hjï h²hh³Nh´Nubj`)�”}”(hŒ ``->mynode``”h]”hŒ->mynode”…”�”}”(hj-!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjï ubhŒ‰ is used to propagate quiescent states up the combining tree. These two fields are constant and therefore do not require synchronization.”…”�”}”(hjï h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MJhj° h²hubhÌ)�”}”(hXgThe ``->grpmask`` field indicates the bit in the ``->mynode->qsmask`` corresponding to this ``rcu_data`` structure, and is also used when propagating quiescent states. The ``->beenonline`` flag is set whenever the corresponding CPU comes online, which means that the debugfs tracing need not dump out any ``rcu_data`` structure for which this flag is not set.”h]”(hŒThe ”…”�”}”(hjE!h²hh³Nh´Nubj`)�”}”(hŒ ``->grpmask``”h]”hŒ ->grpmask”…”�”}”(hjM!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjE!ubhŒ field indicates the bit in the ”…”�”}”(hjE!h²hh³Nh´Nubj`)�”}”(hŒ``->mynode->qsmask``”h]”hŒ->mynode->qsmask”…”�”}”(hj_!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjE!ubhŒ corresponding to this ”…”�”}”(hjE!h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjq!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjE!ubhŒD structure, and is also used when propagating quiescent states. The ”…”�”}”(hjE!h²hh³Nh´Nubj`)�”}”(hŒ``->beenonline``”h]”hŒ ->beenonline”…”�”}”(hjƒ!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjE!ubhŒu flag is set whenever the corresponding CPU comes online, which means that the debugfs tracing need not dump out any ”…”�”}”(hjE!h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj•!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjE!ubhŒ* structure for which this flag is not set.”…”�”}”(hjE!h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MPhj° h²hubeh}”(h]”Œ#connection-to-other-data-structures”ah ]”h"]”Œ#connection to other data structures”ah$]”h&]”uh1hµhj h²hh³hÊh´M?ubh¶)�”}”(hhh]”(h»)�”}”(hŒ)Quiescent-State and Grace-Period Tracking”h]”hŒ)Quiescent-State and Grace-Period Tracking”…”�”}”(hj¸!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjµ!h²hh³hÊh´MXubhÌ)�”}”(hŒBThis portion of the ``rcu_data`` structure is declared as follows:”h]”(hŒThis portion of the ”…”�”}”(hjÆ!h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjÎ!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÆ!ubhŒ" structure is declared as follows:”…”�”}”(hjÆ!h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MZhjµ!h²hubjî)�”}”(hŒw1 unsigned long gp_seq; 2 unsigned long gp_seq_needed; 3 bool cpu_no_qs; 4 bool core_needs_qs; 5 bool gpwrap;”h]”hŒw1 unsigned long gp_seq; 2 unsigned long gp_seq_needed; 3 bool cpu_no_qs; 4 bool core_needs_qs; 5 bool gpwrap;”…”�”}”hjæ!sbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´M^hjµ!h²hubhÌ)�”}”(hXuThe ``->gp_seq`` field is the counterpart of the field of the same name in the ``rcu_state`` and ``rcu_node`` structures. The ``->gp_seq_needed`` field is the counterpart of the field of the same name in the rcu_node structure. They may each lag up to one behind their ``rcu_node`` counterparts, but in ``CONFIG_NO_HZ_IDLE`` and ``CONFIG_NO_HZ_FULL`` kernels can lag arbitrarily far behind for CPUs in dyntick-idle mode (but these counters will catch up upon exit from dyntick-idle mode). If the lower two bits of a given ``rcu_data`` structure's ``->gp_seq`` are zero, then this ``rcu_data`` structure believes that RCU is idle.”h]”(hŒThe ”…”�”}”(hjô!h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hjü!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjô!ubhŒ? field is the counterpart of the field of the same name in the ”…”�”}”(hjô!h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjô!ubhŒ and ”…”�”}”(hjô!h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj "h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjô!ubhŒ structures. The ”…”�”}”(hjô!h²hh³Nh´Nubj`)�”}”(hŒ``->gp_seq_needed``”h]”hŒ->gp_seq_needed”…”�”}”(hj2"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjô!ubhŒ| field is the counterpart of the field of the same name in the rcu_node structure. They may each lag up to one behind their ”…”�”}”(hjô!h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjD"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjô!ubhŒ counterparts, but in ”…”�”}”(hjô!h²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_NO_HZ_IDLE``”h]”hŒCONFIG_NO_HZ_IDLE”…”�”}”(hjV"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjô!ubhŒ and ”…”�”}”(hjô!h²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_NO_HZ_FULL``”h]”hŒCONFIG_NO_HZ_FULL”…”�”}”(hjh"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjô!ubhŒ¬ kernels can lag arbitrarily far behind for CPUs in dyntick-idle mode (but these counters will catch up upon exit from dyntick-idle mode). If the lower two bits of a given ”…”�”}”(hjô!h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjz"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjô!ubhŒ structure’s ”…”�”}”(hjô!h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hjŒ"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjô!ubhŒ are zero, then this ”…”�”}”(hjô!h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjž"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjô!ubhŒ% structure believes that RCU is idle.”…”�”}”(hjô!h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mdhjµ!h²hubj’)�”}”(hhh]”j—)�”}”(hhh]”(jœ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”KGuh1j›hj¹"ubj¨)�”}”(hhh]”(j­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ**Quick Quiz**:”h]”(j»)�”}”(hŒ**Quick Quiz**”h]”hŒ Quick Quiz”…”�”}”(hjÓ"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjÏ"ubhŒ:”…”�”}”(hjÏ"h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MphjÌ"ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjÉ"ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÆ"ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ”All this replication of the grace period numbers can only cause massive confusion. Why not just keep a global sequence number and be done with it???”h]”hŒ”All this replication of the grace period numbers can only cause massive confusion. Why not just keep a global sequence number and be done with it???”…”�”}”(hjý"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mrhjú"ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj÷"ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÆ"ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ **Answer**:”h]”(j»)�”}”(hŒ **Answer**”h]”hŒAnswer”…”�”}”(hj!#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhj#ubhŒ:”…”�”}”(hj#h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mvhj#ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj#ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÆ"ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hX¨Because if there was only a single global sequence numbers, there would need to be a single global lock to allow safely accessing and updating it. And if we are not going to have a single global lock, we need to carefully manage the numbers on a per-node basis. Recall from the answer to a previous Quick Quiz that the consequences of applying a previously sampled quiescent state to the wrong grace period are quite severe.”h]”hX¨Because if there was only a single global sequence numbers, there would need to be a single global lock to allow safely accessing and updating it. And if we are not going to have a single global lock, we need to carefully manage the numbers on a per-node basis. Recall from the answer to a previous Quick Quiz that the consequences of applying a previously sampled quiescent state to the wrong grace period are quite severe.”…”�”}”(hjK#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MxhjH#ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjE#ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÆ"ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j§hj¹"ubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j–hj¶"ubah}”(h]”h ]”h"]”h$]”h&]”uh1j‘hjµ!h²hh³hÊh´NubhÌ)�”}”(hX½The ``->cpu_no_qs`` flag indicates that the CPU has not yet passed through a quiescent state, while the ``->core_needs_qs`` flag indicates that the RCU core needs a quiescent state from the corresponding CPU. The ``->gpwrap`` field indicates that the corresponding CPU has remained idle for so long that the ``gp_seq`` counter is in danger of overflow, which will cause the CPU to disregard the values of its counters on its next exit from idle.”h]”(hŒThe ”…”�”}”(hjx#h²hh³Nh´Nubj`)�”}”(hŒ``->cpu_no_qs``”h]”hŒ ->cpu_no_qs”…”�”}”(hj€#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjx#ubhŒU flag indicates that the CPU has not yet passed through a quiescent state, while the ”…”�”}”(hjx#h²hh³Nh´Nubj`)�”}”(hŒ``->core_needs_qs``”h]”hŒ->core_needs_qs”…”�”}”(hj’#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjx#ubhŒZ flag indicates that the RCU core needs a quiescent state from the corresponding CPU. The ”…”�”}”(hjx#h²hh³Nh´Nubj`)�”}”(hŒ ``->gpwrap``”h]”hŒ->gpwrap”…”�”}”(hj¤#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjx#ubhŒS field indicates that the corresponding CPU has remained idle for so long that the ”…”�”}”(hjx#h²hh³Nh´Nubj`)�”}”(hŒ ``gp_seq``”h]”hŒgp_seq”…”�”}”(hj¶#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjx#ubhŒ counter is in danger of overflow, which will cause the CPU to disregard the values of its counters on its next exit from idle.”…”�”}”(hjx#h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M�hjµ!h²hubeh}”(h]”Œ)quiescent-state-and-grace-period-tracking”ah ]”h"]”Œ)quiescent-state and grace-period tracking”ah$]”h&]”uh1hµhj h²hh³hÊh´MXubh¶)�”}”(hhh]”(h»)�”}”(hŒRCU Callback Handling”h]”hŒRCU Callback Handling”…”�”}”(hjÙ#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjÖ#h²hh³hÊh´MŠubhÌ)�”}”(hXtIn the absence of CPU-hotplug events, RCU callbacks are invoked by the same CPU that registered them. This is strictly a cache-locality optimization: callbacks can and do get invoked on CPUs other than the one that registered them. After all, if the CPU that registered a given callback has gone offline before the callback can be invoked, there really is no other choice.”h]”hXtIn the absence of CPU-hotplug events, RCU callbacks are invoked by the same CPU that registered them. This is strictly a cache-locality optimization: callbacks can and do get invoked on CPUs other than the one that registered them. After all, if the CPU that registered a given callback has gone offline before the callback can be invoked, there really is no other choice.”…”�”}”(hjç#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MŒhjÖ#h²hubhÌ)�”}”(hŒBThis portion of the ``rcu_data`` structure is declared as follows:”h]”(hŒThis portion of the ”…”�”}”(hjõ#h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjý#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjõ#ubhŒ" structure is declared as follows:”…”�”}”(hjõ#h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M“hjÖ#h²hubjî)�”}”(hŒé1 struct rcu_segcblist cblist; 2 long qlen_last_fqs_check; 3 unsigned long n_cbs_invoked; 4 unsigned long n_nocbs_invoked; 5 unsigned long n_cbs_orphaned; 6 unsigned long n_cbs_adopted; 7 unsigned long n_force_qs_snap; 8 long blimit;”h]”hŒé1 struct rcu_segcblist cblist; 2 long qlen_last_fqs_check; 3 unsigned long n_cbs_invoked; 4 unsigned long n_nocbs_invoked; 5 unsigned long n_cbs_orphaned; 6 unsigned long n_cbs_adopted; 7 unsigned long n_force_qs_snap; 8 long blimit;”…”�”}”hj$sbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´M—hjÖ#h²hubhÌ)�”}”(hXýThe ``->cblist`` structure is the segmented callback list described earlier. The CPU advances the callbacks in its ``rcu_data`` structure whenever it notices that another RCU grace period has completed. The CPU detects the completion of an RCU grace period by noticing that the value of its ``rcu_data`` structure's ``->gp_seq`` field differs from that of its leaf ``rcu_node`` structure. Recall that each ``rcu_node`` structure's ``->gp_seq`` field is updated at the beginnings and ends of each grace period.”h]”(hŒThe ”…”�”}”(hj#$h²hh³Nh´Nubj`)�”}”(hŒ ``->cblist``”h]”hŒ->cblist”…”�”}”(hj+$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj#$ubhŒc structure is the segmented callback list described earlier. The CPU advances the callbacks in its ”…”�”}”(hj#$h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj=$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj#$ubhŒ¤ structure whenever it notices that another RCU grace period has completed. The CPU detects the completion of an RCU grace period by noticing that the value of its ”…”�”}”(hj#$h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjO$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj#$ubhŒ structure’s ”…”�”}”(hj#$h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hja$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj#$ubhŒ% field differs from that of its leaf ”…”�”}”(hj#$h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjs$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj#$ubhŒ structure. Recall that each ”…”�”}”(hj#$h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj…$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj#$ubhŒ structure’s ”…”�”}”(hj#$h²hh³Nh´Nubj`)�”}”(hŒ ``->gp_seq``”h]”hŒ->gp_seq”…”�”}”(hj—$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj#$ubhŒB field is updated at the beginnings and ends of each grace period.”…”�”}”(hj#$h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M hjÖ#h²hubhÌ)�”}”(hŒ­The ``->qlen_last_fqs_check`` and ``->n_force_qs_snap`` coordinate the forcing of quiescent states from ``call_rcu()`` and friends when callback lists grow excessively long.”h]”(hŒThe ”…”�”}”(hj¯$h²hh³Nh´Nubj`)�”}”(hŒ``->qlen_last_fqs_check``”h]”hŒ->qlen_last_fqs_check”…”�”}”(hj·$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¯$ubhŒ and ”…”�”}”(hj¯$h²hh³Nh´Nubj`)�”}”(hŒ``->n_force_qs_snap``”h]”hŒ->n_force_qs_snap”…”�”}”(hjÉ$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¯$ubhŒ1 coordinate the forcing of quiescent states from ”…”�”}”(hj¯$h²hh³Nh´Nubj`)�”}”(hŒ``call_rcu()``”h]”hŒ call_rcu()”…”�”}”(hjÛ$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¯$ubhŒ7 and friends when callback lists grow excessively long.”…”�”}”(hj¯$h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M©hjÖ#h²hubhÌ)�”}”(hX9The ``->n_cbs_invoked``, ``->n_cbs_orphaned``, and ``->n_cbs_adopted`` fields count the number of callbacks invoked, sent to other CPUs when this CPU goes offline, and received from other CPUs when those other CPUs go offline. The ``->n_nocbs_invoked`` is used when the CPU's callbacks are offloaded to a kthread.”h]”(hŒThe ”…”�”}”(hjó$h²hh³Nh´Nubj`)�”}”(hŒ``->n_cbs_invoked``”h]”hŒ->n_cbs_invoked”…”�”}”(hjû$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjó$ubhŒ, ”…”�”}”(hjó$h²hh³Nh´Nubj`)�”}”(hŒ``->n_cbs_orphaned``”h]”hŒ->n_cbs_orphaned”…”�”}”(hj %h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjó$ubhŒ, and ”…”�”}”(hjó$h²hh³Nh´Nubj`)�”}”(hŒ``->n_cbs_adopted``”h]”hŒ->n_cbs_adopted”…”�”}”(hj%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjó$ubhŒ¡ fields count the number of callbacks invoked, sent to other CPUs when this CPU goes offline, and received from other CPUs when those other CPUs go offline. The ”…”�”}”(hjó$h²hh³Nh´Nubj`)�”}”(hŒ``->n_nocbs_invoked``”h]”hŒ->n_nocbs_invoked”…”�”}”(hj1%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjó$ubhŒ? is used when the CPU’s callbacks are offloaded to a kthread.”…”�”}”(hjó$h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M­hjÖ#h²hubhÌ)�”}”(hŒmFinally, the ``->blimit`` counter is the maximum number of RCU callbacks that may be invoked at a given time.”h]”(hŒ Finally, the ”…”�”}”(hjI%h²hh³Nh´Nubj`)�”}”(hŒ ``->blimit``”h]”hŒ->blimit”…”�”}”(hjQ%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjI%ubhŒT counter is the maximum number of RCU callbacks that may be invoked at a given time.”…”�”}”(hjI%h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M³hjÖ#h²hubeh}”(h]”Œrcu-callback-handling”ah ]”h"]”Œrcu callback handling”ah$]”h&]”uh1hµhj h²hh³hÊh´MŠubh¶)�”}”(hhh]”(h»)�”}”(hŒDyntick-Idle Handling”h]”hŒDyntick-Idle Handling”…”�”}”(hjt%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjq%h²hh³hÊh´M·ubhÌ)�”}”(hŒBThis portion of the ``rcu_data`` structure is declared as follows:”h]”(hŒThis portion of the ”…”�”}”(hj‚%h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjŠ%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj‚%ubhŒ" structure is declared as follows:”…”�”}”(hj‚%h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¹hjq%h²hubjî)�”}”(hŒ61 int watching_snap; 2 unsigned long dynticks_fqs;”h]”hŒ61 int watching_snap; 2 unsigned long dynticks_fqs;”…”�”}”hj¢%sbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´M½hjq%h²hubhÌ)�”}”(hX_The ``->watching_snap`` field is used to take a snapshot of the corresponding CPU's dyntick-idle state when forcing quiescent states, and is therefore accessed from other CPUs. Finally, the ``->dynticks_fqs`` field is used to count the number of times this CPU is determined to be in dyntick-idle state, and is used for tracing and debugging purposes.”h]”(hŒThe ”…”�”}”(hj°%h²hh³Nh´Nubj`)�”}”(hŒ``->watching_snap``”h]”hŒ->watching_snap”…”�”}”(hj¸%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj°%ubhŒ© field is used to take a snapshot of the corresponding CPU’s dyntick-idle state when forcing quiescent states, and is therefore accessed from other CPUs. Finally, the ”…”�”}”(hj°%h²hh³Nh´Nubj`)�”}”(hŒ``->dynticks_fqs``”h]”hŒ->dynticks_fqs”…”�”}”(hjÊ%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj°%ubhŒ� field is used to count the number of times this CPU is determined to be in dyntick-idle state, and is used for tracing and debugging purposes.”…”�”}”(hj°%h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÀhjq%h²hubhÌ)�”}”(hŒ>This portion of the rcu_data structure is declared as follows:”h]”hŒ>This portion of the rcu_data structure is declared as follows:”…”�”}”(hjâ%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÇhjq%h²hubjî)�”}”(hŒr1 long nesting; 2 long nmi_nesting; 3 atomic_t dynticks; 4 bool rcu_need_heavy_qs; 5 bool rcu_urgent_qs;”h]”hŒr1 long nesting; 2 long nmi_nesting; 3 atomic_t dynticks; 4 bool rcu_need_heavy_qs; 5 bool rcu_urgent_qs;”…”�”}”hjð%sbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´MËhjq%h²hubhÌ)�”}”(hŒÐThese fields in the rcu_data structure maintain the per-CPU dyntick-idle state for the corresponding CPU. The fields may be accessed only from the corresponding CPU (and from tracing) unless otherwise stated.”h]”hŒÐThese fields in the rcu_data structure maintain the per-CPU dyntick-idle state for the corresponding CPU. The fields may be accessed only from the corresponding CPU (and from tracing) unless otherwise stated.”…”�”}”(hjþ%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÑhjq%h²hubhÌ)�”}”(hX¤The ``->nesting`` field counts the nesting depth of process execution, so that in normal circumstances this counter has value zero or one. NMIs, irqs, and tracers are counted by the ``->nmi_nesting`` field. Because NMIs cannot be masked, changes to this variable have to be undertaken carefully using an algorithm provided by Andy Lutomirski. The initial transition from idle adds one, and nested transitions add two, so that a nesting level of five is represented by a ``->nmi_nesting`` value of nine. This counter can therefore be thought of as counting the number of reasons why this CPU cannot be permitted to enter dyntick-idle mode, aside from process-level transitions.”h]”(hŒThe ”…”�”}”(hj &h²hh³Nh´Nubj`)�”}”(hŒ ``->nesting``”h]”hŒ ->nesting”…”�”}”(hj&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj &ubhŒ¥ field counts the nesting depth of process execution, so that in normal circumstances this counter has value zero or one. NMIs, irqs, and tracers are counted by the ”…”�”}”(hj &h²hh³Nh´Nubj`)�”}”(hŒ``->nmi_nesting``”h]”hŒ ->nmi_nesting”…”�”}”(hj&&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj &ubhX field. Because NMIs cannot be masked, changes to this variable have to be undertaken carefully using an algorithm provided by Andy Lutomirski. The initial transition from idle adds one, and nested transitions add two, so that a nesting level of five is represented by a ”…”�”}”(hj &h²hh³Nh´Nubj`)�”}”(hŒ``->nmi_nesting``”h]”hŒ ->nmi_nesting”…”�”}”(hj8&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj &ubhŒ½ value of nine. This counter can therefore be thought of as counting the number of reasons why this CPU cannot be permitted to enter dyntick-idle mode, aside from process-level transitions.”…”�”}”(hj &h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÕhjq%h²hubhÌ)�”}”(hX‚However, it turns out that when running in non-idle kernel context, the Linux kernel is fully capable of entering interrupt handlers that never exit and perhaps also vice versa. Therefore, whenever the ``->nesting`` field is incremented up from zero, the ``->nmi_nesting`` field is set to a large positive number, and whenever the ``->nesting`` field is decremented down to zero, the ``->nmi_nesting`` field is set to zero. Assuming that the number of misnested interrupts is not sufficient to overflow the counter, this approach corrects the ``->nmi_nesting`` field every time the corresponding CPU enters the idle loop from process context.”h]”(hŒÊHowever, it turns out that when running in non-idle kernel context, the Linux kernel is fully capable of entering interrupt handlers that never exit and perhaps also vice versa. Therefore, whenever the ”…”�”}”(hjP&h²hh³Nh´Nubj`)�”}”(hŒ ``->nesting``”h]”hŒ ->nesting”…”�”}”(hjX&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjP&ubhŒ( field is incremented up from zero, the ”…”�”}”(hjP&h²hh³Nh´Nubj`)�”}”(hŒ``->nmi_nesting``”h]”hŒ ->nmi_nesting”…”�”}”(hjj&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjP&ubhŒ; field is set to a large positive number, and whenever the ”…”�”}”(hjP&h²hh³Nh´Nubj`)�”}”(hŒ ``->nesting``”h]”hŒ ->nesting”…”�”}”(hj|&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjP&ubhŒ( field is decremented down to zero, the ”…”�”}”(hjP&h²hh³Nh´Nubj`)�”}”(hŒ``->nmi_nesting``”h]”hŒ ->nmi_nesting”…”�”}”(hjŽ&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjP&ubhŒŽ field is set to zero. Assuming that the number of misnested interrupts is not sufficient to overflow the counter, this approach corrects the ”…”�”}”(hjP&h²hh³Nh´Nubj`)�”}”(hŒ``->nmi_nesting``”h]”hŒ ->nmi_nesting”…”�”}”(hj &h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjP&ubhŒR field every time the corresponding CPU enters the idle loop from process context.”…”�”}”(hjP&h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Máhjq%h²hubhÌ)�”}”(hXfThe ``->dynticks`` field counts the corresponding CPU's transitions to and from either dyntick-idle or user mode, so that this counter has an even value when the CPU is in dyntick-idle mode or user mode and an odd value otherwise. The transitions to/from user mode need to be counted for user mode adaptive-ticks support (see Documentation/timers/no_hz.rst).”h]”(hŒThe ”…”�”}”(hj¸&h²hh³Nh´Nubj`)�”}”(hŒ``->dynticks``”h]”hŒ ->dynticks”…”�”}”(hjÀ&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¸&ubhXV field counts the corresponding CPU’s transitions to and from either dyntick-idle or user mode, so that this counter has an even value when the CPU is in dyntick-idle mode or user mode and an odd value otherwise. The transitions to/from user mode need to be counted for user mode adaptive-ticks support (see Documentation/timers/no_hz.rst).”…”�”}”(hj¸&h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Míhjq%h²hubhÌ)�”}”(hXkThe ``->rcu_need_heavy_qs`` field is used to record the fact that the RCU core code would really like to see a quiescent state from the corresponding CPU, so much so that it is willing to call for heavy-weight dyntick-counter operations. This flag is checked by RCU's context-switch and ``cond_resched()`` code, which provide a momentary idle sojourn in response.”h]”(hŒThe ”…”�”}”(hjØ&h²hh³Nh´Nubj`)�”}”(hŒ``->rcu_need_heavy_qs``”h]”hŒ->rcu_need_heavy_qs”…”�”}”(hjà&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjØ&ubhX field is used to record the fact that the RCU core code would really like to see a quiescent state from the corresponding CPU, so much so that it is willing to call for heavy-weight dyntick-counter operations. This flag is checked by RCU’s context-switch and ”…”�”}”(hjØ&h²hh³Nh´Nubj`)�”}”(hŒ``cond_resched()``”h]”hŒcond_resched()”…”�”}”(hjò&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjØ&ubhŒ: code, which provide a momentary idle sojourn in response.”…”�”}”(hjØ&h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Móhjq%h²hubhÌ)�”}”(hXbFinally, the ``->rcu_urgent_qs`` field is used to record the fact that the RCU core code would really like to see a quiescent state from the corresponding CPU, with the various other fields indicating just how badly RCU wants this quiescent state. This flag is checked by RCU's context-switch path (``rcu_note_context_switch``) and the cond_resched code.”h]”(hŒ Finally, the ”…”�”}”(hj 'h²hh³Nh´Nubj`)�”}”(hŒ``->rcu_urgent_qs``”h]”hŒ->rcu_urgent_qs”…”�”}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj 'ubhX  field is used to record the fact that the RCU core code would really like to see a quiescent state from the corresponding CPU, with the various other fields indicating just how badly RCU wants this quiescent state. This flag is checked by RCU’s context-switch path (”…”�”}”(hj 'h²hh³Nh´Nubj`)�”}”(hŒ``rcu_note_context_switch``”h]”hŒrcu_note_context_switch”…”�”}”(hj$'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj 'ubhŒ) and the cond_resched code.”…”�”}”(hj 'h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Múhjq%h²hubj’)�”}”(hhh]”j—)�”}”(hhh]”(jœ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”KGuh1j›hj?'ubj¨)�”}”(hhh]”(j­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ**Quick Quiz**:”h]”(j»)�”}”(hŒ**Quick Quiz**”h]”hŒ Quick Quiz”…”�”}”(hjY'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjU'ubhŒ:”…”�”}”(hjU'h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MhjR'ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjO'ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjL'ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ¬Why not simply combine the ``->nesting`` and ``->nmi_nesting`` counters into a single counter that just counts the number of reasons that the corresponding CPU is non-idle?”h]”(hŒWhy not simply combine the ”…”�”}”(hjƒ'h²hh³Nh´Nubj`)�”}”(hŒ ``->nesting``”h]”hŒ ->nesting”…”�”}”(hj‹'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjƒ'ubhŒ and ”…”�”}”(hjƒ'h²hh³Nh´Nubj`)�”}”(hŒ``->nmi_nesting``”h]”hŒ ->nmi_nesting”…”�”}”(hj�'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjƒ'ubhŒn counters into a single counter that just counts the number of reasons that the corresponding CPU is non-idle?”…”�”}”(hjƒ'h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj€'ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj}'ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjL'ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ **Answer**:”h]”(j»)�”}”(hŒ **Answer**”h]”hŒAnswer”…”�”}”(hjË'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjÇ'ubhŒ:”…”�”}”(hjÇ'h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MhjÄ'ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjÁ'ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjL'ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ‘Because this would fail in the presence of interrupts whose handlers never return and of handlers that manage to return from a made-up interrupt.”h]”hŒ‘Because this would fail in the presence of interrupts whose handlers never return and of handlers that manage to return from a made-up interrupt.”…”�”}”(hjõ'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M hjò'ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjï'ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjL'ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j§hj?'ubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j–hj<'ubah}”(h]”h ]”h"]”h$]”h&]”uh1j‘hjq%h²hh³hÊh´NubhÌ)�”}”(hŒ\Additional fields are present for some special-purpose builds, and are discussed separately.”h]”hŒ\Additional fields are present for some special-purpose builds, and are discussed separately.”…”�”}”(hj"(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhjq%h²hubeh}”(h]”Œdyntick-idle-handling”ah ]”h"]”Œdyntick-idle handling”ah$]”h&]”uh1hµhj h²hh³hÊh´M·ubeh}”(h]”Œthe-rcu-data-structure”ah ]”h"]”Œthe rcu_data structure”ah$]”h&]”uh1hµhjh²hh³hÊh´M-ubh¶)�”}”(hhh]”(h»)�”}”(hŒThe ``rcu_head`` Structure”h]”(hŒThe ”…”�”}”(hjC(h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_head``”h]”hŒrcu_head”…”�”}”(hjK(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjC(ubhŒ Structure”…”�”}”(hjC(h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hºhj@(h²hh³hÊh´MubhÌ)�”}”(hX5Each ``rcu_head`` structure represents an RCU callback. These structures are normally embedded within RCU-protected data structures whose algorithms use asynchronous grace periods. In contrast, when using algorithms that block waiting for RCU grace periods, RCU users need not provide ``rcu_head`` structures.”h]”(hŒEach ”…”�”}”(hjc(h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_head``”h]”hŒrcu_head”…”�”}”(hjk(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjc(ubhX  structure represents an RCU callback. These structures are normally embedded within RCU-protected data structures whose algorithms use asynchronous grace periods. In contrast, when using algorithms that block waiting for RCU grace periods, RCU users need not provide ”…”�”}”(hjc(h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_head``”h]”hŒrcu_head”…”�”}”(hj}(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjc(ubhŒ structures.”…”�”}”(hjc(h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj@(h²hubhÌ)�”}”(hŒ1The ``rcu_head`` structure has fields as follows:”h]”(hŒThe ”…”�”}”(hj•(h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_head``”h]”hŒrcu_head”…”�”}”(hj�(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj•(ubhŒ! structure has fields as follows:”…”�”}”(hj•(h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj@(h²hubjî)�”}”(hŒC1 struct rcu_head *next; 2 void (*func)(struct rcu_head *head);”h]”hŒC1 struct rcu_head *next; 2 void (*func)(struct rcu_head *head);”…”�”}”hjµ(sbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´Mhj@(h²hubhÌ)�”}”(hXÁThe ``->next`` field is used to link the ``rcu_head`` structures together in the lists within the ``rcu_data`` structures. The ``->func`` field is a pointer to the function to be called when the callback is ready to be invoked, and this function is passed a pointer to the ``rcu_head`` structure. However, ``kfree_rcu()`` uses the ``->func`` field to record the offset of the ``rcu_head`` structure within the enclosing RCU-protected data structure.”h]”(hŒThe ”…”�”}”(hjÃ(h²hh³Nh´Nubj`)�”}”(hŒ ``->next``”h]”hŒ->next”…”�”}”(hjË(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÃ(ubhŒ field is used to link the ”…”�”}”(hjÃ(h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_head``”h]”hŒrcu_head”…”�”}”(hjÝ(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÃ(ubhŒ- structures together in the lists within the ”…”�”}”(hjÃ(h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjï(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÃ(ubhŒ structures. The ”…”�”}”(hjÃ(h²hh³Nh´Nubj`)�”}”(hŒ ``->func``”h]”hŒ->func”…”�”}”(hj)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÃ(ubhŒˆ field is a pointer to the function to be called when the callback is ready to be invoked, and this function is passed a pointer to the ”…”�”}”(hjÃ(h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_head``”h]”hŒrcu_head”…”�”}”(hj)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÃ(ubhŒ structure. However, ”…”�”}”(hjÃ(h²hh³Nh´Nubj`)�”}”(hŒ``kfree_rcu()``”h]”hŒ kfree_rcu()”…”�”}”(hj%)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÃ(ubhŒ uses the ”…”�”}”(hjÃ(h²hh³Nh´Nubj`)�”}”(hŒ ``->func``”h]”hŒ->func”…”�”}”(hj7)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÃ(ubhŒ# field to record the offset of the ”…”�”}”(hjÃ(h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_head``”h]”hŒrcu_head”…”�”}”(hjI)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÃ(ubhŒ= structure within the enclosing RCU-protected data structure.”…”�”}”(hjÃ(h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M"hj@(h²hubhÌ)�”}”(hŒ{Both of these fields are used internally by RCU. From the viewpoint of RCU users, this structure is an opaque “cookieâ€�.”h]”hŒ{Both of these fields are used internally by RCU. From the viewpoint of RCU users, this structure is an opaque “cookieâ€�.”…”�”}”(hja)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M*hj@(h²hubj’)�”}”(hhh]”j—)�”}”(hhh]”(jœ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”KGuh1j›hjr)ubj¨)�”}”(hhh]”(j­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ**Quick Quiz**:”h]”(j»)�”}”(hŒ**Quick Quiz**”h]”hŒ Quick Quiz”…”�”}”(hjŒ)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjˆ)ubhŒ:”…”�”}”(hjˆ)h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M.hj…)ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj‚)ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj)ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒÁGiven that the callback function ``->func`` is passed a pointer to the ``rcu_head`` structure, how is that function supposed to find the beginning of the enclosing RCU-protected data structure?”h]”(hŒ!Given that the callback function ”…”�”}”(hj¶)h²hh³Nh´Nubj`)�”}”(hŒ ``->func``”h]”hŒ->func”…”�”}”(hj¾)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¶)ubhŒ is passed a pointer to the ”…”�”}”(hj¶)h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_head``”h]”hŒrcu_head”…”�”}”(hjÐ)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¶)ubhŒn structure, how is that function supposed to find the beginning of the enclosing RCU-protected data structure?”…”�”}”(hj¶)h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M0hj³)ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj°)ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj)ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ **Answer**:”h]”(j»)�”}”(hŒ **Answer**”h]”hŒAnswer”…”�”}”(hjþ)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjú)ubhŒ:”…”�”}”(hjú)h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M4hj÷)ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjô)ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj)ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hX8In actual practice, there is a separate callback function per type of RCU-protected data structure. The callback function can therefore use the ``container_of()`` macro in the Linux kernel (or other pointer-manipulation facilities in other software environments) to find the beginning of the enclosing structure.”h]”(hŒ�In actual practice, there is a separate callback function per type of RCU-protected data structure. The callback function can therefore use the ”…”�”}”(hj(*h²hh³Nh´Nubj`)�”}”(hŒ``container_of()``”h]”hŒcontainer_of()”…”�”}”(hj0*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj(*ubhŒ– macro in the Linux kernel (or other pointer-manipulation facilities in other software environments) to find the beginning of the enclosing structure.”…”�”}”(hj(*h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M6hj%*ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj"*ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hj)ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j§hjr)ubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j–hjo)ubah}”(h]”h ]”h"]”h$]”h&]”uh1j‘hj@(h²hh³hÊh´Nubeh}”(h]”Œthe-rcu-head-structure”ah ]”h"]”Œthe rcu_head structure”ah$]”h&]”uh1hµhjh²hh³hÊh´Mubh¶)�”}”(hhh]”(h»)�”}”(hŒ4RCU-Specific Fields in the ``task_struct`` Structure”h]”(hŒRCU-Specific Fields in the ”…”�”}”(hjr*h²hh³Nh´Nubj`)�”}”(hŒ``task_struct``”h]”hŒ task_struct”…”�”}”(hjz*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjr*ubhŒ Structure”…”�”}”(hjr*h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hºhjo*h²hh³hÊh´M>ubhÌ)�”}”(hŒgThe ``CONFIG_PREEMPT_RCU`` implementation uses some additional fields in the ``task_struct`` structure:”h]”(hŒThe ”…”�”}”(hj’*h²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_PREEMPT_RCU``”h]”hŒCONFIG_PREEMPT_RCU”…”�”}”(hjš*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj’*ubhŒ3 implementation uses some additional fields in the ”…”�”}”(hj’*h²hh³Nh´Nubj`)�”}”(hŒ``task_struct``”h]”hŒ task_struct”…”�”}”(hj¬*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj’*ubhŒ structure:”…”�”}”(hj’*h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M@hjo*h²hubjî)�”}”(hX³ 1 #ifdef CONFIG_PREEMPT_RCU 2 int rcu_read_lock_nesting; 3 union rcu_special rcu_read_unlock_special; 4 struct list_head rcu_node_entry; 5 struct rcu_node *rcu_blocked_node; 6 #endif /* #ifdef CONFIG_PREEMPT_RCU */ 7 #ifdef CONFIG_TASKS_RCU 8 unsigned long rcu_tasks_nvcsw; 9 bool rcu_tasks_holdout; 10 struct list_head rcu_tasks_holdout_list; 11 int rcu_tasks_idle_cpu; 12 #endif /* #ifdef CONFIG_TASKS_RCU */”h]”hX³ 1 #ifdef CONFIG_PREEMPT_RCU 2 int rcu_read_lock_nesting; 3 union rcu_special rcu_read_unlock_special; 4 struct list_head rcu_node_entry; 5 struct rcu_node *rcu_blocked_node; 6 #endif /* #ifdef CONFIG_PREEMPT_RCU */ 7 #ifdef CONFIG_TASKS_RCU 8 unsigned long rcu_tasks_nvcsw; 9 bool rcu_tasks_holdout; 10 struct list_head rcu_tasks_holdout_list; 11 int rcu_tasks_idle_cpu; 12 #endif /* #ifdef CONFIG_TASKS_RCU */”…”�”}”hjÄ*sbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´MEhjo*h²hubhÌ)�”}”(hX@The ``->rcu_read_lock_nesting`` field records the nesting level for RCU read-side critical sections, and the ``->rcu_read_unlock_special`` field is a bitmask that records special conditions that require ``rcu_read_unlock()`` to do additional work. The ``->rcu_node_entry`` field is used to form lists of tasks that have blocked within preemptible-RCU read-side critical sections and the ``->rcu_blocked_node`` field references the ``rcu_node`` structure whose list this task is a member of, or ``NULL`` if it is not blocked within a preemptible-RCU read-side critical section.”h]”(hŒThe ”…”�”}”(hjÒ*h²hh³Nh´Nubj`)�”}”(hŒ``->rcu_read_lock_nesting``”h]”hŒ->rcu_read_lock_nesting”…”�”}”(hjÚ*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒ*ubhŒN field records the nesting level for RCU read-side critical sections, and the ”…”�”}”(hjÒ*h²hh³Nh´Nubj`)�”}”(hŒ``->rcu_read_unlock_special``”h]”hŒ->rcu_read_unlock_special”…”�”}”(hjì*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒ*ubhŒA field is a bitmask that records special conditions that require ”…”�”}”(hjÒ*h²hh³Nh´Nubj`)�”}”(hŒ``rcu_read_unlock()``”h]”hŒrcu_read_unlock()”…”�”}”(hjþ*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒ*ubhŒ to do additional work. The ”…”�”}”(hjÒ*h²hh³Nh´Nubj`)�”}”(hŒ``->rcu_node_entry``”h]”hŒ->rcu_node_entry”…”�”}”(hj+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒ*ubhŒs field is used to form lists of tasks that have blocked within preemptible-RCU read-side critical sections and the ”…”�”}”(hjÒ*h²hh³Nh´Nubj`)�”}”(hŒ``->rcu_blocked_node``”h]”hŒ->rcu_blocked_node”…”�”}”(hj"+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒ*ubhŒ field references the ”…”�”}”(hjÒ*h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj4+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒ*ubhŒ3 structure whose list this task is a member of, or ”…”�”}”(hjÒ*h²hh³Nh´Nubj`)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hjF+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÒ*ubhŒJ if it is not blocked within a preemptible-RCU read-side critical section.”…”�”}”(hjÒ*h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MRhjo*h²hubhÌ)�”}”(hXõThe ``->rcu_tasks_nvcsw`` field tracks the number of voluntary context switches that this task had undergone at the beginning of the current tasks-RCU grace period, ``->rcu_tasks_holdout`` is set if the current tasks-RCU grace period is waiting on this task, ``->rcu_tasks_holdout_list`` is a list element enqueuing this task on the holdout list, and ``->rcu_tasks_idle_cpu`` tracks which CPU this idle task is running, but only if the task is currently running, that is, if the CPU is currently idle.”h]”(hŒThe ”…”�”}”(hj^+h²hh³Nh´Nubj`)�”}”(hŒ``->rcu_tasks_nvcsw``”h]”hŒ->rcu_tasks_nvcsw”…”�”}”(hjf+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj^+ubhŒŒ field tracks the number of voluntary context switches that this task had undergone at the beginning of the current tasks-RCU grace period, ”…”�”}”(hj^+h²hh³Nh´Nubj`)�”}”(hŒ``->rcu_tasks_holdout``”h]”hŒ->rcu_tasks_holdout”…”�”}”(hjx+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj^+ubhŒG is set if the current tasks-RCU grace period is waiting on this task, ”…”�”}”(hj^+h²hh³Nh´Nubj`)�”}”(hŒ``->rcu_tasks_holdout_list``”h]”hŒ->rcu_tasks_holdout_list”…”�”}”(hjŠ+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj^+ubhŒ@ is a list element enqueuing this task on the holdout list, and ”…”�”}”(hj^+h²hh³Nh´Nubj`)�”}”(hŒ``->rcu_tasks_idle_cpu``”h]”hŒ->rcu_tasks_idle_cpu”…”�”}”(hjœ+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj^+ubhŒ~ tracks which CPU this idle task is running, but only if the task is currently running, that is, if the CPU is currently idle.”…”�”}”(hj^+h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M\hjo*h²hubeh}”(h]”Œ0rcu-specific-fields-in-the-task-struct-structure”ah ]”h"]”Œ0rcu-specific fields in the task_struct structure”ah$]”h&]”uh1hµhjh²hh³hÊh´M>ubh¶)�”}”(hhh]”(h»)�”}”(hŒAccessor Functions”h]”hŒAccessor Functions”…”�”}”(hj¿+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj¼+h²hh³hÊh´MfubhÌ)�”}”(hŒ�The following listing shows the ``rcu_get_root()``, ``rcu_for_each_node_breadth_first`` and ``rcu_for_each_leaf_node()`` function and macros:”h]”(hŒ The following listing shows the ”…”�”}”(hjÍ+h²hh³Nh´Nubj`)�”}”(hŒ``rcu_get_root()``”h]”hŒrcu_get_root()”…”�”}”(hjÕ+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÍ+ubhŒ, ”…”�”}”(hjÍ+h²hh³Nh´Nubj`)�”}”(hŒ#``rcu_for_each_node_breadth_first``”h]”hŒrcu_for_each_node_breadth_first”…”�”}”(hjç+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÍ+ubhŒ and ”…”�”}”(hjÍ+h²hh³Nh´Nubj`)�”}”(hŒ``rcu_for_each_leaf_node()``”h]”hŒrcu_for_each_leaf_node()”…”�”}”(hjù+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hjÍ+ubhŒ function and macros:”…”�”}”(hjÍ+h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhhj¼+h²hubjî)�”}”(hX— 1 static struct rcu_node *rcu_get_root(struct rcu_state *rsp) 2 { 3 return &rsp->node[0]; 4 } 5 6 #define rcu_for_each_node_breadth_first(rsp, rnp) \ 7 for ((rnp) = &(rsp)->node[0]; \ 8 (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) 9 10 #define rcu_for_each_leaf_node(rsp, rnp) \ 11 for ((rnp) = (rsp)->level[NUM_RCU_LVLS - 1]; \ 12 (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++)”h]”hX— 1 static struct rcu_node *rcu_get_root(struct rcu_state *rsp) 2 { 3 return &rsp->node[0]; 4 } 5 6 #define rcu_for_each_node_breadth_first(rsp, rnp) \ 7 for ((rnp) = &(rsp)->node[0]; \ 8 (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) 9 10 #define rcu_for_each_leaf_node(rsp, rnp) \ 11 for ((rnp) = (rsp)->level[NUM_RCU_LVLS - 1]; \ 12 (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++)”…”�”}”hj,sbah}”(h]”h ]”h"]”h$]”h&]”jýjþuh1jíh³hÊh´Mnhj¼+h²hubhÌ)�”}”(hŒ­The ``rcu_get_root()`` simply returns a pointer to the first element of the specified ``rcu_state`` structure's ``->node[]`` array, which is the root ``rcu_node`` structure.”h]”(hŒThe ”…”�”}”(hj,h²hh³Nh´Nubj`)�”}”(hŒ``rcu_get_root()``”h]”hŒrcu_get_root()”…”�”}”(hj',h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj,ubhŒ@ simply returns a pointer to the first element of the specified ”…”�”}”(hj,h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj9,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj,ubhŒ structure’s ”…”�”}”(hj,h²hh³Nh´Nubj`)�”}”(hŒ ``->node[]``”h]”hŒ->node[]”…”�”}”(hjK,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj,ubhŒ array, which is the root ”…”�”}”(hj,h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj],h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj,ubhŒ structure.”…”�”}”(hj,h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M{hj¼+h²hubhÌ)�”}”(hX•As noted earlier, the ``rcu_for_each_node_breadth_first()`` macro takes advantage of the layout of the ``rcu_node`` structures in the ``rcu_state`` structure's ``->node[]`` array, performing a breadth-first traversal by simply traversing the array in order. Similarly, the ``rcu_for_each_leaf_node()`` macro traverses only the last part of the array, thus traversing only the leaf ``rcu_node`` structures.”h]”(hŒAs noted earlier, the ”…”�”}”(hju,h²hh³Nh´Nubj`)�”}”(hŒ%``rcu_for_each_node_breadth_first()``”h]”hŒ!rcu_for_each_node_breadth_first()”…”�”}”(hj},h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hju,ubhŒ, macro takes advantage of the layout of the ”…”�”}”(hju,h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj�,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hju,ubhŒ structures in the ”…”�”}”(hju,h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj¡,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hju,ubhŒ structure’s ”…”�”}”(hju,h²hh³Nh´Nubj`)�”}”(hŒ ``->node[]``”h]”hŒ->node[]”…”�”}”(hj³,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hju,ubhŒe array, performing a breadth-first traversal by simply traversing the array in order. Similarly, the ”…”�”}”(hju,h²hh³Nh´Nubj`)�”}”(hŒ``rcu_for_each_leaf_node()``”h]”hŒrcu_for_each_leaf_node()”…”�”}”(hjÅ,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hju,ubhŒP macro traverses only the last part of the array, thus traversing only the leaf ”…”�”}”(hju,h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj×,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hju,ubhŒ structures.”…”�”}”(hju,h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj¼+h²hubj’)�”}”(hhh]”j—)�”}”(hhh]”(jœ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”KGuh1j›hjò,ubj¨)�”}”(hhh]”(j­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ**Quick Quiz**:”h]”(j»)�”}”(hŒ**Quick Quiz**”h]”hŒ Quick Quiz”…”�”}”(hj -h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhj-ubhŒ:”…”�”}”(hj-h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M‡hj-ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj-ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÿ,ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ_What does ``rcu_for_each_leaf_node()`` do if the ``rcu_node`` tree contains only a single node?”h]”(hŒ What does ”…”�”}”(hj6-h²hh³Nh´Nubj`)�”}”(hŒ``rcu_for_each_leaf_node()``”h]”hŒrcu_for_each_leaf_node()”…”�”}”(hj>-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj6-ubhŒ do if the ”…”�”}”(hj6-h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hjP-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj6-ubhŒ" tree contains only a single node?”…”�”}”(hj6-h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M‰hj3-ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj0-ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÿ,ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒ **Answer**:”h]”(j»)�”}”(hŒ **Answer**”h]”hŒAnswer”…”�”}”(hj~-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jºhjz-ubhŒ:”…”�”}”(hjz-h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MŒhjw-ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hjt-ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÿ,ubj­)�”}”(hhh]”j²)�”}”(hhh]”hÌ)�”}”(hŒPIn the single-node case, ``rcu_for_each_leaf_node()`` traverses the single node.”h]”(hŒIn the single-node case, ”…”�”}”(hj¨-h²hh³Nh´Nubj`)�”}”(hŒ``rcu_for_each_leaf_node()``”h]”hŒrcu_for_each_leaf_node()”…”�”}”(hj°-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj¨-ubhŒ traverses the single node.”…”�”}”(hj¨-h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MŽhj¥-ubah}”(h]”h ]”h"]”h$]”h&]”uh1j±hj¢-ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¬hjÿ,ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j§hjò,ubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j–hjï,ubah}”(h]”h ]”h"]”h$]”h&]”uh1j‘hj¼+h²hh³hÊh´Nubeh}”(h]”Œaccessor-functions”ah ]”h"]”Œaccessor functions”ah$]”h&]”uh1hµhjh²hh³hÊh´Mfubh¶)�”}”(hhh]”(h»)�”}”(hŒSummary”h]”hŒSummary”…”�”}”(hjò-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjï-h²hh³hÊh´M“ubhÌ)�”}”(hX�So the state of RCU is represented by an ``rcu_state`` structure, which contains a combining tree of ``rcu_node`` and ``rcu_data`` structures. Finally, in ``CONFIG_NO_HZ_IDLE`` kernels, each CPU's dyntick-idle state is tracked by dynticks-related fields in the ``rcu_data`` structure. If you made it this far, you are well prepared to read the code walkthroughs in the other articles in this series.”h]”(hŒ)So the state of RCU is represented by an ”…”�”}”(hj.h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_state``”h]”hŒ rcu_state”…”�”}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj.ubhŒ/ structure, which contains a combining tree of ”…”�”}”(hj.h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_node``”h]”hŒrcu_node”…”�”}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj.ubhŒ and ”…”�”}”(hj.h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hj,.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj.ubhŒ structures. Finally, in ”…”�”}”(hj.h²hh³Nh´Nubj`)�”}”(hŒ``CONFIG_NO_HZ_IDLE``”h]”hŒCONFIG_NO_HZ_IDLE”…”�”}”(hj>.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj.ubhŒW kernels, each CPU’s dyntick-idle state is tracked by dynticks-related fields in the ”…”�”}”(hj.h²hh³Nh´Nubj`)�”}”(hŒ ``rcu_data``”h]”hŒrcu_data”…”�”}”(hjP.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j_hj.ubhŒ~ structure. If you made it this far, you are well prepared to read the code walkthroughs in the other articles in this series.”…”�”}”(hj.h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M•hjï-h²hubeh}”(h]”Œsummary”ah ]”h"]”Œsummary”ah$]”h&]”uh1hµhjh²hh³hÊh´M“ubh¶)�”}”(hhh]”(h»)�”}”(hŒAcknowledgments”h]”hŒAcknowledgments”…”�”}”(hjs.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjp.h²hh³hÊh´M�ubhÌ)�”}”(hŒÇI owe thanks to Cyrill Gorcunov, Mathieu Desnoyers, Dhaval Giani, Paul Turner, Abhishek Srivastava, Matt Kowalczyk, and Serge Hallyn for helping me get this document into a more human-readable state.”h]”hŒÇI owe thanks to Cyrill Gorcunov, Mathieu Desnoyers, Dhaval Giani, Paul Turner, Abhishek Srivastava, Matt Kowalczyk, and Serge Hallyn for helping me get this document into a more human-readable state.”…”�”}”(hj�.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MŸhjp.h²hubeh}”(h]”Œacknowledgments”ah ]”h"]”Œacknowledgments”ah$]”h&]”uh1hµhjh²hh³hÊh´M�ubh¶)�”}”(hhh]”(h»)�”}”(hŒLegal Statement”h]”hŒLegal Statement”…”�”}”(hjš.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj—.h²hh³hÊh´M¤ubhÌ)�”}”(hŒ_This work represents the view of the author and does not necessarily represent the view of IBM.”h]”hŒ_This work represents the view of the author and does not necessarily represent the view of IBM.”…”�”}”(hj¨.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¦hj—.h²hubhÌ)�”}”(hŒ2Linux is a registered trademark of Linus Torvalds.”h]”hŒ2Linux is a registered trademark of Linus Torvalds.”…”�”}”(hj¶.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M©hj—.h²hubhÌ)�”}”(hŒWOther company, product, and service names may be trademarks or service marks of others.”h]”hŒWOther company, product, and service names may be trademarks or service marks of others.”…”�”}”(hjÄ.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M«hj—.h²hubeh}”(h]”Œlegal-statement”ah ]”h"]”Œlegal statement”ah$]”h&]”uh1hµhjh²hh³hÊh´M¤ubeh}”(h]”Œdata-structure-relationships”ah ]”h"]”Œdata-structure relationships”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubeh}”(h]”Œ1a-tour-through-tree-rcu-s-data-structures-lwn-net”ah ]”h"]”Œ3a tour through tree_rcu's data structures [lwn.net]”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”j±Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j /Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”a• Œfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”j]”jasŒnameids”}”(jç.jä.j j jß.jÜ.j¬j©j_ j\ Œgrace-period tracking”Nj¤j¡jÙjÖj¶j³jjj�jj\jYjjjÑjÎj j j=(j:(j²!j¯!jÓ#jÐ#jn%jk%j5(j2(jl*ji*j¹+j¶+jì-jé-jm.jj.j”.j‘.j×.jÔ.uŒ nametypes”}”(jç.‰j ‰jß.‰j¬‰j_ ‰jQ/‰j¤‰jÙ‰j¶‰j‰j�ˆj\‰j‰jщj ‰j=(‰j²!‰jÓ#‰jn%‰j5(‰jl*‰j¹+‰jì-‰jm.‰j”.‰j×.‰uh}”(jä.h·j héjÜ.jj©j5j\ j¼jã jb j¡jê jÖj¯j³jZjj¹jjj�jjYj—jj_jÎjj jÜj:(j j¯!j° jÐ#jµ!jk%jÖ#j2(jq%ji*j@(j¶+jo*jé-j¼+jj.jï-j‘.jp.jÔ.j—.uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”j/Ks…”R”Œparse_messages”]”hŒsystem_message”“”)�”}”(hhh]”hÌ)�”}”(hŒ8Duplicate implicit target name: "grace-period tracking".”h]”hŒ