Skip to content

Commit bfad332

Browse files
paulmckrcuFrederic Weisbecker
authored andcommitted
refscale: Add SRCU-fast-updown readers
This commit adds refscale readers based on srcu_read_lock_fast_updown() and srcu_read_unlock_fast_updown() ("refscale.scale_type=srcu-fast-updown"). On my x86 laptop, these are about 2.2ns per pair. Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: <bpf@vger.kernel.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
1 parent 81f00c4 commit bfad332

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

kernel/rcu/refscale.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ static const struct ref_scale_ops rcu_ops = {
185185
// Definitions for SRCU ref scale testing.
186186
DEFINE_STATIC_SRCU(srcu_refctl_scale);
187187
DEFINE_STATIC_SRCU_FAST(srcu_fast_refctl_scale);
188+
DEFINE_STATIC_SRCU_FAST_UPDOWN(srcu_fast_updown_refctl_scale);
188189
static struct srcu_struct *srcu_ctlp = &srcu_refctl_scale;
189190

190191
static void srcu_ref_scale_read_section(const int nloops)
@@ -253,6 +254,42 @@ static const struct ref_scale_ops srcu_fast_ops = {
253254
.name = "srcu-fast"
254255
};
255256

257+
static bool srcu_fast_updown_sync_scale_init(void)
258+
{
259+
srcu_ctlp = &srcu_fast_updown_refctl_scale;
260+
return true;
261+
}
262+
263+
static void srcu_fast_updown_ref_scale_read_section(const int nloops)
264+
{
265+
int i;
266+
struct srcu_ctr __percpu *scp;
267+
268+
for (i = nloops; i >= 0; i--) {
269+
scp = srcu_read_lock_fast_updown(srcu_ctlp);
270+
srcu_read_unlock_fast_updown(srcu_ctlp, scp);
271+
}
272+
}
273+
274+
static void srcu_fast_updown_ref_scale_delay_section(const int nloops, const int udl, const int ndl)
275+
{
276+
int i;
277+
struct srcu_ctr __percpu *scp;
278+
279+
for (i = nloops; i >= 0; i--) {
280+
scp = srcu_read_lock_fast_updown(srcu_ctlp);
281+
un_delay(udl, ndl);
282+
srcu_read_unlock_fast_updown(srcu_ctlp, scp);
283+
}
284+
}
285+
286+
static const struct ref_scale_ops srcu_fast_updown_ops = {
287+
.init = srcu_fast_updown_sync_scale_init,
288+
.readsection = srcu_fast_updown_ref_scale_read_section,
289+
.delaysection = srcu_fast_updown_ref_scale_delay_section,
290+
.name = "srcu-fast-updown"
291+
};
292+
256293
#ifdef CONFIG_TASKS_RCU
257294

258295
// Definitions for RCU Tasks ref scale testing: Empty read markers.
@@ -1170,7 +1207,8 @@ ref_scale_init(void)
11701207
long i;
11711208
int firsterr = 0;
11721209
static const struct ref_scale_ops *scale_ops[] = {
1173-
&rcu_ops, &srcu_ops, &srcu_fast_ops, RCU_TRACE_OPS RCU_TASKS_OPS
1210+
&rcu_ops, &srcu_ops, &srcu_fast_ops, &srcu_fast_updown_ops,
1211+
RCU_TRACE_OPS RCU_TASKS_OPS
11741212
&refcnt_ops, &rwlock_ops, &rwsem_ops, &lock_ops, &lock_irq_ops,
11751213
&acqrel_ops, &sched_clock_ops, &clock_ops, &jiffies_ops,
11761214
&typesafe_ref_ops, &typesafe_lock_ops, &typesafe_seqlock_ops,

0 commit comments

Comments
 (0)