refperf: Convert reader_task structure's "start" field to int

This commit converts the reader_task structure's "start" field to int
in order to demote a full barrier to an smp_load_acquire() and also to
simplify the code a bit.  While in the area, and to enlist the compiler's
help in ensuring that nothing was missed, the field's name was changed
to start_reader.

Also while in the area, change the main_func() store to use
smp_store_release() to further fortify against wait/wake races.

Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
This commit is contained in:
Paul E. McKenney 2020-05-26 11:22:03 -07:00
parent b864f89ff6
commit af2789db13
1 changed files with 4 additions and 5 deletions

View File

@ -80,7 +80,7 @@ torture_param(bool, shutdown, REFPERF_SHUTDOWN,
struct reader_task { struct reader_task {
struct task_struct *task; struct task_struct *task;
atomic_t start; int start_reader;
wait_queue_head_t wq; wait_queue_head_t wq;
u64 last_duration_ns; u64 last_duration_ns;
}; };
@ -243,7 +243,7 @@ ref_perf_reader(void *arg)
VERBOSE_PERFOUT("ref_perf_reader %ld: waiting to start next experiment on cpu %d", me, smp_processor_id()); VERBOSE_PERFOUT("ref_perf_reader %ld: waiting to start next experiment on cpu %d", me, smp_processor_id());
// Wait for signal that this reader can start. // Wait for signal that this reader can start.
wait_event(rt->wq, (atomic_read(&nreaders_exp) && atomic_read(&rt->start)) || wait_event(rt->wq, (atomic_read(&nreaders_exp) && smp_load_acquire(&rt->start_reader)) ||
torture_must_stop()); torture_must_stop());
if (torture_must_stop()) if (torture_must_stop())
@ -252,8 +252,7 @@ ref_perf_reader(void *arg)
// Make sure that the CPU is affinitized appropriately during testing. // Make sure that the CPU is affinitized appropriately during testing.
WARN_ON_ONCE(smp_processor_id() != me); WARN_ON_ONCE(smp_processor_id() != me);
smp_mb__before_atomic(); WRITE_ONCE(rt->start_reader, 0);
atomic_dec(&rt->start);
VERBOSE_PERFOUT("ref_perf_reader %ld: experiment %d started", me, exp_idx); VERBOSE_PERFOUT("ref_perf_reader %ld: experiment %d started", me, exp_idx);
@ -372,7 +371,7 @@ static int main_func(void *arg)
exp_idx = exp; exp_idx = exp;
for (r = 0; r < nreaders; r++) { for (r = 0; r < nreaders; r++) {
atomic_set(&reader_tasks[r].start, 1); smp_store_release(&reader_tasks[r].start_reader, 1);
wake_up(&reader_tasks[r].wq); wake_up(&reader_tasks[r].wq);
} }