Skip to content

Commit dd1277d

Browse files
committed
Merge branches 'fixes.2021.10.07a', 'scftorture.2021.09.16a', 'tasks.2021.09.15a', 'torture.2021.09.13b' and 'torturescript.2021.09.16a' into HEAD
fixes.2021.10.07a: Miscellaneous fixes. scftorture.2021.09.16a: smp_call_function torture-test updates. tasks.2021.09.15a: Tasks-trace RCU updates. torture.2021.09.13b: Other torture-test updates. torturescript.2021.09.16a: Torture-test scripting updates.
5 parents 74aece7 + f2bdf7d + 8af9e2c + 71921a9 + faaaf2a commit dd1277d

File tree

12 files changed

+201
-126
lines changed

12 files changed

+201
-126
lines changed

include/linux/rcupdate_trace.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static inline int rcu_read_lock_trace_held(void)
3131

3232
#ifdef CONFIG_TASKS_TRACE_RCU
3333

34-
void rcu_read_unlock_trace_special(struct task_struct *t, int nesting);
34+
void rcu_read_unlock_trace_special(struct task_struct *t);
3535

3636
/**
3737
* rcu_read_lock_trace - mark beginning of RCU-trace read-side critical section
@@ -80,7 +80,8 @@ static inline void rcu_read_unlock_trace(void)
8080
WRITE_ONCE(t->trc_reader_nesting, nesting);
8181
return; // We assume shallow reader nesting.
8282
}
83-
rcu_read_unlock_trace_special(t, nesting);
83+
WARN_ON_ONCE(nesting != 0);
84+
rcu_read_unlock_trace_special(t);
8485
}
8586

8687
void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func);

include/linux/torture.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ do { \
4747
} while (0)
4848
void verbose_torout_sleep(void);
4949

50+
#define torture_init_error(firsterr) \
51+
({ \
52+
int ___firsterr = (firsterr); \
53+
\
54+
WARN_ONCE(!IS_MODULE(CONFIG_RCU_TORTURE_TEST) && ___firsterr < 0, "Torture-test initialization failed with error code %d\n", ___firsterr); \
55+
___firsterr < 0; \
56+
})
57+
5058
/* Definitions for online/offline exerciser. */
5159
#ifdef CONFIG_HOTPLUG_CPU
5260
int torture_num_online_cpus(void);

kernel/locking/locktorture.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,23 +1022,23 @@ static int __init lock_torture_init(void)
10221022
if (onoff_interval > 0) {
10231023
firsterr = torture_onoff_init(onoff_holdoff * HZ,
10241024
onoff_interval * HZ, NULL);
1025-
if (firsterr)
1025+
if (torture_init_error(firsterr))
10261026
goto unwind;
10271027
}
10281028
if (shuffle_interval > 0) {
10291029
firsterr = torture_shuffle_init(shuffle_interval);
1030-
if (firsterr)
1030+
if (torture_init_error(firsterr))
10311031
goto unwind;
10321032
}
10331033
if (shutdown_secs > 0) {
10341034
firsterr = torture_shutdown_init(shutdown_secs,
10351035
lock_torture_cleanup);
1036-
if (firsterr)
1036+
if (torture_init_error(firsterr))
10371037
goto unwind;
10381038
}
10391039
if (stutter > 0) {
10401040
firsterr = torture_stutter_init(stutter, stutter);
1041-
if (firsterr)
1041+
if (torture_init_error(firsterr))
10421042
goto unwind;
10431043
}
10441044

@@ -1082,7 +1082,7 @@ static int __init lock_torture_init(void)
10821082
/* Create writer. */
10831083
firsterr = torture_create_kthread(lock_torture_writer, &cxt.lwsa[i],
10841084
writer_tasks[i]);
1085-
if (firsterr)
1085+
if (torture_init_error(firsterr))
10861086
goto unwind;
10871087

10881088
create_reader:
@@ -1091,13 +1091,13 @@ static int __init lock_torture_init(void)
10911091
/* Create reader. */
10921092
firsterr = torture_create_kthread(lock_torture_reader, &cxt.lrsa[j],
10931093
reader_tasks[j]);
1094-
if (firsterr)
1094+
if (torture_init_error(firsterr))
10951095
goto unwind;
10961096
}
10971097
if (stat_interval > 0) {
10981098
firsterr = torture_create_kthread(lock_torture_stats, NULL,
10991099
stats_task);
1100-
if (firsterr)
1100+
if (torture_init_error(firsterr))
11011101
goto unwind;
11021102
}
11031103
torture_init_end();

