Re: Question regarding "Control Dependencies" in memory-barriers.txt

2014-08-13 Thread Pranith Kumar
On Wed, Aug 13, 2014 at 8:35 PM, Paul E. McKenney wrote: >> >> If the stores to 'b' differ, then there is no issue. Why not document how to >> avoid re-ordering in the case where both the stores are the same? In that >> case >> using a stronger barrier like mb() should be sufficient for both the

Re: Question regarding "Control Dependencies" in memory-barriers.txt

2014-08-13 Thread Paul E. McKenney
On Wed, Aug 13, 2014 at 08:10:22PM -0400, Pranith Kumar wrote: > > > On Wed, Aug 13, 2014 at 6:44 PM, Paul E. McKenney > wrote: > > > .LFB0: > > .cfi_startproc > > movla, %ecx > > movl$1717986919, %edx > > movl

Re: Question regarding "Control Dependencies" in memory-barriers.txt

2014-08-13 Thread Pranith Kumar
On Wed, Aug 13, 2014 at 6:44 PM, Paul E. McKenney wrote: > .LFB0: > .cfi_startproc > movla, %ecx > movl$1717986919, %edx > movl%ecx, %eax > imull %edx > movl%ecx, %eax >

Re: Question regarding "Control Dependencies" in memory-barriers.txt

2014-08-13 Thread Paul E. McKenney
On Tue, Aug 05, 2014 at 08:13:54AM -0400, Pranith Kumar wrote: > On Tue, Aug 5, 2014 at 3:32 AM, Peter Zijlstra wrote: > >> > >> 685 This transformation loses the ordering between the load from variable > >> 'a' > >> 686 and the store to variable 'b'. If you are relying on this ordering, > >>

Re: Question regarding Control Dependencies in memory-barriers.txt

2014-08-13 Thread Paul E. McKenney
On Tue, Aug 05, 2014 at 08:13:54AM -0400, Pranith Kumar wrote: On Tue, Aug 5, 2014 at 3:32 AM, Peter Zijlstra pet...@infradead.org wrote: 685 This transformation loses the ordering between the load from variable 'a' 686 and the store to variable 'b'. If you are relying on this ordering,

Re: Question regarding Control Dependencies in memory-barriers.txt

2014-08-13 Thread Pranith Kumar
On Wed, Aug 13, 2014 at 6:44 PM, Paul E. McKenney paul...@linux.vnet.ibm.com wrote: .LFB0: .cfi_startproc movla, %ecx movl$1717986919, %edx movl%ecx, %eax imull %edx

Re: Question regarding Control Dependencies in memory-barriers.txt

2014-08-13 Thread Paul E. McKenney
On Wed, Aug 13, 2014 at 08:10:22PM -0400, Pranith Kumar wrote: On Wed, Aug 13, 2014 at 6:44 PM, Paul E. McKenney paul...@linux.vnet.ibm.com wrote: .LFB0: .cfi_startproc movla, %ecx movl$1717986919, %edx

Re: Question regarding Control Dependencies in memory-barriers.txt

2014-08-13 Thread Pranith Kumar
On Wed, Aug 13, 2014 at 8:35 PM, Paul E. McKenney paul...@linux.vnet.ibm.com wrote: If the stores to 'b' differ, then there is no issue. Why not document how to avoid re-ordering in the case where both the stores are the same? In that case using a stronger barrier like mb() should be

Re: Question regarding "Control Dependencies" in memory-barriers.txt

2014-08-05 Thread Peter Zijlstra
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

Re: Question regarding "Control Dependencies" in memory-barriers.txt

2014-08-05 Thread Pranith Kumar
On Tue, Aug 5, 2014 at 3:32 AM, Peter Zijlstra wrote: >> >> 685 This transformation loses the ordering between the load from variable 'a' >> 686 and the store to variable 'b'. If you are relying on this ordering, you >> 687 should do something like the following: >> 688 >> 689 q =

Re: Question regarding "Control Dependencies" in memory-barriers.txt

2014-08-05 Thread Peter Zijlstra
On Mon, Aug 04, 2014 at 05:03:00PM -0400, Pranith Kumar wrote: > On Mon, Aug 4, 2014 at 2:52 PM, Paul E. McKenney > wrote: > >> > >> Given that there is an explicit barrier() in both the branches of > >> if/else statement, how can the above transformation happen? The > >> compiler cannot just

Re: Question regarding Control Dependencies in memory-barriers.txt

2014-08-05 Thread Peter Zijlstra
On Mon, Aug 04, 2014 at 05:03:00PM -0400, Pranith Kumar wrote: On Mon, Aug 4, 2014 at 2:52 PM, Paul E. McKenney paul...@linux.vnet.ibm.com wrote: Given that there is an explicit barrier() in both the branches of if/else statement, how can the above transformation happen? The compiler

Re: Question regarding Control Dependencies in memory-barriers.txt

2014-08-05 Thread Pranith Kumar
On Tue, Aug 5, 2014 at 3:32 AM, Peter Zijlstra pet...@infradead.org wrote: 685 This transformation loses the ordering between the load from variable 'a' 686 and the store to variable 'b'. If you are relying on this ordering, you 687 should do something like the following: 688 689 q

Re: Question regarding Control Dependencies in memory-barriers.txt

2014-08-05 Thread Peter Zijlstra
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

Re: Question regarding "Control Dependencies" in memory-barriers.txt

2014-08-04 Thread Pranith Kumar
On Mon, Aug 4, 2014 at 2:52 PM, Paul E. McKenney wrote: >> >> Given that there is an explicit barrier() in both the branches of >> if/else statement, how can the above transformation happen? The >> compiler cannot just remove the barrier(), right? > > No, the compiler cannot just remove the

Re: Question regarding "Control Dependencies" in memory-barriers.txt

2014-08-04 Thread Paul E. McKenney
On Mon, Aug 04, 2014 at 01:07:47PM -0400, Pranith Kumar wrote: > The section "Control Dependencies" in memory-barriers.txt has the > following text: > > 662 In addition, you need to be careful what you do with the local variable > 'q', > 663 otherwise the compiler might be able to guess the

Question regarding "Control Dependencies" in memory-barriers.txt

2014-08-04 Thread Pranith Kumar
The section "Control Dependencies" in memory-barriers.txt has the following text: 662 In addition, you need to be careful what you do with the local variable 'q', 663 otherwise the compiler might be able to guess the value and again remove 664 the needed conditional. For example: 665 666

Question regarding Control Dependencies in memory-barriers.txt

2014-08-04 Thread Pranith Kumar
The section Control Dependencies in memory-barriers.txt has the following text: 662 In addition, you need to be careful what you do with the local variable 'q', 663 otherwise the compiler might be able to guess the value and again remove 664 the needed conditional. For example: 665 666 q

Re: Question regarding Control Dependencies in memory-barriers.txt

2014-08-04 Thread Paul E. McKenney
On Mon, Aug 04, 2014 at 01:07:47PM -0400, Pranith Kumar wrote: The section Control Dependencies in memory-barriers.txt has the following text: 662 In addition, you need to be careful what you do with the local variable 'q', 663 otherwise the compiler might be able to guess the value and

Re: Question regarding Control Dependencies in memory-barriers.txt

2014-08-04 Thread Pranith Kumar
On Mon, Aug 4, 2014 at 2:52 PM, Paul E. McKenney paul...@linux.vnet.ibm.com wrote: Given that there is an explicit barrier() in both the branches of if/else statement, how can the above transformation happen? The compiler cannot just remove the barrier(), right? No, the compiler cannot just