Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752794AbbFFP2C (ORCPT ); Sat, 6 Jun 2015 11:28:02 -0400 Received: from cantor2.suse.de ([195.135.220.15]:50592 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751782AbbFFP1y (ORCPT ); Sat, 6 Jun 2015 11:27:54 -0400 Message-ID: <1433604461.3165.21.camel@stgolabs.net> Subject: Re: [PATCH 2/4] locking/rtmutex: Use cmp-cmpxchg From: Davidlohr Bueso To: Thomas Gleixner Cc: Peter Zijlstra , Ingo Molnar , Steven Rostedt , Mike Galbraith , "Paul E. McKenney" , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org Date: Sat, 06 Jun 2015 08:27:41 -0700 In-Reply-To: References: <1432056298-18738-1-git-send-email-dave@stgolabs.net> <1432056298-18738-3-git-send-email-dave@stgolabs.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.11 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1353 Lines: 38 On Fri, 2015-06-05 at 14:38 +0200, Thomas Gleixner wrote: > On Tue, 19 May 2015, Davidlohr Bueso wrote: > > > Avoid unnecessary cmpxchg calls, all of our other locks > > use it as well. > > > > Signed-off-by: Davidlohr Bueso > > --- > > kernel/locking/rtmutex.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c > > index 74188d8..1d5cc9d 100644 > > --- a/kernel/locking/rtmutex.c > > +++ b/kernel/locking/rtmutex.c > > @@ -74,7 +74,9 @@ static void fixup_rt_mutex_waiters(struct rt_mutex *lock) > > * set up. > > */ > > #ifndef CONFIG_DEBUG_RT_MUTEXES > > -# define rt_mutex_cmpxchg(l,c,n) (cmpxchg(&l->owner, c, n) == c) > > +# define rt_mutex_cmpxchg(l,c,n) \ > > + (l->owner == c && cmpxchg(&l->owner, c, n) == c) > > Errm. How does that improve stuff like rt_mutex_lock() ? It just avoids a cmpxchg in the fastpath when locked, at the cost of an extra test when unlocked. CCAS techniques have been proven to boost some workloads for both rwsems and mutexes. That's all. Thanks, Davidlohr -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/