From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Paul E. McKenney" Subject: Re: [PATCH v5 2/4] MCS Lock: optimizations and extra comments Date: Tue, 19 Nov 2013 15:05:42 -0800 Message-ID: <20131119230542.GW4138@linux.vnet.ibm.com> References: <1383940325.11046.415.camel@schen9-DESK> <20131119191310.GO4138@linux.vnet.ibm.com> <1384901861.11046.449.camel@schen9-DESK> Reply-To: paulmck@linux.vnet.ibm.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1384901861.11046.449.camel@schen9-DESK> Sender: owner-linux-mm@kvack.org To: Tim Chen Cc: Ingo Molnar , Andrew Morton , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-mm , linux-arch@vger.kernel.org, Linus Torvalds , Waiman Long , Andrea Arcangeli , Alex Shi , Andi Kleen , Michel Lespinasse , Davidlohr Bueso , Matthew R Wilcox , Dave Hansen , Peter Zijlstra , Rik van Riel , Peter Hurley , Raghavendra K T , George Spelvin , "H. Peter Anvin" List-Id: linux-arch.vger.kernel.org On Tue, Nov 19, 2013 at 02:57:41PM -0800, Tim Chen wrote: > On Tue, 2013-11-19 at 11:13 -0800, Paul E. McKenney wrote: > > On Fri, Nov 08, 2013 at 11:52:05AM -0800, Tim Chen wrote: > > > > > > +/* > > > + * Releases the lock. The caller should pass in the corresponding node that > > > + * was used to acquire the lock. > > > + */ > > > static void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *node) > > > { > > > struct mcs_spinlock *next = ACCESS_ONCE(node->next); > > > @@ -51,7 +60,7 @@ static void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *nod > > > /* > > > * Release the lock by setting it to NULL > > > */ > > > - if (cmpxchg(lock, node, NULL) == node) > > > + if (likely(cmpxchg(lock, node, NULL) == node)) > > > > Agreed here as well. Takes a narrow race to hit this. > > > > So, did your testing exercise this path? If the answer is "yes", > > > Paul, > > I did some instrumentation and confirmed that the path in question has > been exercised. So this patch should be okay. Very good! Thanx, Paul -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e31.co.us.ibm.com ([32.97.110.149]:37902 "EHLO e31.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753411Ab3KSXGH (ORCPT ); Tue, 19 Nov 2013 18:06:07 -0500 Received: from /spool/local by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 19 Nov 2013 16:06:07 -0700 Date: Tue, 19 Nov 2013 15:05:42 -0800 From: "Paul E. McKenney" Subject: Re: [PATCH v5 2/4] MCS Lock: optimizations and extra comments Message-ID: <20131119230542.GW4138@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <1383940325.11046.415.camel@schen9-DESK> <20131119191310.GO4138@linux.vnet.ibm.com> <1384901861.11046.449.camel@schen9-DESK> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1384901861.11046.449.camel@schen9-DESK> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Tim Chen Cc: Ingo Molnar , Andrew Morton , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-mm , linux-arch@vger.kernel.org, Linus Torvalds , Waiman Long , Andrea Arcangeli , Alex Shi , Andi Kleen , Michel Lespinasse , Davidlohr Bueso , Matthew R Wilcox , Dave Hansen , Peter Zijlstra , Rik van Riel , Peter Hurley , Raghavendra K T , George Spelvin , "H. Peter Anvin" , Arnd Bergmann , Aswin Chandramouleeswaran , Scott J Norton , Will Deacon , "Figo.zhang" Message-ID: <20131119230542.exnMwmWxnQok4C14msQEL1VnjaQvrcN2kXDEmdjRYq8@z> On Tue, Nov 19, 2013 at 02:57:41PM -0800, Tim Chen wrote: > On Tue, 2013-11-19 at 11:13 -0800, Paul E. McKenney wrote: > > On Fri, Nov 08, 2013 at 11:52:05AM -0800, Tim Chen wrote: > > > > > > +/* > > > + * Releases the lock. The caller should pass in the corresponding node that > > > + * was used to acquire the lock. > > > + */ > > > static void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *node) > > > { > > > struct mcs_spinlock *next = ACCESS_ONCE(node->next); > > > @@ -51,7 +60,7 @@ static void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *nod > > > /* > > > * Release the lock by setting it to NULL > > > */ > > > - if (cmpxchg(lock, node, NULL) == node) > > > + if (likely(cmpxchg(lock, node, NULL) == node)) > > > > Agreed here as well. Takes a narrow race to hit this. > > > > So, did your testing exercise this path? If the answer is "yes", > > > Paul, > > I did some instrumentation and confirmed that the path in question has > been exercised. So this patch should be okay. Very good! Thanx, Paul