From patchwork Thu Feb 27 21:17:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11410551 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 88CF8924 for ; Thu, 27 Feb 2020 21:41:06 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7166824690 for ; Thu, 27 Feb 2020 21:41:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7166824690 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 2A6B034A8D3; Thu, 27 Feb 2020 13:33:26 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 703063489DD for ; Thu, 27 Feb 2020 13:21:21 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 2BAD8A145; Thu, 27 Feb 2020 16:18:20 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 2A94C47C; Thu, 27 Feb 2020 16:18:20 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:17:34 -0500 Message-Id: <1582838290-17243-587-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 586/622] lnet: remove locking protection ln_testprotocompat X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Mr NeilBrown lnet_net_lock(LNET_LOCK_EX) is a heavy-weight lock that is not necessary here. The bits in this field are only set rarely - via an ioctl - and the pattern for reading and clearing them exactly matches test_and_clear_bit(). So change the field to "unsigned long" (so test_and_clear_bit() can be used), and use test_and_clear_bit(), discarding all other locking. WC-bug-id: https://jira.whamcloud.com/browse/LU-12678 Lustre-commit: 624364420970 ("LU-12678 lnet: remove locking protection ln_testprotocompat") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/36856 Reviewed-by: Alexey Lyashkov Reviewed-by: Chris Horn Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- include/linux/lnet/lib-types.h | 2 +- net/lnet/klnds/socklnd/socklnd_proto.c | 17 ++++------------- net/lnet/lnet/acceptor.c | 11 +++-------- net/lnet/lnet/api-ni.c | 2 -- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/include/linux/lnet/lib-types.h b/include/linux/lnet/lib-types.h index 99ed87a..9055da9 100644 --- a/include/linux/lnet/lib-types.h +++ b/include/linux/lnet/lib-types.h @@ -1134,7 +1134,7 @@ struct lnet { struct lnet_lnd *ln_lnds[NUM_LNDS]; /* test protocol compatibility flags */ - int ln_testprotocompat; + unsigned long ln_testprotocompat; /* * 0 - load the NIs from the mod params diff --git a/net/lnet/klnds/socklnd/socklnd_proto.c b/net/lnet/klnds/socklnd/socklnd_proto.c index 887ed2d..195c44f 100644 --- a/net/lnet/klnds/socklnd/socklnd_proto.c +++ b/net/lnet/klnds/socklnd/socklnd_proto.c @@ -484,16 +484,11 @@ if (the_lnet.ln_testprotocompat) { /* single-shot proto check */ - lnet_net_lock(LNET_LOCK_EX); - if (the_lnet.ln_testprotocompat & 1) { + if (test_and_clear_bit(0, &the_lnet.ln_testprotocompat)) hmv->version_major++; /* just different! */ - the_lnet.ln_testprotocompat &= ~1; - } - if (the_lnet.ln_testprotocompat & 2) { + + if (test_and_clear_bit(1, &the_lnet.ln_testprotocompat)) hmv->magic = LNET_PROTO_MAGIC; - the_lnet.ln_testprotocompat &= ~2; - } - lnet_net_unlock(LNET_LOCK_EX); } hdr->src_nid = cpu_to_le64(hello->kshm_src_nid); @@ -541,12 +536,8 @@ if (the_lnet.ln_testprotocompat) { /* single-shot proto check */ - lnet_net_lock(LNET_LOCK_EX); - if (the_lnet.ln_testprotocompat & 1) { + if (test_and_clear_bit(0, &the_lnet.ln_testprotocompat)) hello->kshm_version++; /* just different! */ - the_lnet.ln_testprotocompat &= ~1; - } - lnet_net_unlock(LNET_LOCK_EX); } rc = lnet_sock_write(sock, hello, offsetof(struct ksock_hello_msg, kshm_ips), diff --git a/net/lnet/lnet/acceptor.c b/net/lnet/lnet/acceptor.c index acd1d75..c6a1835 100644 --- a/net/lnet/lnet/acceptor.c +++ b/net/lnet/lnet/acceptor.c @@ -174,16 +174,11 @@ if (the_lnet.ln_testprotocompat) { /* single-shot proto check */ - lnet_net_lock(LNET_LOCK_EX); - if (the_lnet.ln_testprotocompat & 4) { + if (test_and_clear_bit(2, &the_lnet.ln_testprotocompat)) cr.acr_version++; - the_lnet.ln_testprotocompat &= ~4; - } - if (the_lnet.ln_testprotocompat & 8) { + + if (test_and_clear_bit(3, &the_lnet.ln_testprotocompat)) cr.acr_magic = LNET_PROTO_MAGIC; - the_lnet.ln_testprotocompat &= ~8; - } - lnet_net_unlock(LNET_LOCK_EX); } rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout); diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c index cd95bdd..0ca8bef 100644 --- a/net/lnet/lnet/api-ni.c +++ b/net/lnet/lnet/api-ni.c @@ -3842,9 +3842,7 @@ u32 lnet_get_dlc_seq_locked(void) return 0; case IOC_LIBCFS_TESTPROTOCOMPAT: - lnet_net_lock(LNET_LOCK_EX); the_lnet.ln_testprotocompat = data->ioc_flags; - lnet_net_unlock(LNET_LOCK_EX); return 0; case IOC_LIBCFS_LNET_FAULT: