Skip to content

Commit 1806b1f

Browse files
paulmckrcuurezki
authored andcommitted
refscale: Add test for sched_clock()
This commit adds a "sched-clock" test for the sched_clock() function. Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
1 parent fac04ef commit 1806b1f

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

kernel/rcu/refscale.c

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <linux/slab.h>
3737
#include <linux/torture.h>
3838
#include <linux/types.h>
39+
#include <linux/sched/clock.h>
3940

4041
#include "rcu.h"
4142

@@ -531,6 +532,39 @@ static const struct ref_scale_ops acqrel_ops = {
531532

532533
static volatile u64 stopopts;
533534

535+
static void ref_sched_clock_section(const int nloops)
536+
{
537+
u64 x = 0;
538+
int i;
539+
540+
preempt_disable();
541+
for (i = nloops; i >= 0; i--)
542+
x += sched_clock();
543+
preempt_enable();
544+
stopopts = x;
545+
}
546+
547+
static void ref_sched_clock_delay_section(const int nloops, const int udl, const int ndl)
548+
{
549+
u64 x = 0;
550+
int i;
551+
552+
preempt_disable();
553+
for (i = nloops; i >= 0; i--) {
554+
x += sched_clock();
555+
un_delay(udl, ndl);
556+
}
557+
preempt_enable();
558+
stopopts = x;
559+
}
560+
561+
static const struct ref_scale_ops sched_clock_ops = {
562+
.readsection = ref_sched_clock_section,
563+
.delaysection = ref_sched_clock_delay_section,
564+
.name = "sched-clock"
565+
};
566+
567+
534568
static void ref_clock_section(const int nloops)
535569
{
536570
u64 x = 0;
@@ -1130,9 +1164,9 @@ ref_scale_init(void)
11301164
int firsterr = 0;
11311165
static const struct ref_scale_ops *scale_ops[] = {
11321166
&rcu_ops, &srcu_ops, &srcu_lite_ops, RCU_TRACE_OPS RCU_TASKS_OPS
1133-
&refcnt_ops, &rwlock_ops, &rwsem_ops, &lock_ops, &lock_irq_ops, &acqrel_ops,
1134-
&clock_ops, &jiffies_ops, &typesafe_ref_ops, &typesafe_lock_ops,
1135-
&typesafe_seqlock_ops,
1167+
&refcnt_ops, &rwlock_ops, &rwsem_ops, &lock_ops, &lock_irq_ops,
1168+
&acqrel_ops, &sched_clock_ops, &clock_ops, &jiffies_ops,
1169+
&typesafe_ref_ops, &typesafe_lock_ops, &typesafe_seqlock_ops,
11361170
};
11371171

11381172
if (!torture_init_begin(scale_type, verbose))

0 commit comments

Comments
 (0)