Re: [PATCH] mutex: Fix mutex_can_spin_on_owner

2013-07-25 Thread Jan-Simon Möller
On Friday 19 July 2013 16:58:09 Waiman Long wrote: > > I supposed that only the gcc compiler can be used to build Linux kernel > as the kernel source uses a lot of features specific to gcc. Look at http://llvm.linuxfoundation.org - they're using clang with more and more success. -- JS -- To

Re: [PATCH] mutex: Fix mutex_can_spin_on_owner

2013-07-20 Thread Peter Zijlstra
On Fri, Jul 19, 2013 at 03:08:36PM -0400, Waiman Long wrote: > On 07/19/2013 02:31 PM, Peter Zijlstra wrote: > >mutex_can_spin_on_owner() is broken in that it would allow the compiler > >to load lock->owner twice, seeing a pointer first time and a MULL > >pointer the second time. > > > >Signed-off-

Re: [PATCH] mutex: Fix mutex_can_spin_on_owner

2013-07-19 Thread Waiman Long
On 07/19/2013 03:41 PM, Thomas Gleixner wrote: On Fri, 19 Jul 2013, Waiman Long wrote: On 07/19/2013 02:31 PM, Peter Zijlstra wrote: rcu_read_lock(); - if (lock->owner) - retval = lock->owner->on_cpu; + owner = ACCESS_ONCE(lock->owner); + if (owner) +

Re: [PATCH] mutex: Fix mutex_can_spin_on_owner

2013-07-19 Thread Linus Torvalds
On Fri, Jul 19, 2013 at 12:41 PM, Thomas Gleixner wrote: > > That's true for your particular compiler, but it's not guaranteed at > all. So it matters even when your compiler generates the same > code. Others might not. There is a world outside of x8664. Well, in this case, I think we can pretty

Re: [PATCH] mutex: Fix mutex_can_spin_on_owner

2013-07-19 Thread Thomas Gleixner
On Fri, 19 Jul 2013, Waiman Long wrote: > On 07/19/2013 02:31 PM, Peter Zijlstra wrote: > > rcu_read_lock(); > > - if (lock->owner) > > - retval = lock->owner->on_cpu; > > + owner = ACCESS_ONCE(lock->owner); > > + if (owner) > > + retval = owner->on_cpu; > > rcu_re

Re: [PATCH] mutex: Fix mutex_can_spin_on_owner

2013-07-19 Thread Rik van Riel
On 07/19/2013 02:31 PM, Peter Zijlstra wrote: mutex_can_spin_on_owner() is broken in that it would allow the compiler to load lock->owner twice, seeing a pointer first time and a MULL pointer the second time. Signed-off-by: Peter Zijlstra Reviewed-by: Rik van Riel -- All rights reversed --

Re: [PATCH] mutex: Fix mutex_can_spin_on_owner

2013-07-19 Thread Waiman Long
On 07/19/2013 02:31 PM, Peter Zijlstra wrote: mutex_can_spin_on_owner() is broken in that it would allow the compiler to load lock->owner twice, seeing a pointer first time and a MULL pointer the second time. Signed-off-by: Peter Zijlstra --- kernel/mutex.c | 6 -- 1 file changed, 4 inser

Re: [PATCH] mutex: Fix mutex_can_spin_on_owner

2013-07-19 Thread Davidlohr Bueso
On Fri, 2013-07-19 at 20:31 +0200, Peter Zijlstra wrote: > mutex_can_spin_on_owner() is broken in that it would allow the compiler > to load lock->owner twice, seeing a pointer first time and a MULL > pointer the second time. > > Signed-off-by: Peter Zijlstra Yep, I remember this from the rwsem

[PATCH] mutex: Fix mutex_can_spin_on_owner

2013-07-19 Thread Peter Zijlstra
mutex_can_spin_on_owner() is broken in that it would allow the compiler to load lock->owner twice, seeing a pointer first time and a MULL pointer the second time. Signed-off-by: Peter Zijlstra --- kernel/mutex.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/mu