Skip to content

Commit 2db0bda

Browse files
committed
refperf: Add warmup and cooldown processing phases
This commit causes all the readers to start running unmeasured load until all readers have done at least one such run (thus having warmed up), then run the measured load, and then run unmeasured load until all readers have completed their measured load. This approach avoids any thread running measured load while other readers are idle. Cc: Joel Fernandes (Google) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 86e0da2 commit 2db0bda

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

kernel/rcu/refperf.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ static atomic_t nreaders_exp;
100100
// Use to wait for all threads to start.
101101
static atomic_t n_init;
102102
static atomic_t n_started;
103+
static atomic_t n_warmedup;
104+
static atomic_t n_cooleddown;
103105

104106
// Track which experiment is currently running.
105107
static int exp_idx;
@@ -260,8 +262,15 @@ ref_perf_reader(void *arg)
260262

261263
VERBOSE_PERFOUT("ref_perf_reader %ld: experiment %d started", me, exp_idx);
262264

263-
// To prevent noise, keep interrupts disabled. This also has the
264-
// effect of preventing entries into slow path for rcu_read_unlock().
265+
266+
// To reduce noise, do an initial cache-warming invocation, check
267+
// in, and then keep warming until everyone has checked in.
268+
cur_ops->readsection(loops);
269+
if (!atomic_dec_return(&n_warmedup))
270+
while (atomic_read_acquire(&n_warmedup))
271+
cur_ops->readsection(loops);
272+
// Also keep interrupts disabled. This also has the effect
273+
// of preventing entries into slow path for rcu_read_unlock().
265274
local_irq_save(flags);
266275
start = ktime_get_mono_fast_ns();
267276

@@ -271,6 +280,11 @@ ref_perf_reader(void *arg)
271280
local_irq_restore(flags);
272281

273282
rt->last_duration_ns = WARN_ON_ONCE(duration < 0) ? 0 : duration;
283+
// To reduce runtime-skew noise, do maintain-load invocations until
284+
// everyone is done.
285+
if (!atomic_dec_return(&n_cooleddown))
286+
while (atomic_read_acquire(&n_cooleddown))
287+
cur_ops->readsection(loops);
274288

275289
if (atomic_dec_and_test(&nreaders_exp))
276290
wake_up(&main_wq);
@@ -372,6 +386,8 @@ static int main_func(void *arg)
372386
reset_readers();
373387
atomic_set(&nreaders_exp, nreaders);
374388
atomic_set(&n_started, nreaders);
389+
atomic_set(&n_warmedup, nreaders);
390+
atomic_set(&n_cooleddown, nreaders);
375391

376392
exp_idx = exp;
377393

0 commit comments

Comments
 (0)