Skip to content

Commit 86e0da2

Browse files
committed
refperf: More closely synchronize reader start times
Currently, readers are awakened individually. On most systems, this results in significant wakeup delay from one reader to the next, which can result in the first and last reader having sole access to the synchronization primitive in question. If that synchronization primitive involves shared memory, those readers will rack up a huge number of operations in a very short time, causing large perturbations in the results. This commit therefore has the readers busy-wait after being awakened, and uses a new n_started variable to synchronize their start times. Cc: Joel Fernandes (Google) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent af2789d commit 86e0da2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

kernel/rcu/refperf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ static atomic_t nreaders_exp;
9999

100100
// Use to wait for all threads to start.
101101
static atomic_t n_init;
102+
static atomic_t n_started;
102103

103104
// Track which experiment is currently running.
104105
static int exp_idx;
@@ -253,6 +254,9 @@ ref_perf_reader(void *arg)
253254
WARN_ON_ONCE(smp_processor_id() != me);
254255

255256
WRITE_ONCE(rt->start_reader, 0);
257+
if (!atomic_dec_return(&n_started))
258+
while (atomic_read_acquire(&n_started))
259+
cpu_relax();
256260

257261
VERBOSE_PERFOUT("ref_perf_reader %ld: experiment %d started", me, exp_idx);
258262

@@ -367,6 +371,7 @@ static int main_func(void *arg)
367371

368372
reset_readers();
369373
atomic_set(&nreaders_exp, nreaders);
374+
atomic_set(&n_started, nreaders);
370375

371376
exp_idx = exp;
372377

0 commit comments

Comments
 (0)