torture: Check for multiple concurrent torture tests
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Mon, 7 Apr 2014 16:14:11 +0000 (09:14 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Wed, 14 May 2014 16:46:29 +0000 (09:46 -0700)
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 <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
include/linux/torture.h
kernel/locking/locktorture.c
kernel/rcu/rcutorture.c
kernel/torture.c

index b2e2b468e511d43949c5cee31b5e23a06ab433e7..f998574247fd317d3a97c448f063415c0c18e86f 100644 (file)
@@ -81,7 +81,7 @@ void stutter_wait(const char *title);
 int torture_stutter_init(int s);
 
 /* Initialization and cleanup. */
-void torture_init_begin(char *ttype, bool v, int *runnable);
+bool torture_init_begin(char *ttype, bool v, int *runnable);
 void torture_init_end(void);
 bool torture_cleanup(void);
 bool torture_must_stop(void);
index 1952466c7db5f338c7fc51793bee4b8f490f22a7..dbafeac18e4d58b2da77988ff939e8db2e860d0e 100644 (file)
@@ -355,7 +355,8 @@ static int __init lock_torture_init(void)
                &lock_busted_ops, &spin_lock_ops, &spin_lock_irq_ops,
        };
 
-       torture_init_begin(torture_type, verbose, &locktorture_runnable);
+       if (!torture_init_begin(torture_type, verbose, &locktorture_runnable))
+               return -EBUSY;
 
        /* Process args and tell the world that the torturer is on the job. */
        for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
index 4b7b97ff1195b453bbaa497640a4b008a63de7f9..7fa34f86e5bab4a0c99df15233e799b9aa8663de 100644 (file)
@@ -1536,7 +1536,8 @@ rcu_torture_init(void)
                &rcu_ops, &rcu_bh_ops, &rcu_busted_ops, &srcu_ops, &sched_ops,
        };
 
-       torture_init_begin(torture_type, verbose, &rcutorture_runnable);
+       if (!torture_init_begin(torture_type, verbose, &rcutorture_runnable))
+               return -EBUSY;
 
        /* Process args and tell the world that the torturer is on the job. */
        for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
index ae1723a4c75131fb4bba7d21cb1747b0e5add00f..0ed0b49d2ce10e01dfaefbdfd12bd8f788841d32 100644 (file)
@@ -599,14 +599,20 @@ static void torture_stutter_cleanup(void)
  * The runnable parameter points to a flag that controls whether or not
  * the test is currently runnable.  If there is no such flag, pass in NULL.
  */
-void __init torture_init_begin(char *ttype, bool v, int *runnable)
+bool __init torture_init_begin(char *ttype, bool v, int *runnable)
 {
        mutex_lock(&fullstop_mutex);
+       if (torture_type != NULL) {
+               pr_alert("torture_init_begin: refusing %s init: %s running",
+                        ttype, torture_type);
+               mutex_unlock(&fullstop_mutex);
+               return false;
+       }
        torture_type = ttype;
        verbose = v;
        torture_runnable = runnable;
        fullstop = FULLSTOP_DONTSTOP;
-
+       return true;
 }
 EXPORT_SYMBOL_GPL(torture_init_begin);
 
@@ -645,6 +651,9 @@ bool torture_cleanup(void)
        torture_shuffle_cleanup();
        torture_stutter_cleanup();
        torture_onoff_cleanup();
+       mutex_lock(&fullstop_mutex);
+       torture_type = NULL;
+       mutex_unlock(&fullstop_mutex);
        return false;
 }
 EXPORT_SYMBOL_GPL(torture_cleanup);
This page took 0.028276 seconds and 5 git commands to generate.