From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH v7 5/6] MCS Lock: allow architectures to hook in to contended paths Date: Mon, 20 Jan 2014 13:19:48 +0100 Message-ID: <20140120121948.GD31570@twins.programming.kicks-ass.net> References: <1389917311.3138.15.camel@schen9-DESK> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1389917311.3138.15.camel@schen9-DESK> Sender: owner-linux-mm@kvack.org To: Tim Chen Cc: Ingo Molnar , Andrew Morton , Thomas Gleixner , "Paul E.McKenney" , Will Deacon , 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 , Rik van Riel , Peter Hurley , Raghavendra K T , George Spelvin , "H. Peter Anvin" , Arnd Bergmann , Aswin List-Id: linux-arch.vger.kernel.org On Thu, Jan 16, 2014 at 04:08:31PM -0800, Tim Chen wrote: > +#ifndef arch_mcs_spin_lock_contended > +/* > + * Using smp_load_acquire() provides a memory barrier that ensures > + * subsequent operations happen after the lock is acquired. > + */ > +#define arch_mcs_spin_lock_contended(l) \ > + while (!(smp_load_acquire(l))) { \ > + arch_mutex_cpu_relax(); \ > + } > +#endif I think that wants to be: #define arch_mcs_spin_lock_contended(l) \ do { \ while (!smp_load_acquire(l)) \ arch_mutex_cpu_relax(); \ } while (0) So that we properly eat the ';' in: arch_mcs_spin_lock_contended(l);. > +#ifndef arch_mcs_spin_unlock_contended > +/* > + * smp_store_release() provides a memory barrier to ensure all > + * operations in the critical section has been completed before > + * unlocking. > + */ > +#define arch_mcs_spin_unlock_contended(l) \ > + smp_store_release((l), 1) > #endif -- 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 merlin.infradead.org ([205.233.59.134]:55030 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751643AbaATMU3 (ORCPT ); Mon, 20 Jan 2014 07:20:29 -0500 Date: Mon, 20 Jan 2014 13:19:48 +0100 From: Peter Zijlstra Subject: Re: [PATCH v7 5/6] MCS Lock: allow architectures to hook in to contended paths Message-ID: <20140120121948.GD31570@twins.programming.kicks-ass.net> References: <1389917311.3138.15.camel@schen9-DESK> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1389917311.3138.15.camel@schen9-DESK> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Tim Chen Cc: Ingo Molnar , Andrew Morton , Thomas Gleixner , "Paul E.McKenney" , Will Deacon , 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 , Rik van Riel , Peter Hurley , Raghavendra K T , George Spelvin , "H. Peter Anvin" , Arnd Bergmann , Aswin Chandramouleeswaran , Scott J Norton , "Figo.zhang" Message-ID: <20140120121948.Zd3aDv2Wmutqb8oBlQXHCOmoV6YX6O7iauumKk-ampk@z> On Thu, Jan 16, 2014 at 04:08:31PM -0800, Tim Chen wrote: > +#ifndef arch_mcs_spin_lock_contended > +/* > + * Using smp_load_acquire() provides a memory barrier that ensures > + * subsequent operations happen after the lock is acquired. > + */ > +#define arch_mcs_spin_lock_contended(l) \ > + while (!(smp_load_acquire(l))) { \ > + arch_mutex_cpu_relax(); \ > + } > +#endif I think that wants to be: #define arch_mcs_spin_lock_contended(l) \ do { \ while (!smp_load_acquire(l)) \ arch_mutex_cpu_relax(); \ } while (0) So that we properly eat the ';' in: arch_mcs_spin_lock_contended(l);. > +#ifndef arch_mcs_spin_unlock_contended > +/* > + * smp_store_release() provides a memory barrier to ensure all > + * operations in the critical section has been completed before > + * unlocking. > + */ > +#define arch_mcs_spin_unlock_contended(l) \ > + smp_store_release((l), 1) > #endif