torture: Make stutter less vulnerable to compilers and races
The stutter_wait() function repeatedly fetched stutter_pause_test, and should really just fetch it once on each pass. The races should be harmless, but why have the races? Also, the whole point of the value "2" for stutter_pause_test is to get everyone to start at very nearly the same time, but the value "2" was the first jiffy of the stutter rather than the last jiffy of the stutter. This commit rearranges the code to be more sensible. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
This commit is contained in:
parent
2ce77d16db
commit
4ced3314fd
|
@ -573,18 +573,21 @@ static int stutter;
|
|||
*/
|
||||
void stutter_wait(const char *title)
|
||||
{
|
||||
int spt;
|
||||
|
||||
cond_resched_rcu_qs();
|
||||
while (READ_ONCE(stutter_pause_test) ||
|
||||
(torture_runnable && !READ_ONCE(*torture_runnable))) {
|
||||
if (stutter_pause_test)
|
||||
if (READ_ONCE(stutter_pause_test) == 1)
|
||||
spt = READ_ONCE(stutter_pause_test);
|
||||
while (spt || (torture_runnable && !READ_ONCE(*torture_runnable))) {
|
||||
if (spt == 1) {
|
||||
schedule_timeout_interruptible(1);
|
||||
else
|
||||
} else if (spt == 2) {
|
||||
while (READ_ONCE(stutter_pause_test))
|
||||
cond_resched();
|
||||
else
|
||||
} else {
|
||||
schedule_timeout_interruptible(round_jiffies_relative(HZ));
|
||||
}
|
||||
torture_shutdown_absorb(title);
|
||||
spt = READ_ONCE(stutter_pause_test);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(stutter_wait);
|
||||
|
@ -597,17 +600,15 @@ static int torture_stutter(void *arg)
|
|||
{
|
||||
VERBOSE_TOROUT_STRING("torture_stutter task started");
|
||||
do {
|
||||
if (!torture_must_stop()) {
|
||||
if (stutter > 1) {
|
||||
if (!torture_must_stop() && stutter > 1) {
|
||||
WRITE_ONCE(stutter_pause_test, 1);
|
||||
schedule_timeout_interruptible(stutter - 1);
|
||||
WRITE_ONCE(stutter_pause_test, 2);
|
||||
}
|
||||
schedule_timeout_interruptible(1);
|
||||
WRITE_ONCE(stutter_pause_test, 1);
|
||||
}
|
||||
WRITE_ONCE(stutter_pause_test, 0);
|
||||
if (!torture_must_stop())
|
||||
schedule_timeout_interruptible(stutter);
|
||||
WRITE_ONCE(stutter_pause_test, 0);
|
||||
torture_shutdown_absorb("torture_stutter");
|
||||
} while (!torture_must_stop());
|
||||
torture_kthread_stopping("torture_stutter");
|
||||
|
|
Loading…
Reference in New Issue