refscale: Add srcu_read_lock_fast() support using "srcu-fast"
authorPaul E. McKenney <paulmck@kernel.org>
Fri, 10 Jan 2025 00:32:31 +0000 (16:32 -0800)
committerBoqun Feng <boqun.feng@gmail.com>
Wed, 5 Feb 2025 15:12:05 +0000 (07:12 -0800)
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>
kernel/rcu/refscale.c

index 1b47376acdc40be6795673edf2486a712e3e3ba8..f11a7c2af778cd1148988d8beb433c956517ce82 100644 (file)
@@ -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;
@@ -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,