Skip to content

Commit 9f3ee94

Browse files
committed
Merge tag 'rcu.release.v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux
Pull RCU updates from Uladzislau Rezki: "Misc fixes: - check if IRQs are disabled in rcu_exp_need_qs() - instrument KCSAN exclusive-writer assertions - add extra WARN_ON_ONCE() check - set the cpu_no_qs.b.exp under lock - warn if callback enqueued on offline CPU Torture-test updates: - add rcutorture.preempt_duration kernel module parameter - make the TREE03 scenario do preemption - improve pooling timeouts for rcu_torture_writer() - improve output of "Failure/close-call rcutorture reader segments" - add some reader-state debugging checks - update doc of polled APIs - add extra diagnostics for per-reader-segment preemption - add an extra test for sched_clock() - improve testing on unresponsive systems SRCU updates: - improve doc for srcu_read_lock() in terms of return value - fix typo in comments - remove redundant GP sequence checks in the srcu_funnel_gp_start" * tag 'rcu.release.v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux: (31 commits) srcu: Remove redundant GP sequence checks in srcu_funnel_gp_start srcu: Fix typo s/srcu_check_read_flavor()/__srcu_check_read_flavor()/ srcu: Guarantee non-negative return value from srcu_read_lock() MAINTAINERS: Update RCU git tree rcu: Add lockdep_assert_irqs_disabled() to rcu_exp_need_qs() rcu: Add KCSAN exclusive-writer assertions for rdp->cpu_no_qs.b.exp rcu: Make preemptible rcu_exp_handler() check idempotency rcu: Replace open-coded rcu_exp_need_qs() from rcu_exp_handler() with call rcu: Move rcu_report_exp_rdp() setting of ->cpu_no_qs.b.exp under lock rcu: Make rcu_report_exp_cpu_mult() caller acquire lock rcu: Report callbacks enqueued on offline CPU blind spot rcutorture: Use symbols for SRCU reader flavors rcutorture: Add per-reader-segment preemption diagnostics rcutorture: Read CPU ID for decoration protected by both reader types rcutorture: Add preempt_count() to rcutorture_one_extend_check() diagnostics rcutorture: Add parameters to control polled/conditional wait interval rcutorture: Add documentation for recent conditional and polled APIs rcutorture: Ignore attempts to test preemption and forward progress rcutorture: Make rcutorture_one_extend() check reader state rcutorture: Pretty-print rcutorture reader segments ...
2 parents ad37df3 + 4b5c220 commit 9f3ee94

File tree

17 files changed

+465
-101
lines changed

17 files changed

+465
-101
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5524,7 +5524,42 @@
55245524

55255525
rcutorture.gp_cond= [KNL]
55265526
Use conditional/asynchronous update-side
5527-
primitives, if available.
5527+
normal-grace-period primitives, if available.
5528+
5529+
rcutorture.gp_cond_exp= [KNL]
5530+
Use conditional/asynchronous update-side
5531+
expedited-grace-period primitives, if available.
5532+
5533+
rcutorture.gp_cond_full= [KNL]
5534+
Use conditional/asynchronous update-side
5535+
normal-grace-period primitives that also take
5536+
concurrent expedited grace periods into account,
5537+
if available.
5538+
5539+
rcutorture.gp_cond_exp_full= [KNL]
5540+
Use conditional/asynchronous update-side
5541+
expedited-grace-period primitives that also take
5542+
concurrent normal grace periods into account,
5543+
if available.
5544+
5545+
rcutorture.gp_cond_wi= [KNL]
5546+
Nominal wait interval for normal conditional
5547+
grace periods (specified by rcutorture's
5548+
gp_cond and gp_cond_full module parameters),
5549+
in microseconds. The actual wait interval will
5550+
be randomly selected to nanosecond granularity up
5551+
to this wait interval. Defaults to 16 jiffies,
5552+
for example, 16,000 microseconds on a system
5553+
with HZ=1000.
5554+
5555+
rcutorture.gp_cond_wi_exp= [KNL]
5556+
Nominal wait interval for expedited conditional
5557+
grace periods (specified by rcutorture's
5558+
gp_cond_exp and gp_cond_exp_full module
5559+
parameters), in microseconds. The actual wait
5560+
interval will be randomly selected to nanosecond
5561+
granularity up to this wait interval. Defaults to
5562+
128 microseconds.
55285563

