From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Tejun Heo <tj@kernel.org>, Jann Horn <jannh@google.com>,
Benjamin LaHaise <bcrl@kvack.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
linux-kernel@vger.kernel.org
Subject: Re: Simplifying our RCU models
Date: Tue, 6 Mar 2018 12:39:06 -0800 [thread overview]
Message-ID: <20180306203906.GA3918@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180306084738.tcs4ggbby77phlbh@gmail.com>
On Tue, Mar 06, 2018 at 09:47:38AM +0100, Ingo Molnar wrote:
>
> * Paul E. McKenney <paulmck@linux.vnet.ibm.com> wrote:
>
> > > > But if we look at the bigger API picture:
> > > >
> > > > !PREEMPT_RCU PREEMPT_RCU=y
> > > > rcu_read_lock(): atomic preemptible
> > > > rcu_read_lock_sched(): atomic atomic
> > > > srcu_read_lock(): preemptible preemptible
> > > >
> > > > Then we could maintain full read side API flexibility by making PREEMPT_RCU=y the
> > > > only model, merging it with SRCU and using these main read side APIs:
> > > >
> > > > rcu_read_lock_preempt_disable(): atomic
> > > > rcu_read_lock(): preemptible
> >
> > One issue with merging SRCU into rcu_read_lock() is the general blocking within
> > SRCU readers. Once merged in, these guys block everyone. We should focus
> > initially on the non-SRCU variants.
> >
> > On the other hand, Linus's suggestion of merging rcu_read_lock_sched()
> > into rcu_read_lock() just might be feasible. If that really does pan
> > out, we end up with the following:
> >
> > !PREEMPT PREEMPT=y
> > rcu_read_lock(): atomic preemptible
> > srcu_read_lock(): preemptible preemptible
> >
> > In this model, rcu_read_lock_sched() maps to preempt_disable() and (as
> > you say above) rcu_read_lock_bh() maps to local_bh_disable(). The way
> > this works is that in PREEMPT=y kernels, synchronize_rcu() waits not
> > only for RCU read-side critical sections, but also for regions of code
> > with preemption disabled. The main caveat seems to be that there be an
> > assumed point of preemptibility between each interrupt and each softirq
> > handler, which should be OK.
> >
> > There will be some adjustments required for lockdep-RCU, but that should
> > be reasonably straightforward.
> >
> > Seem reasonable?
>
> Yes, that approach sounds very reasonable to me: it is similar to what we do on
> the locking side as well, where we have 'atomic' variants (spinlocks/rwlocks) and
> 'sleeping' variants (mutexes, rwsems, etc.).
>
> ( This means there will be more automatic coupling between BH and preempt critical
> sections and RCU models not captured via explicit RCU-namespace APIs, but that
> should be OK I think. )
Thus far, I have been unable to prove that it cannot work, which is about
as good as it gets at this stage. So here is hoping! ;-)
I will look at your later corrected message, but will gratefully accept
your offer of help with the naming transition.
Thanx, Paul
> A couple of small side notes:
>
> - Could we please also clean up the namespace of the synchronization APIs and
> change them all to an rcu_ prefix, like all the other RCU APIs are? Right now
> have a mixture like rcu_read_lock() but synchronize_rcu(), while I'd reall love
> to be able to do:
>
> git grep '\<rcu_' ...
>
> ... to see RCU API usage within a particular kernel area. This would also clean
> up some of the internal inconsistencies like having 'struct rcu_synchronize'.
>
> - If we are cleaning up the write side APIs, could we move over to a _wait
> nomenclature, i.e. rcu_wait*()?
>
> I.e. the new RCU namespace would be something like:
>
> rcu_read_lock => rcu_read_lock # unchanged
> rcu_read_unlock => rcu_read_unlock # unchanged
>
> call_rcu => rcu_call_rcu
> call_rcu_bh => rcu_call_bh
> call_rcu_sched => rcu_call_sched
>
> synchronize_rcu => rcu_wait_
> synchronize_rcu_bh => rcu_wait_bh
> synchronize_rcu_bh_expedited => rcu_wait_expedited_bh
> synchronize_rcu_expedited => rcu_wait_expedited
> synchronize_rcu_mult => rcu_wait_mult
> synchronize_rcu_sched => rcu_wait_sched
> synchronize_rcu_tasks => rcu_wait_tasks
>
> srcu_read_lock => srcu_read_lock # unchanged
> srcu_read_unlock => srcu_read_unlock # unchanged
>
> synchronize_srcu => srcu_wait
> synchronize_srcu_expedited => srcu_wait_expedited
>
> Note that due to the prefix approach we gain various new patterns:
>
> git grep rcu_wait # matches both rcu and srcu
> git grep rcu_wait # matches all RCU waiting variants
> git grep wait_expedited # matches all expedited variants
>
> ... which all increase the organization of the namespace.
>
> - While we are at it, the two RCU-state API variants, while rarely used, are
> named in a pretty obscure, disconnected fashion as well. A much better naming
> would be:
>
> get_state_synchronize_rcu => rcu_get_state
> cond_synchronize_rcu => rcu_wait_state
>
> ... or so. This would also move them into the new, unified rcu_ prefix
> namespace.
>
> Note how consistent and hierarchical the new RCU API namespace is:
>
> <subsystem-prefix>_<verb>[_<qualifier[s]>]
>
> If you agree with the overall concept of this I'd be glad to help out with
> scripting & testing the RCU namespace transition safely in an unintrusive fashion
> once you've done the model unification work, with compatibility defines to not
> create conflicts, churn and pain, etc.
>
> Thanks,
>
> Ingo
>
next prev parent reply other threads:[~2018-03-06 20:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAG48ez17vOL0oEWqoqdHCjqfGVX+aPhHBrtgCfn35z6jZ=8-Xg@mail.gmail.com>
[not found] ` <CA+55aFzQPQw2UqQ2EEGN1Xe7=qDs-2VTvHVi7SSqGNwqNRg0cQ@mail.gmail.com>
[not found] ` <CAOS58YPzLeiZnwEeN31wWMZhki0t9+3ozdRNv9DgxWKY7OKmGA@mail.gmail.com>
[not found] ` <CA+55aFx48U4W5tUgqW9ioZOHibPhQoDCUDWF_d-7yNCbqFQ7zg@mail.gmail.com>
[not found] ` <20180305001600.GO3918@linux.vnet.ibm.com>
[not found] ` <CA+55aFyOi1XnSqHtg=VfcUiBL+egNL==NRX1Zaeihe8W5OJVgw@mail.gmail.com>
[not found] ` <20180305030949.GP3918@linux.vnet.ibm.com>
[not found] ` <20180305082441.4hao2z4dqn2n5on6@gmail.com>
2018-03-05 14:33 ` Simplifying our RCU models Eric W. Biederman
2018-03-05 16:14 ` Paul E. McKenney
2018-03-06 8:47 ` Ingo Molnar
2018-03-06 9:00 ` Ingo Molnar
2018-03-06 21:06 ` Paul E. McKenney
2018-03-06 20:39 ` Paul E. McKenney [this message]
2018-03-07 15:54 ` Paul E. McKenney
2018-03-07 18:48 ` Linus Torvalds
2018-03-08 20:45 ` Paul E. McKenney
2018-04-10 23:44 ` Paul E. McKenney
2018-06-08 16:51 ` Paul E. McKenney
2018-06-27 22:28 ` Paul E. McKenney
2018-08-29 21:47 ` Paul E. McKenney
2018-03-08 21:19 ` Andrea Parri
[not found] ` <20180309005145.GZ3918@linux.vnet.ibm.com>
[not found] ` <20180309095520.GA5079@andrea>
[not found] ` <20180310160409.GF3918@linux.vnet.ibm.com>
[not found] ` <20180310162946.GA7548@andrea>
[not found] ` <20180310224726.GI3918@linux.vnet.ibm.com>
2018-03-10 23:36 ` Andrea Parri
2018-03-09 9:48 ` Lai Jiangshan
2018-03-10 16:06 ` 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=20180306203906.GA3918@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=bcrl@kvack.org \
--cc=ebiederm@xmission.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.