Skip to content

Commit 9ffdd79

Browse files
Madhuparna04paulmckrcu
authored andcommitted
doc: Convert arrayRCU.txt to arrayRCU.rst
This patch converts arrayRCU from .txt to .rst format, and also adds it to the index.rst file. Signed-off-by: Madhuparna Bhowmik <[email protected]> [ paulmck: Trimmed trailing whitespace. ] Tested-by: Phong Tran <[email protected]> Tested-by: Amol Grover <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent e42617b commit 9ffdd79

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

Documentation/RCU/arrayRCU.txt renamed to Documentation/RCU/arrayRCU.rst

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
Using RCU to Protect Read-Mostly Arrays
1+
.. _array_rcu_doc:
22

3+
Using RCU to Protect Read-Mostly Arrays
4+
=======================================
35

46
Although RCU is more commonly used to protect linked lists, it can
57
also be used to protect arrays. Three situations are as follows:
68

7-
1. Hash Tables
9+
1. :ref:`Hash Tables <hash_tables>`
810

9-
2. Static Arrays
11+
2. :ref:`Static Arrays <static_arrays>`
1012

11-
3. Resizeable Arrays
13+
3. :ref:`Resizable Arrays <resizable_arrays>`
1214

1315
Each of these three situations involves an RCU-protected pointer to an
1416
array that is separately indexed. It might be tempting to consider use
1517
of RCU to instead protect the index into an array, however, this use
16-
case is -not- supported. The problem with RCU-protected indexes into
18+
case is **not** supported. The problem with RCU-protected indexes into
1719
arrays is that compilers can play way too many optimization games with
1820
integers, which means that the rules governing handling of these indexes
1921
are far more trouble than they are worth. If RCU-protected indexes into
@@ -24,30 +26,38 @@ to be safely used.
2426
That aside, each of the three RCU-protected pointer situations are
2527
described in the following sections.
2628

29+
.. _hash_tables:
2730

2831
Situation 1: Hash Tables
32+
------------------------
2933

3034
Hash tables are often implemented as an array, where each array entry
3135
has a linked-list hash chain. Each hash chain can be protected by RCU
3236
as described in the listRCU.txt document. This approach also applies
3337
to other array-of-list situations, such as radix trees.
3438

39+
.. _static_arrays:
3540

3641
Situation 2: Static Arrays
42+
--------------------------
3743

3844
Static arrays, where the data (rather than a pointer to the data) is
3945
located in each array element, and where the array is never resized,
4046
have not been used with RCU. Rik van Riel recommends using seqlock in
4147
this situation, which would also have minimal read-side overhead as long
4248
as updates are rare.
4349

44-
Quick Quiz: Why is it so important that updates be rare when
45-
using seqlock?
50+
Quick Quiz:
51+
Why is it so important that updates be rare when using seqlock?
52+
53+
:ref:`Answer to Quick Quiz <answer_quick_quiz_seqlock>`
4654

55+
.. _resizable_arrays:
4756

48-
Situation 3: Resizeable Arrays
57+
Situation 3: Resizable Arrays
58+
------------------------------
4959

50-
Use of RCU for resizeable arrays is demonstrated by the grow_ary()
60+
Use of RCU for resizable arrays is demonstrated by the grow_ary()
5161
function formerly used by the System V IPC code. The array is used
5262
to map from semaphore, message-queue, and shared-memory IDs to the data
5363
structure that represents the corresponding IPC construct. The grow_ary()
@@ -60,7 +70,7 @@ the remainder of the new, updates the ids->entries pointer to point to
6070
the new array, and invokes ipc_rcu_putref() to free up the old array.
6171
Note that rcu_assign_pointer() is used to update the ids->entries pointer,
6272
which includes any memory barriers required on whatever architecture
63-
you are running on.
73+
you are running on::
6474

6575
static int grow_ary(struct ipc_ids* ids, int newsize)
6676
{
@@ -112,7 +122,7 @@ a simple check suffices. The pointer to the structure corresponding
112122
to the desired IPC object is placed in "out", with NULL indicating
113123
a non-existent entry. After acquiring "out->lock", the "out->deleted"
114124
flag indicates whether the IPC object is in the process of being
115-
deleted, and, if not, the pointer is returned.
125+
deleted, and, if not, the pointer is returned::
116126

117127
struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id)
118128
{
@@ -144,8 +154,10 @@ deleted, and, if not, the pointer is returned.
144154
return out;
145155
}
146156

157+
.. _answer_quick_quiz_seqlock:
147158

148159
Answer to Quick Quiz:
160+
Why is it so important that updates be rare when using seqlock?
149161

150162
The reason that it is important that updates be rare when
151163
using seqlock is that frequent updates can livelock readers.

Documentation/RCU/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RCU concepts
77
.. toctree::
88
:maxdepth: 3
99

10+
arrayRCU
1011
rcu
1112
listRCU
1213
UP

0 commit comments

Comments
 (0)