kernel/rcu/rcuscale.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ kfree_scale_init(void)
758758
init_waitqueue_head(&shutdown_wq);
759759
firsterr = torture_create_kthread(kfree_scale_shutdown, NULL,
760760
shutdown_task);
761-
if (firsterr)
761+
if (torture_init_error(firsterr))
762762
goto unwind;
763763
schedule_timeout_uninterruptible(1);
764764
}
@@ -775,7 +775,7 @@ kfree_scale_init(void)
775775
for (i = 0; i < kfree_nrealthreads; i++) {
776776
firsterr = torture_create_kthread(kfree_scale_thread, (void *)i,
777777
kfree_reader_tasks[i]);
778-
if (firsterr)
778+
if (torture_init_error(firsterr))
779779
goto unwind;
780780
}
781781

@@ -838,7 +838,7 @@ rcu_scale_init(void)
838838
init_waitqueue_head(&shutdown_wq);
839839
firsterr = torture_create_kthread(rcu_scale_shutdown, NULL,
840840
shutdown_task);
841-
if (firsterr)
841+
if (torture_init_error(firsterr))
842842
goto unwind;
843843
schedule_timeout_uninterruptible(1);
844844
}
@@ -852,7 +852,7 @@ rcu_scale_init(void)
852852
for (i = 0; i < nrealreaders; i++) {
853853
firsterr = torture_create_kthread(rcu_scale_reader, (void *)i,
854854
reader_tasks[i]);
855-
if (firsterr)
855+
if (torture_init_error(firsterr))
856856
goto unwind;
857857
}
858858
while (atomic_read(&n_rcu_scale_reader_started) < nrealreaders)
@@ -879,7 +879,7 @@ rcu_scale_init(void)
879879
}
880880
firsterr = torture_create_kthread(rcu_scale_writer, (void *)i,
881881
writer_tasks[i]);
882-
if (firsterr)
882+
if (torture_init_error(firsterr))
883883
goto unwind;
884884
}
885885
torture_init_end();

kernel/rcu/rcutorture.c

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,28 +1432,34 @@ static void rcutorture_one_extend(int *readstate, int newstate,
14321432
/* First, put new protection in place to avoid critical-section gap. */
14331433
if (statesnew & RCUTORTURE_RDR_BH)
14341434
local_bh_disable();
1435+
if (statesnew & RCUTORTURE_RDR_RBH)
1436+
rcu_read_lock_bh();
14351437
if (statesnew & RCUTORTURE_RDR_IRQ)
14361438
local_irq_disable();
14371439
if (statesnew & RCUTORTURE_RDR_PREEMPT)
14381440
preempt_disable();
1439-
if (statesnew & RCUTORTURE_RDR_RBH)
1440-
rcu_read_lock_bh();
14411441
if (statesnew & RCUTORTURE_RDR_SCHED)
14421442
rcu_read_lock_sched();
14431443
if (statesnew & RCUTORTURE_RDR_RCU)
14441444
idxnew = cur_ops->readlock() << RCUTORTURE_RDR_SHIFT;
14451445

1446-
/* Next, remove old protection, irq first due to bh conflict. */
1446+
/*
1447+
* Next, remove old protection, in decreasing order of strength
1448+
* to avoid unlock paths that aren't safe in the stronger
1449+
* context. Namely: BH can not be enabled with disabled interrupts.
1450+
* Additionally PREEMPT_RT requires that BH is enabled in preemptible
1451+
* context.
1452+
*/
14471453
if (statesold & RCUTORTURE_RDR_IRQ)
14481454
local_irq_enable();
1449-
if (statesold & RCUTORTURE_RDR_BH)
1450-
local_bh_enable();
14511455
if (statesold & RCUTORTURE_RDR_PREEMPT)
14521456
preempt_enable();
1453-
if (statesold & RCUTORTURE_RDR_RBH)
1454-
rcu_read_unlock_bh();
14551457
if (statesold & RCUTORTURE_RDR_SCHED)
14561458
rcu_read_unlock_sched();
1459+
if (statesold & RCUTORTURE_RDR_BH)
1460+
local_bh_enable();
1461+
if (statesold & RCUTORTURE_RDR_RBH)
1462+
rcu_read_unlock_bh();
14571463
if (statesold & RCUTORTURE_RDR_RCU) {
14581464
bool lockit = !statesnew && !(torture_random(trsp) & 0xffff);
14591465

@@ -1496,18 +1502,36 @@ rcutorture_extend_mask(int oldmask, struct torture_random_state *trsp)
14961502
int mask = rcutorture_extend_mask_max();
14971503
unsigned long randmask1 = torture_random(trsp) >> 8;
14981504
unsigned long randmask2 = randmask1 >> 3;
1505+
unsigned long preempts = RCUTORTURE_RDR_PREEMPT | RCUTORTURE_RDR_SCHED;
1506+
unsigned long preempts_irq = preempts | RCUTORTURE_RDR_IRQ;
1507+
unsigned long bhs = RCUTORTURE_RDR_BH | RCUTORTURE_RDR_RBH;
14991508

15001509
WARN_ON_ONCE(mask >> RCUTORTURE_RDR_SHIFT);
15011510
/* Mostly only one bit (need preemption!), sometimes lots of bits. */
15021511
if (!(randmask1 & 0x7))
15031512
mask = mask & randmask2;
15041513
else
15051514
mask = mask & (1 << (randmask2 % RCUTORTURE_RDR_NBITS));
1506-
/* Can't enable bh w/irq disabled. */
1507-
if ((mask & RCUTORTURE_RDR_IRQ) &&
1508-
((!(mask & RCUTORTURE_RDR_BH) && (oldmask & RCUTORTURE_RDR_BH)) ||
1509-
(!(mask & RCUTORTURE_RDR_RBH) && (oldmask & RCUTORTURE_RDR_RBH))))
1510-
mask |= RCUTORTURE_RDR_BH | RCUTORTURE_RDR_RBH;
1515+
1516+
/*
1517+
* Can't enable bh w/irq disabled.
1518+
*/
1519+
if (mask & RCUTORTURE_RDR_IRQ)
1520+
mask |= oldmask & bhs;
1521+
1522+
/*
1523+
* Ideally these sequences would be detected in debug builds
1524+
* (regardless of RT), but until then don't stop testing
1525+
* them on non-RT.
1526+
*/
1527+
if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
1528+
/* Can't modify BH in atomic context */
1529+
if (oldmask & preempts_irq)
1530+
mask &= ~bhs;
1531+
if ((oldmask | mask) & preempts_irq)
1532+
mask |= oldmask & bhs;
1533+
}
1534+
15111535
return mask ?: RCUTORTURE_RDR_RCU;
15121536
}
15131537