55295564
rcutorture.gp_exp= [KNL]
55305565
Use expedited update-side primitives, if available.
@@ -5533,6 +5568,43 @@
55335568
Use normal (non-expedited) asynchronous
55345569
update-side primitives, if available.
55355570

5571+
rcutorture.gp_poll= [KNL]
5572+
Use polled update-side normal-grace-period
5573+
primitives, if available.
5574+
5575+
rcutorture.gp_poll_exp= [KNL]
5576+
Use polled update-side expedited-grace-period
5577+
primitives, if available.
5578+
5579+
rcutorture.gp_poll_full= [KNL]
5580+
Use polled update-side normal-grace-period
5581+
primitives that also take concurrent expedited
5582+
grace periods into account, if available.
5583+
5584+
rcutorture.gp_poll_exp_full= [KNL]
5585+
Use polled update-side expedited-grace-period
5586+
primitives that also take concurrent normal
5587+
grace periods into account, if available.
5588+
5589+
rcutorture.gp_poll_wi= [KNL]
5590+
Nominal wait interval for normal conditional
5591+
grace periods (specified by rcutorture's
5592+
gp_poll and gp_poll_full module parameters),
5593+
in microseconds. The actual wait interval will
5594+
be randomly selected to nanosecond granularity up
5595+
to this wait interval. Defaults to 16 jiffies,
5596+
for example, 16,000 microseconds on a system
5597+
with HZ=1000.
5598+
5599+
rcutorture.gp_poll_wi_exp= [KNL]
5600+
Nominal wait interval for expedited conditional
5601+
grace periods (specified by rcutorture's
5602+
gp_poll_exp and gp_poll_exp_full module
5603+
parameters), in microseconds. The actual wait
5604+
interval will be randomly selected to nanosecond
5605+
granularity up to this wait interval. Defaults to
5606+
128 microseconds.
5607+
55365608
rcutorture.gp_sync= [KNL]
55375609
Use normal (non-expedited) synchronous
55385610
update-side primitives, if available. If all
@@ -5586,6 +5658,22 @@
55865658
Set time (jiffies) between CPU-hotplug operations,
55875659
or zero to disable CPU-hotplug testing.
55885660

5661+
rcutorture.preempt_duration= [KNL]
5662+
Set duration (in milliseconds) of preemptions
5663+
by a high-priority FIFO real-time task. Set to
5664+
zero (the default) to disable. The CPUs to
5665+
preempt are selected randomly from the set that
5666+
are online at a given point in time. Races with
5667+
CPUs going offline are ignored, with that attempt
5668+
at preemption skipped.
5669+
5670+
rcutorture.preempt_interval= [KNL]
5671+
Set interval (in milliseconds, defaulting to one
5672+
second) between preemptions by a high-priority
5673+
FIFO real-time task. This delay is mediated
5674+
by an hrtimer and is further fuzzed to avoid
5675+
inadvertent synchronizations.
5676+
55895677
rcutorture.read_exit_burst= [KNL]
55905678
The number of times in a given read-then-exit
55915679
episode that a set of read-then-exit kthreads

MAINTAINERS

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13315,7 +13315,7 @@ L: [email protected]
1331513315
1331613316
1331713317
S: Supported
13318-
T: git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
13318+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git rcu/dev
1331913319
F: Documentation/atomic_bitops.txt
1332013320
F: Documentation/atomic_t.txt
1332113321
F: Documentation/core-api/refcount-vs-atomic.rst
@@ -19629,7 +19629,7 @@ R: Mathieu Desnoyers <[email protected]>
1962919629
R: Lai Jiangshan <[email protected]>
1963019630
1963119631
S: Supported
19632-
T: git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
19632+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git rcu/dev
1963319633
F: tools/testing/selftests/rcutorture
1963419634

1963519635
RDACM20 Camera Sensor
@@ -19708,7 +19708,7 @@ R: Zqiang <[email protected]>
1970819708
1970919709
S: Supported
1971019710
W: http://www.rdrop.com/users/paulmck/RCU/
19711-
T: git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
19711+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git rcu/dev
1971219712
F: Documentation/RCU/
1971319713
F: include/linux/rcu*
1971419714
F: kernel/rcu/
@@ -21606,7 +21606,7 @@ R: Mathieu Desnoyers <[email protected]>
2160621606
2160721607
S: Supported
2160821608
W: http://www.rdrop.com/users/paulmck/RCU/
21609-
T: git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
21609+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git rcu/dev
2161021610
F: include/linux/srcu*.h
2161121611
F: kernel/rcu/srcu*.c
2161221612

