linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Daniel Lustig <dlustig@nvidia.com>,
	Will Deacon <will.deacon@arm.com>,
	Andrea Parri <andrea.parri@amarulasolutions.com>,
	Andrea Parri <parri.andrea@gmail.com>,
	Kernel development list <linux-kernel@vger.kernel.org>,
	linux-arch@vger.kernel.org, mingo@kernel.org,
	peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com,
	dhowells@redhat.com, Jade Alglave <j.alglave@ucl.ac.uk>,
	Luc Maranget <luc.maranget@inria.fr>,
	akiyks@gmail.com, Palmer Dabbelt <palmer@sifive.com>
Subject: Re: [PATCH RFC LKMM 1/7] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire
Date: Tue, 11 Sep 2018 13:03:28 -0700	[thread overview]
Message-ID: <20180911200328.GA4225@linux.vnet.ibm.com> (raw)
Message-ID: <20180911200328.n5p0g-kjeu3LUMg3BZYnJbGGu3f7r7ZCDmOBY8C3Yt0@z> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1809111455420.1461-100000@iolanthe.rowland.org>

On Tue, Sep 11, 2018 at 03:31:53PM -0400, Alan Stern wrote:
> On Thu, 12 Jul 2018, Paul E. McKenney wrote:
> 
> > > > Take for instance the pattern where RCU relies on RCsc locks, this is an
> > > > entirely simple and straight forward use of locks, yet completely fails
> > > > on this subtle point.
> > > 
> > > Do you happen to remember exactly where in the kernel source this 
> > > occurs?
> > 
> > Look for the uses of raw_spin_lock_irq_rcu_node() and friends in
> > kernel/rcu and include/linux/*rcu*, along with the explanation in
> > Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.html
> 
> I just now started looking at this for the first time, and I was struck
> by the sloppy thinking displayed in the very first paragraph of the
> HTML document!  For example, consider the third sentence:
> 
> 	Similarly, any code that happens before the beginning of a 
> 	given RCU grace period is guaranteed to see the effects of all
> 	accesses following the end of that grace period that are within
> 	RCU read-side critical sections.
> 
> Is RCU now a time machine?  :-)

Why not?  ;-)

> I think what you meant to write in the second and third sentences was 
> something more like this:
> 
> 	Any code in an RCU critical section that extends beyond the 
> 	end of a given RCU grace period is guaranteed to see the 
> 	effects of all accesses which were visible to the grace 
> 	period's CPU before the start of the grace period.  Similarly, 
> 	any code that follows an RCU grace period (on the grace 
> 	period's CPU) is guaranteed to see the effects of all accesses 
> 	which were visible to an RCU critical section that began
> 	before the start of the grace period.

That looks to me to be an improvement, other than that the "(on the
grace period's CPU)" seems a bit restrictive -- you could for example
have a release-acquire chain starting after the grace period, right?

> Also, the document doesn't seem to explain how Tree RCU relies on the
> lock-ordering guarantees of raw_spin_lock_rcu_node() and friends.  It
> _says_ that these guarantees are used, but not how or where.  (Unless I 
> missed something; I didn't read the document all that carefully.)

The closest is this sentence: "But the only part of rcu_prepare_for_idle()
that really matters for this discussion are lines 37–39", which
refers to this code:

37     raw_spin_lock_rcu_node(rnp);
38     needwake = rcu_accelerate_cbs(rsp, rnp, rdp);
39     raw_spin_unlock_rcu_node(rnp);

I could add a sentence explaining the importance of the
smp_mb__after_unlock_lock() -- is that what you are getting at?

> In any case, you should bear in mind that the lock ordering provided by
> Peter's raw_spin_lock_rcu_node() and friends is not the same as what we
> have been discussing for the LKMM:
> 
> 	Peter's routines are meant for the case where you release
> 	one lock and then acquire another (for example, locks in 
> 	two different levels of the RCU tree).
> 
> 	The LKMM patch applies only to cases where one CPU releases
> 	a lock and then that CPU or another acquires the _same_ lock 
> 	again.
> 
> As another difference, the litmus test given near the start of the
> "Tree RCU Grace Period Memory Ordering Building Blocks" section would
> not be forbidden by the LKMM, even with RCtso locks, if it didn't use
> raw_spin_lock_rcu_node().  This is because the litmus test is forbidden
> only when locks are RCsc, which is what raw_spin_lock_rcu_node()  
> provides.

Agreed.

> So I don't see how the RCU code can be held up as an example either for
> or against requiring locks to be RCtso.

Agreed again.  The use of smp_mb__after_unlock_lock() instead
provides RCsc.  But this use case is deemed sufficiently rare that
smp_mb__after_unlock_lock() is defined within RCU.

							Thanx, Paul

  parent reply	other threads:[~2018-09-12  1:04 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-29 21:10 [PATCH RFC memory-model 0/7] Memory-model changes Paul E. McKenney
2018-08-29 21:10 ` Paul E. McKenney
2018-08-29 21:10 ` [PATCH RFC LKMM 1/7] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire Paul E. McKenney
2018-08-29 21:10   ` Paul E. McKenney
2018-08-30 12:50   ` Andrea Parri
2018-08-30 12:50     ` Andrea Parri
2018-08-30 21:31     ` Alan Stern
2018-08-30 21:31       ` Alan Stern
2018-08-31  9:17       ` Andrea Parri
2018-08-31  9:17         ` Andrea Parri
2018-08-31 14:52         ` Alan Stern
2018-08-31 14:52           ` Alan Stern
2018-08-31 16:06           ` Will Deacon
2018-08-31 16:06             ` Will Deacon
2018-08-31 18:28             ` Andrea Parri
2018-08-31 18:28               ` Andrea Parri
2018-09-03  9:01               ` Andrea Parri
2018-09-03  9:01                 ` Andrea Parri
2018-09-03 17:04                 ` Will Deacon
2018-09-03 17:04                   ` Will Deacon
2018-09-04  8:11                   ` Andrea Parri
2018-09-04  8:11                     ` Andrea Parri
2018-09-04 19:09                     ` Alan Stern
2018-09-04 19:09                       ` Alan Stern
2018-09-05  7:21                       ` Andrea Parri
2018-09-05  7:21                         ` Andrea Parri
2018-09-05 14:33                         ` Akira Yokosawa
2018-09-05 14:33                           ` Akira Yokosawa
2018-09-05 14:53                           ` Paul E. McKenney
2018-09-05 14:53                             ` Paul E. McKenney
2018-09-05 15:00                           ` Andrea Parri
2018-09-05 15:00                             ` Andrea Parri
2018-09-05 15:04                             ` Akira Yokosawa
2018-09-05 15:04                               ` Akira Yokosawa
2018-09-05 15:24                               ` Andrea Parri
2018-09-05 15:24                                 ` Andrea Parri
2018-09-03 17:52                 ` Alan Stern
2018-09-03 17:52                   ` Alan Stern
2018-09-03 18:28                   ` Andrea Parri
2018-09-03 18:28                     ` Andrea Parri
2018-09-06  1:25                 ` Alan Stern
2018-09-06  1:25                   ` Alan Stern
2018-09-06  9:36                   ` Andrea Parri
2018-09-06  9:36                     ` Andrea Parri
2018-09-07 16:00                     ` Alan Stern
2018-09-07 16:00                       ` Alan Stern
2018-09-07 16:09                       ` Will Deacon
2018-09-07 16:09                         ` Will Deacon
2018-09-07 16:39                         ` Daniel Lustig
2018-09-07 16:39                           ` Daniel Lustig
2018-09-07 17:38                           ` Alan Stern
2018-09-07 17:38                             ` Alan Stern
2018-09-08  0:04                             ` Daniel Lustig
2018-09-08  0:04                               ` Daniel Lustig
2018-09-08  9:58                             ` Andrea Parri
2018-09-08  9:58                               ` Andrea Parri
2018-09-11 19:31                               ` Alan Stern
2018-09-11 19:31                                 ` Alan Stern
2018-09-11 20:03                                 ` Paul E. McKenney [this message]
2018-09-11 20:03                                   ` Paul E. McKenney
2018-09-12 14:24                                   ` Alan Stern
2018-09-12 14:24                                     ` Alan Stern
2018-09-13 17:07                                   ` Alan Stern
2018-09-13 17:07                                     ` Alan Stern
2018-09-14 14:37                                     ` Andrea Parri
2018-09-14 14:37                                       ` Andrea Parri
2018-09-14 16:29                                       ` Alan Stern
2018-09-14 16:29                                         ` Alan Stern
2018-09-14 19:44                                         ` Andrea Parri
2018-09-14 19:44                                           ` Andrea Parri
2018-09-14 21:08                                       ` [PATCH v5] " Alan Stern
2018-09-14 21:08                                         ` Alan Stern
2018-09-15  3:56                                         ` Paul E. McKenney
2018-09-15  3:56                                           ` Paul E. McKenney
2018-09-03 17:05               ` [PATCH RFC LKMM 1/7] " Will Deacon
2018-09-03 17:05                 ` Will Deacon
2018-08-31 17:55           ` Andrea Parri
2018-08-31 17:55             ` Andrea Parri
2018-08-29 21:10 ` [PATCH RFC LKMM 2/7] doc: Replace smp_cond_acquire() with smp_cond_load_acquire() Paul E. McKenney
2018-08-29 21:10   ` Paul E. McKenney
2018-09-14 16:59   ` Will Deacon
2018-09-14 16:59     ` Will Deacon
2018-09-14 18:20     ` Paul E. McKenney
2018-09-14 18:20       ` Paul E. McKenney
2018-08-29 21:10 ` [PATCH RFC LKMM 3/7] EXP tools/memory-model: Add more LKMM limitations Paul E. McKenney
2018-08-29 21:10   ` Paul E. McKenney
2018-08-30  9:17   ` Andrea Parri
2018-08-30  9:17     ` Andrea Parri
2018-08-30 22:18     ` Paul E. McKenney
2018-08-30 22:18       ` Paul E. McKenney
2018-08-31  9:43       ` Andrea Parri
2018-08-31  9:43         ` Andrea Parri
2018-09-06 18:34         ` Paul E. McKenney
2018-09-06 18:34           ` Paul E. McKenney
2018-08-29 21:10 ` [PATCH RFC LKMM 4/7] tools/memory-model: Fix a README typo Paul E. McKenney
2018-08-29 21:10   ` Paul E. McKenney
2018-08-29 21:10 ` [PATCH RFC LKMM 5/7] EXP tools/memory-model: Add scripts to check github litmus tests Paul E. McKenney
2018-08-29 21:10   ` Paul E. McKenney
2018-08-29 21:10 ` [PATCH RFC LKMM 6/7] EXP tools/memory-model: Make scripts take "-j" abbreviation for "--jobs" Paul E. McKenney
2018-08-29 21:10   ` Paul E. McKenney
2018-08-29 21:10 ` [PATCH RFC LKMM 7/7] EXP tools/memory-model: Add .cfg and .cat files for s390 Paul E. McKenney
2018-08-29 21:10   ` Paul E. McKenney
2018-08-31 16:06   ` Will Deacon
2018-08-31 16:06     ` Will Deacon
2018-09-01 17:08     ` Paul E. McKenney
2018-09-01 17:08       ` Paul E. McKenney
2018-09-14 16:36 ` [PATCH RFC memory-model 0/7] Memory-model changes Paul E. McKenney
2018-09-14 16:36   ` Paul E. McKenney
2018-09-14 17:19   ` Alan Stern
2018-09-14 17:19     ` Alan Stern
2018-09-14 18:29     ` Paul E. McKenney
2018-09-14 18:29       ` 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=20180911200328.GA4225@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akiyks@gmail.com \
    --cc=andrea.parri@amarulasolutions.com \
    --cc=boqun.feng@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=dlustig@nvidia.com \
    --cc=j.alglave@ucl.ac.uk \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luc.maranget@inria.fr \
    --cc=mingo@kernel.org \
    --cc=npiggin@gmail.com \
    --cc=palmer@sifive.com \
    --cc=parri.andrea@gmail.com \
    --cc=peterz@infradead.org \
    --cc=stern@rowland.harvard.edu \
    --cc=will.deacon@arm.com \
    /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;
as well as URLs for NNTP newsgroup(s).