Received: by 10.192.165.148 with SMTP id m20csp164817imm; Thu, 3 May 2018 17:13:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqSjAa1uFGFppa7qY6C2JglfWrJ8Zx0o9iUsRHdn2kWV4A1Uz9x3REQ3LcZhpNOurhkpGdV X-Received: by 10.98.127.145 with SMTP id a139mr24874711pfd.25.1525392806114; Thu, 03 May 2018 17:13:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525392806; cv=none; d=google.com; s=arc-20160816; b=rbXkFYfRSi6vO28YkHa/k7xlPW/3hbR+MX334D3rk4OEU3FA5O/0zAlwCTMDvpFfTi sSw2qJZI4QfkjfEhucaxZR2HHRzQ2XZL+VfpBN78FfKW/H4FBBgeFNysrdkGkXH1cd8A THLxGl3VGrHSj5pEiL189D6vUPzeV09gH+WuBWKLL4/qy81paGNI3SWWz7xLXs8YhJ5H AfTXpqSBG+lTQfX3QuwMhALg48sCu/f6NAiQ8BtpSfXert3NQzgCVIB+cpTGlSnEoLr4 9IEmaqEpHT9x12Sa1BGnNTP7xFqYDhtZ6Lg+gCf/TmPrIqqhzIufyMPIpgZfw52a/G2H zCVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=5BxBtGAt0rXChvcfYY5AlqCjZV0PAPgBYeNQOOgzXOA=; b=BUxzzkdtdmPMS+WCVJEXgAPMoYE076skTEUbFYQUpyPQp9kKWpSim/FC9IauYz/UpU lxqnRdpEZsJXDJM7ENKwWOMZfFH5QWIBCOSCp1TQGeLD3ovYdxgnyOBuPqr5osZ3P8MG dAlXjJ4v38AqdUBDloMbW1F3Wj5/nuK3WReKCzLR5jxrJZWnxomUUXcfOSt6nTgZ9xyU bDH12hqEondxUBVpJ6XnPVZ4L3NWoTipQdVTI+D0et9zkucdkIPMXth5Gd9KyXG00UuB EgsrU9EgRvBmMNYOx0i8jXmX7HI5gWhhPl3n5694d0LE6f3lnND9g/vPJMB6aPCSGvwX mK8A== 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 v129-v6si12296512pgb.179.2018.05.03.17.13.11; Thu, 03 May 2018 17:13:26 -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 S1751311AbeEDAL5 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 3 May 2018 20:11:57 -0400 Received: from mga01.intel.com ([192.55.52.88]:31464 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751116AbeEDAL4 (ORCPT ); Thu, 3 May 2018 20:11:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 17:11:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,360,1520924400"; d="scan'208";a="221488513" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga005.jf.intel.com with ESMTP; 03 May 2018 17:11:55 -0700 Received: from FMSMSX109.amr.corp.intel.com ([169.254.15.12]) by FMSMSX106.amr.corp.intel.com ([169.254.5.29]) with mapi id 14.03.0319.002; Thu, 3 May 2018 17:11:55 -0700 From: "Dilger, Andreas" To: David Laight CC: James Simmons , Greg Kroah-Hartman , "devel@driverdev.osuosl.org" , "Drokin, Oleg" , "Siyao, Lai" , Jinshan Xiong , NeilBrown , 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 Thread-Topic: [PATCH 1/4] staging: lustre: obdclass: change spinlock of key to rwlock Thread-Index: AQHT4uWKeBM3CaAgP0S7TBmjqoBdPaQfKJCA Date: Fri, 4 May 2018 00:11:54 +0000 Message-ID: <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> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.252.137.157] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On May 3, 2018, at 07:50, David Laight wrote: > > From: James Simmons >> Sent: 02 May 2018 19:22 >> From: Li Xi >> >> Most of the time, keys are never changed. So rwlock might be >> better for the concurrency of key read. > > 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. > > ... >> - 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); > > WTF, seems unlikely that you need to hold any kind of lock > over an atomic_inc(). > > 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=121776#comment-121776 That said, it might be good to include this information into the commit comment itself. Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation