From patchwork Wed Jan 17 20:22:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 10172817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 334ED602DC for ; Thu, 18 Jan 2018 10:29:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 225AF25D9E for ; Thu, 18 Jan 2018 10:29:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 153D72624A; Thu, 18 Jan 2018 10:29:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 899C425D9E for ; Thu, 18 Jan 2018 10:29:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E6606E80E; Thu, 18 Jan 2018 09:45:40 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) by gabe.freedesktop.org (Postfix) with ESMTPS id 56E616E1C4 for ; Wed, 17 Jan 2018 20:23:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3ElzK6NAQLv4ojELN8+xCOmG6zA4J9XN650mKnrTQCk=; b=SDhyZzF12VTzityQwA4sjfnNz ktW5Yj5Xv+7eluFVWwvrK/jzrZXI+kvkMpFKWbl0rgw9kQXc6nC1WNaJOOkfd0OpKAe3s40z1lLgr pL662gj23c+VkduuNTY3dU2Nckd8Uk8fyysMuXVjTvuSNrYmZ4aluCMmW1RdD4WZ2QF/0kUdQOWRw m6KTQKsI0796bC52++RHl5+Y5nadoNr+b1lFRf0ama+SDVS5e40jmLKJD3aV+ikmOD30vGNlJySyT 8gZ62shFjUUj/WBIhjOpgYBx7LzSYLv++xT1GkQnRhETJ8YNfH1gPWZDd311X7EndRkO1Qg0I7Hsr 8Q+k/xgBw==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1ebuEk-0006Mh-C7; Wed, 17 Jan 2018 20:23:06 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Date: Wed, 17 Jan 2018 12:22:02 -0800 Message-Id: <20180117202203.19756-99-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180117202203.19756-1-willy@infradead.org> References: <20180117202203.19756-1-willy@infradead.org> Cc: linux-s390@vger.kernel.org, David Howells , linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-sh@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-usb@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Stefano Stabellini , linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org, Bjorn Andersson , linux-btrfs@vger.kernel.org Subject: [Intel-gfx] [PATCH v6 98/99] qrtr: Convert to XArray X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox Moved the kref protection under the xa_lock too. Signed-off-by: Matthew Wilcox --- net/qrtr/qrtr.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 77ab05e23001..7de9a06d2aa2 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -104,10 +104,10 @@ static inline struct qrtr_sock *qrtr_sk(struct sock *sk) static unsigned int qrtr_local_nid = -1; /* for node ids */ -static RADIX_TREE(qrtr_nodes, GFP_KERNEL); +static DEFINE_XARRAY(qrtr_nodes); /* broadcast list */ static LIST_HEAD(qrtr_all_nodes); -/* lock for qrtr_nodes, qrtr_all_nodes and node reference */ +/* lock for qrtr_all_nodes */ static DEFINE_MUTEX(qrtr_node_lock); /* local port allocation management */ @@ -148,12 +148,15 @@ static int qrtr_bcast_enqueue(struct qrtr_node *node, struct sk_buff *skb, * kref_put_mutex. As such, the node mutex is expected to be locked on call. */ static void __qrtr_node_release(struct kref *kref) + __releases(qrtr_nodes.xa_lock) { struct qrtr_node *node = container_of(kref, struct qrtr_node, ref); if (node->nid != QRTR_EP_NID_AUTO) - radix_tree_delete(&qrtr_nodes, node->nid); + __xa_erase(&qrtr_nodes, node->nid); + xa_unlock(&qrtr_nodes); + mutex_lock(&qrtr_node_lock); list_del(&node->item); mutex_unlock(&qrtr_node_lock); @@ -174,7 +177,7 @@ static void qrtr_node_release(struct qrtr_node *node) { if (!node) return; - kref_put_mutex(&node->ref, __qrtr_node_release, &qrtr_node_lock); + kref_put_lock(&node->ref, __qrtr_node_release, &qrtr_nodes.xa_lock); } /* Pass an outgoing packet socket buffer to the endpoint driver. */ @@ -217,10 +220,10 @@ static struct qrtr_node *qrtr_node_lookup(unsigned int nid) { struct qrtr_node *node; - mutex_lock(&qrtr_node_lock); - node = radix_tree_lookup(&qrtr_nodes, nid); + xa_lock(&qrtr_nodes); + node = xa_load(&qrtr_nodes, nid); node = qrtr_node_acquire(node); - mutex_unlock(&qrtr_node_lock); + xa_unlock(&qrtr_nodes); return node; } @@ -235,10 +238,8 @@ static void qrtr_node_assign(struct qrtr_node *node, unsigned int nid) if (node->nid != QRTR_EP_NID_AUTO || nid == QRTR_EP_NID_AUTO) return; - mutex_lock(&qrtr_node_lock); - radix_tree_insert(&qrtr_nodes, nid, node); node->nid = nid; - mutex_unlock(&qrtr_node_lock); + xa_store(&qrtr_nodes, nid, node, GFP_KERNEL); } /**