Skip to content

Commit af2789d

Browse files
committed
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) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent b864f89 commit af2789d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

kernel/rcu/refperf.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ torture_param(bool, shutdown, REFPERF_SHUTDOWN,
8080

8181
struct reader_task {
8282
struct task_struct *task;
83-
atomic_t start;
83+
int start_reader;
8484
wait_queue_head_t wq;
8585
u64 last_duration_ns;
8686
};
@@ -243,7 +243,7 @@ ref_perf_reader(void *arg)
243243
VERBOSE_PERFOUT("ref_perf_reader %ld: waiting to start next experiment on cpu %d", me, smp_processor_id());
244244

245245
// Wait for signal that this reader can start.
246-
wait_event(rt->wq, (atomic_read(&nreaders_exp) && atomic_read(&rt->start)) ||
246+
wait_event(rt->wq, (atomic_read(&nreaders_exp) && smp_load_acquire(&rt->start_reader)) ||
247247
torture_must_stop());
248248

249249
if (torture_must_stop())
@@ -252,8 +252,7 @@ ref_perf_reader(void *arg)
252252
// Make sure that the CPU is affinitized appropriately during testing.
253253
WARN_ON_ONCE(smp_processor_id() != me);
254254

255-
smp_mb__before_atomic();
256-
atomic_dec(&rt->start);
255+
WRITE_ONCE(rt->start_reader, 0);
257256

258257
VERBOSE_PERFOUT("ref_perf_reader %ld: experiment %d started", me, exp_idx);
259258

@@ -372,7 +371,7 @@ static int main_func(void *arg)
372371
exp_idx = exp;
373372

374373
for (r = 0; r < nreaders; r++) {
375-
atomic_set(&reader_tasks[r].start, 1);
374+
smp_store_release(&reader_tasks[r].start_reader, 1);
376375
wake_up(&reader_tasks[r].wq);
377376
}
378377

0 commit comments

Comments
 (0)