summaryrefslogtreecommitdiffstats
path: root/kernel/torture.c
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-01-31 17:37:28 -0800
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-02-23 09:03:21 -0800
commit7fafaac5b9ce22cc57777865390520476ad2262d (patch)
treec857b24b21d277b45803878af0715c817fb4716a /kernel/torture.c
parent14562d1cf12b434da2c69b5603a4149ac43f3b48 (diff)
downloadlinux-7fafaac5b9ce22cc57777865390520476ad2262d.tar.bz2
rcutorture: Fix rcutorture shutdown races
Not all of the rcutorture kthreads waited for kthread_should_stop() before returning from their top-level functions, and none of them used torture_shutdown_absorb() properly. These problems can result in segfaults and hangs at shutdown time, and some recent changes perturbed timing sufficiently to make them much more probable. This commit therefore creates a torture_kthread_stopping() function that does the proper kthread shutdown dance in one centralized location. Accommodate this grouping by making VERBOSE_TOROUT_STRING() capable of taking a non-const string as its argument, which allows the new torture_kthread_stopping() to pass its "title" argument directly to the updated version of VERBOSE_TOROUT_STRING(). Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/torture.c')
-rw-r--r--kernel/torture.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/kernel/torture.c b/kernel/torture.c
index 5e2838f902f9..330576660cf4 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -169,7 +169,7 @@ torture_onoff(void *arg)
}
schedule_timeout_interruptible(onoff_interval);
}
- VERBOSE_TOROUT_STRING("torture_onoff task stopping");
+ torture_kthread_stopping("torture_onoff");
return 0;
}
@@ -370,7 +370,7 @@ static int torture_shuffle(void *arg)
torture_shuffle_tasks();
torture_shutdown_absorb("torture_shuffle");
} while (!torture_must_stop());
- VERBOSE_TOROUT_STRING("torture_shuffle task stopping");
+ torture_kthread_stopping("torture_shuffle");
return 0;
}
@@ -465,7 +465,7 @@ static int torture_shutdown(void *arg)
jiffies_snap = jiffies;
}
if (torture_must_stop()) {
- VERBOSE_TOROUT_STRING("torture_shutdown task stopping");
+ torture_kthread_stopping("torture_shutdown");
return 0;
}
@@ -583,7 +583,7 @@ static int torture_stutter(void *arg)
ACCESS_ONCE(stutter_pause_test) = 0;
torture_shutdown_absorb("torture_stutter");
} while (!torture_must_stop());
- VERBOSE_TOROUT_STRING("torture_stutter task stopping");
+ torture_kthread_stopping("torture_stutter");
return 0;
}
@@ -696,3 +696,21 @@ bool torture_must_stop_irq(void)
return ACCESS_ONCE(fullstop) != FULLSTOP_DONTSTOP;
}
EXPORT_SYMBOL_GPL(torture_must_stop_irq);
+
+/*
+ * Each kthread must wait for kthread_should_stop() before returning from
+ * its top-level function, otherwise segfaults ensue. This function
+ * prints a "stopping" message and waits for kthread_should_stop(), and
+ * should be called from all torture kthreads immediately prior to
+ * returning.
+ */
+void torture_kthread_stopping(char *title)
+{
+ if (verbose)
+ VERBOSE_TOROUT_STRING(title);
+ while (!kthread_should_stop()) {
+ torture_shutdown_absorb(title);
+ schedule_timeout_uninterruptible(1);
+ }
+}
+EXPORT_SYMBOL_GPL(torture_kthread_stopping);