@@ -23731,7 +23731,7 @@ M: "Paul E. McKenney" <[email protected]>
2373123731
M: Josh Triplett <[email protected]>
2373223732
2373323733
S: Supported
23734-
T: git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
23734+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git rcu/dev
2373523735
F: Documentation/RCU/torture.rst
2373623736
F: kernel/locking/locktorture.c
2373723737
F: kernel/rcu/rcuscale.c

include/linux/rcupdate_wait.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,15 @@ static inline void cond_resched_rcu(void)
6565
#endif
6666
}
6767

68+
// Has the current task blocked within its current RCU read-side
69+
// critical section?
70+
static inline bool has_rcu_reader_blocked(void)
71+
{
72+
#ifdef CONFIG_PREEMPT_RCU
73+
return !list_empty(&current->rcu_node_entry);
74+
#else
75+
return false;
76+
#endif
77+
}
78+
6879
#endif /* _LINUX_SCHED_RCUPDATE_WAIT_H */

include/linux/srcu.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ int init_srcu_struct(struct srcu_struct *ssp);
4343
#define __SRCU_DEP_MAP_INIT(srcu_name)
4444
#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
4545

46+
/* Values for SRCU Tree srcu_data ->srcu_reader_flavor, but also used by rcutorture. */
47+
#define SRCU_READ_FLAVOR_NORMAL 0x1 // srcu_read_lock().
48+
#define SRCU_READ_FLAVOR_NMI 0x2 // srcu_read_lock_nmisafe().
49+
#define SRCU_READ_FLAVOR_LITE 0x4 // srcu_read_lock_lite().
50+
#define SRCU_READ_FLAVOR_ALL 0x7 // All of the above.
51+
4652
#ifdef CONFIG_TINY_SRCU
4753
#include <linux/srcutiny.h>
4854
#elif defined(CONFIG_TREE_SRCU)
@@ -232,13 +238,14 @@ static inline int srcu_read_lock_held(const struct srcu_struct *ssp)
232238
* a mutex that is held elsewhere while calling synchronize_srcu() or
233239
* synchronize_srcu_expedited().
234240
*
235-
* The return value from srcu_read_lock() must be passed unaltered
236-
* to the matching srcu_read_unlock(). Note that srcu_read_lock() and
237-
* the matching srcu_read_unlock() must occur in the same context, for
238-
* example, it is illegal to invoke srcu_read_unlock() in an irq handler
239-
* if the matching srcu_read_lock() was invoked in process context. Or,
240-
* for that matter to invoke srcu_read_unlock() from one task and the
241-
* matching srcu_read_lock() from another.
241+
* The return value from srcu_read_lock() is guaranteed to be
242+
* non-negative. This value must be passed unaltered to the matching
243+
* srcu_read_unlock(). Note that srcu_read_lock() and the matching
244+
* srcu_read_unlock() must occur in the same context, for example, it is
245+
* illegal to invoke srcu_read_unlock() in an irq handler if the matching
246+
* srcu_read_lock() was invoked in process context. Or, for that matter to
247+
* invoke srcu_read_unlock() from one task and the matching srcu_read_lock()
248+
* from another.
242249
*/
243250
static inline int srcu_read_lock(struct srcu_struct *ssp) __acquires(ssp)
244251
{

include/linux/srcutree.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct srcu_data {
2626
atomic_long_t srcu_lock_count[2]; /* Locks per CPU. */
2727
atomic_long_t srcu_unlock_count[2]; /* Unlocks per CPU. */
2828
int srcu_reader_flavor; /* Reader flavor for srcu_struct structure? */
29+
/* Values: SRCU_READ_FLAVOR_.* */
2930

3031
/* Update-side state. */
3132
spinlock_t __private lock ____cacheline_internodealigned_in_smp;
@@ -43,11 +44,6 @@ struct srcu_data {
4344
struct srcu_struct *ssp;
4445
};
4546

46-
/* Values for ->srcu_reader_flavor. */
47-
#define SRCU_READ_FLAVOR_NORMAL 0x1 // srcu_read_lock().
48-
#define SRCU_READ_FLAVOR_NMI 0x2 // srcu_read_lock_nmisafe().
49-
#define SRCU_READ_FLAVOR_LITE 0x4 // srcu_read_lock_lite().
50-
5147
/*
5248
* Node in SRCU combining tree, similar in function to rcu_data.
5349
*/
@@ -258,7 +254,7 @@ static inline void srcu_check_read_flavor_lite(struct srcu_struct *ssp)
258254
if (likely(READ_ONCE(sdp->srcu_reader_flavor) & SRCU_READ_FLAVOR_LITE))
259255
return;
260256

261-
// Note that the cmpxchg() in srcu_check_read_flavor() is fully ordered.
257+
// Note that the cmpxchg() in __srcu_check_read_flavor() is fully ordered.
262258
__srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_LITE);
263259
}
264260

include/linux/torture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void _torture_stop_kthread(char *m, struct task_struct **tp);
130130
#endif
131131

132132
#if IS_ENABLED(CONFIG_RCU_TORTURE_TEST) || IS_MODULE(CONFIG_RCU_TORTURE_TEST) || IS_ENABLED(CONFIG_LOCK_TORTURE_TEST) || IS_MODULE(CONFIG_LOCK_TORTURE_TEST)
133-
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask);
133+
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask, bool dowarn);
134134
#endif
135135

136136
#endif /* __LINUX_TORTURE_H */

kernel/locking/locktorture.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static const struct kernel_param_ops lt_bind_ops = {
106106
module_param_cb(bind_readers, &lt_bind_ops, &bind_readers, 0644);
107107
module_param_cb(bind_writers, &lt_bind_ops, &bind_writers, 0644);
108108

109-
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask);
109+
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask, bool dowarn);
110110

111111
static struct task_struct *stats_task;
112112
static struct task_struct **writer_tasks;
@@ -1358,7 +1358,7 @@ static int __init lock_torture_init(void)
13581358
if (torture_init_error(firsterr))
13591359
goto unwind;
13601360
if (cpumask_nonempty(bind_writers))
1361-
torture_sched_setaffinity(writer_tasks[i]->pid, bind_writers);
1361+
torture_sched_setaffinity(writer_tasks[i]->pid, bind_writers, true);
13621362

13631363
create_reader:
13641364
if (cxt.cur_ops->readlock == NULL || (j >= cxt.nrealreaders_stress))
@@ -1369,7 +1369,7 @@ static int __init lock_torture_init(void)
13691369
if (torture_init_error(firsterr))
13701370
goto unwind;
13711371
if (cpumask_nonempty(bind_readers))
1372-
torture_sched_setaffinity(reader_tasks[j]->pid, bind_readers);
1372+
torture_sched_setaffinity(reader_tasks[j]->pid, bind_readers, true);
13731373
}
13741374
if (stat_interval > 0) {
13751375
firsterr = torture_create_kthread(lock_torture_stats, NULL,

kernel/rcu/Kconfig.debug

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,37 @@ config RCU_TORTURE_TEST
5353
Say M if you want the RCU torture tests to build as a module.
5454
Say N if you are unsure.
5555

56+
config RCU_TORTURE_TEST_CHK_RDR_STATE
57+
tristate "Check rcutorture reader state"
58+
depends on RCU_TORTURE_TEST
59+
default n
60+
help
61+
This option causes rcutorture to check the desired rcutorture
62+
reader state for each segment against the actual context.
63+
Note that PREEMPT_COUNT must be enabled if the preempt-disabled
64+
and bh-disabled checks are to take effect, and that PREEMPT_RCU
65+
must be enabled for the RCU-nesting checks to take effect.
66+
These checks add overhead, and this Kconfig options is therefore
67+
disabled by default.
68+
69+
Say Y here if you want rcutorture reader contexts checked.
70+
Say N if you are unsure.
71+
72+
config RCU_TORTURE_TEST_LOG_CPU
73+
tristate "Log CPU for rcutorture failures"
74+
depends on RCU_TORTURE_TEST
75+
default n
76+
help
77+
This option causes rcutorture to decorate each entry of its
78+
log of failure/close-call rcutorture reader segments with the
79+
number of the CPU that the reader was running on at the time.
80+
This information can be useful, but it does incur additional
81+
overhead, overhead that can make both failures and close calls
82+
less probable.
83+
84+
Say Y here if you want CPU IDs logged.
85+
Say N if you are unsure.
86+
5687
config RCU_REF_SCALE_TEST
5788
tristate "Scalability tests for read-side synchronization (RCU and others)"
5889
depends on DEBUG_KERNEL

0 commit comments

Comments
 (0)