Skip to content

Commit b5a2801

Browse files
committed
refscale: Add a "jiffies" test
This commit adds a "jiffies" test to refscale, allowing use of jiffies to be compared to ktime_get_real_fast_ns(). On my x86 laptop, jiffies is more than 20x faster. (Though for many uses, the tens-of-nanoseconds overhead of ktime_get_real_fast_ns() will be just fine.) Signed-off-by: Paul E. McKenney <[email protected]>
1 parent f5063e8 commit b5a2801

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

kernel/rcu/refscale.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,38 @@ static struct ref_scale_ops clock_ops = {
528528
.name = "clock"
529529
};
530530

531+
static void ref_jiffies_section(const int nloops)
532+
{
533+
u64 x = 0;
534+
int i;
535+
536+
preempt_disable();
537+
for (i = nloops; i >= 0; i--)
538+
x += jiffies;
539+
preempt_enable();
540+
stopopts = x;
541+
}
542+
543+
static void ref_jiffies_delay_section(const int nloops, const int udl, const int ndl)
544+
{
545+
u64 x = 0;
546+
int i;
547+
548+
preempt_disable();
549+
for (i = nloops; i >= 0; i--) {
550+
x += jiffies;
551+
un_delay(udl, ndl);
552+
}
553+
preempt_enable();
554+
stopopts = x;
555+
}
556+
557+
static struct ref_scale_ops jiffies_ops = {
558+
.readsection = ref_jiffies_section,
559+
.delaysection = ref_jiffies_delay_section,
560+
.name = "jiffies"
561+
};
562+
531563
////////////////////////////////////////////////////////////////////////
532564
//
533565
// Methods leveraging SLAB_TYPESAFE_BY_RCU.
@@ -1047,7 +1079,7 @@ ref_scale_init(void)
10471079
int firsterr = 0;
10481080
static struct ref_scale_ops *scale_ops[] = {
10491081
&rcu_ops, &srcu_ops, RCU_TRACE_OPS RCU_TASKS_OPS &refcnt_ops, &rwlock_ops,
1050-
&rwsem_ops, &lock_ops, &lock_irq_ops, &acqrel_ops, &clock_ops,
1082+
&rwsem_ops, &lock_ops, &lock_irq_ops, &acqrel_ops, &clock_ops, &jiffies_ops,
10511083
&typesafe_ref_ops, &typesafe_lock_ops, &typesafe_seqlock_ops,
10521084
};
10531085

0 commit comments

Comments
 (0)