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 X-Patchwork-Id: 10170791 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 C662760386 for ; Wed, 17 Jan 2018 20:24:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7B0F20602 for ; Wed, 17 Jan 2018 20:24:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B637720700; Wed, 17 Jan 2018 20:24:45 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 581C52223E for ; Wed, 17 Jan 2018 20:24:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753223AbeAQUYm (ORCPT ); Wed, 17 Jan 2018 15:24:42 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:34793 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754016AbeAQUXH (ORCPT ); Wed, 17 Jan 2018 15:23:07 -0500 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 Cc: Matthew Wilcox , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-usb@vger.kernel.org, Bjorn Andersson , Stefano Stabellini , iommu@lists.linux-foundation.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, intel-gfx@lists.freedesktop.org, cgroups@vger.kernel.org, linux-sh@vger.kernel.org, David Howells Subject: [PATCH v6 98/99] qrtr: Convert to XArray 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> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org 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); } /**