History

rcutorture: Fix stutter_wait() return value and freelist checks

The stutter_wait() function is supposed to return true if it actually waits and false otherwise, but it instead unconditionally returns false. Which hides a bug in rcu_torture_writer() that fails to account for the fact that one of the rcu_tortures[] array elements will normally be referenced by rcu_torture_current, and thus not be on the freelist. This commit therefore corrects the stutter_wait() return value and adds a check for rcu_torture_current to rcu_torture_writer()'s check that things get freed after everything goes quiescent. In addition, this commit causes torture_stutter() to give a bit more than one second (instead of only one jiffy) warning of the end of the stutter interval. Finally, this commit disables long-delay readers and aggressive update-side forward-progress checks while forward-progress testing is in flight.

Paul E. McKenney committed 7 years ago

Commit e8516c61 parent 140e53f2 files · +25 −8Browse files

Unified · Split

2 files
  1. kernel/rcu/rcutorture.c +12 −4
  2. kernel/torture.c +13 −4
kernel/rcu/rcutorture.c+12−4
@@ -1010,10 +1010,13 @@ rcu_torture_writer(void *arg) · 1009 unmodified lines
10101010 !rcu_gp_is_normal();
10111011 }
10121012 rcu_torture_writer_state = RTWS_STUTTER;
1013− if (stutter_wait("rcu_torture_writer"))
1013+ if (stutter_wait("rcu_torture_writer") &&
1014+ !READ_ONCE(rcu_fwd_cb_nodelay))
10141015 for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++)
1015− if (list_empty(&rcu_tortures[i].rtort_free))
1016− WARN_ON_ONCE(1);
1016+ if (list_empty(&rcu_tortures[i].rtort_free) &&
1017+ rcu_access_pointer(rcu_torture_current) !=
1018+ &rcu_tortures[i])
1019+ WARN(1, "%s: rtort_pipe_count: %d\n", __func__, rcu_tortures[i].rtort_pipe_count);
10171020 } while (!torture_must_stop());
10181021 /* Reset expediting back to unexpedited. */
10191022 if (expediting > 0)
@@ -1709,6 +1712,8 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries) · 689 unmodified lines
17091712 }
17101713
17111714 /* Tight loop containing cond_resched(). */
1715+ WRITE_ONCE(rcu_fwd_cb_nodelay, true);
1716+ cur_ops->sync(); /* Later readers see above write. */
17121717 if (selfpropcb) {
17131718 WRITE_ONCE(fcs.stop, 0);
17141719 cur_ops->call(&fcs.rh, rcu_torture_fwd_prog_cb);
@@ -1747,6 +1752,8 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries) · 32 unmodified lines
17471752 WARN_ON(READ_ONCE(fcs.stop) != 2);
17481753 destroy_rcu_head_on_stack(&fcs.rh);
17491754 }
1755+ schedule_timeout_uninterruptible(HZ / 10); /* Let kthreads recover. */
1756+ WRITE_ONCE(rcu_fwd_cb_nodelay, false);
17501757 }
17511758
17521759 /* Carry out call_rcu() forward-progress testing. */
@@ -1816,7 +1823,6 @@ static void rcu_torture_fwd_prog_cr(void) · 63 unmodified lines
18161823 cur_ops->cb_barrier(); /* Wait for callbacks to be invoked. */
18171824 (void)rcu_torture_fwd_prog_cbfree();
18181825
1819− WRITE_ONCE(rcu_fwd_cb_nodelay, false);
18201826 if (!torture_must_stop() && !READ_ONCE(rcu_fwd_emergency_stop)) {
18211827 WARN_ON(n_max_gps < MIN_FWD_CBS_LAUNDERED);
18221828 pr_alert("%s Duration %lu barrier: %lu pending %ld n_launders: %ld n_launders_sa: %ld n_max_gps: %ld n_max_cbs: %ld cver %ld gps %ld\n",
@@ -1827,6 +1833,8 @@ static void rcu_torture_fwd_prog_cr(void) · 4 unmodified lines
18271833 n_max_gps, n_max_cbs, cver, gps);
18281834 rcu_torture_fwd_cb_hist();
18291835 }
1836+ schedule_timeout_uninterruptible(HZ); /* Let CBs drain. */
1837+ WRITE_ONCE(rcu_fwd_cb_nodelay, false);
18301838 }
18311839
18321840
kernel/torture.c+13−4
@@ -578,10 +578,12 @@ static int stutter; · 577 unmodified lines
578578 bool stutter_wait(const char *title)
579579 {
580580 int spt;
581+ bool ret = false;
581582
582583 cond_resched_tasks_rcu_qs();
583584 spt = READ_ONCE(stutter_pause_test);
584585 for (; spt; spt = READ_ONCE(stutter_pause_test)) {
586+ ret = true;
585587 if (spt == 1) {
586588 schedule_timeout_interruptible(1);
587589 } else if (spt == 2) {
@@ -592,7 +594,7 @@ bool stutter_wait(const char *title) · 4 unmodified lines
592594 }
593595 torture_shutdown_absorb(title);
594596 }
595− return !!spt;
597+ return ret;
596598 }
597599 EXPORT_SYMBOL_GPL(stutter_wait);
598600
@@ -602,13 +604,20 @@ EXPORT_SYMBOL_GPL(stutter_wait); · 3 unmodified lines
602604 */
603605 static int torture_stutter(void *arg)
604606 {
607+ int wtime;
608+
605609 VERBOSE_TOROUT_STRING("torture_stutter task started");
606610 do {
607611 if (!torture_must_stop() && stutter > 1) {
608− WRITE_ONCE(stutter_pause_test, 1);
609− schedule_timeout_interruptible(stutter - 1);
612+ wtime = stutter;
613+ if (stutter > HZ + 1) {
614+ WRITE_ONCE(stutter_pause_test, 1);
615+ wtime = stutter - HZ - 1;
616+ schedule_timeout_interruptible(wtime);
617+ wtime = HZ + 1;
618+ }
610619 WRITE_ONCE(stutter_pause_test, 2);
611− schedule_timeout_interruptible(1);
620+ schedule_timeout_interruptible(wtime);
612621 }
613622 WRITE_ONCE(stutter_pause_test, 0);
614623 if (!torture_must_stop())

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t