aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/torture.c
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-01-31 20:37:28 -0500
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-02-23 12:03:21 -0500
commit7fafaac5b9ce22cc57777865390520476ad2262d (patch)
treec857b24b21d277b45803878af0715c817fb4716a /kernel/torture.c
parent14562d1cf12b434da2c69b5603a4149ac43f3b48 (diff)
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)
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);