From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kirill Tkhai Subject: [PATCH 3/3] net: Remove spinlock from get_net_ns_by_id() Date: Thu, 21 Dec 2017 16:14:21 +0300 Message-ID: <151386205963.3724.7673833316098613356.stgit@localhost.localdomain> References: <151386201910.3724.7199367937841370542.stgit@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: eric.dumazet@gmail.com, ktkhai@virtuozzo.com, ebiederm@xmission.com To: netdev@vger.kernel.org, davem@davemloft.net Return-path: Received: from mail-ve1eur01on0117.outbound.protection.outlook.com ([104.47.1.117]:45335 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751734AbdLUNO3 (ORCPT ); Thu, 21 Dec 2017 08:14:29 -0500 In-Reply-To: <151386201910.3724.7199367937841370542.stgit@localhost.localdomain> Sender: netdev-owner@vger.kernel.org List-ID: idr_find() is safe under rcu_read_lock() and maybe_get_net() guarantees that net is alive. Signed-off-by: Kirill Tkhai --- net/core/net_namespace.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 6a4eab438221..a675f35a18ff 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -279,11 +279,9 @@ struct net *get_net_ns_by_id(struct net *net, int id) return NULL; rcu_read_lock(); - spin_lock_bh(&net->nsid_lock); peer = idr_find(&net->netns_ids, id); if (peer) peer = maybe_get_net(peer); - spin_unlock_bh(&net->nsid_lock); rcu_read_unlock(); return peer;