@@ -2741,7 +2765,7 @@ static int rcu_torture_read_exit(void *unused)
27412765
static int rcu_torture_read_exit_init(void)
27422766
{
27432767
if (read_exit_burst <= 0)
2744-
return -EINVAL;
2768+
return 0;
27452769
init_waitqueue_head(&read_exit_wq);
27462770
read_exit_child_stop = false;
27472771
read_exit_child_stopped = false;
@@ -2819,7 +2843,7 @@ rcu_torture_cleanup(void)
28192843
rcutorture_seq_diff(gp_seq, start_gp_seq));
28202844
torture_stop_kthread(rcu_torture_stats, stats_task);
28212845
torture_stop_kthread(rcu_torture_fqs, fqs_task);
2822-
if (rcu_torture_can_boost())
2846+
if (rcu_torture_can_boost() && rcutor_hp >= 0)
28232847
cpuhp_remove_state(rcutor_hp);
28242848

28252849
/*
@@ -3037,7 +3061,7 @@ rcu_torture_init(void)
30373061
rcu_torture_write_types();
30383062
firsterr = torture_create_kthread(rcu_torture_writer, NULL,
30393063
writer_task);
3040-
if (firsterr)
3064+
if (torture_init_error(firsterr))
30413065
goto unwind;
30423066
if (nfakewriters > 0) {
30433067
fakewriter_tasks = kcalloc(nfakewriters,
@@ -3052,7 +3076,7 @@ rcu_torture_init(void)
30523076
for (i = 0; i < nfakewriters; i++) {
30533077
firsterr = torture_create_kthread(rcu_torture_fakewriter,
30543078
NULL, fakewriter_tasks[i]);
3055-
if (firsterr)
3079+
if (torture_init_error(firsterr))
30563080
goto unwind;
30573081
}
30583082
reader_tasks = kcalloc(nrealreaders, sizeof(reader_tasks[0]),
@@ -3068,7 +3092,7 @@ rcu_torture_init(void)
30683092
rcu_torture_reader_mbchk[i].rtc_chkrdr = -1;
30693093
firsterr = torture_create_kthread(rcu_torture_reader, (void *)i,
30703094
reader_tasks[i]);
3071-
if (firsterr)
3095+
if (torture_init_error(firsterr))
30723096
goto unwind;
30733097
}
30743098
nrealnocbers = nocbs_nthreads;
@@ -3088,18 +3112,18 @@ rcu_torture_init(void)
30883112
}
30893113
for (i = 0; i < nrealnocbers; i++) {
30903114
firsterr = torture_create_kthread(rcu_nocb_toggle, NULL, nocb_tasks[i]);
3091-
if (firsterr)
3115+
if (torture_init_error(firsterr))
30923116
goto unwind;
30933117
}
30943118
if (stat_interval > 0) {
30953119
firsterr = torture_create_kthread(rcu_torture_stats, NULL,
30963120
stats_task);
3097-
if (firsterr)
3121+
if (torture_init_error(firsterr))
30983122
goto unwind;
30993123
}
31003124
if (test_no_idle_hz && shuffle_interval > 0) {
31013125
firsterr = torture_shuffle_init(shuffle_interval * HZ);
3102-
if (firsterr)
3126+
if (torture_init_error(firsterr))
31033127
goto unwind;
31043128
}
31053129
if (stutter < 0)
@@ -3109,7 +3133,7 @@ rcu_torture_init(void)
31093133

31103134
t = cur_ops->stall_dur ? cur_ops->stall_dur() : stutter * HZ;
31113135
firsterr = torture_stutter_init(stutter * HZ, t);
3112-
if (firsterr)
3136+
if (torture_init_error(firsterr))
31133137
goto unwind;
31143138
}
31153139
if (fqs_duration < 0)
@@ -3118,7 +3142,7 @@ rcu_torture_init(void)
31183142
/* Create the fqs thread */
31193143
firsterr = torture_create_kthread(rcu_torture_fqs, NULL,
31203144
fqs_task);
3121-
if (firsterr)
3145+
if (torture_init_error(firsterr))
31223146
goto unwind;
31233147
}
31243148
if (test_boost_interval < 1)
@@ -3132,9 +3156,9 @@ rcu_torture_init(void)
31323156
firsterr = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "RCU_TORTURE",
31333157
rcutorture_booster_init,
31343158
rcutorture_booster_cleanup);
3135-
if (firsterr < 0)
3136-
goto unwind;
31373159
rcutor_hp = firsterr;
3160+
if (torture_init_error(firsterr))
3161+
goto unwind;
31383162

