Skip to content

Commit baf5fe7

Browse files
author
Ingo Molnar
committed
Merge branch 'for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu into core/rcu
Pull RCU changes from Paul E. McKenney: - Make kfree_rcu() use kfree_bulk() for added performance - RCU updates - Callback-overload handling updates - Tasks-RCU KCSAN and sparse updates - Locking torture test and RCU torture test updates - Documentation updates - Miscellaneous fixes Signed-off-by: Ingo Molnar <[email protected]>
2 parents 16fbf79 + aa93ec6 commit baf5fe7

File tree

34 files changed

+1015
-294
lines changed

34 files changed

+1015
-294
lines changed

Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A Tour Through TREE_RCU's Grace-Period Memory Ordering
44

55
August 8, 2017
66

7-
This article was contributed by Paul E.&nbsp;McKenney
7+
This article was contributed by Paul E. McKenney
88

99
Introduction
1010
============
@@ -48,7 +48,7 @@ Tree RCU Grace Period Memory Ordering Building Blocks
4848

4949
The workhorse for RCU's grace-period memory ordering is the
5050
critical section for the ``rcu_node`` structure's
51-
``-&gt;lock``. These critical sections use helper functions for lock
51+
``->lock``. These critical sections use helper functions for lock
5252
acquisition, including ``raw_spin_lock_rcu_node()``,
5353
``raw_spin_lock_irq_rcu_node()``, and ``raw_spin_lock_irqsave_rcu_node()``.
5454
Their lock-release counterparts are ``raw_spin_unlock_rcu_node()``,
@@ -102,9 +102,9 @@ lock-acquisition and lock-release functions::
102102
23 r3 = READ_ONCE(x);
103103
24 }
104104
25
105-
26 WARN_ON(r1 == 0 &amp;&amp; r2 == 0 &amp;&amp; r3 == 0);
105+
26 WARN_ON(r1 == 0 && r2 == 0 && r3 == 0);
106106

107-
The ``WARN_ON()`` is evaluated at &ldquo;the end of time&rdquo;,
107+
The ``WARN_ON()`` is evaluated at "the end of time",
108108
after all changes have propagated throughout the system.
109109
Without the ``smp_mb__after_unlock_lock()`` provided by the
110110
acquisition functions, this ``WARN_ON()`` could trigger, for example

Documentation/RCU/listRCU.rst

Lines changed: 214 additions & 67 deletions
Large diffs are not rendered by default.

Documentation/RCU/rcu.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ must be long enough that any readers accessing the item being deleted have
1111
since dropped their references. For example, an RCU-protected deletion
1212
from a linked list would first remove the item from the list, wait for
1313
a grace period to elapse, then free the element. See the
14-
Documentation/RCU/listRCU.rst file for more information on using RCU with
15-
linked lists.
14+
:ref:`Documentation/RCU/listRCU.rst <list_rcu_doc>` for more information on
15+
using RCU with linked lists.
1616

1717
Frequently Asked Questions
1818
--------------------------
@@ -50,7 +50,7 @@ Frequently Asked Questions
5050
- If I am running on a uniprocessor kernel, which can only do one
5151
thing at a time, why should I wait for a grace period?
5252

53-
See the Documentation/RCU/UP.rst file for more information.
53+
See :ref:`Documentation/RCU/UP.rst <up_doc>` for more information.
5454

5555
- How can I see where RCU is currently used in the Linux kernel?
5656

@@ -68,18 +68,18 @@ Frequently Asked Questions
6868

6969
- Why the name "RCU"?
7070

71-
"RCU" stands for "read-copy update". The file Documentation/RCU/listRCU.rst
72-
has more information on where this name came from, search for
73-
"read-copy update" to find it.
71+
"RCU" stands for "read-copy update".
72+
:ref:`Documentation/RCU/listRCU.rst <list_rcu_doc>` has more information on where
73+
this name came from, search for "read-copy update" to find it.
7474

7575
- I hear that RCU is patented? What is with that?
7676

