History

refscale: Add measurement of clock readout

This commit adds a "clock" type to refscale, which checks the performance of ktime_get_real_fast_ns(). Use the "clocksource=" kernel boot parameter to select the underlying clock source. [ paulmck: Work around compiler false positive per kernel test robot. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

Paul E. McKenney committed 5 years ago

Commit 25f6fa51 parent 2734d6c1 file · +35 −1Browse files

Unified · Split

kernel/rcu/refscale.c+35−1
@@ -467,6 +467,40 @@ static struct ref_scale_ops acqrel_ops = { · 466 unmodified lines
467467 .name = "acqrel"
468468 };
469469
470+static volatile u64 stopopts;
471+
472+static void ref_clock_section(const int nloops)
473+{
474+ u64 x = 0;
475+ int i;
476+
477+ preempt_disable();
478+ for (i = nloops; i >= 0; i--)
479+ x += ktime_get_real_fast_ns();
480+ preempt_enable();
481+ stopopts = x;
482+}
483+
484+static void ref_clock_delay_section(const int nloops, const int udl, const int ndl)
485+{
486+ u64 x = 0;
487+ int i;
488+
489+ preempt_disable();
490+ for (i = nloops; i >= 0; i--) {
491+ x += ktime_get_real_fast_ns();
492+ un_delay(udl, ndl);
493+ }
494+ preempt_enable();
495+ stopopts = x;
496+}
497+
498+static struct ref_scale_ops clock_ops = {
499+ .readsection = ref_clock_section,
500+ .delaysection = ref_clock_delay_section,
501+ .name = "clock"
502+};
503+
470504 static void rcu_scale_one_reader(void)
471505 {
472506 if (readdelay <= 0)
@@ -759,7 +793,7 @@ ref_scale_init(void) · 286 unmodified lines
759793 int firsterr = 0;
760794 static struct ref_scale_ops *scale_ops[] = {
761795 &rcu_ops, &srcu_ops, &rcu_trace_ops, &rcu_tasks_ops, &refcnt_ops, &rwlock_ops,
762− &rwsem_ops, &lock_ops, &lock_irq_ops, &acqrel_ops,
796+ &rwsem_ops, &lock_ops, &lock_irq_ops, &acqrel_ops, &clock_ops,
763797 };
764798
765799 if (!torture_init_begin(scale_type, verbose))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t