summaryrefslogtreecommitdiffstats
path: root/kernel/torture.c
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-01-29 07:40:27 -0800
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-02-23 09:01:04 -0800
commitf67a33561e6e5463b548219df98130da95f2e4a7 (patch)
tree6cdbf7152900045acb4f0f9d5426f995adf0ba66 /kernel/torture.c
parentc2884de38e01134ae040d55aa5644049d1bb850f (diff)
downloadlinux-f67a33561e6e5463b548219df98130da95f2e4a7.tar.gz
linux-f67a33561e6e5463b548219df98130da95f2e4a7.tar.bz2
linux-f67a33561e6e5463b548219df98130da95f2e4a7.zip
rcutorture: Abstract torture_shutdown_absorb()
Because handling races between rmmod and normal shutdown is not specific to rcutorture, this commit renames rcutorture_shutdown_absorb() to torture_shutdown_absorb() and pulls it out into then kernel/torture.c module. This implies pulling the fullstop mechanism into kernel/torture.c as well. The exporting of fullstop and fullstop_mutex is ugly and must die. And it does in fact die in later commits that introduce higher-level APIs that encapsulate both of these variables. 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.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/kernel/torture.c b/kernel/torture.c
index c82c70f7828e..f05042036ae8 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -49,6 +49,11 @@
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com>");
+int fullstop = FULLSTOP_RMMOD;
+EXPORT_SYMBOL_GPL(fullstop);
+DEFINE_MUTEX(fullstop_mutex);
+EXPORT_SYMBOL_GPL(fullstop_mutex);
+
#define TORTURE_RANDOM_MULT 39916801 /* prime */
#define TORTURE_RANDOM_ADD 479001701 /* prime */
#define TORTURE_RANDOM_REFRESH 10000
@@ -69,3 +74,18 @@ torture_random(struct torture_random_state *trsp)
return swahw32(trsp->trs_state);
}
EXPORT_SYMBOL_GPL(torture_random);
+
+/*
+ * Absorb kthreads into a kernel function that won't return, so that
+ * they won't ever access module text or data again.
+ */
+void torture_shutdown_absorb(const char *title)
+{
+ while (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) {
+ pr_notice(
+ "torture thread %s parking due to system shutdown\n",
+ title);
+ schedule_timeout_uninterruptible(MAX_SCHEDULE_TIMEOUT);
+ }
+}
+EXPORT_SYMBOL_GPL(torture_shutdown_absorb);