From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751917AbcFFLO2 (ORCPT ); Mon, 6 Jun 2016 07:14:28 -0400 Received: from ozlabs.org ([103.22.144.67]:57214 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751852AbcFFLO1 (ORCPT ); Mon, 6 Jun 2016 07:14:27 -0400 In-Reply-To: <20160603034948.17589-1-boqun.feng@gmail.com> To: Boqun Feng , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org From: Michael Ellerman Cc: Peter Zijlstra , Boqun Feng , Will Deacon , Paul Mackerras , "Paul E. McKenney" Subject: Re: [v2] powerpc: spinlock: Fix spin_unlock_wait() Message-Id: <3rNXCQ1t8Nz9t42@ozlabs.org> Date: Mon, 6 Jun 2016 21:14:26 +1000 (AEST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2016-03-06 at 03:49:48 UTC, Boqun Feng wrote: > diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h > index 523673d7583c..2ed893662866 100644 > --- a/arch/powerpc/include/asm/spinlock.h > +++ b/arch/powerpc/include/asm/spinlock.h > @@ -64,6 +64,25 @@ static inline int arch_spin_is_locked(arch_spinlock_t *lock) > } > > /* > + * Use a ll/sc loop to read the lock value, the STORE part of this operation is > + * used for making later lock operation observe it. > + */ > +static inline bool arch_spin_is_locked_sync(arch_spinlock_t *lock) > +{ > + arch_spinlock_t tmp; > + > + __asm__ __volatile__( > +"1: " PPC_LWARX(%0, 0, %2, 1) "\n" As discussed offline I think we want to use EH=0 here (the final parameter). >>From the ISA: The value of EH provides a hint as to whether the program will perform a subsequent store to the word in storage addressed by EA before some other processor attempts to modify it. 0 Other programs might attempt to modify the word in storage addressed by EA regardless of the result of the corresponding stwcx. instruction. cheers