linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: parallel@lists.isocpp.org, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org, gcc@gcc.gnu.org,
	llvm-dev@lists.llvm.org
Cc: Peter.Sewell@cl.cam.ac.uk, torvalds@linux-foundation.org,
	Mark.Batty@cl.cam.ac.uk, peterz@infradead.org,
	will.deacon@arm.com, Ramana.Radhakrishnan@arm.com,
	dhowells@redhat.com, akpm@linux-foundation.org, mingo@kernel.org,
	michaelw@ca.ibm.com, boehm@acm.org, Jens.Maurer@gmx.net,
	luc.maranget@inria.fr, j.alglave@ucl.ac.uk
Subject: Proposal for new memory_order_consume definition
Date: Wed, 17 Feb 2016 17:10:33 -0800	[thread overview]
Message-ID: <20160218011033.GA1505@linux.vnet.ibm.com> (raw)

Hello!

A proposal (quaintly identified as P0190R0) for a new memory_order_consume
definition may be found here:

	http://www2.rdrop.com/users/paulmck/submission/consume.2016.02.10b.pdf

As requested at the October C++ Standards Committee meeting, this
is a follow-on to P0098R1 that picks one alternative and describes
it in detail.  This approach focuses on existing practice, with the
goal of supporting existing code with existing compilers.  In the last
clang/LLVM patch I saw for basic support of this change, you could count
the changed lines and still have lots of fingers and toes left over.
Those who have been following this story will recognize that this is
a very happy contrast to work that would be required to implement the
definition in the current standard.

I expect that P0190R0 will be discussed at the upcoming C++ Standards
Committee meeting taking place the week of February 29th.  Points of
discussion are likely to include:

o	May memory_order_consume dependency ordering be used in
	unannotated code?  I believe that this must be the case,
	especially given that this is our experience base.  P0190R0
	therefore recommends this approach.

o	If memory_order_consume dependency ordering can be used in
	unannotated code, must implementations support annotation?
	I believe that annotation support should be required, at the very
	least for formal verification, which can be quite difficult to
	carry out on unannotated code.  In addition, it seems likely
	that annotations can enable much better diagnostics.  P0190R0
	therefore recommends this approach.

o	If implementations must support annotation, what form should that
	annotation take?  P0190R0 recommends the [[carries_dependency]]
	attribute, but I am not picky as long as it can be (1) applied
	to all relevant pointer-like objects and (2) used in C as well
	as C++.  ;-)

o	If memory_order_consume dependency ordering can be used in
	unannotated code, how best to define the situations where
	the compiler can determine the exact value of the pointer in
	question?  (In current defacto implementations, this can
	defeat dependency ordering.  Interestingly enough, this case
	is not present in the Linux kernel, but still needs to be
	defined.)

	Options include:
	
	o	Provide new intrinsics that carry out the
		comparisons, but guarantee to preserve dependencies,
		as recommended by P0190R0 (std::pointer_cmp_eq_dep(),
		std::pointer_cmp_ne_dep(), std::pointer_cmp_gt_dep(),
		std::pointer_cmp_ge_dep(), std::pointer_cmp_lt_dep(),
		and std::pointer_cmp_le_dep()).

	o	State that -any- comparison involving an unannotated
		pointer loses the dependency.

o	How is the common idiom of marking pointers by setting low-order
	bits to be supported when those pointers carry dependencies?
	At the moment, I believe that setting bits in pointers results in
	undefined behavior even without dependency ordering, so P0190R0
	kicks this particular can down the road.  One option that
	has been suggested is to provide intrinsics for this purpose.
	(Sorry, but I forget who suggested this.)

Thoughts?

							Thanx, Paul

             reply	other threads:[~2016-02-18  1:10 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-18  1:10 Paul E. McKenney [this message]
2016-02-20  2:15 ` [isocpp-parallel] Proposal for new memory_order_consume definition Tony V E
2016-02-20 19:53   ` Paul E. McKenney
2016-02-26  0:46     ` Hans Boehm via llvm-dev
2016-02-26 23:56       ` Lawrence Crowl
2016-02-27 17:06       ` Paul E. McKenney
2016-02-27 19:16         ` Linus Torvalds via llvm-dev
2016-02-27 23:10           ` Paul E. McKenney via llvm-dev
2016-02-27 23:10             ` Paul E. McKenney
2016-02-28  8:27             ` Markus Trippelsdorf via llvm-dev
2016-02-28  8:27               ` Markus Trippelsdorf
2016-02-28 16:13               ` Linus Torvalds
2016-02-28 16:50                 ` via llvm-dev
2016-02-28 16:50                   ` [llvm-dev] " cbergstrom
2016-02-29 17:37                 ` Michael Matz
2016-02-29 17:57                   ` Linus Torvalds via llvm-dev
2016-02-29 17:57                     ` Linus Torvalds
2016-02-29 19:38                 ` Lawrence Crowl
2016-02-29 21:10                   ` James Y Knight via llvm-dev
2016-02-29 21:12                   ` James Y Knight via llvm-dev
2016-02-29 21:12                     ` [llvm-dev] " James Y Knight
2016-02-29 20:45                 ` Toon Moene
2016-02-29 20:45                   ` Toon Moene
2016-02-29 18:17         ` Michael Matz
2016-03-01  1:28           ` Paul E. McKenney via llvm-dev
2016-03-01  1:28             ` 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=20160218011033.GA1505@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=Jens.Maurer@gmx.net \
    --cc=Mark.Batty@cl.cam.ac.uk \
    --cc=Peter.Sewell@cl.cam.ac.uk \
    --cc=Ramana.Radhakrishnan@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=boehm@acm.org \
    --cc=dhowells@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=j.alglave@ucl.ac.uk \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm-dev@lists.llvm.org \
    --cc=luc.maranget@inria.fr \
    --cc=michaelw@ca.ibm.com \
    --cc=mingo@kernel.org \
    --cc=parallel@lists.isocpp.org \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    --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).