Skip to content

Commit 41eea65

Browse files
committed
Merge tag 'core-rcu-2020-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull RCU changes from Ingo Molnar: - Debugging for smp_call_function() - RT raw/non-raw lock ordering fixes - Strict grace periods for KASAN - New smp_call_function() torture test - Torture-test updates - Documentation updates - Miscellaneous fixes [ This doesn't actually pull the tag - I've dropped the last merge from the RCU branch due to questions about the series. - Linus ] * tag 'core-rcu-2020-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (77 commits) smp: Make symbol 'csd_bug_count' static kernel/smp: Provide CSD lock timeout diagnostics smp: Add source and destination CPUs to __call_single_data rcu: Shrink each possible cpu krcp rcu/segcblist: Prevent useless GP start if no CBs to accelerate torture: Add gdb support rcutorture: Allow pointer leaks to test diagnostic code rcutorture: Hoist OOM registry up one level refperf: Avoid null pointer dereference when buf fails to allocate rcutorture: Properly synchronize with OOM notifier rcutorture: Properly set rcu_fwds for OOM handling torture: Add kvm.sh --help and update help message rcutorture: Add CONFIG_PROVE_RCU_LIST to TREE05 torture: Update initrd documentation rcutorture: Replace HTTP links with HTTPS ones locktorture: Make function torture_percpu_rwsem_init() static torture: document --allcpus argument added to the kvm.sh script rcutorture: Output number of elapsed grace periods rcutorture: Remove KCSAN stubs rcu: Remove unused "cpu" parameter from rcu_report_qs_rdp() ...
2 parents 373014b + b36c830 commit 41eea65

Some content is hidden

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

57 files changed

+1582
-421
lines changed

Documentation/RCU/Design/Data-Structures/Data-Structures.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ exit and perhaps also vice versa. Therefore, whenever the
963963
``->dynticks_nesting`` field is incremented up from zero, the
964964
``->dynticks_nmi_nesting`` field is set to a large positive number, and
965965
whenever the ``->dynticks_nesting`` field is decremented down to zero,
966-
the the ``->dynticks_nmi_nesting`` field is set to zero. Assuming that
966+
the ``->dynticks_nmi_nesting`` field is set to zero. Assuming that
967967
the number of misnested interrupts is not sufficient to overflow the
968968
counter, this approach corrects the ``->dynticks_nmi_nesting`` field
969969
every time the corresponding CPU enters the idle loop from process

Documentation/RCU/Design/Requirements/Requirements.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,7 +2162,7 @@ scheduling-clock interrupt be enabled when RCU needs it to be:
21622162
this sort of thing.
21632163
#. If a CPU is in a portion of the kernel that is absolutely positively
21642164
no-joking guaranteed to never execute any RCU read-side critical
2165-
sections, and RCU believes this CPU to to be idle, no problem. This
2165+
sections, and RCU believes this CPU to be idle, no problem. This
21662166
sort of thing is used by some architectures for light-weight
21672167
exception handlers, which can then avoid the overhead of
21682168
``rcu_irq_enter()`` and ``rcu_irq_exit()`` at exception entry and
@@ -2431,7 +2431,7 @@ However, there are legitimate preemptible-RCU implementations that do
24312431
not have this property, given that any point in the code outside of an
24322432
RCU read-side critical section can be a quiescent state. Therefore,
24332433
*RCU-sched* was created, which follows “classic” RCU in that an
2434-
RCU-sched grace period waits for for pre-existing interrupt and NMI
2434+
RCU-sched grace period waits for pre-existing interrupt and NMI
24352435
handlers. In kernels built with ``CONFIG_PREEMPT=n``, the RCU and
24362436
RCU-sched APIs have identical implementations, while kernels built with
24372437
``CONFIG_PREEMPT=y`` provide a separate implementation for each.

Documentation/RCU/whatisRCU.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ order to amortize their overhead over many uses of the corresponding APIs.
360360

361361
There are at least three flavors of RCU usage in the Linux kernel. The diagram
362362
above shows the most common one. On the updater side, the rcu_assign_pointer(),
363-
sychronize_rcu() and call_rcu() primitives used are the same for all three
363+
synchronize_rcu() and call_rcu() primitives used are the same for all three
364364
flavors. However for protection (on the reader side), the primitives used vary
365365
depending on the flavor:
366366

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 135 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,6 +3095,10 @@
30953095
and gids from such clients. This is intended to ease
30963096
migration from NFSv2/v3.
30973097

3098+
nmi_backtrace.backtrace_idle [KNL]
3099+
Dump stacks even of idle CPUs in response to an
3100+
NMI stack-backtrace request.
3101+
30983102
nmi_debug= [KNL,SH] Specify one or more actions to take
30993103
when a NMI is triggered.
31003104
Format: [state][,regs][,debounce][,die]
@@ -4174,46 +4178,55 @@
41744178
This wake_up() will be accompanied by a
41754179
WARN_ONCE() splat and an ftrace_dump().
41764180

4181+
rcutree.rcu_unlock_delay= [KNL]
4182+
In CONFIG_RCU_STRICT_GRACE_PERIOD=y kernels,
4183+
this specifies an rcu_read_unlock()-time delay
4184+
in microseconds. This defaults to zero.
4185+
Larger delays increase the probability of
4186+
catching RCU pointer leaks, that is, buggy use
4187+
of RCU-protected pointers after the relevant
4188+
rcu_read_unlock() has completed.
4189+
41774190
rcutree.sysrq_rcu= [KNL]
41784191
Commandeer a sysrq key to dump out Tree RCU's
41794192
rcu_node tree with an eye towards determining
41804193
why a new grace period has not yet started.
41814194

4182-
rcuperf.gp_async= [KNL]
4195+
rcuscale.gp_async= [KNL]
41834196
Measure performance of asynchronous
41844197
grace-period primitives such as call_rcu().
41854198

4186-
rcuperf.gp_async_max= [KNL]
4199+
rcuscale.gp_async_max= [KNL]
41874200
Specify the maximum number of outstanding
41884201
callbacks per writer thread. When a writer
41894202
thread exceeds this limit, it invokes the
41904203
corresponding flavor of rcu_barrier() to allow
41914204
previously posted callbacks to drain.
41924205

4193-
rcuperf.gp_exp= [KNL]
4206+
rcuscale.gp_exp= [KNL]
41944207
Measure performance of expedited synchronous
41954208
grace-period primitives.
41964209

4197-
rcuperf.holdoff= [KNL]
4210+
rcuscale.holdoff= [KNL]
41984211
Set test-start holdoff period. The purpose of
41994212
this parameter is to delay the start of the
42004213
test until boot completes in order to avoid
42014214
interference.
42024215

4203-
rcuperf.kfree_rcu_test= [KNL]
4216+
rcuscale.kfree_rcu_test= [KNL]
42044217
Set to measure performance of kfree_rcu() flooding.
42054218

4206-
rcuperf.kfree_nthreads= [KNL]
4219+
rcuscale.kfree_nthreads= [KNL]
42074220
The number of threads running loops of kfree_rcu().
42084221

4209-
rcuperf.kfree_alloc_num= [KNL]
4222+
rcuscale.kfree_alloc_num= [KNL]
42104223
Number of allocations and frees done in an iteration.
42114224

4212-
rcuperf.kfree_loops= [KNL]
4213-
Number of loops doing rcuperf.kfree_alloc_num number
4225+
rcuscale.kfree_loops= [KNL]
4226+
Number of loops doing rcuscale.kfree_alloc_num number
42144227
of allocations and frees.
42154228

4216-
rcuperf.nreaders= [KNL]
4229+
rcuscale.nreaders= [KNL]
42174230
Set number of RCU readers. The value -1 selects
42184231
N, where N is the number of CPUs. A value
42194232
"n" less than -1 selects N-n+1, where N is again
@@ -4222,23 +4235,23 @@
42224235
A value of "n" less than or equal to -N selects
42234236
a single reader.
42244237

4225-
rcuperf.nwriters= [KNL]
4238+
rcuscale.nwriters= [KNL]
42264239
Set number of RCU writers. The values operate
4227-
the same as for rcuperf.nreaders.
4240+
the same as for rcuscale.nreaders.
42284241
N, where N is the number of CPUs
42294242

4230-
rcuperf.perf_type= [KNL]
4243+
rcuscale.perf_type= [KNL]
42314244
Specify the RCU implementation to test.
42324245

4233-
rcuperf.shutdown= [KNL]
4246+
rcuscale.shutdown= [KNL]
42344247
Shut the system down after performance tests
42354248
complete. This is useful for hands-off automated
42364249
testing.
42374250

4238-
rcuperf.verbose= [KNL]
4251+
rcuscale.verbose= [KNL]
42394252
Enable additional printk() statements.
42404253

4241-
rcuperf.writer_holdoff= [KNL]
4254+
rcuscale.writer_holdoff= [KNL]
42424255
Write-side holdoff between grace periods,
42434256
in microseconds. The default of zero says
42444257
no holdoff.
@@ -4291,6 +4304,18 @@
42914304
are zero, rcutorture acts as if is interpreted
42924305
they are all non-zero.
42934306

