lkml.org 
[lkml]   [2013]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mutex: Fix mutex_can_spin_on_owner
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_read_unlock();
> > /*
> > * if lock->owner is not set, the mutex owner may have just
> > acquired
>

> I am fine with this change. However, the compiler is smart enough to
> not do two memory accesses to the same memory location. So this will
> not change the generated code. Below is the relevant x86 code for
> that section of code:

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.

Thanks,

tglx


\
 
 \ /
  Last update: 2013-07-19 22:01    [W:0.079 / U:0.552 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site