[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20160225154201.GN3522@linux.vnet.ibm.com>
Date: Thu, 25 Feb 2016 07:42:01 -0800
From: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
Lai Jiangshan <jiangshanlai@...il.com>, dipankar@...ibm.com,
Andrew Morton <akpm@...ux-foundation.org>,
josh@...htriplett.org, Thomas Gleixner <tglx@...utronix.de>,
rostedt <rostedt@...dmis.org>,
David Howells <dhowells@...hat.com>, edumazet@...gle.com,
dvhart@...ux.intel.com, fweisbec@...il.com,
Oleg Nesterov <oleg@...hat.com>,
bobby prani <bobby.prani@...il.com>
Subject: Re: [PATCH tip/core/rcu 02/14] documentation: Fix control dependency
and identical stores
On Thu, Feb 25, 2016 at 03:48:38PM +0100, Peter Zijlstra wrote:
> On Thu, Feb 25, 2016 at 06:07:03AM -0800, Paul E. McKenney wrote:
> > Still bad wording...
> >
> > It hasn't actually moved anything over the barrier(). It has instead
> > moved both the barrier() and the WRITE_ONCE(b, p) to precede the "if
> > (q)". Mathieu mentioned this over IRC yesterday, and I queue a change
> > so that the paragraph now reads as follows:
> >
> > (*) If both legs of the "if" statement begin with identical stores to
> > the same variable, then those stores must be ordered, either by
> > preceding both of them with smp_mb() or by using smp_store_release()
> > to carry out the stores. Please note that it is -not- sufficient
> > to use barrier() at beginning of each leg of the "if" statement
> > because, as shown by the example above, optimizing compilers can
> > destroy the control dependency while respecting the letter of the
> > barrier() law.
> >
> > Does hat help?
>
> Maybe.. I still feel the compiler should not do this; but I'm having a
> hard time explaining why.
The compiler guys would probably argue that the variable "q" is in a
register, so that the "memory" constraint does not apply. Then the code
movement does not move any actual memory accesses across the "memory"
constraint, and hence they would argue them to be perfectly legal.
That said, I completely agree that this sort of code movement is at
the very least rather unfriendly to concurrent code. :-/
Thanx, Paul
Powered by blists - more mailing lists