Skip to content

Commit 8f0cb66

Browse files
committed
Merge tag 'core-rcu-2020-08-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull RCU updates from Ingo Molnar: - kfree_rcu updates - RCU tasks updates - Read-side scalability tests - SRCU updates - Torture-test updates - Documentation updates - Miscellaneous fixes * tag 'core-rcu-2020-08-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (109 commits) torture: Remove obsolete "cd $KVM" torture: Avoid duplicate specification of qemu command torture: Dump ftrace at shutdown only if requested torture: Add kvm-tranform.sh script for qemu-cmd files torture: Add more tracing crib notes to kvm.sh torture: Improve diagnostic for KCSAN-incapable compilers torture: Correctly summarize build-only runs torture: Pass --kmake-arg to all make invocations rcutorture: Check for unwatched readers torture: Abstract out console-log error detection torture: Add a stop-run capability torture: Create qemu-cmd in --buildonly runs rcu/rcutorture: Replace 0 with false torture: Add --allcpus argument to the kvm.sh script torture: Remove whitespace from identify_qemu_vcpus output rcutorture: NULL rcu_torture_current earlier in cleanup code rcutorture: Handle non-statistic bang-string error messages torture: Set configfile variable to current scenario rcutorture: Add races with task-exit processing locktorture: Use true and false to assign to bool variables ...
2 parents 5ece081 + c1cc478 commit 8f0cb66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2395
-680
lines changed

Documentation/RCU/Design/Requirements/Requirements.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2583,7 +2583,12 @@ not work to have these markers in the trampoline itself, because there
25832583
would need to be instructions following ``rcu_read_unlock()``. Although
25842584
``synchronize_rcu()`` would guarantee that execution reached the
25852585
``rcu_read_unlock()``, it would not be able to guarantee that execution
2586-
had completely left the trampoline.
2586+
had completely left the trampoline. Worse yet, in some situations
2587+
the trampoline's protection must extend a few instructions *prior* to
2588+
execution reaching the trampoline. For example, these few instructions
2589+
might calculate the address of the trampoline, so that entering the
2590+
trampoline would be pre-ordained a surprisingly long time before execution
2591+
actually reached the trampoline itself.
25872592

25882593
The solution, in the form of `Tasks
25892594
RCU <https://lwn.net/Articles/607117/>`__, is to have implicit read-side

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
================================
14
Review Checklist for RCU Patches
5+
================================
26

37

48
This document contains a checklist for producing and reviewing patches
@@ -411,18 +415,21 @@ over a rather long period of time, but improvements are always welcome!
411415
__rcu sparse checks to validate your RCU code. These can help
412416
find problems as follows:
413417

414-
CONFIG_PROVE_LOCKING: check that accesses to RCU-protected data
418+
CONFIG_PROVE_LOCKING:
419+
check that accesses to RCU-protected data
415420
structures are carried out under the proper RCU
416421
read-side critical section, while holding the right
417422
combination of locks, or whatever other conditions
418423
are appropriate.
419424

420-
CONFIG_DEBUG_OBJECTS_RCU_HEAD: check that you don't pass the
425+
CONFIG_DEBUG_OBJECTS_RCU_HEAD:
426+
check that you don't pass the
421427
same object to call_rcu() (or friends) before an RCU
422428
grace period has elapsed since the last time that you
423429
passed that same object to call_rcu() (or friends).
424430

425-
__rcu sparse checks: tag the pointer to the RCU-protected data
431+
__rcu sparse checks:
432+
tag the pointer to the RCU-protected data
426433
structure with __rcu, and sparse will warn you if you
427434
access that pointer without the services of one of the
428435
variants of rcu_dereference().
@@ -442,8 +449,8 @@ over a rather long period of time, but improvements are always welcome!
442449

443450
You instead need to use one of the barrier functions:
444451

