From patchwork Wed May 8 06:06:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 163624 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp2259988ilm; Tue, 7 May 2019 23:07:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBBD5dIiLgNKlQC8RRxuKEx1DLSlKLBFdb5f6WhLT68QSocnozREIxt6R28FGx6Rqcx7eC X-Received: by 2002:a63:c509:: with SMTP id f9mr22937716pgd.143.1557295629727; Tue, 07 May 2019 23:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557295629; cv=none; d=google.com; s=arc-20160816; b=0V4lQ66PCvbFovvqyvDUjxO9Stp17prceaVeLIrQAcfcSvmlH+jLI0kLGX1DbtmAyX +4UMXLqLoPkJxsuz5P6d7dVF5F3Qi903Vo7JRl7AQZAbN1xOM7oE1/BN1pVzAVEvT7Tn 4oZGT6HwzhCd02Lk2U3LS6CD8G1v2/J037Vy2oPp5PzQ0pMgZuGPcIqOXn8KWJ0GDDz0 LqDnoVYz2flOJeazbFGGwIDJ7NecGXS2NBbeW4Svo9qaiQf4p6uu33WDKfLPhEJJf7b5 AYi83Hi0w8MgES90bk5ORUZ3800e2ZR+ovLiw3TBDk60e+SiQfdbwhJya1cXEQT/PmoV 4tgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=5IgbbTEWxx9612vWZb+A6P+LPisYaMkTp+oYoBjVljQ=; b=HbLs+YVikSWDKnymhRXbwCWJOejNaBnpKjVQ59o2u35os9eBi6od+WOByX3jEBxu+2 wpEVK8hqJfnSjMi51NwfqCRGt0V1qtpe0ewZndjJHFXNFCEUlEvYNINhLeScpkOeBDvf zqrsHg3HmDh0UkSB48yup6/NL2CnyhDV4gDd3E6xKDgMXqeh8cUh8qKWQ9jO3GPnisLc pqYqkhMXvxJ9JT015qgtz8Jj0siJCBeOcLp4kCJD0zmwhO5yqJqDtFhcHI18nGfl/mOI 0ZQgyoihkSdZtFbPJVkPxEs/FD0zgbKWEXTs2XsGv1ojx8MA2vX8rZuZBBr9vp4RBKBg P+9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="L/bxrM+J"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si20113540pgs.86.2019.05.07.23.07.09; Tue, 07 May 2019 23:07:09 -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; dkim=pass header.i=@linaro.org header.s=google header.b="L/bxrM+J"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728700AbfEHGHI (ORCPT + 30 others); Wed, 8 May 2019 02:07:08 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:40547 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728630AbfEHGGv (ORCPT ); Wed, 8 May 2019 02:06:51 -0400 Received: by mail-pl1-f193.google.com with SMTP id b3so9382162plr.7 for ; Tue, 07 May 2019 23:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5IgbbTEWxx9612vWZb+A6P+LPisYaMkTp+oYoBjVljQ=; b=L/bxrM+JHPq69ydLVroJHc6ezcUZtRdVhf8h5c+uTnt5DKqt1RUtVh2oS3D7/r5B1H KFjM/EMJ6gZqR6GRjMPALRLwQc5h9sCopFUYQj2XRNFTvy/tHj17VkppsfdskI8iBq/C i2AQmfR0Rzrmzsy89Hwwf7wbo2TpP9hHNyA9qzzxhnFAYeV1ouBVauOx40r/6+IPTt2A LJMMBerTq6n4+jaAmbXexhvnKYmVU660ABRSAUngUJE5/rC8cpU7TZP0zLDNFPXHoDEX +nT4FJF9HEls18UXmV60PR/kQDqAUNkmKPkOVG6RFCO1IovVSjRfTyIHXQVZbCROmuPR 63WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5IgbbTEWxx9612vWZb+A6P+LPisYaMkTp+oYoBjVljQ=; b=cSRJsqjNUUQr1J20YjPINaPpGkFCtO4nQcSWW7ynz0T3bAJk/JiUi2vupb8l1cvGuB CkDZB1X7EY4KmAYeUqZJ0iXKOIb2+uVbTCdT/k63BjMmOft6fbPHHtnZzixDdayAd2p9 Xoh3hNfgt8ALGlTIzmhWsYccyIcBM+bATJ1u0S1YvaHyMTnOWLrOvvmvtuH8WjriJaDg scf8B3RtJ7MTJ2TZrfmiwd8wWc/TArS3tzrqHjttfz241tYWj4wXlx0mED7aZ4KkptFX wEBMVv+YgnNuLiCKsKPdk882qS5WqK5hEWmL4ppGCXkMLIgR2E/DZtIkSosO/4jmY83y AiGw== X-Gm-Message-State: APjAAAXaWk0cpb+bY0dr8uY/JFFLURL4AHfoWb4GhKrnZo9wDODjTQvB JJPZmmFW7mCazEZUjPnxltx2Qq91s6U= X-Received: by 2002:a17:902:8ec6:: with SMTP id x6mr43914309plo.123.1557295610614; Tue, 07 May 2019 23:06:50 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id t5sm2756130pgn.80.2019.05.07.23.06.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 May 2019 23:06:49 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" , Arun Kumar Neelakantam , Chris Lew Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 3/5] net: qrtr: Migrate node lookup tree to spinlock Date: Tue, 7 May 2019 23:06:41 -0700 Message-Id: <20190508060643.30936-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190508060643.30936-1-bjorn.andersson@linaro.org> References: <20190508060643.30936-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move operations on the qrtr_nodes radix tree under a separate spinlock and make the qrtr_nodes tree GFP_ATOMIC, to allow operation from atomic context in a subsequent patch. Signed-off-by: Bjorn Andersson --- net/qrtr/qrtr.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) -- 2.18.0 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 62abd622618d..9075751028a2 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -16,6 +16,7 @@ #include #include /* For TIOCINQ/OUTQ */ #include +#include #include #include @@ -106,10 +107,11 @@ static inline struct qrtr_sock *qrtr_sk(struct sock *sk) static unsigned int qrtr_local_nid = NUMA_NO_NODE; /* for node ids */ -static RADIX_TREE(qrtr_nodes, GFP_KERNEL); +static RADIX_TREE(qrtr_nodes, GFP_ATOMIC); +static DEFINE_SPINLOCK(qrtr_nodes_lock); /* broadcast list */ static LIST_HEAD(qrtr_all_nodes); -/* lock for qrtr_nodes, qrtr_all_nodes and node reference */ +/* lock for qrtr_all_nodes and node reference */ static DEFINE_MUTEX(qrtr_node_lock); /* local port allocation management */ @@ -171,10 +173,13 @@ static void __qrtr_node_release(struct kref *kref) { struct radix_tree_iter iter; struct qrtr_node *node = container_of(kref, struct qrtr_node, ref); + unsigned long flags; void __rcu **slot; + spin_lock_irqsave(&qrtr_nodes_lock, flags); if (node->nid != QRTR_EP_NID_AUTO) radix_tree_delete(&qrtr_nodes, node->nid); + spin_unlock_irqrestore(&qrtr_nodes_lock, flags); list_del(&node->item); mutex_unlock(&qrtr_node_lock); @@ -340,11 +345,12 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb, static struct qrtr_node *qrtr_node_lookup(unsigned int nid) { struct qrtr_node *node; + unsigned long flags; - mutex_lock(&qrtr_node_lock); + spin_lock_irqsave(&qrtr_nodes_lock, flags); node = radix_tree_lookup(&qrtr_nodes, nid); node = qrtr_node_acquire(node); - mutex_unlock(&qrtr_node_lock); + spin_unlock_irqrestore(&qrtr_nodes_lock, flags); return node; } @@ -356,13 +362,15 @@ static struct qrtr_node *qrtr_node_lookup(unsigned int nid) */ static void qrtr_node_assign(struct qrtr_node *node, unsigned int nid) { + unsigned long flags; + if (node->nid != QRTR_EP_NID_AUTO || nid == QRTR_EP_NID_AUTO) return; - mutex_lock(&qrtr_node_lock); + spin_lock_irqsave(&qrtr_nodes_lock, flags); radix_tree_insert(&qrtr_nodes, nid, node); node->nid = nid; - mutex_unlock(&qrtr_node_lock); + spin_unlock_irqrestore(&qrtr_nodes_lock, flags); } /**