From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757677AbcJQJdE (ORCPT ); Mon, 17 Oct 2016 05:33:04 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:51890 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755048AbcJQJc4 (ORCPT ); Mon, 17 Oct 2016 05:32:56 -0400 Date: Mon, 17 Oct 2016 11:32:42 +0200 From: Peter Zijlstra To: Will Deacon Cc: Linus Torvalds , Waiman Long , Jason Low , Ding Tianhong , Thomas Gleixner , 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: <20161017093242.GN3117@twins.programming.kicks-ass.net> References: <20161007145243.361481786@infradead.org> <20161007150211.416377482@infradead.org> <20161013152801.GD13138@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161013152801.GD13138@arm.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 Thu, Oct 13, 2016 at 04:28:01PM +0100, Will Deacon wrote: > On Fri, Oct 07, 2016 at 04:52:51PM +0200, Peter Zijlstra wrote: > > @@ -457,15 +472,20 @@ static bool mutex_optimistic_spin(struct > > * release the lock or go to sleep. > > */ > > owner = __mutex_owner(lock); > > - if (owner && !mutex_spin_on_owner(lock, owner)) > > - break; > > + if (owner) { > > + if (waiter && owner == task) { > > + smp_mb(); /* ACQUIRE */ > > Hmm, is this barrier actually needed? This only happens on the handoff path, > and we take the wait_lock immediately after this succeeds anyway. That > control dependency, coupled with the acquire semantics of the spin_lock, > should be sufficient, no? Yes, I think you're right. But like said in that earlier email, I'd like to keep this for now. Once this code has settled we can reconsider this.