445-
o call_rcu() -> rcu_barrier()
446-
o call_srcu() -> srcu_barrier()
452+
- call_rcu() -> rcu_barrier()
453+
- call_srcu() -> srcu_barrier()
447454

448455
However, these barrier functions are absolutely -not- guaranteed
449456
to wait for a grace period. In fact, if there are no call_rcu()

Documentation/RCU/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
13
.. _rcu_concepts:
24

35
============
@@ -8,10 +10,17 @@ RCU concepts
810
:maxdepth: 3
911

1012
arrayRCU
13+
checklist
14+
lockdep
15+
lockdep-splat
1116
rcubarrier
1217
rcu_dereference
1318
whatisRCU
1419
rcu
20+
rculist_nulls
21+
rcuref
22+
torture
23+
stallwarn
1524
listRCU
1625
NMI-RCU
1726
UP

Documentation/RCU/lockdep-splat.txt renamed to Documentation/RCU/lockdep-splat.rst

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
=================
4+
Lockdep-RCU Splat
5+
=================
6+
17
Lockdep-RCU was added to the Linux kernel in early 2010
28
(http://lwn.net/Articles/371986/). This facility checks for some common
39
misuses of the RCU API, most notably using one of the rcu_dereference()
@@ -12,55 +18,54 @@ overwriting or worse. There can of course be false positives, this
1218
being the real world and all that.
1319

1420
So let's look at an example RCU lockdep splat from 3.0-rc5, one that
15-
has long since been fixed:
16-
17-
=============================
18-
WARNING: suspicious RCU usage
19-
-----------------------------
20-
block/cfq-iosched.c:2776 suspicious rcu_dereference_protected() usage!
21-
22-
other info that might help us debug this:
23-
24-
25-
rcu_scheduler_active = 1, debug_locks = 0
26-
3 locks held by scsi_scan_6/1552:
27-
#0: (&shost->scan_mutex){+.+.}, at: [<ffffffff8145efca>]
28-
scsi_scan_host_selected+0x5a/0x150
29-
#1: (&eq->sysfs_lock){+.+.}, at: [<ffffffff812a5032>]
30-
elevator_exit+0x22/0x60
31-
#2: (&(&q->__queue_lock)->rlock){-.-.}, at: [<ffffffff812b6233>]
32-
cfq_exit_queue+0x43/0x190
33-
34-
stack backtrace:
35-
Pid: 1552, comm: scsi_scan_6 Not tainted 3.0.0-rc5 #17
36-
Call Trace:
37-
[<ffffffff810abb9b>] lockdep_rcu_dereference+0xbb/0xc0
38-
[<ffffffff812b6139>] __cfq_exit_single_io_context+0xe9/0x120
39-
[<ffffffff812b626c>] cfq_exit_queue+0x7c/0x190
40-
[<ffffffff812a5046>] elevator_exit+0x36/0x60
41-
[<ffffffff812a802a>] blk_cleanup_queue+0x4a/0x60
42-
[<ffffffff8145cc09>] scsi_free_queue+0x9/0x10
43-
[<ffffffff81460944>] __scsi_remove_device+0x84/0xd0
44-
[<ffffffff8145dca3>] scsi_probe_and_add_lun+0x353/0xb10
45-
[<ffffffff817da069>] ? error_exit+0x29/0xb0
46-
[<ffffffff817d98ed>] ? _raw_spin_unlock_irqrestore+0x3d/0x80
47-
[<ffffffff8145e722>] __scsi_scan_target+0x112/0x680
48-
[<ffffffff812c690d>] ? trace_hardirqs_off_thunk+0x3a/0x3c
49-
[<ffffffff817da069>] ? error_exit+0x29/0xb0
50-
[<ffffffff812bcc60>] ? kobject_del+0x40/0x40
51-
[<ffffffff8145ed16>] scsi_scan_channel+0x86/0xb0
52-
[<ffffffff8145f0b0>] scsi_scan_host_selected+0x140/0x150
53-
[<ffffffff8145f149>] do_scsi_scan_host+0x89/0x90
54-
[<ffffffff8145f170>] do_scan_async+0x20/0x160
55-
[<ffffffff8145f150>] ? do_scsi_scan_host+0x90/0x90
56-
[<ffffffff810975b6>] kthread+0xa6/0xb0
57-
[<ffffffff817db154>] kernel_thread_helper+0x4/0x10
58-
[<ffffffff81066430>] ? finish_task_switch+0x80/0x110
59-
[<ffffffff817d9c04>] ? retint_restore_args+0xe/0xe
60-
[<ffffffff81097510>] ? __kthread_init_worker+0x70/0x70
61-
[<ffffffff817db150>] ? gs_change+0xb/0xb
62-
63-
Line 2776 of block/cfq-iosched.c in v3.0-rc5 is as follows:
21+
has long since been fixed::
22+
23+
=============================
24+
WARNING: suspicious RCU usage
25+
-----------------------------
26+
block/cfq-iosched.c:2776 suspicious rcu_dereference_protected() usage!
27+
28+
other info that might help us debug this::
29+
30+
rcu_scheduler_active = 1, debug_locks = 0
31+
3 locks held by scsi_scan_6/1552:
32+
#0: (&shost->scan_mutex){+.+.}, at: [<ffffffff8145efca>]
33+
scsi_scan_host_selected+0x5a/0x150
34+
#1: (&eq->sysfs_lock){+.+.}, at: [<ffffffff812a5032>]
35+
elevator_exit+0x22/0x60
36+
#2: (&(&q->__queue_lock)->rlock){-.-.}, at: [<ffffffff812b6233>]
37+
cfq_exit_queue+0x43/0x190
38+
39+
stack backtrace:
40+
Pid: 1552, comm: scsi_scan_6 Not tainted 3.0.0-rc5 #17
41+
Call Trace:
42+
[<ffffffff810abb9b>] lockdep_rcu_dereference+0xbb/0xc0
43+
[<ffffffff812b6139>] __cfq_exit_single_io_context+0xe9/0x120
44+
[<ffffffff812b626c>] cfq_exit_queue+0x7c/0x190
45+
[<ffffffff812a5046>] elevator_exit+0x36/0x60
46+
[<ffffffff812a802a>] blk_cleanup_queue+0x4a/0x60
47+
[<ffffffff8145cc09>] scsi_free_queue+0x9/0x10
48+
[<ffffffff81460944>] __scsi_remove_device+0x84/0xd0
49+
[<ffffffff8145dca3>] scsi_probe_and_add_lun+0x353/0xb10
50+
[<ffffffff817da069>] ? error_exit+0x29/0xb0
51+
[<ffffffff817d98ed>] ? _raw_spin_unlock_irqrestore+0x3d/0x80
52+
[<ffffffff8145e722>] __scsi_scan_target+0x112/0x680
53+
[<ffffffff812c690d>] ? trace_hardirqs_off_thunk+0x3a/0x3c
54+
[<ffffffff817da069>] ? error_exit+0x29/0xb0
55+
[<ffffffff812bcc60>] ? kobject_del+0x40/0x40
56+
[<ffffffff8145ed16>] scsi_scan_channel+0x86/0xb0
57+
[<ffffffff8145f0b0>] scsi_scan_host_selected+0x140/0x150
58+
[<ffffffff8145f149>] do_scsi_scan_host+0x89/0x90
59+
[<ffffffff8145f170>] do_scan_async+0x20/0x160
60+
[<ffffffff8145f150>] ? do_scsi_scan_host+0x90/0x90
61+
[<ffffffff810975b6>] kthread+0xa6/0xb0
62+
[<ffffffff817db154>] kernel_thread_helper+0x4/0x10
63+
[<ffffffff81066430>] ? finish_task_switch+0x80/0x110
64+
[<ffffffff817d9c04>] ? retint_restore_args+0xe/0xe
65+
[<ffffffff81097510>] ? __kthread_init_worker+0x70/0x70
66+
[<ffffffff817db150>] ? gs_change+0xb/0xb
67+
68+
Line 2776 of block/cfq-iosched.c in v3.0-rc5 is as follows::
6469

6570
if (rcu_dereference(ioc->ioc_data) == cic) {
6671

@@ -70,7 +75,7 @@ case. Instead, we hold three locks, one of which might be RCU related.
7075
And maybe that lock really does protect this reference. If so, the fix
7176
is to inform RCU, perhaps by changing __cfq_exit_single_io_context() to
7277
take the struct request_queue "q" from cfq_exit_queue() as an argument,
73-
which would permit us to invoke rcu_dereference_protected as follows:
78+
which would permit us to invoke rcu_dereference_protected as follows::
7479

7580
if (rcu_dereference_protected(ioc->ioc_data,
7681
lockdep_is_held(&q->queue_lock)) == cic) {
@@ -85,7 +90,7 @@ On the other hand, perhaps we really do need an RCU read-side critical
8590
section. In this case, the critical section must span the use of the
8691
return value from rcu_dereference(), or at least until there is some
8792
reference count incremented or some such. One way to handle this is to
88-
add rcu_read_lock() and rcu_read_unlock() as follows:
93+
add rcu_read_lock() and rcu_read_unlock() as follows::
8994

9095
rcu_read_lock();
9196
if (rcu_dereference(ioc->ioc_data) == cic) {
@@ -102,7 +107,7 @@ above lockdep-RCU splat.
102107
But in this particular case, we don't actually dereference the pointer
103108
returned from rcu_dereference(). Instead, that pointer is just compared
104109
to the cic pointer, which means that the rcu_dereference() can be replaced
105-
by rcu_access_pointer() as follows:
110+
by rcu_access_pointer() as follows::
106111

107112
if (rcu_access_pointer(ioc->ioc_data) == cic) {
108113

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
========================
14
RCU and lockdep checking
5+
========================
26

37
All flavors of RCU have lockdep checking available, so that lockdep is
48
aware of when each task enters and leaves any flavor of RCU read-side
@@ -8,7 +12,7 @@ tracking to include RCU state, which can sometimes help when debugging
812
deadlocks and the like.
913

1014
In addition, RCU provides the following primitives that check lockdep's
11-
state:
15+
state::
1216

1317
rcu_read_lock_held() for normal RCU.
1418
rcu_read_lock_bh_held() for RCU-bh.
@@ -63,7 +67,7 @@ checking of rcu_dereference() primitives:
6367
The rcu_dereference_check() check expression can be any boolean
6468
expression, but would normally include a lockdep expression. However,
6569
any boolean expression can be used. For a moderately ornate example,
66-
consider the following:
70+
consider the following::
6771

6872
file = rcu_dereference_check(fdt->fd[fd],
6973
lockdep_is_held(&files->file_lock) ||
@@ -82,7 +86,7 @@ RCU read-side critical sections, in case (2) the ->file_lock prevents
8286
any change from taking place, and finally, in case (3) the current task
8387
is the only task accessing the file_struct, again preventing any change
8488
from taking place. If the above statement was invoked only from updater
85-
code, it could instead be written as follows:
89+
code, it could instead be written as follows::
8690

8791
file = rcu_dereference_protected(fdt->fd[fd],
8892
lockdep_is_held(&files->file_lock) ||
@@ -105,7 +109,7 @@ false and they are called from outside any RCU read-side critical section.
105109

106110
For example, the workqueue for_each_pwq() macro is intended to be used
107111
either within an RCU read-side critical section or with wq->mutex held.
108-
It is thus implemented as follows:
112+
It is thus implemented as follows::
109113

110114
#define for_each_pwq(pwq, wq)
111115
list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node,

0 commit comments

Comments
 (0)