summaryrefslogtreecommitdiff
path: root/kernel/torture.c
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-01-30 15:49:29 -0800
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-02-23 09:01:12 -0800
commit36970bb91d89618d3495babf44b934e9c9db6bbc (patch)
treecee37f3089c868338f626124124fe2f90c26cdbd /kernel/torture.c
parent4622b487ecf0094401ac10e504606e5cbdea5a6e (diff)
rcutorture: Privatize fullstop
This commit introduces the torture_must_stop() function in order to keep use of the fullstop variable local to kernel/torture.c. There is also a torture_must_stop_irq() counterpart for use from RCU callbacks, timeout handlers, and the like. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'kernel/torture.c')
-rw-r--r--kernel/torture.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/kernel/torture.c b/kernel/torture.c
index b02fa2785bbb..ed360cf948da 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -52,8 +52,11 @@ MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com>");
static char *torture_type;
static bool verbose;
-int fullstop = FULLSTOP_RMMOD;
-EXPORT_SYMBOL_GPL(fullstop);
+/* Mediate rmmod and system shutdown. Concurrent rmmod & shutdown illegal! */
+#define FULLSTOP_DONTSTOP 0 /* Normal operation. */
+#define FULLSTOP_SHUTDOWN 1 /* System shutdown with torture running. */
+#define FULLSTOP_RMMOD 2 /* Normal rmmod of torture. */
+static int fullstop = FULLSTOP_RMMOD;
static DEFINE_MUTEX(fullstop_mutex);
#ifdef CONFIG_HOTPLUG_CPU
@@ -458,6 +461,7 @@ void __init torture_init_begin(char *ttype, bool v)
mutex_lock(&fullstop_mutex);
torture_type = ttype;
verbose = v;
+ fullstop = FULLSTOP_DONTSTOP;
}
EXPORT_SYMBOL_GPL(torture_init_begin);
@@ -498,3 +502,22 @@ bool torture_cleanup(void)
return false;
}
EXPORT_SYMBOL_GPL(torture_cleanup);
+
+/*
+ * Is it time for the current torture test to stop?
+ */
+bool torture_must_stop(void)
+{
+ return torture_must_stop_irq() || kthread_should_stop();
+}
+EXPORT_SYMBOL_GPL(torture_must_stop);
+
+/*
+ * Is it time for the current torture test to stop? This is the irq-safe
+ * version, hence no check for kthread_should_stop().
+ */
+bool torture_must_stop_irq(void)
+{
+ return fullstop != FULLSTOP_DONTSTOP;
+}
+EXPORT_SYMBOL_GPL(torture_must_stop_irq);