Skip to content

Commit bfefc73

Browse files
committed
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>
1 parent 9c029b8 commit bfefc73

3 files changed

Lines changed: 19 additions & 27 deletions

File tree

‎include/linux/torture.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,10 @@ int torture_shuffle_init(long shuffint);
7575
/* Test auto-shutdown handling. */
7676
void torture_shutdown_absorb(const char *title);
7777
int torture_shutdown_init(int ssecs, void (*cleanup)(void));
78-
void torture_shutdown_cleanup(void);
7978

8079
/* Task stuttering, which forces load/no-load transitions. */
8180
void stutter_wait(const char *title);
8281
int torture_stutter_init(int s);
83-
void torture_stutter_cleanup(void);
8482

8583
/* Initialization and cleanup. */
8684
void torture_init_begin(char *ttype, bool v, int *runnable);

‎kernel/rcu/rcutorture.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@
5353
MODULE_LICENSE("GPL");
5454
MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and Josh Triplett <josh@freedesktop.org>");
5555

56-
MODULE_ALIAS("rcutorture");
57-
#ifdef MODULE_PARAM_PREFIX
58-
#undef MODULE_PARAM_PREFIX
59-
#endif
60-
#define MODULE_PARAM_PREFIX "rcutorture."
6156

6257
torture_param(int, fqs_duration, 0,
6358
"Duration of fqs bursts (us), 0 to disable");
@@ -1269,7 +1264,6 @@ rcu_torture_cleanup(void)
12691264

12701265
rcu_torture_barrier_cleanup();
12711266
torture_stop_kthread(rcu_torture_stall, stall_task);
1272-
torture_stutter_cleanup();
12731267
torture_stop_kthread(rcu_torture_writer, writer_task);
12741268

12751269
if (reader_tasks) {
@@ -1297,7 +1291,6 @@ rcu_torture_cleanup(void)
12971291
for_each_possible_cpu(i)
12981292
rcutorture_booster_cleanup(i);
12991293
}
1300-
torture_shutdown_cleanup();
13011294

13021295
/* Wait for all RCU callbacks to fire. */
13031296

‎kernel/torture.c‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -477,20 +477,6 @@ int torture_shutdown_init(int ssecs, void (*cleanup)(void))
477477
}
478478
EXPORT_SYMBOL_GPL(torture_shutdown_init);
479479

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-
*/
484-
void 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-
}
492-
EXPORT_SYMBOL_GPL(torture_shutdown_cleanup);
493-
494480
/*
495481
* Detect and respond to a system shutdown.
496482
*/
@@ -512,6 +498,20 @@ static struct notifier_block torture_shutdown_nb = {
512498
.notifier_call = torture_shutdown_notify,
513499
};
514500

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+
*/
505+
static 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+
515515
/*
516516
* Variables for stuttering, which means to periodically pause and
517517
* restart testing in order to catch bugs that appear when load is
@@ -575,15 +575,14 @@ EXPORT_SYMBOL_GPL(torture_stutter_init);
575575
/*
576576
* Cleanup after the torture_stutter kthread.
577577
*/
578-
void torture_stutter_cleanup(void)
578+
static void torture_stutter_cleanup(void)
579579
{
580580
if (!stutter_task)
581581
return;
582582
VERBOSE_TOROUT_STRING("Stopping torture_stutter task");
583583
kthread_stop(stutter_task);
584584
stutter_task = NULL;
585585
}
586-
EXPORT_SYMBOL_GPL(torture_stutter_cleanup);
587586

588587
/*
589588
* Initialize torture module. Please note that this is -not- invoked via
@@ -619,7 +618,8 @@ EXPORT_SYMBOL_GPL(torture_init_end);
619618
* Clean up torture module. Please note that this is -not- invoked via
620619
* the usual module_exit() mechanism, but rather by an explicit call from
621620
* 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.
623623
*
624624
* This must be called before the caller starts shutting down its own
625625
* kthreads.
@@ -635,8 +635,9 @@ bool torture_cleanup(void)
635635
}
636636
ACCESS_ONCE(fullstop) = FULLSTOP_RMMOD;
637637
mutex_unlock(&fullstop_mutex);
638-
unregister_reboot_notifier(&torture_shutdown_nb);
638+
torture_shutdown_cleanup();
639639
torture_shuffle_cleanup();
640+
torture_stutter_cleanup();
640641
torture_onoff_cleanup();
641642
return false;
642643
}

0 commit comments

Comments
 (0)