Skip to content

Commit efeff6b

Browse files
committed
rcutorture: Warn on individual rcu_torture_init() error conditions
When running rcutorture as a module, any rcu_torture_init() issues will be reflected in the error code from modprobe or insmod, as the case may be. However, these error codes are not available when running rcutorture built-in, for example, when using the kvm.sh script. This commit therefore adds WARN_ON_ONCE() to allow distinguishing rcu_torture_init() errors when running rcutorture built-in. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent fda8486 commit efeff6b

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

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/rcu/rcutorture.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,7 +3037,7 @@ rcu_torture_init(void)
30373037
rcu_torture_write_types();
30383038
firsterr = torture_create_kthread(rcu_torture_writer, NULL,
30393039
writer_task);
3040-
if (firsterr)
3040+
if (torture_init_error(firsterr))
30413041
goto unwind;
30423042
if (nfakewriters > 0) {
30433043
fakewriter_tasks = kcalloc(nfakewriters,
@@ -3052,7 +3052,7 @@ rcu_torture_init(void)
30523052
for (i = 0; i < nfakewriters; i++) {
30533053
firsterr = torture_create_kthread(rcu_torture_fakewriter,
30543054
NULL, fakewriter_tasks[i]);
3055-
if (firsterr)
3055+
if (torture_init_error(firsterr))
30563056
goto unwind;
30573057
}
30583058
reader_tasks = kcalloc(nrealreaders, sizeof(reader_tasks[0]),
@@ -3068,7 +3068,7 @@ rcu_torture_init(void)
30683068
rcu_torture_reader_mbchk[i].rtc_chkrdr = -1;
30693069
firsterr = torture_create_kthread(rcu_torture_reader, (void *)i,
30703070
reader_tasks[i]);
3071-
if (firsterr)
3071+
if (torture_init_error(firsterr))
30723072
goto unwind;
30733073
}
30743074
nrealnocbers = nocbs_nthreads;
@@ -3088,18 +3088,18 @@ rcu_torture_init(void)
30883088
}
30893089
for (i = 0; i < nrealnocbers; i++) {
30903090
firsterr = torture_create_kthread(rcu_nocb_toggle, NULL, nocb_tasks[i]);
3091-
if (firsterr)
3091+
if (torture_init_error(firsterr))
30923092
goto unwind;
30933093
}
30943094
if (stat_interval > 0) {
30953095
firsterr = torture_create_kthread(rcu_torture_stats, NULL,
30963096
stats_task);
3097-
if (firsterr)
3097+
if (torture_init_error(firsterr))
30983098
goto unwind;
30993099
}
31003100
if (test_no_idle_hz && shuffle_interval > 0) {
31013101
firsterr = torture_shuffle_init(shuffle_interval * HZ);
3102-
if (firsterr)
3102+
if (torture_init_error(firsterr))
31033103
goto unwind;
31043104
}
31053105
if (stutter < 0)
@@ -3109,7 +3109,7 @@ rcu_torture_init(void)
31093109

31103110
t = cur_ops->stall_dur ? cur_ops->stall_dur() : stutter * HZ;
31113111
firsterr = torture_stutter_init(stutter * HZ, t);
3112-
if (firsterr)
3112+
if (torture_init_error(firsterr))
31133113
goto unwind;
31143114
}
31153115
if (fqs_duration < 0)
@@ -3118,7 +3118,7 @@ rcu_torture_init(void)
31183118
/* Create the fqs thread */
31193119
firsterr = torture_create_kthread(rcu_torture_fqs, NULL,
31203120
fqs_task);
3121-
if (firsterr)
3121+
if (torture_init_error(firsterr))
31223122
goto unwind;
31233123
}
31243124
if (test_boost_interval < 1)
@@ -3132,7 +3132,7 @@ rcu_torture_init(void)
31323132
firsterr = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "RCU_TORTURE",
31333133
rcutorture_booster_init,
31343134
rcutorture_booster_cleanup);
3135-
if (firsterr < 0)
3135+
if (torture_init_error(firsterr))
31363136
goto unwind;
31373137
rcutor_hp = firsterr;
31383138

@@ -3153,23 +3153,23 @@ rcu_torture_init(void)
31533153
}
31543154
shutdown_jiffies = jiffies + shutdown_secs * HZ;
31553155
firsterr = torture_shutdown_init(shutdown_secs, rcu_torture_cleanup);
3156-
if (firsterr)
3156+
if (torture_init_error(firsterr))
31573157
goto unwind;
31583158
firsterr = torture_onoff_init(onoff_holdoff * HZ, onoff_interval,
31593159
rcutorture_sync);
3160-
if (firsterr)
3160+
if (torture_init_error(firsterr))
31613161
goto unwind;
31623162
firsterr = rcu_torture_stall_init();
3163-
if (firsterr)
3163+
if (torture_init_error(firsterr))
31643164
goto unwind;
31653165
firsterr = rcu_torture_fwd_prog_init();
3166-
if (firsterr)
3166+
if (torture_init_error(firsterr))
31673167
goto unwind;
31683168
firsterr = rcu_torture_barrier_init();
3169-
if (firsterr)
3169+
if (torture_init_error(firsterr))
31703170
goto unwind;
31713171
firsterr = rcu_torture_read_exit_init();
3172-
if (firsterr)
3172+
if (torture_init_error(firsterr))
31733173
goto unwind;
31743174
if (object_debug)
31753175
rcu_test_debug_objects();

0 commit comments

Comments
 (0)