On Thu, Jan 16, 2025 at 12:21 PM Paul E. McKenney <[email protected]> wrote:
>
> +/*
> + * Counts the new reader in the appropriate per-CPU element of the
> + * srcu_struct.  Returns a pointer that must be passed to the matching
> + * srcu_read_unlock_fast().
> + *
> + * Note that this_cpu_inc() is an RCU read-side critical section either
> + * because it disables interrupts, because it is a single instruction,
> + * or because it is a read-modify-write atomic operation, depending on
> + * the whims of the architecture.
> + */
> +static inline struct srcu_ctr __percpu *__srcu_read_lock_fast(struct 
> srcu_struct *ssp)
> +{
> +       struct srcu_ctr __percpu *scp = READ_ONCE(ssp->srcu_ctrp);
> +
> +       RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching 
> srcu_read_lock_fast().");
> +       this_cpu_inc(scp->srcu_locks.counter); /* Y */
> +       barrier(); /* Avoid leaking the critical section. */
> +       return scp;
> +}

This doesn't look fast.
If I'm reading this correctly,
even with debugs off RCU_LOCKDEP_WARN() will still call
rcu_is_watching() and this doesn't look cheap or fast.

Reply via email to