aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-02-04 15:35:27 -0500
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-02-23 12:04:27 -0500
commitbfefc73aa1d1bad317bccef8a15da39263d3d962 (patch)
tree7eb61b4f1a677785d4cc2fc2570648ac05519cf0
parent9c029b86098decd4660eec511b8d2d42da3e7dd9 (diff)
rcutorture: Stop generic kthreads in torture_cleanup()
The specific torture modules (like rcutorture) need to call torture_cleanup() in any case, so this commit makes torture_cleanup() deal with torture_shutdown_cleanup() and torture_stutter_cleanup() so that the specific modules don't have to deal with these details. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
-rw-r--r--include/linux/torture.h2
-rw-r--r--kernel/rcu/rcutorture.c7
-rw-r--r--kernel/torture.c37
3 files changed, 19 insertions, 27 deletions
diff --git a/include/linux/torture.h b/include/linux/torture.h
index 7ccfb0a16728..b2e2b468e511 100644
--- a/include/linux/torture.h
+++ b/include/linux/torture.h
@@ -75,12 +75,10 @@ int torture_shuffle_init(long shuffint);
75/* Test auto-shutdown handling. */ 75/* Test auto-shutdown handling. */
76void torture_shutdown_absorb(const char *title); 76void torture_shutdown_absorb(const char *title);
77int torture_shutdown_init(int ssecs, void (*cleanup)(void)); 77int torture_shutdown_init(int ssecs, void (*cleanup)(void));
78void torture_shutdown_cleanup(void);
79 78
80/* Task stuttering, which forces load/no-load transitions. */ 79/* Task stuttering, which forces load/no-load transitions. */
81void stutter_wait(const char *title); 80void stutter_wait(const char *title);
82int torture_stutter_init(int s); 81int torture_stutter_init(int s);
83void torture_stutter_cleanup(void);
84 82
85/* Initialization and cleanup. */ 83/* Initialization and cleanup. */
86void torture_init_begin(char *ttype, bool v, int *runnable); 84void torture_init_begin(char *ttype, bool v, int *runnable);
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 37bd4beea198..40792e76a116 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -53,11 +53,6 @@
53MODULE_LICENSE("GPL"); 53MODULE_LICENSE("GPL");
54MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and Josh Triplett <josh@freedesktop.org>"); 54MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and Josh Triplett <josh@freedesktop.org>");
55 55
56MODULE_ALIAS("rcutorture");
57#ifdef MODULE_PARAM_PREFIX
58#undef MODULE_PARAM_PREFIX
59#endif
60#define MODULE_PARAM_PREFIX "rcutorture."
61 56
62torture_param(int, fqs_duration, 0, 57torture_param(int, fqs_duration, 0,
63 "Duration of fqs bursts (us), 0 to disable"); 58 "Duration of fqs bursts (us), 0 to disable");
@@ -1269,7 +1264,6 @@ rcu_torture_cleanup(void)
1269 1264
1270 rcu_torture_barrier_cleanup(); 1265 rcu_torture_barrier_cleanup();
1271 torture_stop_kthread(rcu_torture_stall, stall_task); 1266 torture_stop_kthread(rcu_torture_stall, stall_task);
1272 torture_stutter_cleanup();
1273 torture_stop_kthread(rcu_torture_writer, writer_task); 1267 torture_stop_kthread(rcu_torture_writer, writer_task);
1274 1268
1275 if (reader_tasks) { 1269 if (reader_tasks) {
@@ -1297,7 +1291,6 @@ rcu_torture_cleanup(void)
1297 for_each_possible_cpu(i) 1291 for_each_possible_cpu(i)
1298 rcutorture_booster_cleanup(i); 1292 rcutorture_booster_cleanup(i);
1299 } 1293 }
1300 torture_shutdown_cleanup();
1301 1294
1302 /* Wait for all RCU callbacks to fire. */ 1295 /* Wait for all RCU callbacks to fire. */
1303 1296
diff --git a/kernel/torture.c b/kernel/torture.c
index 871f63611f7f..b26c7b42becd 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -478,20 +478,6 @@ int torture_shutdown_init(int ssecs, void (*cleanup)(void))
478EXPORT_SYMBOL_GPL(torture_shutdown_init); 478EXPORT_SYMBOL_GPL(torture_shutdown_init);
479 479
480/* 480/*
481 * Shut down the shutdown task. Say what??? Heh! This can happen if
482 * the torture module gets an rmmod before the shutdown time arrives. ;-)
483 */
484void torture_shutdown_cleanup(void)
485{
486 if (shutdown_task != NULL) {
487 VERBOSE_TOROUT_STRING("Stopping torture_shutdown task");
488 kthread_stop(shutdown_task);
489 }
490 shutdown_task = NULL;
491}
492EXPORT_SYMBOL_GPL(torture_shutdown_cleanup);
493
494/*
495 * Detect and respond to a system shutdown. 481 * Detect and respond to a system shutdown.
496 */ 482 */
497static int torture_shutdown_notify(struct notifier_block *unused1, 483static int torture_shutdown_notify(struct notifier_block *unused1,
@@ -513,6 +499,20 @@ static struct notifier_block torture_shutdown_nb = {
513}; 499};
514 500
515/* 501/*
502 * Shut down the shutdown task. Say what??? Heh! This can happen if
503 * the torture module gets an rmmod before the shutdown time arrives. ;-)
504 */
505static void torture_shutdown_cleanup(void)
506{
507 unregister_reboot_notifier(&torture_shutdown_nb);
508 if (shutdown_task != NULL) {
509 VERBOSE_TOROUT_STRING("Stopping torture_shutdown task");
510 kthread_stop(shutdown_task);
511 }
512 shutdown_task = NULL;
513}
514
515/*
516 * Variables for stuttering, which means to periodically pause and 516 * Variables for stuttering, which means to periodically pause and
517 * restart testing in order to catch bugs that appear when load is 517 * restart testing in order to catch bugs that appear when load is
518 * suddenly applied to or removed from the system. 518 * suddenly applied to or removed from the system.
@@ -575,7 +575,7 @@ EXPORT_SYMBOL_GPL(torture_stutter_init);
575/* 575/*
576 * Cleanup after the torture_stutter kthread. 576 * Cleanup after the torture_stutter kthread.
577 */ 577 */
578void torture_stutter_cleanup(void) 578static void torture_stutter_cleanup(void)
579{ 579{
580 if (!stutter_task) 580 if (!stutter_task)
581 return; 581 return;
@@ -583,7 +583,6 @@ void torture_stutter_cleanup(void)
583 kthread_stop(stutter_task); 583 kthread_stop(stutter_task);
584 stutter_task = NULL; 584 stutter_task = NULL;
585} 585}
586EXPORT_SYMBOL_GPL(torture_stutter_cleanup);
587 586
588/* 587/*
589 * Initialize torture module. Please note that this is -not- invoked via 588 * Initialize torture module. Please note that this is -not- invoked via
@@ -619,7 +618,8 @@ EXPORT_SYMBOL_GPL(torture_init_end);
619 * Clean up torture module. Please note that this is -not- invoked via 618 * Clean up torture module. Please note that this is -not- invoked via
620 * the usual module_exit() mechanism, but rather by an explicit call from 619 * the usual module_exit() mechanism, but rather by an explicit call from
621 * the client torture module. Returns true if a race with system shutdown 620 * the client torture module. Returns true if a race with system shutdown
622 * is detected. 621 * is detected, otherwise, all kthreads started by functions in this file
622 * will be shut down.
623 * 623 *
624 * This must be called before the caller starts shutting down its own 624 * This must be called before the caller starts shutting down its own
625 * kthreads. 625 * kthreads.
@@ -635,8 +635,9 @@ bool torture_cleanup(void)
635 } 635 }
636 ACCESS_ONCE(fullstop) = FULLSTOP_RMMOD; 636 ACCESS_ONCE(fullstop) = FULLSTOP_RMMOD;
637 mutex_unlock(&fullstop_mutex); 637 mutex_unlock(&fullstop_mutex);
638 unregister_reboot_notifier(&torture_shutdown_nb); 638 torture_shutdown_cleanup();
639 torture_shuffle_cleanup(); 639 torture_shuffle_cleanup();
640 torture_stutter_cleanup();
640 torture_onoff_cleanup(); 641 torture_onoff_cleanup();
641 return false; 642 return false;
642} 643}