aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/torture.c
diff options
context:
space:
mode:
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)
169 } 169 }
170 schedule_timeout_interruptible(onoff_interval); 170 schedule_timeout_interruptible(onoff_interval);
171 } 171 }
172 VERBOSE_TOROUT_STRING("torture_onoff task stopping"); 172 torture_kthread_stopping("torture_onoff");
173 return 0; 173 return 0;
174} 174}
175 175
@@ -370,7 +370,7 @@ static int torture_shuffle(void *arg)
370 torture_shuffle_tasks(); 370 torture_shuffle_tasks();
371 torture_shutdown_absorb("torture_shuffle"); 371 torture_shutdown_absorb("torture_shuffle");
372 } while (!torture_must_stop()); 372 } while (!torture_must_stop());
373 VERBOSE_TOROUT_STRING("torture_shuffle task stopping"); 373 torture_kthread_stopping("torture_shuffle");
374 return 0; 374 return 0;
375} 375}
376 376
@@ -465,7 +465,7 @@ static int torture_shutdown(void *arg)
465 jiffies_snap = jiffies; 465 jiffies_snap = jiffies;
466 } 466 }
467 if (torture_must_stop()) { 467 if (torture_must_stop()) {
468 VERBOSE_TOROUT_STRING("torture_shutdown task stopping"); 468 torture_kthread_stopping("torture_shutdown");
469 return 0; 469 return 0;
470 } 470 }
471 471
@@ -583,7 +583,7 @@ static int torture_stutter(void *arg)
583 ACCESS_ONCE(stutter_pause_test) = 0; 583 ACCESS_ONCE(stutter_pause_test) = 0;
584 torture_shutdown_absorb("torture_stutter"); 584 torture_shutdown_absorb("torture_stutter");
585 } while (!torture_must_stop()); 585 } while (!torture_must_stop());
586 VERBOSE_TOROUT_STRING("torture_stutter task stopping"); 586 torture_kthread_stopping("torture_stutter");
587 return 0; 587 return 0;
588} 588}
589 589
@@ -696,3 +696,21 @@ bool torture_must_stop_irq(void)
696 return ACCESS_ONCE(fullstop) != FULLSTOP_DONTSTOP; 696 return ACCESS_ONCE(fullstop) != FULLSTOP_DONTSTOP;
697} 697}
698EXPORT_SYMBOL_GPL(torture_must_stop_irq); 698EXPORT_SYMBOL_GPL(torture_must_stop_irq);
699
700/*
701 * Each kthread must wait for kthread_should_stop() before returning from
702 * its top-level function, otherwise segfaults ensue. This function
703 * prints a "stopping" message and waits for kthread_should_stop(), and
704 * should be called from all torture kthreads immediately prior to
705 * returning.
706 */
707void torture_kthread_stopping(char *title)
708{
709 if (verbose)
710 VERBOSE_TOROUT_STRING(title);
711 while (!kthread_should_stop()) {
712 torture_shutdown_absorb(title);
713 schedule_timeout_uninterruptible(1);
714 }
715}
716EXPORT_SYMBOL_GPL(torture_kthread_stopping);