diff options
-rw-r--r-- | include/linux/torture.h | 2 | ||||
-rw-r--r-- | kernel/rcu/rcutorture.c | 23 | ||||
-rw-r--r-- | kernel/torture.c | 29 |
3 files changed, 24 insertions, 30 deletions
diff --git a/include/linux/torture.h b/include/linux/torture.h index 31d69930e5cf..742d8a402f19 100644 --- a/include/linux/torture.h +++ b/include/linux/torture.h | |||
@@ -46,8 +46,6 @@ | |||
46 | #define FULLSTOP_SHUTDOWN 1 /* System shutdown with rcutorture running. */ | 46 | #define FULLSTOP_SHUTDOWN 1 /* System shutdown with rcutorture running. */ |
47 | #define FULLSTOP_RMMOD 2 /* Normal rmmod of rcutorture. */ | 47 | #define FULLSTOP_RMMOD 2 /* Normal rmmod of rcutorture. */ |
48 | extern int fullstop; | 48 | extern int fullstop; |
49 | /* Protect fullstop transitions and spawning of kthreads. */ | ||
50 | extern struct mutex fullstop_mutex; | ||
51 | 49 | ||
52 | #define TORTURE_FLAG "-torture:" | 50 | #define TORTURE_FLAG "-torture:" |
53 | #define TOROUT_STRING(s) \ | 51 | #define TOROUT_STRING(s) \ |
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 68a689fc6ffa..2560e9313887 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c | |||
@@ -190,23 +190,6 @@ static DECLARE_WAIT_QUEUE_HEAD(barrier_wq); | |||
190 | static void rcu_torture_cleanup(void); | 190 | static void rcu_torture_cleanup(void); |
191 | 191 | ||
192 | /* | 192 | /* |
193 | * Detect and respond to a system shutdown. | ||
194 | */ | ||
195 | static int | ||
196 | rcutorture_shutdown_notify(struct notifier_block *unused1, | ||
197 | unsigned long unused2, void *unused3) | ||
198 | { | ||
199 | mutex_lock(&fullstop_mutex); | ||
200 | if (fullstop == FULLSTOP_DONTSTOP) | ||
201 | fullstop = FULLSTOP_SHUTDOWN; | ||
202 | else | ||
203 | pr_warn(/* but going down anyway, so... */ | ||
204 | "Concurrent 'rmmod rcutorture' and shutdown illegal!\n"); | ||
205 | mutex_unlock(&fullstop_mutex); | ||
206 | return NOTIFY_DONE; | ||
207 | } | ||
208 | |||
209 | /* | ||
210 | * Allocate an element from the rcu_tortures pool. | 193 | * Allocate an element from the rcu_tortures pool. |
211 | */ | 194 | */ |
212 | static struct rcu_torture * | 195 | static struct rcu_torture * |
@@ -1098,10 +1081,6 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag) | |||
1098 | onoff_interval, onoff_holdoff); | 1081 | onoff_interval, onoff_holdoff); |
1099 | } | 1082 | } |
1100 | 1083 | ||
1101 | static struct notifier_block rcutorture_shutdown_nb = { | ||
1102 | .notifier_call = rcutorture_shutdown_notify, | ||
1103 | }; | ||
1104 | |||
1105 | static void rcutorture_booster_cleanup(int cpu) | 1084 | static void rcutorture_booster_cleanup(int cpu) |
1106 | { | 1085 | { |
1107 | struct task_struct *t; | 1086 | struct task_struct *t; |
@@ -1428,7 +1407,6 @@ rcu_torture_cleanup(void) | |||
1428 | cur_ops->cb_barrier(); | 1407 | cur_ops->cb_barrier(); |
1429 | return; | 1408 | return; |
1430 | } | 1409 | } |
1431 | unregister_reboot_notifier(&rcutorture_shutdown_nb); | ||
1432 | 1410 | ||
1433 | rcu_torture_barrier_cleanup(); | 1411 | rcu_torture_barrier_cleanup(); |
1434 | rcu_torture_stall_cleanup(); | 1412 | rcu_torture_stall_cleanup(); |
@@ -1774,7 +1752,6 @@ rcu_torture_init(void) | |||
1774 | firsterr = i; | 1752 | firsterr = i; |
1775 | goto unwind; | 1753 | goto unwind; |
1776 | } | 1754 | } |
1777 | register_reboot_notifier(&rcutorture_shutdown_nb); | ||
1778 | i = rcu_torture_stall_init(); | 1755 | i = rcu_torture_stall_init(); |
1779 | if (i != 0) { | 1756 | if (i != 0) { |
1780 | firsterr = i; | 1757 | firsterr = i; |
diff --git a/kernel/torture.c b/kernel/torture.c index 41ae5cc3c4c3..b02fa2785bbb 100644 --- a/kernel/torture.c +++ b/kernel/torture.c | |||
@@ -54,8 +54,7 @@ static bool verbose; | |||
54 | 54 | ||
55 | int fullstop = FULLSTOP_RMMOD; | 55 | int fullstop = FULLSTOP_RMMOD; |
56 | EXPORT_SYMBOL_GPL(fullstop); | 56 | EXPORT_SYMBOL_GPL(fullstop); |
57 | DEFINE_MUTEX(fullstop_mutex); | 57 | static DEFINE_MUTEX(fullstop_mutex); |
58 | EXPORT_SYMBOL_GPL(fullstop_mutex); | ||
59 | 58 | ||
60 | #ifdef CONFIG_HOTPLUG_CPU | 59 | #ifdef CONFIG_HOTPLUG_CPU |
61 | 60 | ||
@@ -422,15 +421,33 @@ EXPORT_SYMBOL_GPL(torture_shuffle_cleanup); | |||
422 | void torture_shutdown_absorb(const char *title) | 421 | void torture_shutdown_absorb(const char *title) |
423 | { | 422 | { |
424 | while (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) { | 423 | while (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) { |
425 | pr_notice( | 424 | pr_notice("torture thread %s parking due to system shutdown\n", |
426 | "torture thread %s parking due to system shutdown\n", | 425 | title); |
427 | title); | ||
428 | schedule_timeout_uninterruptible(MAX_SCHEDULE_TIMEOUT); | 426 | schedule_timeout_uninterruptible(MAX_SCHEDULE_TIMEOUT); |
429 | } | 427 | } |
430 | } | 428 | } |
431 | EXPORT_SYMBOL_GPL(torture_shutdown_absorb); | 429 | EXPORT_SYMBOL_GPL(torture_shutdown_absorb); |
432 | 430 | ||
433 | /* | 431 | /* |
432 | * Detect and respond to a system shutdown. | ||
433 | */ | ||
434 | static int torture_shutdown_notify(struct notifier_block *unused1, | ||
435 | unsigned long unused2, void *unused3) | ||
436 | { | ||
437 | mutex_lock(&fullstop_mutex); | ||
438 | if (fullstop == FULLSTOP_DONTSTOP) | ||
439 | fullstop = FULLSTOP_SHUTDOWN; | ||
440 | else | ||
441 | pr_warn("Concurrent rmmod and shutdown illegal!\n"); | ||
442 | mutex_unlock(&fullstop_mutex); | ||
443 | return NOTIFY_DONE; | ||
444 | } | ||
445 | |||
446 | static struct notifier_block torture_shutdown_nb = { | ||
447 | .notifier_call = torture_shutdown_notify, | ||
448 | }; | ||
449 | |||
450 | /* | ||
434 | * Initialize torture module. Please note that this is -not- invoked via | 451 | * Initialize torture module. Please note that this is -not- invoked via |
435 | * the usual module_init() mechanism, but rather by an explicit call from | 452 | * the usual module_init() mechanism, but rather by an explicit call from |
436 | * the client torture module. This call must be paired with a later | 453 | * the client torture module. This call must be paired with a later |
@@ -451,6 +468,7 @@ EXPORT_SYMBOL_GPL(torture_init_begin); | |||
451 | void __init torture_init_end(void) | 468 | void __init torture_init_end(void) |
452 | { | 469 | { |
453 | mutex_unlock(&fullstop_mutex); | 470 | mutex_unlock(&fullstop_mutex); |
471 | register_reboot_notifier(&torture_shutdown_nb); | ||
454 | } | 472 | } |
455 | EXPORT_SYMBOL_GPL(torture_init_end); | 473 | EXPORT_SYMBOL_GPL(torture_init_end); |
456 | 474 | ||
@@ -474,6 +492,7 @@ bool torture_cleanup(void) | |||
474 | } | 492 | } |
475 | fullstop = FULLSTOP_RMMOD; | 493 | fullstop = FULLSTOP_RMMOD; |
476 | mutex_unlock(&fullstop_mutex); | 494 | mutex_unlock(&fullstop_mutex); |
495 | unregister_reboot_notifier(&torture_shutdown_nb); | ||
477 | torture_shuffle_cleanup(); | 496 | torture_shuffle_cleanup(); |
478 | torture_onoff_cleanup(); | 497 | torture_onoff_cleanup(); |
479 | return false; | 498 | return false; |