Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1470468

Re: [RFC][PATCH -v2 4/4] locking/mutex: Add lock handoff to avoid starvation

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [RFC][PATCH -v2 4/4] locking/mutex: Add lock handoff to avoid starvation
Date 2016-08-26 00:30 +0200
Message-ID <sabjP-72N-3@gated-at.bofh.it> (permalink)
References <sa7SV-4G3-9@gated-at.bofh.it> <sa7SW-4G3-27@gated-at.bofh.it> <sabjP-72N-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Aug 25, 2016 at 06:00:19PM -0400, Waiman Long wrote:
> On 08/25/2016 02:37 PM, Peter Zijlstra wrote:
> >@@ -468,9 +496,12 @@ void __sched mutex_unlock(struct mutex *
> >  	DEBUG_LOCKS_WARN_ON(__mutex_owner(lock) != current);
> >  #endif
> >
> >-	owner = atomic_long_fetch_and(MUTEX_FLAGS,&lock->owner);
> >+	owner = atomic_long_read(&lock->owner);
> >+	if (!(owner&  MUTEX_FLAG_HANDOFF))
> >+		owner = atomic_long_fetch_and(MUTEX_FLAGS,&lock->owner);
> >+
> >  	if (__owner_flags(owner))
> >-		__mutex_unlock_slowpath(lock);
> >+		__mutex_unlock_slowpath(lock, owner);
> >  }
> >  EXPORT_SYMBOL(mutex_unlock);
> 
> I don't think the race condition is fixed when we don't make sure that lock
> handoff only happens from current=>new. The problem is due to the fact that
> the MUTEX_FLAG_HANDOFF check in the unlock fastpath isn't serialized by the
> wait_lock. As a result, it is possible that the owner is NULL while the
> HANDOFF bit is set. Or an optimistic spinner may have stolen the lock in the
> interim.

You're right.. I'll try again tomorrow.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC][PATCH -v2 0/4] locking/mutex: Rewrite basic mutex Peter Zijlstra <peterz@infradead.org> - 2016-08-25 20:50 +0200
  [RFC][PATCH -v2 3/4] locking/mutex: Allow MUTEX_SPIN_ON_OWNER when DEBUG_MUTEXES Peter Zijlstra <peterz@infradead.org> - 2016-08-25 20:50 +0200
  [RFC][PATCH -v2 4/4] locking/mutex: Add lock handoff to avoid starvation Peter Zijlstra <peterz@infradead.org> - 2016-08-25 20:50 +0200
    Re: [RFC][PATCH -v2 4/4] locking/mutex: Add lock handoff to avoid  starvation Peter Zijlstra <peterz@infradead.org> - 2016-08-26 00:30 +0200
      Re: [RFC][PATCH -v2 4/4] locking/mutex: Add lock handoff to avoid  starvation Peter Zijlstra <peterz@infradead.org> - 2016-08-26 17:20 +0200
        Re: [RFC][PATCH -v2 4/4] locking/mutex: Add lock handoff to avoid  starvation Peter Zijlstra <peterz@infradead.org> - 2016-08-29 17:50 +0200
          Re: [RFC][PATCH -v2 4/4] locking/mutex: Add lock handoff to avoid  starvation Peter Zijlstra <peterz@infradead.org> - 2016-08-30 14:00 +0200

csiph-web