Skip to content

Commit edd6f78

Browse files
paulmckrcuFrederic Weisbecker
authored andcommitted
refscale: Add local_irq_disable() and local_irq_save() readers
This commit adds refscale readers based on local_irq_disable() and local_irq_enable() ("refscale.scale_type=irq") and on local_irq_save() and local_irq_restore ("refscale.scale_type=irqsave"). On my x86 laptop, these are about 2.8ns and 7.5ns per enable/disable pair, respectively. Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
1 parent 3a86608 commit edd6f78

1 file changed

Lines changed: 65 additions & 1 deletion

File tree

kernel/rcu/refscale.c

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

632+
static void ref_irq_section(const int nloops)
633+
{
634+
int i;
635+
636+
preempt_disable();
637+
for (i = nloops; i >= 0; i--) {
638+
local_irq_disable();
639+
local_irq_enable();
640+
}
641+
preempt_enable();
642+
}
643+
644+
static void ref_irq_delay_section(const int nloops, const int udl, const int ndl)
645+
{
646+
int i;
647+
648+
preempt_disable();
649+
for (i = nloops; i >= 0; i--) {
650+
local_irq_disable();
651+
un_delay(udl, ndl);
652+
local_irq_enable();
653+
}
654+
preempt_enable();
655+
}
656+
657+
static const struct ref_scale_ops irq_ops = {
658+
.readsection = ref_irq_section,
659+
.delaysection = ref_irq_delay_section,
660+
.name = "irq"
661+
};
662+
663+
static void ref_irqsave_section(const int nloops)
664+
{
665+
unsigned long flags;
666+
int i;
667+
668+
preempt_disable();
669+
for (i = nloops; i >= 0; i--) {
670+
local_irq_save(flags);
671+
local_irq_restore(flags);
672+
}
673+
preempt_enable();
674+
}
675+
676+
static void ref_irqsave_delay_section(const int nloops, const int udl, const int ndl)
677+
{
678+
unsigned long flags;
679+
int i;
680+
681+
preempt_disable();
682+
for (i = nloops; i >= 0; i--) {
683+
local_irq_save(flags);
684+
un_delay(udl, ndl);
685+
local_irq_restore(flags);
686+
}
687+
preempt_enable();
688+
}
689+
690+
static const struct ref_scale_ops irqsave_ops = {
691+
.readsection = ref_irqsave_section,
692+
.delaysection = ref_irqsave_delay_section,
693+
.name = "irqsave"
694+
};
695+
632696
////////////////////////////////////////////////////////////////////////
633697
//
634698
// Methods leveraging SLAB_TYPESAFE_BY_RCU.
@@ -1165,7 +1229,7 @@ ref_scale_init(void)
11651229
static const struct ref_scale_ops *scale_ops[] = {
11661230
&rcu_ops, &srcu_ops, &srcu_fast_ops, RCU_TRACE_OPS RCU_TASKS_OPS
11671231
&refcnt_ops, &rwlock_ops, &rwsem_ops, &lock_ops, &lock_irq_ops,
1168-
&acqrel_ops, &sched_clock_ops, &clock_ops, &jiffies_ops,
1232+
&acqrel_ops, &sched_clock_ops, &clock_ops, &jiffies_ops, &irq_ops, &irqsave_ops,
11691233
&typesafe_ref_ops, &typesafe_lock_ops, &typesafe_seqlock_ops,
11701234
};
11711235

0 commit comments

Comments
 (0)