From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754972AbcJRMUT (ORCPT ); Tue, 18 Oct 2016 08:20:19 -0400 Received: from merlin.infradead.org ([205.233.59.134]:56930 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbcJRMUL (ORCPT ); Tue, 18 Oct 2016 08:20:11 -0400 Date: Tue, 18 Oct 2016 14:19:41 +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 , Chris Wilson , Daniel Vetter Subject: Re: [PATCH -v4 8/8] locking/mutex: Enable optimistic spinning of woken waiter Message-ID: <20161018121941.GU3117@twins.programming.kicks-ass.net> References: <20161007145243.361481786@infradead.org> <20161007150211.416377482@infradead.org> <58055CF8.2060806@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <58055CF8.2060806@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 Mon, Oct 17, 2016 at 07:21:28PM -0400, Waiman Long wrote: > On 10/07/2016 10:52 AM, Peter Zijlstra wrote: > >@@ -600,7 +630,7 @@ __mutex_lock_common(struct mutex *lock, > > mutex_acquire_nest(&lock->dep_map, subclass, 0, nest_lock, ip); > > > > if (__mutex_trylock(lock, false) || > >- mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx)) { > >+ mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, false)) { > > /* got the lock, yay! */ > > lock_acquired(&lock->dep_map, ip); > > if (use_ww_ctx) > >@@ -669,7 +699,8 @@ __mutex_lock_common(struct mutex *lock, > > * state back to RUNNING and fall through the next schedule(), > > * or we must see its unlock and acquire. > > */ > >- if (__mutex_trylock(lock, first)) > >+ if ((first&& mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, true)) || > >+ __mutex_trylock(lock, first)) > > Do we need a __mutex_trylock() here? mutex_optimistic_spin() will do the > trylock and we have one at the top of the loop. Yes, mutex_optimistic_spin() can be a no-op.