Skip to content

Commit

Permalink
refscale: Add srcu_read_lock_fast() support using "srcu-fast"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paul E. McKenney authored and Boqun Feng committed Feb 5, 2025
1 parent 176d19e commit 4c3fca0
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion kernel/rcu/refscale.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,36 @@ static const struct ref_scale_ops srcu_ops = {
.name = "srcu"
};

static void srcu_fast_ref_scale_read_section(const int nloops)
{
int i;
struct srcu_ctr __percpu *scp;

for (i = nloops; i >= 0; i--) {
scp = srcu_read_lock_fast(srcu_ctlp);
srcu_read_unlock_fast(srcu_ctlp, scp);
}
}

static void srcu_fast_ref_scale_delay_section(const int nloops, const int udl, const int ndl)
{
int i;
struct srcu_ctr __percpu *scp;

for (i = nloops; i >= 0; i--) {
scp = srcu_read_lock_fast(srcu_ctlp);
un_delay(udl, ndl);
srcu_read_unlock_fast(srcu_ctlp, scp);
}
}

static const struct ref_scale_ops srcu_fast_ops = {
.init = rcu_sync_scale_init,
.readsection = srcu_fast_ref_scale_read_section,
.delaysection = srcu_fast_ref_scale_delay_section,
.name = "srcu-fast"
};

static void srcu_lite_ref_scale_read_section(const int nloops)
{
int i;
Expand Down Expand Up @@ -1163,7 +1193,7 @@ ref_scale_init(void)
long i;
int firsterr = 0;
static const struct ref_scale_ops *scale_ops[] = {
&rcu_ops, &srcu_ops, &srcu_lite_ops, RCU_TRACE_OPS RCU_TASKS_OPS
&rcu_ops, &srcu_ops, &srcu_fast_ops, &srcu_lite_ops, RCU_TRACE_OPS RCU_TASKS_OPS
&refcnt_ops, &rwlock_ops, &rwsem_ops, &lock_ops, &lock_irq_ops,
&acqrel_ops, &sched_clock_ops, &clock_ops, &jiffies_ops,
&typesafe_ref_ops, &typesafe_lock_ops, &typesafe_seqlock_ops,
Expand Down

0 comments on commit 4c3fca0

Please sign in to comment.