From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750992AbcBLUkh (ORCPT ); Fri, 12 Feb 2016 15:40:37 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:49893 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750714AbcBLUkg (ORCPT ); Fri, 12 Feb 2016 15:40:36 -0500 Date: Fri, 12 Feb 2016 21:40:27 +0100 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Linus Torvalds , Ding Tianhong , Jason Low , Davidlohr Bueso , "Paul E. McKenney" , Thomas Gleixner , Will Deacon , Tim Chen , Waiman Long Subject: Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Message-ID: <20160212204027.GZ6357@twins.programming.kicks-ass.net> References: <1455298335-53229-1-git-send-email-Waiman.Long@hpe.com> <1455298335-53229-2-git-send-email-Waiman.Long@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1455298335-53229-2-git-send-email-Waiman.Long@hpe.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 12, 2016 at 12:32:12PM -0500, Waiman Long wrote: > @@ -358,8 +373,8 @@ static bool mutex_optimistic_spin(struct mutex *lock, > } > > mutex_set_owner(lock); > - osq_unlock(&lock->osq); > - return true; > + acquired = true; > + break; > } > > /* > @@ -380,7 +395,10 @@ static bool mutex_optimistic_spin(struct mutex *lock, > cpu_relax_lowlatency(); > } > > - osq_unlock(&lock->osq); > + if (!waiter) > + osq_unlock(&lock->osq); > + if (acquired || waiter) > + return acquired; > done: > /* > * If we fell out of the spin path because of need_resched(), Is there a reason to not also preempt in the wait-loop? Surely the same reason is still valid there too?