Skip to content

Commit 5228084

Browse files
committed
torture: Check for multiple concurrent torture tests
The torture tests are designed to run in isolation, but do not enforce this isolation. This commit therefore checks for concurrent torture tests, and refuses to start new tests while old tests are running. Signed-off-by: Paul E. McKenney <[email protected]> Reviewed-by: Josh Triplett <[email protected]>
1 parent d065eac commit 5228084

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

include/linux/torture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void stutter_wait(const char *title);
8181
int torture_stutter_init(int s);
8282

8383
/* Initialization and cleanup. */
84-
void torture_init_begin(char *ttype, bool v, int *runnable);
84+
bool torture_init_begin(char *ttype, bool v, int *runnable);
8585
void torture_init_end(void);
8686
bool torture_cleanup(void);
8787
bool torture_must_stop(void);

kernel/locking/locktorture.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ static int __init lock_torture_init(void)
355355
&lock_busted_ops, &spin_lock_ops, &spin_lock_irq_ops,
356356
};
357357

358-
torture_init_begin(torture_type, verbose, &locktorture_runnable);
358+
if (!torture_init_begin(torture_type, verbose, &locktorture_runnable))
359+
return -EBUSY;
359360

360361
/* Process args and tell the world that the torturer is on the job. */
361362
for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {

kernel/rcu/rcutorture.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,8 @@ rcu_torture_init(void)
15361536
&rcu_ops, &rcu_bh_ops, &rcu_busted_ops, &srcu_ops, &sched_ops,
15371537
};
15381538

1539-
torture_init_begin(torture_type, verbose, &rcutorture_runnable);
1539+
if (!torture_init_begin(torture_type, verbose, &rcutorture_runnable))
1540+
return -EBUSY;
15401541

15411542
/* Process args and tell the world that the torturer is on the job. */
15421543
for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {

kernel/torture.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,14 +599,20 @@ static void torture_stutter_cleanup(void)
599599
* The runnable parameter points to a flag that controls whether or not
600600
* the test is currently runnable. If there is no such flag, pass in NULL.
601601
*/
602-
void __init torture_init_begin(char *ttype, bool v, int *runnable)
602+
bool __init torture_init_begin(char *ttype, bool v, int *runnable)
603603
{
604604
mutex_lock(&fullstop_mutex);
605+
if (torture_type != NULL) {
606+
pr_alert("torture_init_begin: refusing %s init: %s running",
607+
ttype, torture_type);
608+
mutex_unlock(&fullstop_mutex);
609+
return false;
610+
}
605611
torture_type = ttype;
606612
verbose = v;
607613
torture_runnable = runnable;
608614
fullstop = FULLSTOP_DONTSTOP;
609-
615+
return true;
610616
}
611617
EXPORT_SYMBOL_GPL(torture_init_begin);
612618

@@ -645,6 +651,9 @@ bool torture_cleanup(void)
645651
torture_shuffle_cleanup();
646652
torture_stutter_cleanup();
647653
torture_onoff_cleanup();
654+
mutex_lock(&fullstop_mutex);
655+
torture_type = NULL;
656+
mutex_unlock(&fullstop_mutex);
648657
return false;
649658
}
650659
EXPORT_SYMBOL_GPL(torture_cleanup);

0 commit comments

Comments
 (0)