From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032861AbdAEPlj (ORCPT ); Thu, 5 Jan 2017 10:41:39 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34153 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968105AbdAEPlb (ORCPT ); Thu, 5 Jan 2017 10:41:31 -0500 Date: Thu, 5 Jan 2017 23:40:34 +0800 From: Boqun Feng To: Waiman Long Cc: Pan Xinhui , Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Message-ID: <20170105154034.GD15084@tardis.cn.ibm.com> References: <1482697561-23848-1-git-send-email-longman@redhat.com> <20170103161836.GY3107@twins.programming.kicks-ass.net> <20170104094149.GD25813@worktop.programming.kicks-ass.net> <006322ad-2e72-c8fe-361f-233f1821063a@linux.vnet.ibm.com> <349c5926-cd35-2313-b8a0-ebfe6eb5e4a0@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oFbHfjnMgUMsrGjO" Content-Disposition: inline In-Reply-To: <349c5926-cd35-2313-b8a0-ebfe6eb5e4a0@redhat.com> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --oFbHfjnMgUMsrGjO Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 05, 2017 at 10:17:46AM -0500, Waiman Long wrote: > On 01/05/2017 03:16 AM, Pan Xinhui wrote: > > > > > > =E5=9C=A8 2017/1/4 17:41, Peter Zijlstra =E5=86=99=E9=81=93: > >> On Tue, Jan 03, 2017 at 05:07:54PM -0500, Waiman Long wrote: > >>> On 01/03/2017 11:18 AM, Peter Zijlstra wrote: > >>>> On Sun, Dec 25, 2016 at 03:26:01PM -0500, Waiman Long wrote: > >>>>> A number of cmpxchg calls in qspinlock_paravirt.h were replaced by > >>>>> more > >>>>> relaxed versions to improve performance on architectures that use > >>>>> LL/SC. > >>>> Claim without numbers ;-) > >>> > >>> Well it is hard to produce actual numbers here as I don't have the > >>> setup > >>> to gather data. > >> > >> Surely RHT has big PPC machines around? I know that getting to them is= a > >> wee bit of a bother, but they should be available somewhere. > >> > > hi, > > > > I do some tests about cmpxchg and cmpxchg_acquire before on ppc. > > > > loops in 15s of each cmpxchg is below. > > > > cmpxchg_relaxed: 336663 > > cmpxchg_release: 369054 > > cmpxchg_acquire: 363364 > > cmpxchg: 179435 > > > > so cmpxchg is really expensive than others. > > but I also have doubt about the cmpxchg_relaxed, it should be the > > cheapest, but from the tests, release/acquire are faster than it. > > > > thanks > > xinhui > > > Thanks for doing the test. It looks like we should just focus on using > either cmpxchg_release or cmpxchg_acquire and forget about cmpxchg_relaxe= d. >=20 _relaxed is more lightweight in two aspects: 1. _relaxed is not a compiler barrier, so it allows compilers do more optimizations than _acquire and _release. 2. _relaxed doesn't introduce HW barriers and doesn't performs worse than _acquire and _release in _most_ _usual_ cases. =20 And on some ll/sc archs without a lightweigt barrier like "lwsync" for _acquire and _release, #2 could be more significant. So don't hesitate to use _relaxed whenever it's possible and reasonable ;-) Regards, Boqun > Cheers, > Longman >=20 --oFbHfjnMgUMsrGjO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEj5IosQTPz8XU1wRHSXnow7UH+rgFAlhuaO4ACgkQSXnow7UH +rgGfgf/QaxzPVV/cN0ptUa6ARSsIpMclGnYGmOjv+K6y9w989b2ylofb3qrTfz6 UyqM3fu8oARygJmdjcW/doTYoh1RmX/0MzY+JuW1D+QbZjXdA1TrYdvrr/O4Pyru gib9T+GUUp6x1rTL6ZRb07M/NewSHE1O1xbmogFpHxD/F8xKM0QyzQo/a3n72B6R HIDPENv6Cf3ZfESBL7yIEGWDg9S1QN5mk2nNHt5caOdMEb6GnHN34J0CEjJt26Ng p/A9lJwPsWOWxvf0TcI0I+eQEOaiuceSj0b4Rg7jRvMWSwjAQ7dJ1U99h+EmS6bU qEWP0RpZehtJrnb1s2SqhLbcje9ymw== =LLN8 -----END PGP SIGNATURE----- --oFbHfjnMgUMsrGjO--