4307+
rcutorture.irqreader= [KNL]
4308+
Run RCU readers from irq handlers, or, more
4309+
accurately, from a timer handler. Not all RCU
4310+
flavors take kindly to this sort of thing.
4311+
4312+
rcutorture.leakpointer= [KNL]
4313+
Leak an RCU-protected pointer out of the reader.
4314+
This can of course result in splats, and is
4315+
intended to test the ability of things like
4316+
CONFIG_RCU_STRICT_GRACE_PERIOD=y to detect
4317+
such leaks.
4318+
42944319
rcutorture.n_barrier_cbs= [KNL]
42954320
Set callbacks/threads for rcu_barrier() testing.
42964321

@@ -4512,8 +4537,8 @@
45124537
refscale.shutdown= [KNL]
45134538
Shut down the system at the end of the performance
45144539
test. This defaults to 1 (shut it down) when
4515-
rcuperf is built into the kernel and to 0 (leave
4516-
it running) when rcuperf is built as a module.
4540+
refscale is built into the kernel and to 0 (leave
4541+
it running) when refscale is built as a module.
45174542

45184543
refscale.verbose= [KNL]
45194544
Enable additional printk() statements.
@@ -4659,6 +4684,98 @@
46594684
Format: integer between 0 and 10
46604685
Default is 0.
46614686

4687+
scftorture.holdoff= [KNL]
4688+
Number of seconds to hold off before starting
4689+
test. Defaults to zero for module insertion and
4690+
to 10 seconds for built-in smp_call_function()
4691+
tests.
4692+
4693+
scftorture.longwait= [KNL]
4694+
Request ridiculously long waits randomly selected
4695+
up to the chosen limit in seconds. Zero (the
4696+
default) disables this feature. Please note
4697+
that requesting even small non-zero numbers of
4698+
seconds can result in RCU CPU stall warnings,
4699+
softlockup complaints, and so on.
4700+
4701+
scftorture.nthreads= [KNL]
4702+
Number of kthreads to spawn to invoke the
4703+
smp_call_function() family of functions.
4704+
The default of -1 specifies a number of kthreads
4705+
equal to the number of CPUs.
4706+
4707+
scftorture.onoff_holdoff= [KNL]
4708+
Number seconds to wait after the start of the
4709+
test before initiating CPU-hotplug operations.
4710+
4711+
scftorture.onoff_interval= [KNL]
4712+
Number seconds to wait between successive
4713+
CPU-hotplug operations. Specifying zero (which
4714+
is the default) disables CPU-hotplug operations.
4715+
4716+
scftorture.shutdown_secs= [KNL]
4717+
The number of seconds following the start of the
4718+
test after which to shut down the system. The
4719+
default of zero avoids shutting down the system.
4720+
Non-zero values are useful for automated tests.
4721+
4722+
scftorture.stat_interval= [KNL]
4723+
The number of seconds between outputting the
4724+
current test statistics to the console. A value
4725+
of zero disables statistics output.
4726+
4727+
scftorture.stutter_cpus= [KNL]
4728+
The number of jiffies to wait between each change
4729+
to the set of CPUs under test.
4730+
4731+
scftorture.use_cpus_read_lock= [KNL]
4732+
Use use_cpus_read_lock() instead of the default
4733+
preempt_disable() to disable CPU hotplug
4734+
while invoking one of the smp_call_function*()
4735+
functions.
4736+
4737+
scftorture.verbose= [KNL]
4738+
Enable additional printk() statements.
4739+
4740+
scftorture.weight_single= [KNL]
4741+
The probability weighting to use for the
4742+
smp_call_function_single() function with a zero
4743+
"wait" parameter. A value of -1 selects the
4744+
default if all other weights are -1. However,
4745+
if at least one weight has some other value, a
4746+
value of -1 will instead select a weight of zero.
4747+
4748+
scftorture.weight_single_wait= [KNL]
4749+
The probability weighting to use for the
4750+
smp_call_function_single() function with a
4751+
non-zero "wait" parameter. See weight_single.
4752+
4753+
scftorture.weight_many= [KNL]
4754+
The probability weighting to use for the
4755+
smp_call_function_many() function with a zero
4756+
"wait" parameter. See weight_single.
4757+
Note well that setting a high probability for
4758+
this weighting can place serious IPI load
4759+
on the system.
4760+
4761+
scftorture.weight_many_wait= [KNL]
4762+
The probability weighting to use for the
4763+
smp_call_function_many() function with a
4764+
non-zero "wait" parameter. See weight_single
4765+
and weight_many.
4766+
4767+
scftorture.weight_all= [KNL]
4768+
The probability weighting to use for the
4769+
smp_call_function_all() function with a zero
4770+
"wait" parameter. See weight_single and
4771+
weight_many.
4772+
4773+
scftorture.weight_all_wait= [KNL]
4774+
The probability weighting to use for the
4775+
smp_call_function_all() function with a
4776+
non-zero "wait" parameter. See weight_single
4777+
and weight_many.
4778+
46624779
skew_tick= [KNL] Offset the periodic timer tick per cpu to mitigate
46634780
xtime_lock contention on larger systems, and/or RCU lock
46644781
contention on all systems with CONFIG_MAXSMP set.

MAINTAINERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17672,8 +17672,9 @@ S: Supported
1767217672
T: git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
1767317673
F: Documentation/RCU/torture.rst
1767417674
F: kernel/locking/locktorture.c
17675-
F: kernel/rcu/rcuperf.c
17675+
F: kernel/rcu/rcuscale.c
1767617676
F: kernel/rcu/rcutorture.c
17677+
F: kernel/rcu/refscale.c
1767717678
F: kernel/torture.c
1767817679

1767917680
TOSHIBA ACPI EXTRAS DRIVER

arch/x86/kvm/mmu/page_track.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
229229
return;
230230

231231
idx = srcu_read_lock(&head->track_srcu);
232-
hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
232+
hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
233+
srcu_read_lock_held(&head->track_srcu))
233234
if (n->track_write)
234235
n->track_write(vcpu, gpa, new, bytes, n);
235236
srcu_read_unlock(&head->track_srcu, idx);
@@ -254,7 +255,8 @@ void kvm_page_track_flush_slot(struct kvm *kvm, struct kvm_memory_slot *slot)
254255
return;
255256

256257
idx = srcu_read_lock(&head->track_srcu);
257-
hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
258+
hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
259+
srcu_read_lock_held(&head->track_srcu))
258260
if (n->track_flush_slot)
259261
n->track_flush_slot(kvm, slot, n);
260262
srcu_read_unlock(&head->track_srcu, idx);

include/linux/rculist.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,17 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
6363
RCU_LOCKDEP_WARN(!(cond) && !rcu_read_lock_any_held(), \
6464
"RCU-list traversed in non-reader section!"); \
6565
})
66+
67+
#define __list_check_srcu(cond) \
68+
({ \
69+
RCU_LOCKDEP_WARN(!(cond), \
70+
"RCU-list traversed without holding the required lock!");\
71+
})
6672
#else
6773
#define __list_check_rcu(dummy, cond, extra...) \
6874
({ check_arg_count_one(extra); })
75+
76+
#define __list_check_srcu(cond) ({ })
6977
#endif
7078

7179
/*
@@ -385,6 +393,25 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,
385393
&pos->member != (head); \
386394
pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
387395

396+
/**
397+
* list_for_each_entry_srcu - iterate over rcu list of given type
398+
* @pos: the type * to use as a loop cursor.
399+
* @head: the head for your list.
400+
* @member: the name of the list_head within the struct.
401+
* @cond: lockdep expression for the lock required to traverse the list.
402+
*
403+
* This list-traversal primitive may safely run concurrently with
404+
* the _rcu list-mutation primitives such as list_add_rcu()
405+
* as long as the traversal is guarded by srcu_read_lock().
406+
* The lockdep expression srcu_read_lock_held() can be passed as the
407+
* cond argument from read side.
408+
*/
409+
#define list_for_each_entry_srcu(pos, head, member, cond) \
410+
for (__list_check_srcu(cond), \
411+
pos = list_entry_rcu((head)->next, typeof(*pos), member); \
412+
&pos->member != (head); \
413+
pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
414+
388415
/**
389416
* list_entry_lockless - get the struct for this entry
390417
* @ptr: the &struct list_head pointer.
@@ -683,6 +710,27 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,
683710
pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(\
684711
&(pos)->member)), typeof(*(pos)), member))
685712

713+
/**
714+
* hlist_for_each_entry_srcu - iterate over rcu list of given type
715+
* @pos: the type * to use as a loop cursor.
716+
* @head: the head for your list.
717+
* @member: the name of the hlist_node within the struct.
718+
* @cond: lockdep expression for the lock required to traverse the list.
719+
*
720+
* This list-traversal primitive may safely run concurrently with
721+
* the _rcu list-mutation primitives such as hlist_add_head_rcu()
722+
* as long as the traversal is guarded by srcu_read_lock().
723+
* The lockdep expression srcu_read_lock_held() can be passed as the
724+
* cond argument from read side.
725+
*/
726+
#define hlist_for_each_entry_srcu(pos, head, member, cond) \
727+
for (__list_check_srcu(cond), \
728+
pos = hlist_entry_safe(rcu_dereference_raw(hlist_first_rcu(head)),\
729+
typeof(*(pos)), member); \
730+
pos; \
731+
pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(\
732+
&(pos)->member)), typeof(*(pos)), member))
733+
686734
/**
687735
* hlist_for_each_entry_rcu_notrace - iterate over rcu list of given type (for tracing)
688736
* @pos: the type * to use as a loop cursor.

0 commit comments

Comments
 (0)