7777
Yes, it is. There are several known patents related to RCU,
78-
search for the string "Patent" in RTFP.txt to find them.
78+
search for the string "Patent" in Documentation/RCU/RTFP.txt to find them.
7979
Of these, one was allowed to lapse by the assignee, and the
8080
others have been contributed to the Linux kernel under GPL.
8181
There are now also LGPL implementations of user-level RCU
82-
available (http://liburcu.org/).
82+
available (https://liburcu.org/).
8383

8484
- I hear that RCU needs work in order to support realtime kernels?
8585

@@ -88,5 +88,5 @@ Frequently Asked Questions
8888

8989
- Where can I find more information on RCU?
9090

91-
See the RTFP.txt file in this directory.
91+
See the Documentation/RCU/RTFP.txt file.
9292
Or point your browser at (http://www.rdrop.com/users/paulmck/RCU/).

Documentation/RCU/torture.txt

Lines changed: 140 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,14 @@ using a dynamically allocated srcu_struct (hence "srcud-" rather than
124124
debugging. The final "T" entry contains the totals of the counters.
125125

126126

127-
USAGE
127+
USAGE ON SPECIFIC KERNEL BUILDS
128128

129-
The following script may be used to torture RCU:
129+
It is sometimes desirable to torture RCU on a specific kernel build,
130+
for example, when preparing to put that kernel build into production.
131+
In that case, the kernel should be built with CONFIG_RCU_TORTURE_TEST=m
132+
so that the test can be started using modprobe and terminated using rmmod.
133+
134+
For example, the following script may be used to torture RCU:
130135

131136
#!/bin/sh
132137

@@ -142,8 +147,136 @@ checked for such errors. The "rmmod" command forces a "SUCCESS",
142147
two are self-explanatory, while the last indicates that while there
143148
were no RCU failures, CPU-hotplug problems were detected.
144149

145-
However, the tools/testing/selftests/rcutorture/bin/kvm.sh script
146-
provides better automation, including automatic failure analysis.
147-
It assumes a qemu/kvm-enabled platform, and runs guest OSes out of initrd.
148-
See tools/testing/selftests/rcutorture/doc/initrd.txt for instructions
149-
on setting up such an initrd.
150+
151+
USAGE ON MAINLINE KERNELS
152+
153+
When using rcutorture to test changes to RCU itself, it is often
154+
necessary to build a number of kernels in order to test that change
155+
across a broad range of combinations of the relevant Kconfig options
156+
and of the relevant kernel boot parameters. In this situation, use
157+
of modprobe and rmmod can be quite time-consuming and error-prone.
158+
159+
Therefore, the tools/testing/selftests/rcutorture/bin/kvm.sh
160+
script is available for mainline testing for x86, arm64, and
161+
powerpc. By default, it will run the series of tests specified by
162+
tools/testing/selftests/rcutorture/configs/rcu/CFLIST, with each test
163+
running for 30 minutes within a guest OS using a minimal userspace
164+
supplied by an automatically generated initrd. After the tests are
165+
complete, the resulting build products and console output are analyzed
166+
for errors and the results of the runs are summarized.
167+
168+
On larger systems, rcutorture testing can be accelerated by passing the
169+
--cpus argument to kvm.sh. For example, on a 64-CPU system, "--cpus 43"
170+
would use up to 43 CPUs to run tests concurrently, which as of v5.4 would
171+
complete all the scenarios in two batches, reducing the time to complete
172+
from about eight hours to about one hour (not counting the time to build
173+
the sixteen kernels). The "--dryrun sched" argument will not run tests,
174+
but rather tell you how the tests would be scheduled into batches. This
175+
can be useful when working out how many CPUs to specify in the --cpus
176+
argument.
177+
178+
Not all changes require that all scenarios be run. For example, a change
179+
to Tree SRCU might run only the SRCU-N and SRCU-P scenarios using the
180+
--configs argument to kvm.sh as follows: "--configs 'SRCU-N SRCU-P'".
181+
Large systems can run multiple copies of of the full set of scenarios,
182+
for example, a system with 448 hardware threads can run five instances
183+
of the full set concurrently. To make this happen:
184+
185+
kvm.sh --cpus 448 --configs '5*CFLIST'
186+
187+
Alternatively, such a system can run 56 concurrent instances of a single
188+
eight-CPU scenario:
189+
190+
kvm.sh --cpus 448 --configs '56*TREE04'
191+
192+
Or 28 concurrent instances of each of two eight-CPU scenarios:
193+
194+
kvm.sh --cpus 448 --configs '28*TREE03 28*TREE04'
195+
196+
Of course, each concurrent instance will use memory, which can be
197+
limited using the --memory argument, which defaults to 512M. Small
198+
values for memory may require disabling the callback-flooding tests
199+
using the --bootargs parameter discussed below.
200+
201+
Sometimes additional debugging is useful, and in such cases the --kconfig
202+
parameter to kvm.sh may be used, for example, "--kconfig 'CONFIG_KASAN=y'".
203+
204+
Kernel boot arguments can also be supplied, for example, to control
205+
rcutorture's module parameters. For example, to test a change to RCU's
206+
CPU stall-warning code, use "--bootargs 'rcutorture.stall_cpu=30'".
207+
This will of course result in the scripting reporting a failure, namely
208+
the resuling RCU CPU stall warning. As noted above, reducing memory may
209+
require disabling rcutorture's callback-flooding tests:
210+
211+
kvm.sh --cpus 448 --configs '56*TREE04' --memory 128M \
212+
--bootargs 'rcutorture.fwd_progress=0'
213+
214+
Sometimes all that is needed is a full set of kernel builds. This is
215+
what the --buildonly argument does.
216+
217+
Finally, the --trust-make argument allows each kernel build to reuse what
218+
it can from the previous kernel build.
219+
220+
There are additional more arcane arguments that are documented in the
221+
source code of the kvm.sh script.
222+
223+
If a run contains failures, the number of buildtime and runtime failures
224+
is listed at the end of the kvm.sh output, which you really should redirect
225+
to a file. The build products and console output of each run is kept in
226+
tools/testing/selftests/rcutorture/res in timestamped directories. A
227+
given directory can be supplied to kvm-find-errors.sh in order to have
228+
it cycle you through summaries of errors and full error logs. For example:
229+
230+
tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh \
231+
tools/testing/selftests/rcutorture/res/2020.01.20-15.54.23
232+
233+
However, it is often more convenient to access the files directly.
234+
Files pertaining to all scenarios in a run reside in the top-level
235+
directory (2020.01.20-15.54.23 in the example above), while per-scenario
236+
files reside in a subdirectory named after the scenario (for example,
237+
"TREE04"). If a given scenario ran more than once (as in "--configs
238+
'56*TREE04'" above), the directories corresponding to the second and
239+
subsequent runs of that scenario include a sequence number, for example,
240+
"TREE04.2", "TREE04.3", and so on.
241+
242+
The most frequently used file in the top-level directory is testid.txt.
243+
If the test ran in a git repository, then this file contains the commit
244+
that was tested and any uncommitted changes in diff format.
245+
246+
The most frequently used files in each per-scenario-run directory are:
247+
248+
.config: This file contains the Kconfig options.
249+
250+
Make.out: This contains build output for a specific scenario.
251+
252+
console.log: This contains the console output for a specific scenario.
253+
This file may be examined once the kernel has booted, but
254+
it might not exist if the build failed.
255+
256+
vmlinux: This contains the kernel, which can be useful with tools like
257+
objdump and gdb.
258+
259+
A number of additional files are available, but are less frequently used.
260+
Many are intended for debugging of rcutorture itself or of its scripting.
261+
262+
As of v5.4, a successful run with the default set of scenarios produces
263+
the following summary at the end of the run on a 12-CPU system:
264+
265+
SRCU-N ------- 804233 GPs (148.932/s) [srcu: g10008272 f0x0 ]
266+
SRCU-P ------- 202320 GPs (37.4667/s) [srcud: g1809476 f0x0 ]
267+
SRCU-t ------- 1122086 GPs (207.794/s) [srcu: g0 f0x0 ]
268+
SRCU-u ------- 1111285 GPs (205.794/s) [srcud: g1 f0x0 ]
269+
TASKS01 ------- 19666 GPs (3.64185/s) [tasks: g0 f0x0 ]
270+
TASKS02 ------- 20541 GPs (3.80389/s) [tasks: g0 f0x0 ]
271+
TASKS03 ------- 19416 GPs (3.59556/s) [tasks: g0 f0x0 ]
272+
TINY01 ------- 836134 GPs (154.84/s) [rcu: g0 f0x0 ] n_max_cbs: 34198
273+
TINY02 ------- 850371 GPs (157.476/s) [rcu: g0 f0x0 ] n_max_cbs: 2631
274+
TREE01 ------- 162625 GPs (30.1157/s) [rcu: g1124169 f0x0 ]
275+
TREE02 ------- 333003 GPs (61.6672/s) [rcu: g2647753 f0x0 ] n_max_cbs: 35844
276+
TREE03 ------- 306623 GPs (56.782/s) [rcu: g2975325 f0x0 ] n_max_cbs: 1496497
277+
CPU count limited from 16 to 12
278+
TREE04 ------- 246149 GPs (45.5831/s) [rcu: g1695737 f0x0 ] n_max_cbs: 434961
279+
TREE05 ------- 314603 GPs (58.2598/s) [rcu: g2257741 f0x2 ] n_max_cbs: 193997
280+
TREE07 ------- 167347 GPs (30.9902/s) [rcu: g1079021 f0x0 ] n_max_cbs: 478732
281+
CPU count limited from 16 to 12
282+
TREE09 ------- 752238 GPs (139.303/s) [rcu: g13075057 f0x0 ] n_max_cbs: 99011

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3984,6 +3984,15 @@
39843984
Set threshold of queued RCU callbacks below which
39853985
batch limiting is re-enabled.
39863986

3987+
rcutree.qovld= [KNL]
3988+
Set threshold of queued RCU callbacks beyond which
3989+
RCU's force-quiescent-state scan will aggressively
3990+
enlist help from cond_resched() and sched IPIs to
3991+
help CPUs more quickly reach quiescent states.
3992+
Set to less than zero to make this be set based
3993+
on rcutree.qhimark at boot time and to zero to
3994+
disable more aggressive help enlistment.
3995+
39873996
rcutree.rcu_idle_gp_delay= [KNL]
39883997
Set wakeup interval for idle CPUs that have
39893998
RCU callbacks (RCU_FAST_NO_HZ=y).
@@ -4199,6 +4208,12 @@
41994208
rcupdate.rcu_cpu_stall_suppress= [KNL]
42004209
Suppress RCU CPU stall warning messages.
42014210

4211+
rcupdate.rcu_cpu_stall_suppress_at_boot= [KNL]
4212+
Suppress RCU CPU stall warning messages and
4213+
rcutorture writer stall warnings that occur
4214+
during early boot, that is, during the time
4215+
before the init task is spawned.
4216+
42024217
rcupdate.rcu_cpu_stall_timeout= [KNL]
42034218
Set timeout for RCU CPU stall warning messages.
42044219

@@ -4871,6 +4886,10 @@
48714886
topology updates sent by the hypervisor to this
48724887
LPAR.
48734888

4889+
torture.disable_onoff_at_boot= [KNL]
4890+
Prevent the CPU-hotplug component of torturing
4891+
until after init has spawned.
4892+
48744893
tp720= [HW,PS2]
48754894

48764895
tpm_suspend_pcr=[HW,TPM]

Documentation/memory-barriers.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ As a further example, consider this sequence of events:
185185
=============== ===============
186186
{ A == 1, B == 2, C == 3, P == &A, Q == &C }
187187
B = 4; Q = P;
188-
P = &B D = *Q;
188+
P = &B; D = *Q;
189189

190190
There is an obvious data dependency here, as the value loaded into D depends on
191191
the address retrieved from P by CPU 2. At the end of the sequence, any of the
@@ -569,7 +569,7 @@ following sequence of events:
569569
{ A == 1, B == 2, C == 3, P == &A, Q == &C }
570570
B = 4;
571571
<write barrier>
572-
WRITE_ONCE(P, &B)
572+
WRITE_ONCE(P, &B);
573573
Q = READ_ONCE(P);
574574
D = *Q;
575575

@@ -1721,7 +1721,7 @@ of optimizations:
17211721
and WRITE_ONCE() are more selective: With READ_ONCE() and
17221722
WRITE_ONCE(), the compiler need only forget the contents of the
17231723
indicated memory locations, while with barrier() the compiler must
1724-
discard the value of all memory locations that it has currented
1724+
discard the value of all memory locations that it has currently
17251725
cached in any machine registers. Of course, the compiler must also
17261726
respect the order in which the READ_ONCE()s and WRITE_ONCE()s occur,
17271727
though the CPU of course need not do so.
@@ -1833,7 +1833,7 @@ Aside: In the case of data dependencies, the compiler would be expected
18331833
to issue the loads in the correct order (eg. `a[b]` would have to load
18341834
the value of b before loading a[b]), however there is no guarantee in
18351835
the C specification that the compiler may not speculate the value of b
1836-
(eg. is equal to 1) and load a before b (eg. tmp = a[1]; if (b != 1)
1836+
(eg. is equal to 1) and load a[b] before b (eg. tmp = a[1]; if (b != 1)
18371837
tmp = a[b]; ). There is also the problem of a compiler reloading b after
18381838
having loaded a[b], thus having a newer copy of b than a[b]. A consensus
18391839
has not yet been reached about these problems, however the READ_ONCE()

fs/nfs/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,7 +2489,7 @@ static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre
24892489
rcu_read_lock();
24902490
if (nfsi->cache_validity & NFS_INO_INVALID_ACCESS)
24912491
goto out;
2492-
lh = rcu_dereference(nfsi->access_cache_entry_lru.prev);
2492+
lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
24932493
cache = list_entry(lh, struct nfs_access_entry, lru);
24942494
if (lh == &nfsi->access_cache_entry_lru ||
24952495
cred_fscmp(cred, cache->cred) != 0)

include/linux/rculist.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
6060
#define __list_check_rcu(dummy, cond, extra...) \
6161
({ \
6262
check_arg_count_one(extra); \
63-
RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \
63+
RCU_LOCKDEP_WARN(!(cond) && !rcu_read_lock_any_held(), \
6464
"RCU-list traversed in non-reader section!"); \
65-
})
65+
})
6666
#else
6767
#define __list_check_rcu(dummy, cond, extra...) \
6868
({ check_arg_count_one(extra); })

include/linux/rcutiny.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ void rcu_scheduler_starting(void);
8383
static inline void rcu_scheduler_starting(void) { }
8484
#endif /* #else #ifndef CONFIG_SRCU */
8585
static inline void rcu_end_inkernel_boot(void) { }
86+
static inline bool rcu_inkernel_boot_has_ended(void) { return true; }
8687
static inline bool rcu_is_watching(void) { return true; }
8788
static inline void rcu_momentary_dyntick_idle(void) { }
8889
static inline void kfree_rcu_scheduler_running(void) { }

include/linux/rcutree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ void exit_rcu(void);
5454
void rcu_scheduler_starting(void);
5555
extern int rcu_scheduler_active __read_mostly;
5656
void rcu_end_inkernel_boot(void);
57+
bool rcu_inkernel_boot_has_ended(void);
5758
bool rcu_is_watching(void);
5859
#ifndef CONFIG_PREEMPTION
5960
void rcu_all_qs(void);

0 commit comments

Comments
 (0)