Skip to content

Commit 64e4b43

Browse files
committed
rcutorture: Make rcu_torture_reader() use cond_resched()
The rcu_torture_reader() function currently uses schedule(). This commit therefore speeds things up a bit by substituting cond_resched(). This change makes rcu_torture_reader() more CPU-bound, so this commit also adjusts the number of readers (the "nreaders" module parameter, which feeds into the "nrealreaders" variable) to allow one CPU to be free of readers on SMP systems. The point of this is to increase the probability that readers will be watching while an updater makes a change. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
1 parent ac1bea8 commit 64e4b43

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎kernel/rcu/rcutorture.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ rcu_torture_reader(void *arg)
942942
__this_cpu_inc(rcu_torture_batch[completed]);
943943
preempt_enable();
944944
cur_ops->readunlock(idx);
945-
schedule();
945+
cond_resched();
946946
stutter_wait("rcu_torture_reader");
947947
} while (!torture_must_stop());
948948
if (irqreader && cur_ops->irq_capable)
@@ -1482,10 +1482,13 @@ rcu_torture_init(void)
14821482
if (cur_ops->init)
14831483
cur_ops->init(); /* no "goto unwind" prior to this point!!! */
14841484

1485-
if (nreaders >= 0)
1485+
if (nreaders >= 0) {
14861486
nrealreaders = nreaders;
1487-
else
1488-
nrealreaders = 2 * num_online_cpus();
1487+
} else {
1488+
nrealreaders = num_online_cpus() - 1;
1489+
if (nrealreaders <= 0)
1490+
nrealreaders = 1;
1491+
}
14891492
rcu_torture_print_module_parms(cur_ops, "Start of test");
14901493

14911494
/* Set up the freelist. */

0 commit comments

Comments
 (0)