Skip to content

Commit 057df3e

Browse files
paulmckrcuFrederic Weisbecker
authored andcommitted
refscale: Add preempt_disable() readers
This commit adds refscale readers based on preempt_disable() and preempt_enable() ("refscale.scale_type=preempt"). On my x86 laptop, these are about 2.8ns. Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
1 parent 78a731c commit 057df3e

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

kernel/rcu/refscale.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,37 @@ static const struct ref_scale_ops jiffies_ops = {
629629
.name = "jiffies"
630630
};
631631

632+
static void ref_preempt_section(const int nloops)
633+
{
634+
int i;
635+
636+
migrate_disable();
637+
for (i = nloops; i >= 0; i--) {
638+
preempt_disable();
639+
preempt_enable();
640+
}
641+
migrate_enable();
642+
}
643+
644+
static void ref_preempt_delay_section(const int nloops, const int udl, const int ndl)
645+
{
646+
int i;
647+
648+
migrate_disable();
649+
for (i = nloops; i >= 0; i--) {
650+
preempt_disable();
651+
un_delay(udl, ndl);
652+
preempt_enable();
653+
}
654+
migrate_enable();
655+
}
656+
657+
static const struct ref_scale_ops preempt_ops = {
658+
.readsection = ref_preempt_section,
659+
.delaysection = ref_preempt_delay_section,
660+
.name = "preempt"
661+
};
662+
632663
static void ref_bh_section(const int nloops)
633664
{
634665
int i;
@@ -1261,7 +1292,7 @@ ref_scale_init(void)
12611292
&rcu_ops, &srcu_ops, &srcu_fast_ops, RCU_TRACE_OPS RCU_TASKS_OPS
12621293
&refcnt_ops, &rwlock_ops, &rwsem_ops, &lock_ops, &lock_irq_ops,
12631294
&acqrel_ops, &sched_clock_ops, &clock_ops, &jiffies_ops,
1264-
&bh_ops, &irq_ops, &irqsave_ops,
1295+
&preempt_ops, &bh_ops, &irq_ops, &irqsave_ops,
12651296
&typesafe_ref_ops, &typesafe_lock_ops, &typesafe_seqlock_ops,
12661297
};
12671298

0 commit comments

Comments
 (0)