[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7cdb6f45-de42-4139-a050-b318a69ad86d@paulmck-laptop>
Date: Sat, 13 Sep 2025 15:05:47 -0700
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Waiman Long <llong@...hat.com>
Cc: Hillf Danton <hdanton@...a.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
pengdonglin <dolinux.peng@...il.com>, linux-kernel@...r.kernel.org,
herbert@...dor.apana.org.au
Subject: Re: [PATCH] rcu: Remove redundant rcu_read_lock/unlock() in
spin_lock critical sections
On Sat, Sep 13, 2025 at 01:23:03PM -0400, Waiman Long wrote:
> On 9/13/25 4:00 AM, Hillf Danton wrote:
> > On Fri, 12 Sep 2025 20:33:31 -0400 Waiman Long wrote:
> > > On 9/12/25 5:35 PM, Sebastian Andrzej Siewior wrote:
> > > > On 2025-09-12 17:13:09 [-0400], Waiman Long wrote:
> > > > > On 9/12/25 2:50 AM, pengdonglin wrote:
> > > > > > From: pengdonglin <pengdonglin@...omi.com>
> > > > > >
> > > > > > When CONFIG_PREEMPT_RT is disabled, spin_lock*()
> > > > > > operations implicitly
> > > > > > disable preemption, which provides RCU read-side protection. When
> > > > > > CONFIG_PREEMPT_RT is enabled, spin_lock*() implementations internally
> > > > > > manage RCU read-side critical sections.
> > > > > I have some doubt about your claim that disabling preemption
> > > > > provides RCU
> > > > > read-side protection. It is true for some flavors but
> > > > > probably not all. I do
> > > > > know that disabling interrupt will provide RCU read-side
> > > > > protection. So for
> > > > > spin_lock_irq*() calls, that is valid. I am not sure about
> > > > > spin_lock_bh(),
> > > > > maybe it applies there too. we need some RCU people to confirm.
> > > > The claim is valid since Paul merged the three flavours we had. Before
> > > > that preempt_disable() (and disabling irqs) would match
> > > > rcu_read_lock_sched(). rcu_read_lock() and rcu_read_lock_bh() were
> > > > different in terms of grace period and clean up.
> > > > So _now_ we could remove it if it makes things easier.
> > >
> > > Thanks for the clarification.
> > >
> > > In this case, I think the patch description should mention the
> > > commit that unify the 3 RCU flavors to make sure that this patch
> > > won't be accidentally backport'ed to an older kernel without the
> > > necessary prerequisite commit(s).
> >
> > This change also affects the dereference helpers.
> >
> > #define rcu_dereference_check(p, c) \
> > __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
> > (c) || rcu_read_lock_held(), __rcu)
> >
> Right, this macro will need to be updated as well to avoid false positive if
> we decide that preempt_disabled region is a valid rcu_read_lock critical
> section.
I suggest that you instead use the new rcu_dereference_all_check()
that Herbert Xu (added on CC) has put together here:
https://lore.kernel.org/all/aLlflTV_SDwMB7mq@gondor.apana.org.au/
This way, people wanting rcu_read_lock() and nothing else can continue
using rcu_dereference_check() and you can use rcu_dereference_all_check()
that takes rcu_read_lock() along all any other types of RCU readers.
Thanx, Paul
Powered by blists - more mailing lists