From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934001AbcJLSef (ORCPT ); Wed, 12 Oct 2016 14:34:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:59774 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755854AbcJLSeS (ORCPT ); Wed, 12 Oct 2016 14:34:18 -0400 Date: Wed, 12 Oct 2016 10:59:32 -0700 From: Davidlohr Bueso To: Peter Zijlstra Cc: Linus Torvalds , Waiman Long , Jason Low , Ding Tianhong , Thomas Gleixner , Will Deacon , Ingo Molnar , Imre Deak , Linux Kernel Mailing List , Tim Chen , Terry Rudd , "Paul E. McKenney" , Jason Low , Chris Wilson , Daniel Vetter Subject: Re: [PATCH -v4 2/8] locking/mutex: Rework mutex::owner Message-ID: <20161012175932.GA4908@linux-80c1.suse> References: <20161007145243.361481786@infradead.org> <20161007150210.995135898@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20161007150210.995135898@infradead.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 07 Oct 2016, Peter Zijlstra wrote: >+/* >+ * Optimistic trylock that only works in the uncontended case. Make sure to >+ * follow with a __mutex_trylock() before failing. >+ */ >+static __always_inline bool __mutex_trylock_fast(struct mutex *lock) >+{ >+ unsigned long curr = (unsigned long)current; >+ >+ if (!atomic_long_cmpxchg_acquire(&lock->owner, 0UL, curr)) >+ return true; Do we want to do a ccas check for !lock->owner? Although I can see a possible case of 'optimizing for the contended' reasons for nay. Thanks, Davidlohr