31393163
// Testing RCU priority boosting requires rcutorture do
31403164
// some serious abuse. Counter this by running ksoftirqd
@@ -3153,23 +3177,23 @@ rcu_torture_init(void)
31533177
}
31543178
shutdown_jiffies = jiffies + shutdown_secs * HZ;
31553179
firsterr = torture_shutdown_init(shutdown_secs, rcu_torture_cleanup);
3156-
if (firsterr)
3180+
if (torture_init_error(firsterr))
31573181
goto unwind;
31583182
firsterr = torture_onoff_init(onoff_holdoff * HZ, onoff_interval,
31593183
rcutorture_sync);
3160-
if (firsterr)
3184+
if (torture_init_error(firsterr))
31613185
goto unwind;
31623186
firsterr = rcu_torture_stall_init();
3163-
if (firsterr)
3187+
if (torture_init_error(firsterr))
31643188
goto unwind;
31653189
firsterr = rcu_torture_fwd_prog_init();
3166-
if (firsterr)
3190+
if (torture_init_error(firsterr))
31673191
goto unwind;
31683192
firsterr = rcu_torture_barrier_init();
3169-
if (firsterr)
3193+
if (torture_init_error(firsterr))
31703194
goto unwind;
31713195
firsterr = rcu_torture_read_exit_init();
3172-
if (firsterr)
3196+
if (torture_init_error(firsterr))
31733197
goto unwind;
31743198
if (object_debug)
31753199
rcu_test_debug_objects();

kernel/rcu/refscale.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ ref_scale_init(void)
824824
init_waitqueue_head(&shutdown_wq);
825825
firsterr = torture_create_kthread(ref_scale_shutdown, NULL,
826826
shutdown_task);
827-
if (firsterr)
827+
if (torture_init_error(firsterr))
828828
goto unwind;
829829
schedule_timeout_uninterruptible(1);
830830
}
@@ -851,7 +851,7 @@ ref_scale_init(void)
851851
for (i = 0; i < nreaders; i++) {
852852
firsterr = torture_create_kthread(ref_scale_reader, (void *)i,
853853
reader_tasks[i].task);
854-
if (firsterr)
854+
if (torture_init_error(firsterr))
855855
goto unwind;
856856

857857
init_waitqueue_head(&(reader_tasks[i].wq));
@@ -860,7 +860,7 @@ ref_scale_init(void)
860860
// Main Task
861861
init_waitqueue_head(&main_wq);
862862
firsterr = torture_create_kthread(main_func, NULL, main_task);
863-
if (firsterr)
863+
if (torture_init_error(firsterr))
864864
goto unwind;
865865

866866
torture_init_end();

0 commit comments

Comments
 (0)