Re: Additional compiler barrier required in sched_preempt_enable_no_resched?

2016-05-16 Thread Peter Zijlstra
On Mon, May 16, 2016 at 12:55:57PM +0200, Peter Zijlstra wrote: > > So the barriers already forbid that the compiler reorders code. How on earth > > is the compiler supposed to optimize the dec/inc out? > > Order things like: > > > #define sched_preempt_enable_no_resched() \ > > do { \ > >

Re: Additional compiler barrier required in sched_preempt_enable_no_resched?

2016-05-16 Thread Peter Zijlstra
On Mon, May 16, 2016 at 12:55:57PM +0200, Peter Zijlstra wrote: > You're right in that the 'proper' sequence: > > > #define preempt_enable() \ > > do { \ > > barrier(); \ > > if (unlikely(preempt_count_dec_and_test())) \ > > __preempt_schedule(); \ > > } while (0) >

Re: Additional compiler barrier required in sched_preempt_enable_no_resched?

2016-05-16 Thread Peter Zijlstra
On Sat, May 14, 2016 at 05:39:37PM +0200, Thomas Gleixner wrote: > I have a hard time to understand why the compiler optimizes out stuff w/o that > patch. > > We already have: > > #define preempt_disable() \ > do { \ > preempt_count_inc(); \ > barrier(); \ > } while (0) > > #defi

Re: Additional compiler barrier required in sched_preempt_enable_no_resched?

2016-05-14 Thread Vikram Mulukutla
On 5/14/2016 8:39 AM, Thomas Gleixner wrote: On Fri, 13 May 2016, Vikram Mulukutla wrote: On 5/13/2016 7:58 AM, Peter Zijlstra wrote: diff --git a/include/asm-generic/preempt.h b/include/asm-generic/preempt.h index 5d8ffa3e6f8c..c1cde3577551 100644 --- a/include/asm-generic/preempt.h +++ b/incl

Re: Additional compiler barrier required in sched_preempt_enable_no_resched?

2016-05-14 Thread Thomas Gleixner
On Fri, 13 May 2016, Vikram Mulukutla wrote: > On 5/13/2016 7:58 AM, Peter Zijlstra wrote: > > diff --git a/include/asm-generic/preempt.h b/include/asm-generic/preempt.h > > index 5d8ffa3e6f8c..c1cde3577551 100644 > > --- a/include/asm-generic/preempt.h > > +++ b/include/asm-generic/preempt.h > > @

Re: Additional compiler barrier required in sched_preempt_enable_no_resched?

2016-05-13 Thread Vikram Mulukutla
On 5/13/2016 7:58 AM, Peter Zijlstra wrote: On Thu, May 12, 2016 at 11:39:47PM -0700, Vikram Mulukutla wrote: Hi, I came across a piece of engineering code that looked like: preempt_disable(); /* --cut, lots of code-- */ preempt_enable_no_resched(); put_user() preempt_disable(); (If you wish

Re: Additional compiler barrier required in sched_preempt_enable_no_resched?

2016-05-13 Thread Peter Zijlstra
On Thu, May 12, 2016 at 11:39:47PM -0700, Vikram Mulukutla wrote: > Hi, > > I came across a piece of engineering code that looked like: > > preempt_disable(); > /* --cut, lots of code-- */ > preempt_enable_no_resched(); > put_user() > preempt_disable(); > > (If you wish to seriously question the

Re: Additional compiler barrier required in sched_preempt_enable_no_resched?

2016-05-13 Thread Thomas Gleixner
On Thu, 12 May 2016, Vikram Mulukutla wrote: > preempt_disable(); > /* --cut, lots of code-- */ > preempt_enable_no_resched(); > put_user() > preempt_disable(); > > (If you wish to seriously question the usage of the preempt API in this > manner, I unfortunately have no comment since I didn't writ

Additional compiler barrier required in sched_preempt_enable_no_resched?

2016-05-12 Thread Vikram Mulukutla
Hi, I came across a piece of engineering code that looked like: preempt_disable(); /* --cut, lots of code-- */ preempt_enable_no_resched(); put_user() preempt_disable(); (If you wish to seriously question the usage of the preempt API in this manner, I unfortunately have no comment since I didn