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>
Unified · Split
| @@ -467,6 +467,40 @@ static struct ref_scale_ops acqrel_ops = { · 466 unmodified lines | |||
| 467 | .name = "acqrel" | 467 | .name = "acqrel" |
| 468 | }; | 468 | }; |
| 469 | 469 | ||
| 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 | |||
| 470 | static void rcu_scale_one_reader(void) | 504 | static void rcu_scale_one_reader(void) |
| 471 | { | 505 | { |
| 472 | if (readdelay <= 0) | 506 | if (readdelay <= 0) |
| @@ -759,7 +793,7 @@ ref_scale_init(void) · 286 unmodified lines | |||
| 759 | int firsterr = 0; | 793 | int firsterr = 0; |
| 760 | static struct ref_scale_ops *scale_ops[] = { | 794 | static struct ref_scale_ops *scale_ops[] = { |
| 761 | &rcu_ops, &srcu_ops, &rcu_trace_ops, &rcu_tasks_ops, &refcnt_ops, &rwlock_ops, | 795 | &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, |
| 763 | }; | 797 | }; |
| 764 | 798 | ||
| 765 | if (!torture_init_begin(scale_type, verbose)) | 799 | if (!torture_init_begin(scale_type, verbose)) |