Skip to content

Commit 4c3fca0

Browse files
paulmckrcufbq
authored andcommitted
refscale: Add srcu_read_lock_fast() support using "srcu-fast"
This commit creates a new srcu-fast option for the refscale.scale_type module parameter that selects srcu_read_lock_fast() and srcu_read_unlock_fast(). Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andrii Nakryiko <andrii@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Kent Overstreet <kent.overstreet@linux.dev> Cc: <bpf@vger.kernel.org> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
1 parent 176d19e commit 4c3fca0

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

kernel/rcu/refscale.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,36 @@ static const struct ref_scale_ops srcu_ops = {
216216
.name = "srcu"
217217
};
218218

219+
static void srcu_fast_ref_scale_read_section(const int nloops)
220+
{
221+
int i;
222+
struct srcu_ctr __percpu *scp;
223+
224+
for (i = nloops; i >= 0; i--) {
225+
scp = srcu_read_lock_fast(srcu_ctlp);
226+
srcu_read_unlock_fast(srcu_ctlp, scp);
227+
}
228+
}
229+
230+
static void srcu_fast_ref_scale_delay_section(const int nloops, const int udl, const int ndl)
231+
{
232+
int i;
233+
struct srcu_ctr __percpu *scp;
234+
235+
for (i = nloops; i >= 0; i--) {
236+
scp = srcu_read_lock_fast(srcu_ctlp);
237+
un_delay(udl, ndl);
238+
srcu_read_unlock_fast(srcu_ctlp, scp);
239+
}
240+
}
241+
242+
static const struct ref_scale_ops srcu_fast_ops = {
243+
.init = rcu_sync_scale_init,
244+
.readsection = srcu_fast_ref_scale_read_section,
245+
.delaysection = srcu_fast_ref_scale_delay_section,
246+
.name = "srcu-fast"
247+
};
248+
219249
static void srcu_lite_ref_scale_read_section(const int nloops)
220250
{
221251
int i;
@@ -1163,7 +1193,7 @@ ref_scale_init(void)
11631193
long i;
11641194
int firsterr = 0;
11651195
static const struct ref_scale_ops *scale_ops[] = {
1166-
&rcu_ops, &srcu_ops, &srcu_lite_ops, RCU_TRACE_OPS RCU_TASKS_OPS
1196+
&rcu_ops, &srcu_ops, &srcu_fast_ops, &srcu_lite_ops, RCU_TRACE_OPS RCU_TASKS_OPS
11671197
&refcnt_ops, &rwlock_ops, &rwsem_ops, &lock_ops, &lock_irq_ops,
11681198
&acqrel_ops, &sched_clock_ops, &clock_ops, &jiffies_ops,
11691199
&typesafe_ref_ops, &typesafe_lock_ops, &typesafe_seqlock_ops,

0 commit comments

Comments
 (0)