Received: by 10.192.165.148 with SMTP id m20csp1872629imm; Thu, 3 May 2018 06:49:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqgTO4sK1kSjJ1lIQXp4jih3YIkfzXibGzC2cXWCK7fcLIfZnvVkNUCB13zA8ln4mCAkO38 X-Received: by 2002:a63:618b:: with SMTP id v133-v6mr18857835pgb.285.1525355394509; Thu, 03 May 2018 06:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525355394; cv=none; d=google.com; s=arc-20160816; b=cnuWo/4s6Ac2hiqE/Qi9vm7MD2IeyqfTelxaY5Hu1zDGR3YlmdxsFvNplpy0PDisUe 8F7HVxV8AgluGkcsmb23svQwkyFvoWuRRUCOQ3uHczo8dKK4aR5ITN7qwNI+pVUUHOZQ NynNyRJ9qwp20NS+JD7t5EdImSkVXwyBD3IVi7SSZQKwh5prIwaJRX9+dY/RJCioCNXe fvqvsv8VZ8r364dWwEByqREj/9B20N2mpHAiRGRphBw+5EeDkjGWh7ZzUA/TbzrneTbS s2k2jBZ9oyzR/qzb9AOYVp4z8peaevzeaP7jMp6LxpEcAMYFu9kISs7AeDEEUHDq+t4x b0Mg== 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-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=ozhFYdp+iqOPsZvJPyxELGCr/TJDoVgmoS5lnqk2rr4=; b=iTo9Ci9U7inYMoXLCWjBNq22x0EbnutZOOd9S/Nx58a+uVuQ/Kz4VPTs7Ztbwbr1Qf iLU0xdJsAVp7YZQOtE1u9Iu9yDfER9eXnfTZCsxJAVY0P7ZgCWcDJ8bh3dvi9jhTTuwt 2rPMZaUwS6R+jXbbh2kHdSjt9MOkpxHDIx+wDCbtfIwrM7BVd/ZmnwvshNkp/LObjXdb r6gFxe2cGyehWdIyCm+WdnB3TllucKrea+wY8+O7XjIYC97LYWa299Ah+ZNv+pp99XtF u+Xf9PCZy0FLnqSr2tLJGCKLiahE2rHZTTBoFfvYKLOTJV+JNTM1RBXBOJDnkHMXH4ie 2Sqw== 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 p21-v6si11158625pgv.401.2018.05.03.06.49.40; Thu, 03 May 2018 06:49:54 -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 S1751174AbeECNtQ convert rfc822-to-8bit (ORCPT + 99 others); Thu, 3 May 2018 09:49:16 -0400 Received: from smtp-out6.electric.net ([192.162.217.188]:63891 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750922AbeECNtO (ORCPT ); Thu, 3 May 2018 09:49:14 -0400 Received: from 1fEEbW-0004Qs-Vc by out6c.electric.net with emc1-ok (Exim 4.90_1) (envelope-from ) id 1fEEba-0005Gc-Vu; Thu, 03 May 2018 06:49:06 -0700 Received: by emcmailer; Thu, 03 May 2018 06:49:06 -0700 Received: from [156.67.243.126] (helo=AcuMS.aculab.com) by out6c.electric.net with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fEEbW-0004Qs-Vc; Thu, 03 May 2018 06:49:02 -0700 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 3 May 2018 14:50:07 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 3 May 2018 14:50:07 +0100 From: David Laight To: 'James Simmons' , Greg Kroah-Hartman , "devel@driverdev.osuosl.org" , Andreas Dilger , "Oleg Drokin" , Lai Siyao , "Jinshan Xiong" , NeilBrown CC: 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: AQHT4kKj75feMa9hUUOW7d3VlFt3tKQeBXug Date: Thu, 3 May 2018 13:50:07 +0000 Message-ID: References: <1525285308-15347-1-git-send-email-jsimmons@infradead.org> <1525285308-15347-2-git-send-email-jsimmons@infradead.org> In-Reply-To: <1525285308-15347-2-git-send-email-jsimmons@infradead.org> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.33] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 156.67.243.126 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuMS.aculab.com X-TLS: TLSv1.2:ECDHE-RSA-AES256-SHA384:256 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 X-Virus-Status: Scanned by VirusSMART (c) X-Virus-Status: Scanned by VirusSMART (s) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) David