lkml.org 
[lkml]   [2020]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: One potential issue with concurrent execution of RCU callbacks...
On Tue, Dec 08, 2020 at 09:19:27AM -0800, Paul E. McKenney wrote:
> On Tue, Dec 08, 2020 at 04:54:57PM +0100, Frederic Weisbecker wrote:
> > On Tue, Dec 08, 2020 at 06:58:10AM -0800, Paul E. McKenney wrote:
> > > Hello, Frederic,
> > >
> > > Boqun just asked if RCU callbacks ran in BH-disabled context to avoid
> > > concurrent execution of the same callback. Of course, this raises the
> > > question of whether a self-posting callback can have two instances of
> > > itself running concurrently while a CPU is in the process of transitioning
> > > between softirq and rcuo invocation of callbacks.
> > >
> > > I believe that the answer is "no" because BH-disabled context is
> > > an implicit RCU read-side critical section. Therefore, the initial
> > > invocation of the RCU callback must complete in order for a new grace
> > > period to complete, and a new grace period must complete before the
> > > second invocation of that same callback to start.
> > >
> > > Does that make sense, or am I missing something?
> >
> > Sounds like a good explanation. But then why are we actually calling
> > the entire rcu_do_batch() under BH-disabled context? Was it to quieten
> > lockdep against rcu_callback_map ?
>
> Inertia and lack of complaints about it. ;-)
>
> Plus when called from softirq, neither local_bh_disable() nor
> rcu_read_lock() is necessary, and so represents pointless overhead.
>
> > Wouldn't rcu_read_lock() around callbacks invocation be enough? Or is
> > there another reason for the BH-disabled context that I'm missing?
>
> There are likely to be callback functions that use spin_lock() instead
> of spin_lock_bh() because they know that they are invoked in BH-disabled
> context.

Ah right. So perhaps we can keep local_bh_disable() instead.

>
> But what does this change help?

It reduces the code scope running with BH disabled.
Also narrowing down helps to understand what it actually protects.

Thanks.

\
 
 \ /
  Last update: 2020-12-08 18:57    [W:1.207 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site