From: Joel Fernandes <joelagnelf@nvidia.com>
To: paulmck@kernel.org
Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com, rostedt@goodmis.org, bpf@vger.kernel.org
Subject: Re: [PATCH v3 5/4] srcu: Document __srcu_read_{,un}lock_fast() implicit RCU readers
Date: Wed, 23 Jul 2025 12:10:46 -0400 [thread overview]
Message-ID: <fa4fd174-065d-4a04-b080-ffe04d31313f@nvidia.com> (raw)
In-Reply-To: <9FAE52D6-D073-43D9-93D3-3E49006943B2@nvidia.com>
On 7/23/2025 9:32 AM, joelagnelf@nvidia.com wrote:
>
>
>> On Jul 22, 2025, at 6:17 PM, Paul E. McKenney <paulmck@kernel.org> wrote:
>>
>> This commit documents the implicit RCU readers that are implied by the
>> this_cpu_inc() and atomic_long_inc() operations in __srcu_read_lock_fast()
>> and __srcu_read_unlock_fast(). While in the area, fix the documentation
>> of the memory pairing of atomic_long_inc() in __srcu_read_lock_fast().
>
> Just to clarify, the implication here is since SRCU-fast uses synchronize_rcu on the update side, these operations result in blocking of classical RCU too. So simply using srcu fast is another way of achieving the previously used pre-empt-disabling in the use cases.
Hi Paul, it was nice sync'ing with you off-list. Following are my suggestions
and where I am coming from:
1. For someone who doesn't know SRCU-fast depends on synchronize_rcu (me after a
few beers :P), the word 'RCU' in the comment you added to this patch, might come
across as 'which RCU are we referring to - SRCU or classical RCU or some other'.
So I would call it 'classical RCU reader' in the comment.
2. It would be good to call out specifically that, the SRCU-fast critical
section is akin to a classical RCU reader, because of its implementation's
dependence on synchronize_rcu() to overcome the lack of read-side memory barriers.
3. I think since the potential size of these code comment suggestions, it may
make sense to provide a bigger comment suggesting these than providing them
inline as you did. And also calling out the tracing usecase in the comments for
additional usecase clarification.
I could provide a patch to do all this soon, as we discussed, as well (unless
you're Ok with making this change as well).
Thanks!
- Joel
>
> Or is the rationale for this something else?
>
> I would probably spell this out more in a longer comment above the if/else, than modify the inline comments.
>
> But I am probably misunderstood the whole thing. :-(
>
> -Joel
>
>>
>> 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>
>>
>> diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h
>> index 043b5a67ef71e..78e1a7b845ba9 100644
>> --- a/include/linux/srcutree.h
>> +++ b/include/linux/srcutree.h
>> @@ -245,9 +245,9 @@ static inline struct srcu_ctr __percpu *__srcu_read_lock_fast(struct srcu_struct
>> struct srcu_ctr __percpu *scp = READ_ONCE(ssp->srcu_ctrp);
>>
>> if (!IS_ENABLED(CONFIG_NEED_SRCU_NMI_SAFE))
>> - this_cpu_inc(scp->srcu_locks.counter); /* Y */
>> + this_cpu_inc(scp->srcu_locks.counter); // Y, and implicit RCU reader.
>> else
>> - atomic_long_inc(raw_cpu_ptr(&scp->srcu_locks)); /* Z */
>> + atomic_long_inc(raw_cpu_ptr(&scp->srcu_locks)); // Y, and implicit RCU reader.
>> barrier(); /* Avoid leaking the critical section. */
>> return scp;
>> }
>> @@ -271,9 +271,9 @@ static inline void __srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_
>> {
>> barrier(); /* Avoid leaking the critical section. */
>> if (!IS_ENABLED(CONFIG_NEED_SRCU_NMI_SAFE))
>> - this_cpu_inc(scp->srcu_unlocks.counter); /* Z */
>> + this_cpu_inc(scp->srcu_unlocks.counter); // Z, and implicit RCU reader.
>> else
>> - atomic_long_inc(raw_cpu_ptr(&scp->srcu_unlocks)); /* Z */
>> + atomic_long_inc(raw_cpu_ptr(&scp->srcu_unlocks)); // Z, and implicit RCU reader.
>> }
>>
>> void __srcu_check_read_flavor(struct srcu_struct *ssp, int read_flavor);
>>
next prev parent reply other threads:[~2025-07-23 16:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-21 16:24 [PATCH v3 0/4] Switch __DECLARE_TRACE() to notrace variant of SRCU-fast Paul E. McKenney
2025-07-21 16:24 ` [PATCH v3 1/4] srcu: Move rcu_is_watching() checks to srcu_read_{,un}lock_fast() Paul E. McKenney
2025-07-22 22:04 ` Joel Fernandes
2025-07-21 16:24 ` [PATCH v3 2/4] srcu: Add srcu_read_lock_fast_notrace() and srcu_read_unlock_fast_notrace() Paul E. McKenney
2025-07-22 22:11 ` Joel Fernandes
2025-07-22 22:34 ` Paul E. McKenney
2025-07-22 22:47 ` Steven Rostedt
2025-07-22 22:51 ` Paul E. McKenney
2025-07-23 15:23 ` Mathieu Desnoyers
2025-07-23 16:28 ` Paul E. McKenney
2025-07-21 16:24 ` [PATCH v3 3/4] srcu: Add guards for notrace variants of SRCU-fast readers Paul E. McKenney
2025-07-22 22:16 ` Joel Fernandes
2025-07-21 16:24 ` [PATCH v3 4/4] tracing: Guard __DECLARE_TRACE() use of __DO_TRACE_CALL() with SRCU-fast Paul E. McKenney
2025-07-22 22:16 ` [PATCH v3 5/4] srcu: Document __srcu_read_{,un}lock_fast() implicit RCU readers Paul E. McKenney
2025-07-23 13:32 ` Joel Fernandes
2025-07-23 16:10 ` Joel Fernandes [this message]
2025-07-23 16:24 ` Paul E. McKenney
2025-07-22 22:17 ` [PATCH v3 6/4] srcu: Document srcu_flip() memory-barrier D relation to SRCU-fast Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fa4fd174-065d-4a04-b080-ffe04d31313f@nvidia.com \
--to=joelagnelf@nvidia.com \
--cc=bpf@vger.kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome