Skip to content

Commit 4b5c220

Browse files
committed
Merge branches 'fixes.2024.12.14a', 'rcutorture.2024.12.14a', 'srcu.2024.12.14a' and 'torture-test.2024.12.14a' into rcu-merge.2024.12.14a
fixes.2024.12.14a: RCU fixes rcutorture.2024.12.14a: Torture-test updates srcu.2024.12.14a: SRCU updates torture-test.2024.12.14a: Adding an extra test, fixes
4 parents 8f6f163 + 0fef924 + 45c7c67 + 6ca774f commit 4b5c220

File tree

13 files changed

+410
-70
lines changed

13 files changed

+410
-70
lines changed

Documentation/admin-guide/kernel-parameters.txt

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

53635363
rcutorture.gp_cond= [KNL]
53645364
Use conditional/asynchronous update-side
5365-
primitives, if available.
5365+
normal-grace-period primitives, if available.
5366+
5367+
rcutorture.gp_cond_exp= [KNL]
5368+
Use conditional/asynchronous update-side
5369+
expedited-grace-period primitives, if available.
5370+
5371+
rcutorture.gp_cond_full= [KNL]
5372+
Use conditional/asynchronous update-side
5373+
normal-grace-period primitives that also take
5374+
concurrent expedited grace periods into account,
5375+
if available.
5376+
5377+
rcutorture.gp_cond_exp_full= [KNL]
5378+
Use conditional/asynchronous update-side
5379+
expedited-grace-period primitives that also take
5380+
concurrent normal grace periods into account,
5381+
if available.
5382+
5383+
rcutorture.gp_cond_wi= [KNL]
5384+
Nominal wait interval for normal conditional
5385+
grace periods (specified by rcutorture's
5386+
gp_cond and gp_cond_full module parameters),
5387+
in microseconds. The actual wait interval will
5388+
be randomly selected to nanosecond granularity up
5389+
to this wait interval. Defaults to 16 jiffies,
5390+
for example, 16,000 microseconds on a system
5391+
with HZ=1000.
5392+
5393+
rcutorture.gp_cond_wi_exp= [KNL]
5394+
Nominal wait interval for expedited conditional
5395+
grace periods (specified by rcutorture's
5396+
gp_cond_exp and gp_cond_exp_full module
5397+
parameters), in microseconds. The actual wait
5398+
interval will be randomly selected to nanosecond
5399+
granularity up to this wait interval. Defaults to
5400+
128 microseconds.
53665401

53675402
rcutorture.gp_exp= [KNL]
53685403
Use expedited update-side primitives, if available.
@@ -5371,6 +5406,43 @@
53715406
Use normal (non-expedited) asynchronous
53725407
update-side primitives, if available.
53735408

5409+
rcutorture.gp_poll= [KNL]
5410+
Use polled update-side normal-grace-period
5411+
primitives, if available.
5412+
5413+
rcutorture.gp_poll_exp= [KNL]
5414+
Use polled update-side expedited-grace-period
5415+
primitives, if available.
5416+
5417+
rcutorture.gp_poll_full= [KNL]
5418+
Use polled update-side normal-grace-period
5419+
primitives that also take concurrent expedited
5420+
grace periods into account, if available.
5421+
5422+
rcutorture.gp_poll_exp_full= [KNL]
5423+
Use polled update-side expedited-grace-period
5424+
primitives that also take concurrent normal
5425+
grace periods into account, if available.
5426+
5427+
rcutorture.gp_poll_wi= [KNL]
5428+
Nominal wait interval for normal conditional
5429+
grace periods (specified by rcutorture's
5430+
gp_poll and gp_poll_full module parameters),
5431+
in microseconds. The actual wait interval will
5432+
be randomly selected to nanosecond granularity up
5433+
to this wait interval. Defaults to 16 jiffies,
5434+
for example, 16,000 microseconds on a system
5435+
with HZ=1000.
5436+
5437+
rcutorture.gp_poll_wi_exp= [KNL]
5438+
Nominal wait interval for expedited conditional
5439+
grace periods (specified by rcutorture's
5440+
gp_poll_exp and gp_poll_exp_full module
5441+
parameters), in microseconds. The actual wait
5442+
interval will be randomly selected to nanosecond
5443+
granularity up to this wait interval. Defaults to
5444+
128 microseconds.
5445+
53745446
rcutorture.gp_sync= [KNL]
53755447
Use normal (non-expedited) synchronous
53765448
update-side primitives, if available. If all
@@ -5424,6 +5496,22 @@
54245496
Set time (jiffies) between CPU-hotplug operations,
54255497
or zero to disable CPU-hotplug testing.
54265498

5499+
rcutorture.preempt_duration= [KNL]
5500+
Set duration (in milliseconds) of preemptions
5501+
by a high-priority FIFO real-time task. Set to
5502+
zero (the default) to disable. The CPUs to
5503+
preempt are selected randomly from the set that
5504+
are online at a given point in time. Races with
5505+
CPUs going offline are ignored, with that attempt
5506+
at preemption skipped.
5507+
5508+
rcutorture.preempt_interval= [KNL]
5509+
Set interval (in milliseconds, defaulting to one
5510+
second) between preemptions by a high-priority
5511+
FIFO real-time task. This delay is mediated
5512+
by an hrtimer and is further fuzzed to avoid
5513+
inadvertent synchronizations.
5514+
54275515
rcutorture.read_exit_burst= [KNL]
54285516
The number of times in a given read-then-exit
54295517
episode that a set of read-then-exit kthreads

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)