Received: by 10.192.165.148 with SMTP id m20csp192050imm; Thu, 3 May 2018 17:54:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpVLoKcjXmpA/+487XmkySu49Ov4KiPnH7Z0z3n4103NAxDzB049VD7xf9aTxmrraGUSr2I X-Received: by 10.98.163.145 with SMTP id q17mr25080928pfl.87.1525395252865; Thu, 03 May 2018 17:54:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525395252; cv=none; d=google.com; s=arc-20160816; b=G2D1kk3dFL6hDJ4P1Lr9ucvjAF9ScWOSJjUZGWgpjAHSZ2moUP7189itAtku6MGgjO hsY0cSs6BXYXMOzWws6lez+L0pYi/3MkmqRoZ5ezgsE0odon7iZty3wY1ifwz053eLw4 OFm+DifVD8FqueTZjYOnwMib2hBLj0NmLphBJgaPp3I8v5KKiO7Lv9A8p8VfolNIZ7gb R8uS5nHrp9Da4ZtV+DVFeoMonHBrK/EUNLk8elY0d4DUlZuwP0s1Hhw4CXjw70SnbweL 42hCuK+OWq9W6aWQ0UajWhFvnbajngg23zhw33ILD4Ra1IAlsH8ImDy3tdsMgYmRFAIb BTXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:references :in-reply-to:subject:cc:date:to:from:arc-authentication-results; bh=rpXgPUjm9QuBePUuYPsOh0va7n6tfbCWoZ0l913XCzg=; b=tnPcULRrKzs3LcgW+K8jBLewz/zxss5roNwVOK9JmtR4t9b0tlkILrn9dP2bAFFWJv xv8MJAEuPQbBb21hyihXGSKAsGzCXBSxarC16g1zZiUdHDOwju5wcIGp736orCFIrAKx aKnzQdGQ2cK8BqcqLoeqUPX2Ek1Q565lC5pJCIlJ8nnpouL/BA8UG+FWSybqqXMrrRbF tgsSSH7YY2kC57Xnyv+jxAkbk77fSY3i0hOx/iZofDyysOIiV9ctrfsW0+WEhp8UaWc2 pHvZYf48r8WlVP2VC7Xc2+13FmVuxLtTDMQzabiT67bKJhsKY9emFA3YT7uJHl4ukGbn Mu4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1-v6si12241075pln.437.2018.05.03.17.53.58; Thu, 03 May 2018 17:54:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751279AbeEDAxs (ORCPT + 99 others); Thu, 3 May 2018 20:53:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:36150 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751116AbeEDAxr (ORCPT ); Thu, 3 May 2018 20:53:47 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C82DEABC8; Fri, 4 May 2018 00:53:45 +0000 (UTC) From: NeilBrown To: "Dilger\, Andreas" , David Laight Date: Fri, 04 May 2018 10:53:36 +1000 Cc: James Simmons , Greg Kroah-Hartman , "devel\@driverdev.osuosl.org" , "Drokin\, Oleg" , "Siyao\, Lai" , Jinshan Xiong , Linux Kernel Mailing List , Lustre Development List , Li Xi , Gu Zheng Subject: Re: [PATCH 1/4] staging: lustre: obdclass: change spinlock of key to rwlock In-Reply-To: <55458B75-4105-4F4F-BB50-3D506611AB24@intel.com> References: <1525285308-15347-1-git-send-email-jsimmons@infradead.org> <1525285308-15347-2-git-send-email-jsimmons@infradead.org> <55458B75-4105-4F4F-BB50-3D506611AB24@intel.com> Message-ID: <87a7tgfdgv.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, May 04 2018, Dilger, Andreas wrote: > On May 3, 2018, at 07:50, David Laight wrote: >>=20 >> From: James Simmons >>> Sent: 02 May 2018 19:22 >>> From: Li Xi >>>=20 >>> Most of the time, keys are never changed. So rwlock might be >>> better for the concurrency of key read. >>=20 >> OTOH unless there is contention on the spin lock during reads the >> additional cost of a rwlock (probably double that of a spinlock) >> will hurt performance. >>=20 >> ... >>> - spin_lock(&lu_keys_guard); >>> + read_lock(&lu_keys_guard); >>> atomic_inc(&lu_key_initing_cnt); >>> - spin_unlock(&lu_keys_guard); >>> + read_unlock(&lu_keys_guard); >>=20 >> WTF, seems unlikely that you need to hold any kind of lock >> over an atomic_inc(). >>=20 >> If this is just ensuring that no code holds the lock then >> it would need to request the write_lock(). >> (and would need a comment) > > There was a fair amount of benchmarking done for this that shows the > performance is significantly improved with the patch, which can be > seen in the ticket that was referenced in the original commit comment: > > https://jira.hpdd.intel.com/browse/LU-6800?focusedCommentId=3D121776#comm= ent-121776 That does surprise me. The only places where the lock is held for read are very short - clearing a few fields or incrementing a value. But numbers don't lie. I wonder if the next patch would have had just as big an effect. Taking and dropping the lock 40 times is not likely to be good for performance. Thanks, NeilBrown > > That said, it might be good to include this information into the > commit comment itself. > > Cheers, Andreas > -- > Andreas Dilger > Lustre Principal Architect > Intel Corporation --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlrrrxAACgkQOeye3VZi gbm6HQ//dCdH9MwD3kUjEKaLymrwQR/nuNHP4IEppOJAlmi0vbOHR1GNcMWsLDeU AaYtGyi7e+7sxpo7OihX7+VGKVK3XrVnVoFzrJ3X9Hd5EFfx6ikGKqlQ08FpIskX 8juWuCAvqx92SRbqN7+jX0KtYqeH5A+E8UP//t/eks771+Q3Z+kZEmKW4s98WjOS ABruCPT2Rf7y7dc4rReECjX07ODSYktYEY0TPkQQUGjn8GiTpX2h7ZX3bd+Bisec gXUNtk+jMaQThIUmuE1KP6eXjIv/w2d9fADLadh/qk10nV5gkkHGXjodvvIx69es 5YrEwn4azzYEEWNkDPX9otRJIvLrnvrPg46g/15RjIT9n3si8Hn8D6ld154/AaxH 5w9aQwVS2Q5tR5eAUfTxfJI5KMEI42tBEEQd9RZxRqlrfpbgwNKk2B5cZ6sQpHjg pVqhaMgXmJ9+5ApbHOQigtF3GCe0AmzSngklGNwBr6ZEhlY8Z4hCtPLlFFdnI+LE TTE+i9ixFj0G1dF0TZ/rt0laQNCflobgUA9SCc1I6C+nazaX8kpdS2VjxvpWrVM+ JkJihlmu/Eltce0xToTcXgqoAnrobYQ17/Hs5A1c0/xVO+q14/MlUMWc9YnI2Kp2 86fO/glP3vMiN/PZVPzfTYKGlUbInGOBieXKC2KBScMyKfm8/vc= =zv+U -----END PGP SIGNATURE----- --=-=-=--