From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Andrea Parri <parri.andrea@gmail.com>,
Will Deacon <will.deacon@arm.com>,
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>,
Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: Linux-kernel examples for LKMM recipes
Date: Tue, 17 Oct 2017 11:56:09 -0700 [thread overview]
Message-ID: <20171017185609.GU3521@linux.vnet.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1710131605350.1364-100000@iolanthe.rowland.org>
On Fri, Oct 13, 2017 at 04:09:26PM -0400, Alan Stern wrote:
> On Fri, 13 Oct 2017, Paul E. McKenney wrote:
> > On Fri, Oct 13, 2017 at 03:44:07PM -0400, Alan Stern wrote:
> > > On Wed, 11 Oct 2017, Paul E. McKenney wrote:
[ . . . ]
> > Perhaps the recipes document should just baldly state that any execution
> > having only one thread and/or having only one variable will be fully
> > ordered?
>
> That wouldn't be a bad idea. (Although the part about only one thread
> should be pretty obvious.)
>
> Also, you have to be a little careful because the ordering of the
> execution may not always agree with the ordering of the source code.
> The compiler is allowed to evaluate the arguments to a function call,
> for example, in any order it likes.
How about this?
0. Simple special cases
If there is only one CPU on the one hand or only one variable
on the other, the code will execute in order. There are (as
usual) some things to be careful of:
a. There are some aspects of the C language that are
unordered. For example, the compiler can output code
computing arguments of a multi-parameter function in
any order it likes, or even interleaved if it so chooses.
b. Compilers are permitted to use the "as-if" rule.
That is, a compiler can emit whatever code it likes,
as long as the results appear just as if the compiler
had followed all the relevant rules. To see this,
compiler with a high level of optimization and run
the debugger on the resulting binary.
c. If there is only one variable but multiple CPUs, all
accesses to that variable must be aligned and full sized.
Variables that straddle cachelines or pages void your
full-ordering warranty, as do undersized accesses that
load from or store to only part of the variable.
Thanx, Paul
next prev parent reply other threads:[~2017-10-17 18:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 22:32 Linux-kernel examples for LKMM recipes Paul E. McKenney
2017-10-12 1:23 ` Boqun Feng
2017-10-12 11:27 ` Will Deacon
2017-10-17 20:37 ` Paul E. McKenney
2017-10-17 20:56 ` Paul E. McKenney
2017-10-12 13:27 ` Andrea Parri
2017-10-17 20:18 ` Paul E. McKenney
2017-10-13 19:44 ` Alan Stern
2017-10-13 20:00 ` Paul E. McKenney
2017-10-13 20:09 ` Alan Stern
2017-10-17 18:56 ` Paul E. McKenney [this message]
2017-10-17 19:38 ` Alan Stern
2017-10-17 20:33 ` Paul E. McKenney
2017-10-17 21:03 ` Alan Stern
2017-10-17 21:55 ` Paul E. McKenney
2017-10-18 14:43 ` Alan Stern
2017-10-18 20:28 ` Paul E. McKenney
2017-10-18 21:18 ` Alan Stern
2017-10-18 22:57 ` 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=20171017185609.GU3521@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=boqun.feng@gmail.com \
--cc=dhowells@redhat.com \
--cc=j.alglave@ucl.ac.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=luc.maranget@inria.fr \
--cc=npiggin@gmail.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