[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c8b77029-7652-04e7-efaa-693206b7ec62@stressinduktion.org>
Date: Tue, 7 Jun 2016 14:41:44 +0200
From: Hannes Frederic Sowa <hannes@...essinduktion.org>
To: Peter Zijlstra <peterz@...radead.org>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Cc: Will Deacon <will.deacon@....com>,
Vineet Gupta <Vineet.Gupta1@...opsys.com>,
Waiman Long <waiman.long@....com>,
linux-kernel@...r.kernel.org, torvalds@...ux-foundation.org,
manfred@...orfullife.com, dave@...olabs.net, boqun.feng@...il.com,
tj@...nel.org, pablo@...filter.org, kaber@...sh.net,
davem@...emloft.net, oleg@...hat.com,
netfilter-devel@...r.kernel.org, sasha.levin@...cle.com,
hofrat@...dl.org
Subject: Re: [RFC][PATCH 1/3] locking: Introduce smp_acquire__after_ctrl_dep
On 07.06.2016 09:15, Peter Zijlstra wrote:
>>
>> diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
>> index 147ae8ec836f..a4d0a99de04d 100644
>> --- a/Documentation/memory-barriers.txt
>> +++ b/Documentation/memory-barriers.txt
>> @@ -806,6 +806,41 @@ out-guess your code. More generally, although READ_ONCE() does force
>> the compiler to actually emit code for a given load, it does not force
>> the compiler to use the results.
>>
>> +In addition, control dependencies apply only to the then-clause and
>> +else-clause of the if-statement in question. In particular, it does
>> +not necessarily apply to code following the if-statement:
>> +
>> + q = READ_ONCE(a);
>> + if (q) {
>> + WRITE_ONCE(b, p);
>> + } else {
>> + WRITE_ONCE(b, r);
>> + }
>> + WRITE_ONCE(c, 1); /* BUG: No ordering against the read from "a". */
>> +
>> +It is tempting to argue that there in fact is ordering because the
>> +compiler cannot reorder volatile accesses and also cannot reorder
>> +the writes to "b" with the condition. Unfortunately for this line
>> +of reasoning, the compiler might compile the two writes to "b" as
>> +conditional-move instructions, as in this fanciful pseudo-assembly
>> +language:
I wonder if we already guarantee by kernel compiler settings that this
behavior is not allowed by at least gcc.
We unconditionally set --param allow-store-data-races=0 which should
actually prevent gcc from generating such conditional stores.
Am I seeing this correct here?
Thanks,
Hannes
Powered by blists - more mailing lists