[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <57BF6A73.1050505@hpe.com>
Date: Thu, 25 Aug 2016 18:00:19 -0400
From: Waiman Long <waiman.long@....com>
To: Peter Zijlstra <peterz@...radead.org>
CC: Linus Torvalds <torvalds@...ux-foundation.org>,
Jason Low <jason.low2@....com>,
Ding Tianhong <dingtianhong@...wei.com>,
"Thomas Gleixner" <tglx@...utronix.de>,
Will Deacon <Will.Deacon@....com>,
Ingo Molnar <mingo@...hat.com>,
Imre Deak <imre.deak@...el.com>,
"Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>,
Davidlohr Bueso <dave@...olabs.net>,
"Tim Chen" <tim.c.chen@...ux.intel.com>,
Terry Rudd <terry.rudd@....com>,
"Paul E. McKenney" <paulmck@...ibm.com>,
Jason Low <jason.low2@...com>,
Chris Wilson <chris@...is-wilson.co.uk>,
Daniel Vetter <daniel.vetter@...ll.ch>
Subject: Re: [RFC][PATCH -v2 4/4] locking/mutex: Add lock handoff to avoid
starvation
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.
Cheers,
Longman
Powered by blists - more mailing lists