From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751977AbbJTDRi (ORCPT ); Mon, 19 Oct 2015 23:17:38 -0400 Received: from mail-ig0-f173.google.com ([209.85.213.173]:36811 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751151AbbJTDRh (ORCPT ); Mon, 19 Oct 2015 23:17:37 -0400 Date: Tue, 20 Oct 2015 11:17:14 +0800 From: Boqun Feng To: Waiman Long Cc: Peter Zijlstra , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Scott J Norton , Douglas Hatch , Davidlohr Bueso Subject: Re: [PATCH tip/locking/core v8 1/5] locking/qspinlock: Use _acquire/_release versions of cmpxchg & xchg Message-ID: <20151020031714.GA935@fixme-laptop.cn.ibm.com> References: <1444949467-34807-1-git-send-email-Waiman.Long@hpe.com> <1444949467-34807-2-git-send-email-Waiman.Long@hpe.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3MwIy2ne0vdjdPXF" Content-Disposition: inline In-Reply-To: <1444949467-34807-2-git-send-email-Waiman.Long@hpe.com> 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 --3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Waiman, On Thu, Oct 15, 2015 at 06:51:03PM -0400, Waiman Long wrote: > This patch replaces the cmpxchg() and xchg() calls in the native > qspinlock code with the more relaxed _acquire or _release versions of > those calls to enable other architectures to adopt queued spinlocks > with less memory barrier performance overhead. >=20 > Signed-off-by: Waiman Long > --- > include/asm-generic/qspinlock.h | 9 +++++---- > kernel/locking/qspinlock.c | 29 ++++++++++++++++++++++++----- > 2 files changed, 29 insertions(+), 9 deletions(-) >=20 > diff --git a/include/asm-generic/qspinlock.h b/include/asm-generic/qspinl= ock.h > index e2aadbc..39e1cb2 100644 > --- a/include/asm-generic/qspinlock.h > +++ b/include/asm-generic/qspinlock.h > @@ -12,8 +12,9 @@ > * GNU General Public License for more details. > * > * (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P. > + * (C) Copyright 2015 Hewlett-Packard Enterprise Development LP > * > - * Authors: Waiman Long > + * Authors: Waiman Long > */ > #ifndef __ASM_GENERIC_QSPINLOCK_H > #define __ASM_GENERIC_QSPINLOCK_H > @@ -62,7 +63,7 @@ static __always_inline int queued_spin_is_contended(str= uct qspinlock *lock) > static __always_inline int queued_spin_trylock(struct qspinlock *lock) > { > if (!atomic_read(&lock->val) && > - (atomic_cmpxchg(&lock->val, 0, _Q_LOCKED_VAL) =3D=3D 0)) > + (atomic_cmpxchg_acquire(&lock->val, 0, _Q_LOCKED_VAL) =3D=3D 0)) > return 1; > return 0; > } > @@ -77,7 +78,7 @@ static __always_inline void queued_spin_lock(struct qsp= inlock *lock) > { > u32 val; > =20 > - val =3D atomic_cmpxchg(&lock->val, 0, _Q_LOCKED_VAL); > + val =3D atomic_cmpxchg_acquire(&lock->val, 0, _Q_LOCKED_VAL); > if (likely(val =3D=3D 0)) > return; > queued_spin_lock_slowpath(lock, val); > @@ -93,7 +94,7 @@ static __always_inline void queued_spin_unlock(struct q= spinlock *lock) > /* > * smp_mb__before_atomic() in order to guarantee release semantics > */ > - smp_mb__before_atomic_dec(); > + smp_mb__before_atomic(); > atomic_sub(_Q_LOCKED_VAL, &lock->val); Just be curious, you don't use atomic_sub_release() here on purpose? Regards, Boqun > } > #endif --3MwIy2ne0vdjdPXF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJWJbI2AAoJEEl56MO1B/q4YNEIAJlgohdRw+dzQx5ZuOlE+EKy 2xQH70CxzASpRtD3HoUcvDJ11EiQFLfNGRXNj3ZSpfDlJb3Xl/a3dsToxZMltR3m 1mmtvLPAVbTUlHhe26uuK2jAUI3KHigoozjioEfxOLolJk4JA5RQJvRH8K/kloiE EeBcME1kaE4mX7lMuntFGK0jGwavqAGGD+Y8se2rMF7YamarF9D2aKaJ2yAqeYc+ yVLDNQ12BEBfKYsAW9t9lusfn3Z+TW9nkS5HFIh1yMlf46q2ALigBc2zuHY9tm++ Gk+woIr32UYZr7wsLtw4FMKm9jbltEFI8rkcDOQcqC43r814gFqtL9XWINnknB4= =gVmS -----END PGP SIGNATURE----- --3MwIy2ne0vdjdPXF--