lkml.org 
[lkml]   [2016]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 1/3] locking/mutex: Rework mutex::owner
On Wed, Aug 24, 2016 at 05:34:12PM +0200, Peter Zijlstra wrote:
> On Wed, Aug 24, 2016 at 10:56:59AM +0100, Will Deacon wrote:
> > > + owner = atomic_long_read(&lock->owner);
> > > + for (;;) {
> > > + unsigned long old;
> > > +
> > > + old = atomic_long_cmpxchg_release(&lock->owner, owner, owner & 0x03);
> > > + if (old == owner)
> > > + break;
> > > +
> > > + owner = old;
> > > + }
> >
> > Can you rewrite this using atomic_long_fetch_and_release?
>
> Yes, until patch 3/3.. but now that you mention it I think we can do:
>
> owner = atomic_long_read(&lock->owner);
> if (!(owner & MUTEX_FLAG_HANDOFF))
> (void)atomic_long_fetch_and_release(MUTEX_FLAGS, &lock->owner);
>

And of course, x86 would very much like atomic_long_and_release() here,
such that it can do LOCK ADD instead of a LOCK CMPXCHG loop. But of
course, we don't have that ...

\
 
 \ /
  Last update: 2016-09-17 09:57    [W:0.075 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site