[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140805125819.GY19379@twins.programming.kicks-ass.net>
Date: Tue, 5 Aug 2014 14:58:19 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Pranith Kumar <pranith@...ech.edu>
Cc: Paul McKenney <paulmck@...ux.vnet.ibm.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: Question regarding "Control Dependencies" in memory-barriers.txt
On Tue, Aug 05, 2014 at 08:13:54AM -0400, Pranith Kumar wrote:
> >> 689 q = ACCESS_ONCE(a);
> >> 690 BUILD_BUG_ON(MAX <= 1); /* Order load from a with store to b. */
> >> 691 if (q % MAX) {
> >> 692 ACCESS_ONCE(b) = p;
> >> 693 do_something();
> >> 694 } else {
> >> 695 ACCESS_ONCE(b) = p;
> >> 696 do_something_else();
> >> 697 }
> >> 698
> I don't think the write to 'b' here is speculative since it is
> happening in both the legs of the if() conditional. The write to b can
> be pulled out to before the conditional. Without the barrier(), isn't
> the following a valid transformation of the above?
>
> BUILD_BUG_ON(MAX <= 1); /* this will be compiled out if MAX != 1*/
> q = ACCESS_ONCE(a);
> ACCESS_ONCE(b) = p; / *BUG: No ordering */
> if (q % MAX) {
> do_something();
> } else {
> do_something_else();
> }
>
> I don't see how it is preserving the ordering.
Ah, that's what you meant. Yes possibly that's true.
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists