From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755666AbcHWUtX (ORCPT ); Tue, 23 Aug 2016 16:49:23 -0400 Received: from merlin.infradead.org ([205.233.59.134]:52874 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754944AbcHWUtW (ORCPT ); Tue, 23 Aug 2016 16:49:22 -0400 Date: Tue, 23 Aug 2016 22:32:04 +0200 From: Peter Zijlstra To: Waiman Long Cc: Linus Torvalds , Jason Low , Ding Tianhong , Thomas Gleixner , Will Deacon , Ingo Molnar , Imre Deak , Linux Kernel Mailing List , Davidlohr Bueso , Tim Chen , Terry Rudd , "Paul E. McKenney" , Jason Low Subject: Re: [RFC][PATCH 3/3] locking/mutex: Add lock handoff to avoid starvation Message-ID: <20160823203204.GU10153@twins.programming.kicks-ass.net> References: <20160823124617.015645861@infradead.org> <20160823124856.898171453@infradead.org> <57BCA869.1050501@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57BCA869.1050501@hpe.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 23, 2016 at 03:47:53PM -0400, Waiman Long wrote: > On 08/23/2016 08:46 AM, Peter Zijlstra wrote: > >N > >@@ -573,8 +600,14 @@ __mutex_lock_common(struct mutex *lock, > > schedule_preempt_disabled(); > > spin_lock_mutex(&lock->wait_lock, flags); > > > >+ if (__mutex_owner(lock) == current) > >+ break; > >+ > > if (__mutex_trylock(lock)) > > break; > >+ > >+ if (__mutex_waiter_is_first(lock,&waiter)) > >+ __mutex_set_flag(lock, MUTEX_FLAG_HANDOFF); > > } > > __set_task_state(task, TASK_RUNNING); > > > > > > You may want to think about doing some spinning while the owner is active > instead of going back to sleep again here. For sure; I just didn't bother pulling in your patches. I didn't want to sink in more time in case people really hated on 1/3 ;-)