Skip to content

Commit b864f89

Browse files
committed
refperf: Tune reader measurement interval
This commit moves a printk() out of the measurement interval, converts a atomic_dec()/atomic_read() pair to atomic_dec_and_test(), and adds a smp_mb__before_atomic() to avoid potential wake/wait hangs. These changes have the added benefit of reducing the number of loops required for amortizing loop overhead for CONFIG_PREEMPT=n RCU measurements from 1,000,000 to 10,000. This reduction in turn shortens the test, reducing the probability of interference. Cc: Joel Fernandes (Google) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 2990750 commit b864f89

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

kernel/rcu/refperf.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,30 +252,29 @@ 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();
255256
atomic_dec(&rt->start);
256257

258+
VERBOSE_PERFOUT("ref_perf_reader %ld: experiment %d started", me, exp_idx);
259+
257260
// To prevent noise, keep interrupts disabled. This also has the
258261
// effect of preventing entries into slow path for rcu_read_unlock().
259262
local_irq_save(flags);
260263
start = ktime_get_mono_fast_ns();
261264

262-
VERBOSE_PERFOUT("ref_perf_reader %ld: experiment %d started", me, exp_idx);
263-
264265
cur_ops->readsection(loops);
265266

266267
duration = ktime_get_mono_fast_ns() - start;
267268
local_irq_restore(flags);
268269

269270
rt->last_duration_ns = WARN_ON_ONCE(duration < 0) ? 0 : duration;
270271

271-
atomic_dec(&nreaders_exp);
272+
if (atomic_dec_and_test(&nreaders_exp))
273+
wake_up(&main_wq);
272274

273275
VERBOSE_PERFOUT("ref_perf_reader %ld: experiment %d ended, (readers remaining=%d)",
274276
me, exp_idx, atomic_read(&nreaders_exp));
275277

276-
if (!atomic_read(&nreaders_exp))
277-
wake_up(&main_wq);
278-
279278
if (!torture_must_stop())
280279
goto repeat;
281280
end:

0 commit comments

Comments
 (0)