aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/torture.h2
-rw-r--r--kernel/locking/locktorture.c3
-rw-r--r--kernel/rcu/rcutorture.c3
-rw-r--r--kernel/torture.c13
4 files changed, 16 insertions, 5 deletions
diff --git a/include/linux/torture.h b/include/linux/torture.h
index b2e2b468e511..f998574247fd 100644
--- a/include/linux/torture.h
+++ b/include/linux/torture.h
@@ -81,7 +81,7 @@ void stutter_wait(const char *title);
81int torture_stutter_init(int s); 81int torture_stutter_init(int s);
82 82
83/* Initialization and cleanup. */ 83/* Initialization and cleanup. */
84void torture_init_begin(char *ttype, bool v, int *runnable); 84bool torture_init_begin(char *ttype, bool v, int *runnable);
85void torture_init_end(void); 85void torture_init_end(void);
86bool torture_cleanup(void); 86bool torture_cleanup(void);
87bool torture_must_stop(void); 87bool torture_must_stop(void);
diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index 1952466c7db5..dbafeac18e4d 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -355,7 +355,8 @@ static int __init lock_torture_init(void)
355 &lock_busted_ops, &spin_lock_ops, &spin_lock_irq_ops, 355 &lock_busted_ops, &spin_lock_ops, &spin_lock_irq_ops,
356 }; 356 };
357 357
358 torture_init_begin(torture_type, verbose, &locktorture_runnable); 358 if (!torture_init_begin(torture_type, verbose, &locktorture_runnable))
359 return -EBUSY;
359 360
360 /* Process args and tell the world that the torturer is on the job. */ 361 /* Process args and tell the world that the torturer is on the job. */
361 for (i = 0; i < ARRAY_SIZE(torture_ops); i++) { 362 for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 4b7b97ff1195..7fa34f86e5ba 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1536,7 +1536,8 @@ rcu_torture_init(void)
1536 &rcu_ops, &rcu_bh_ops, &rcu_busted_ops, &srcu_ops, &sched_ops, 1536 &rcu_ops, &rcu_bh_ops, &rcu_busted_ops, &srcu_ops, &sched_ops,
1537 }; 1537 };
1538 1538
1539 torture_init_begin(torture_type, verbose, &rcutorture_runnable); 1539 if (!torture_init_begin(torture_type, verbose, &rcutorture_runnable))
1540 return -EBUSY;
1540 1541
1541 /* Process args and tell the world that the torturer is on the job. */ 1542 /* Process args and tell the world that the torturer is on the job. */
1542 for (i = 0; i < ARRAY_SIZE(torture_ops); i++) { 1543 for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
diff --git a/kernel/torture.c b/kernel/torture.c
index ae1723a4c751..0ed0b49d2ce1 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -599,14 +599,20 @@ static void torture_stutter_cleanup(void)
599 * The runnable parameter points to a flag that controls whether or not 599 * The runnable parameter points to a flag that controls whether or not
600 * the test is currently runnable. If there is no such flag, pass in NULL. 600 * the test is currently runnable. If there is no such flag, pass in NULL.
601 */ 601 */
602void __init torture_init_begin(char *ttype, bool v, int *runnable) 602bool __init torture_init_begin(char *ttype, bool v, int *runnable)
603{ 603{
604 mutex_lock(&fullstop_mutex); 604 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 }
605 torture_type = ttype; 611 torture_type = ttype;
606 verbose = v; 612 verbose = v;
607 torture_runnable = runnable; 613 torture_runnable = runnable;
608 fullstop = FULLSTOP_DONTSTOP; 614 fullstop = FULLSTOP_DONTSTOP;
609 615 return true;
610} 616}
611EXPORT_SYMBOL_GPL(torture_init_begin); 617EXPORT_SYMBOL_GPL(torture_init_begin);
612 618
@@ -645,6 +651,9 @@ bool torture_cleanup(void)
645 torture_shuffle_cleanup(); 651 torture_shuffle_cleanup();
646 torture_stutter_cleanup(); 652 torture_stutter_cleanup();
647 torture_onoff_cleanup(); 653 torture_onoff_cleanup();
654 mutex_lock(&fullstop_mutex);
655 torture_type = NULL;
656 mutex_unlock(&fullstop_mutex);
648 return false; 657 return false;
649} 658}
650EXPORT_SYMBOL_GPL(torture_cleanup); 659EXPORT_SYMBOL_GPL(torture_cleanup);