Skip to content

Commit 6705cae

Browse files
Madhuparna04paulmckrcu
authored andcommitted
doc: Converted NMI-RCU.txt to NMI-RCU.rst.
This patch converts NMI-RCU from txt to rst format. Also adds NMI-RCU in the index.rst file. Signed-off-by: Madhuparna Bhowmik <[email protected]> [ paulmck: Apply feedback from Phong Tran. ] Tested-by: Phong Tran <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 9ffdd79 commit 6705cae

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

Documentation/RCU/NMI-RCU.txt renamed to Documentation/RCU/NMI-RCU.rst

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
.. _NMI_rcu_doc:
2+
13
Using RCU to Protect Dynamic NMI Handlers
4+
=========================================
25

36

47
Although RCU is usually used to protect read-mostly data structures,
@@ -9,7 +12,7 @@ work in "arch/x86/oprofile/nmi_timer_int.c" and in
912
"arch/x86/kernel/traps.c".
1013

1114
The relevant pieces of code are listed below, each followed by a
12-
brief explanation.
15+
brief explanation::
1316

1417
static int dummy_nmi_callback(struct pt_regs *regs, int cpu)
1518
{
@@ -18,12 +21,12 @@ brief explanation.
1821

1922
The dummy_nmi_callback() function is a "dummy" NMI handler that does
2023
nothing, but returns zero, thus saying that it did nothing, allowing
21-
the NMI handler to take the default machine-specific action.
24+
the NMI handler to take the default machine-specific action::
2225

2326
static nmi_callback_t nmi_callback = dummy_nmi_callback;
2427

2528
This nmi_callback variable is a global function pointer to the current
26-
NMI handler.
29+
NMI handler::
2730

2831
void do_nmi(struct pt_regs * regs, long error_code)
2932
{
@@ -53,11 +56,12 @@ anyway. However, in practice it is a good documentation aid, particularly
5356
for anyone attempting to do something similar on Alpha or on systems
5457
with aggressive optimizing compilers.
5558

56-
Quick Quiz: Why might the rcu_dereference_sched() be necessary on Alpha,
57-
given that the code referenced by the pointer is read-only?
59+
Quick Quiz:
60+
Why might the rcu_dereference_sched() be necessary on Alpha, given that the code referenced by the pointer is read-only?
5861

62+
:ref:`Answer to Quick Quiz <answer_quick_quiz_NMI>`
5963

60-
Back to the discussion of NMI and RCU...
64+
Back to the discussion of NMI and RCU::
6165

6266
void set_nmi_callback(nmi_callback_t callback)
6367
{
@@ -68,7 +72,7 @@ The set_nmi_callback() function registers an NMI handler. Note that any
6872
data that is to be used by the callback must be initialized up -before-
6973
the call to set_nmi_callback(). On architectures that do not order
7074
writes, the rcu_assign_pointer() ensures that the NMI handler sees the
71-
initialized values.
75+
initialized values::
7276

7377
void unset_nmi_callback(void)
7478
{
@@ -82,7 +86,7 @@ up any data structures used by the old NMI handler until execution
8286
of it completes on all other CPUs.
8387

8488
One way to accomplish this is via synchronize_rcu(), perhaps as
85-
follows:
89+
follows::
8690

8791
unset_nmi_callback();
8892
synchronize_rcu();
@@ -98,24 +102,23 @@ to free up the handler's data as soon as synchronize_rcu() returns.
98102
Important note: for this to work, the architecture in question must
99103
invoke nmi_enter() and nmi_exit() on NMI entry and exit, respectively.
100104

105+
.. _answer_quick_quiz_NMI:
101106

102-
Answer to Quick Quiz
103-
104-
Why might the rcu_dereference_sched() be necessary on Alpha, given
105-
that the code referenced by the pointer is read-only?
107+
Answer to Quick Quiz:
108+
Why might the rcu_dereference_sched() be necessary on Alpha, given that the code referenced by the pointer is read-only?
106109

107-
Answer: The caller to set_nmi_callback() might well have
108-
initialized some data that is to be used by the new NMI
109-
handler. In this case, the rcu_dereference_sched() would
110-
be needed, because otherwise a CPU that received an NMI
111-
just after the new handler was set might see the pointer
112-
to the new NMI handler, but the old pre-initialized
113-
version of the handler's data.
110+
The caller to set_nmi_callback() might well have
111+
initialized some data that is to be used by the new NMI
112+
handler. In this case, the rcu_dereference_sched() would
113+
be needed, because otherwise a CPU that received an NMI
114+
just after the new handler was set might see the pointer
115+
to the new NMI handler, but the old pre-initialized
116+
version of the handler's data.
114117

115-
This same sad story can happen on other CPUs when using
116-
a compiler with aggressive pointer-value speculation
117-
optimizations.
118+
This same sad story can happen on other CPUs when using
119+
a compiler with aggressive pointer-value speculation
120+
optimizations.
118121

119-
More important, the rcu_dereference_sched() makes it
120-
clear to someone reading the code that the pointer is
121-
being protected by RCU-sched.
122+
More important, the rcu_dereference_sched() makes it
123+
clear to someone reading the code that the pointer is
124+
being protected by RCU-sched.

Documentation/RCU/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ RCU concepts
1010
arrayRCU
1111
rcu
1212
listRCU
13+
NMI-RCU
1314
UP
1415

1516
Design/Memory-Ordering/Tree-RCU-Memory-Ordering

0 commit comments

Comments
 (0)