From patchwork Fri May 31 01:17:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 165469 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp64246ili; Thu, 30 May 2019 18:18:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCsaqOZxrF9fWZ0p6DrvEkgRGz7RR92OF0+QA8DJzZK4Vd+9wb7AOejWVsYGM8U3iews4K X-Received: by 2002:a17:902:ab90:: with SMTP id f16mr6295758plr.262.1559265486323; Thu, 30 May 2019 18:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559265486; cv=none; d=google.com; s=arc-20160816; b=Sn90ibutCe/M0utE2pliW+I/92wD/ee6cMR3nAQtWHhKtNhgvHtOwU9BuIyYK12UU+ Zz2UTjp2HJLYz8xrPkQp8QNCd4P1o5YlzMmHFwvGela+OnNGcuzLAtNjmltzZLINo01N DoGogI4oS3aKFfgstiRDUgShUCn8i9aeHdHDEUVrhjw4IRJaQbcYt2owDxHPVRRqc4F5 JCoJt3J3TgKFxr60gyOypE0AiGvNYX1kZ0S47EcPPJTO+DnuI2Dn8uyW/DKb3972SmA/ Tdb4TN6UlDWCvwUx0jH4sO6rI+MIAZ+y3y8vIjtf6rRrL6F2QnYul3A5IZ3BaqYMN30l 5qXA== 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=lQChNdDCdNXbbkNhmVNEtdud6LkQIlqNuY3CF0Rb0Z0=; b=DZma9P/OtZAWYPykynb0gsmkgEaSoLwbhmy86sGY+2jnsQ49yp8hnerkRgAxL0CuNP DYf77T02KhC+5SpxdO7XrAr1GoVm/+bA1M5p6E61hPKILDLaQ2bgDYC1Wb1lHDJBnJIS lCsbzOiiC+zYINpevJCloPxaeEMGzQn7VvvYwz9yMroPhwo1NQpAcdRKb6hRpFmPZTtm jq2CGw7UUxhnXUlNUTmIFUiFG9mkedNR6v51TWfNEZFSbX649EXdMoz7AKjFHugyMD/F 1a1J7DzUhALd9UEGzdClNtkKUieC3mBlAuTIrRzaZytCgKkgJ0MfZU6Sw7KDaFoFZ5/d to/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W3OeWcHl; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 j14si4671548pfh.232.2019.05.30.18.18.05; Thu, 30 May 2019 18:18:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=W3OeWcHl; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1726869AbfEaBR7 (ORCPT + 15 others); Thu, 30 May 2019 21:17:59 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:39904 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726867AbfEaBR7 (ORCPT ); Thu, 30 May 2019 21:17:59 -0400 Received: by mail-pg1-f196.google.com with SMTP id 196so3027067pgc.6 for ; Thu, 30 May 2019 18:17:58 -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=lQChNdDCdNXbbkNhmVNEtdud6LkQIlqNuY3CF0Rb0Z0=; b=W3OeWcHl7rImj19BvH3xjv9qop1HI7j9YSy/j6zBzACzYwC6JaihSDcOsdsg5sFn/1 kdsGeVuhdWNMYluF+P8YSYUYX9/i1CEcgDGVqYYPcSSDBRfJiE/2h62TSjbMFtd82U0Z SIKPMzzqe8bndsaw2VK+ZYXmtHy5IvQesbsfsmOxYkmUkJOlDJewCP7RHmY9pmsY2FGt TVJ/lFwAVsrabskBcHFZ+uF1fPEmUP9STg//wLbMy/KirP3tySf1frZh116kwGCJ4IdL Hu3REat1yy8eVz6GroR+tHAaJPZeMvRby+lsWwnub/eogjUb15zvq0orpri6pW434s3k r3NQ== 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=lQChNdDCdNXbbkNhmVNEtdud6LkQIlqNuY3CF0Rb0Z0=; b=IPI9FpMqoQkGbRJWuGx4/kUa0ja5q9uh0xAqf/QggcQsZQhrL2N+K2SPFKC6bu5jqz K9L3Sq0OmcTxEFnOzKNvIL+OZosJp2m9HPo6p5e4QOyxc6ercA+eE9EVzwVF/LXA8Z2U HJ+HTeUItPjJbNMV1pdhNtypY2+zF50d2FM6dq47861YDVQQiFBKrnLMNi8r3VxIkmmr aszx/DPNtIClPC5N2iD6ZhPhH1cI9S9qZGlFyYOdyEUNdZoaPQxR+0jYNtmpD+UYsOhi POBVRaJ9+lqu5hCthk2KOo5UK00YX6BRHO5P5EZS9a612cC5pfT0T2dhz08JTcDUqLCm oxgQ== X-Gm-Message-State: APjAAAVIuPyLUYYu5hwoMVGjihfIIhXR3h2sW2svQZEn9AqL5cwN9uly 1U/uYeAv3OVu/TjE+p5Qmmq1Ig== X-Received: by 2002:a65:64d5:: with SMTP id t21mr6466607pgv.310.1559265478172; Thu, 30 May 2019 18:17:58 -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 j20sm1819042pff.183.2019.05.30.18.17.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 18:17:57 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: Arun Kumar Neelakantam , Chris Lew , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 1/5] net: qrtr: Move resume-tx transmission to recvmsg Date: Thu, 30 May 2019 18:17:49 -0700 Message-Id: <20190531011753.11840-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190531011753.11840-1-bjorn.andersson@linaro.org> References: <20190531011753.11840-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The confirm-rx bit is used to implement a per port flow control, in order to make sure that no messages are dropped due to resource exhaustion. Move the resume-tx transmission to recvmsg to only confirm messages as they are consumed by the application. Signed-off-by: Bjorn Andersson --- Changes since v1: - Renamed qrtr_send_resume_tx() net/qrtr/qrtr.c | 60 +++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 27 deletions(-) -- 2.18.0 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 05fa058bee59..89fb846cc244 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -369,22 +369,11 @@ static void qrtr_port_put(struct qrtr_sock *ipc); static void qrtr_node_rx_work(struct work_struct *work) { struct qrtr_node *node = container_of(work, struct qrtr_node, work); - struct qrtr_ctrl_pkt *pkt; - struct sockaddr_qrtr dst; - struct sockaddr_qrtr src; struct sk_buff *skb; while ((skb = skb_dequeue(&node->rx_queue)) != NULL) { struct qrtr_sock *ipc; - struct qrtr_cb *cb; - int confirm; - - cb = (struct qrtr_cb *)skb->cb; - src.sq_node = cb->src_node; - src.sq_port = cb->src_port; - dst.sq_node = cb->dst_node; - dst.sq_port = cb->dst_port; - confirm = !!cb->confirm_rx; + struct qrtr_cb *cb = (struct qrtr_cb *)skb->cb; qrtr_node_assign(node, cb->src_node); @@ -397,20 +386,6 @@ static void qrtr_node_rx_work(struct work_struct *work) qrtr_port_put(ipc); } - - if (confirm) { - skb = qrtr_alloc_ctrl_packet(&pkt); - if (!skb) - break; - - pkt->cmd = cpu_to_le32(QRTR_TYPE_RESUME_TX); - pkt->client.node = cpu_to_le32(dst.sq_node); - pkt->client.port = cpu_to_le32(dst.sq_port); - - if (qrtr_node_enqueue(node, skb, QRTR_TYPE_RESUME_TX, - &dst, &src)) - break; - } } } @@ -823,6 +798,34 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) return rc; } +static int qrtr_send_resume_tx(struct qrtr_cb *cb) +{ + struct sockaddr_qrtr remote = { AF_QIPCRTR, cb->src_node, cb->src_port }; + struct sockaddr_qrtr local = { AF_QIPCRTR, cb->dst_node, cb->dst_port }; + struct qrtr_ctrl_pkt *pkt; + struct qrtr_node *node; + struct sk_buff *skb; + int ret; + + node = qrtr_node_lookup(remote.sq_node); + if (!node) + return -EINVAL; + + skb = qrtr_alloc_ctrl_packet(&pkt); + if (!skb) + return -ENOMEM; + + pkt->cmd = cpu_to_le32(QRTR_TYPE_RESUME_TX); + pkt->client.node = cpu_to_le32(cb->dst_node); + pkt->client.port = cpu_to_le32(cb->dst_port); + + ret = qrtr_node_enqueue(node, skb, QRTR_TYPE_RESUME_TX, &local, &remote); + + qrtr_node_release(node); + + return ret; +} + static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, int flags) { @@ -845,6 +848,7 @@ static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg, release_sock(sk); return rc; } + cb = (struct qrtr_cb *)skb->cb; copied = skb->len; if (copied > size) { @@ -858,7 +862,6 @@ static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg, rc = copied; if (addr) { - cb = (struct qrtr_cb *)skb->cb; addr->sq_family = AF_QIPCRTR; addr->sq_node = cb->src_node; addr->sq_port = cb->src_port; @@ -866,6 +869,9 @@ static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg, } out: + if (cb->confirm_rx) + qrtr_send_resume_tx(cb); + skb_free_datagram(sk, skb); release_sock(sk); From patchwork Fri May 31 01:17:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 165470 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp64255ili; Thu, 30 May 2019 18:18:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqy547V7DxpaiG2oxDyoazq2F09BatUQN5rmljWgDxpsdAXYK8xtsbpW9Kuy9/Ye/egcqS4o X-Received: by 2002:a65:5302:: with SMTP id m2mr6224775pgq.369.1559265486633; Thu, 30 May 2019 18:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559265486; cv=none; d=google.com; s=arc-20160816; b=pkt0IJN3bOS5CTimdauzSlbt2Lh7vGTfCsEAtuKBocPuiyCvEqFLrbdN9hFIGuoqZg 8GQwJmbnJvsiuTmL8NBpoZwvX+uYBRuFE4fCC0nlKSkmtXbjiaopj0FAlTG9h9nN8wyl kdw2SGqa2ueKYxfC7lCbKXMPcYkifFxgW3Oah9/b73zDtGRAMDxdpe/GSipxF7C0oaoD 0RqrCjPnXi6cXq4BtdNoP9ImRERd0xkTCxwt6B3luHw82HN5hz9VPLBSzSWtCEZ4a4JZ caLHFRYBYNku5yGh077N+jW/K4bknCvVtuB72My1WC/rNLEQzKDru8iT+iS6PwaWzepz L+cQ== 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=nJd7utTcuGxgb7dSskEJaX31zJV6idHmDZghQAynF00=; b=aMyra/DsK+5LavmZF8QXnyY3ha7DS5f8tnJXxuIi3Wm2xIcWrbQ2B4uOyxEc2Kr0zg hTsaZ/6PzDzEie+Irk0XOG6FLEt44lI4NWnqOTVDPfcFYMM1tCp+sslQWFGzD+sG8DGF +Sp6Wm69UX24XrxSHidm+rAetfuu6YukWiwqPiOlbqa5C0V0sa/A4B4erc0IN0SLqn6R A2jLyoSpqFG0Z7W1zD3BV+fLQEIkteW+3kNtsYFBk35edt/Hka+e5Q9GaTrHZGYJJx4r WYjqOg9Io0m3bz3RbGyb+WRDqCY0YaiKdozSPP9HeE/O+P5jMTjo2dXscHuTVF2NG4Ms wjfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rpNJZzSF; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 j14si4671548pfh.232.2019.05.30.18.18.06; Thu, 30 May 2019 18:18:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=rpNJZzSF; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1726878AbfEaBSB (ORCPT + 15 others); Thu, 30 May 2019 21:18:01 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:44057 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726876AbfEaBSB (ORCPT ); Thu, 30 May 2019 21:18:01 -0400 Received: by mail-pg1-f196.google.com with SMTP id n2so3010323pgp.11 for ; Thu, 30 May 2019 18:18:00 -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=nJd7utTcuGxgb7dSskEJaX31zJV6idHmDZghQAynF00=; b=rpNJZzSFFR4m29xwb8hL+xkPQjt4v6fVSgGkpZ9XLILWEKeq7LM2xJBRqR/eTb5NPT Of6ouPRIvtLYZ91J6JnyiusETp3+jCcH+d7LVDQimJoL1vjJbjAdpGxE6qrNK37B2993 wEPuJ+rm28+EsoVLvKnH4LIRoX3tIz2sUiZDIbyY4MJcIOBhu4RzlMxg8Duw7YLylUi8 hLT51GqFTzsrJa9Xy8TCIsIfJ5hxXn2U9DrE/Ua2PtbyY8aJ1C8FcxdTLsqcDByfbOqS G0F3luFh8bBLZAJznqO/9NhXtrLh81JxOq4Lvy6ZYSrKNyLv8dmqMZFd21qVaYSfGSfr yDDg== 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=nJd7utTcuGxgb7dSskEJaX31zJV6idHmDZghQAynF00=; b=HZjVvZrHQAGJofbz2oXKC9BFg57p0rdtfLbR+Y8Fb+Lt9QY/pxM/gdGqoPPOm1bkip gg6N02DX9dR6UZ8Y+78BTqcLajTz9iBXF8zUb5xxWkPvZbZn7LcKIhB1CT+25mrv82XY mKO/iRjwKYoOcELKzbIA2VllfKr9VMM5I2IrHycgfOHJCtXcPHSCGlYfTB6bvaV4sDhe ON9pLpdM3D5fwRxhthu8xh00vYFu6r2hiPm0lZuKtGGBsPggpkMEJevCMscPFmJ+2QKB TdiW0xXeuYo/fonEY4J2uPFrt37uXKgkCLrrjNoZRlBWMbbv19FRlcCToiLYurQt26rz DJng== X-Gm-Message-State: APjAAAV5de0VP0Do/+1Ol6HoRhrPy1vxmCxO2XX9nmL2PEXLg9Jggl+T eMDtQ8b+T8YQPEQuiTA7LVy1pjr60Bk= X-Received: by 2002:a65:4c84:: with SMTP id m4mr6405725pgt.382.1559265480353; Thu, 30 May 2019 18:18:00 -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 j20sm1819042pff.183.2019.05.30.18.17.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 18:17:59 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: Arun Kumar Neelakantam , Chris Lew , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 3/5] net: qrtr: Migrate node lookup tree to spinlock Date: Thu, 30 May 2019 18:17:51 -0700 Message-Id: <20190531011753.11840-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190531011753.11840-1-bjorn.andersson@linaro.org> References: <20190531011753.11840-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 --- Changes since v1: - None 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 38cc052b7a31..fdee32b979fe 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 */ @@ -173,10 +175,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); @@ -383,11 +388,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; } @@ -399,13 +405,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); } /** From patchwork Fri May 31 01:17:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 165472 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp64296ili; Thu, 30 May 2019 18:18:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/u/tficDK3eesZ8yU6kcpgIhKrDh24/57z3keAfUJ9QzTb3wVVGDomdI9ZrBt4JctQJhp X-Received: by 2002:a17:90a:650c:: with SMTP id i12mr6494136pjj.44.1559265488348; Thu, 30 May 2019 18:18:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559265488; cv=none; d=google.com; s=arc-20160816; b=poBWBLjRovxD24/kl1PWJRshtWgxLcdP+HIBLN9MSejB49Yj41Sw617CxccCjHfriH Dd9Cp4MK3Be++6dsphvRamf3onkgT5ntMLxdP9En5LY3TzmMp5au2ush1xhM/wZbVf05 L0yTgSnAG4bJ89YTVcOBFS7RNc6P2b5RQ6EkLK1cjFPuazceb8n0GvTSNcDy69d57Suy 3jGHPjRJLSiAIpb5aicXYJYrlEJvowgqnH9JaafPntTDuMuPoaiAKjhYY2fy3HBFR0Ju M3mq+FRARVsLMJ1QGWugC35SdNe7tlDHpDGDA+kjmKC0hZ2zMnnWL+D52SSfC33uto3g BOjg== 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=4uHEAa5GeZzr2h0opAabsUuB1kTv1SagFVuFPuo6Vy4=; b=Ls4sW4w5pWaDBGr7z6bWxxucW5OaQSW2pEsALGLJqxCMOdL3bNl/TLkM6JS/syidjD tlNjdGIcE8mHZI6iVDIls5HqyPTUmn6fOwODr8cj7IrN01QgJCYxd9t0M8gO2jhAFyFL 2qciHRp06jYk8FfzAKEuemGCH3jKDgG3EuqHxa1LMqALvqWel4X8cvMUbxhlakOa1Toj HcIRk5LmXbt7qdWynh0s9kS1l4r+GsIFzyjpbQNM6BY0a5HzSRv/m58PgCsM++jE4tIk Ft1cKxqXOhYyBHTfQvqbvNwz0PSR4e92ocR6KzkIqPBOaH9lg098cnm6xirEK8HuB4dQ Uhxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=migBA7G0; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 j14si4671548pfh.232.2019.05.30.18.18.08; Thu, 30 May 2019 18:18:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=migBA7G0; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1726935AbfEaBSD (ORCPT + 15 others); Thu, 30 May 2019 21:18:03 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36414 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726909AbfEaBSD (ORCPT ); Thu, 30 May 2019 21:18:03 -0400 Received: by mail-pf1-f195.google.com with SMTP id u22so5080816pfm.3 for ; Thu, 30 May 2019 18:18:02 -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=4uHEAa5GeZzr2h0opAabsUuB1kTv1SagFVuFPuo6Vy4=; b=migBA7G0X8TRyWt+AlogD9HOesTE9MlGY/VHdPuOv2b4R05pmowj823gTs5tiG2Pov sSM2x9XvzPtsJczvx912e+oBwNoeY01DDuG3j1RTintQIw2Z9zKUXgRya/xSQ3WAfMA/ mz9V6ymLT0qqERhwb6SQDuwBuWSZmUFu23sOd+OfIGIM2E1HKn1jxxJoUSIEytKr0Sm4 6rKrQhG8WyFbNg6SsnzSfWvGTpgn4kRZRqxjg9Cz+Si6LvJBNtliij/XI3FjAmHk9+xs q6SB7k1FJaoPMpQ7Xk71ak8xHKrI/uWpJv3i6+MtXEV5OABRTwdwkHziRE60+tfrSbzA xdOQ== 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=4uHEAa5GeZzr2h0opAabsUuB1kTv1SagFVuFPuo6Vy4=; b=na5Gv4BhXxTxz7dDG1pYV4cZqBgaRBlZobTaFAWBNu/znUQy5nVntWPwPWuiICGzdx zdUqyPUby9vwD6nasFC6Tm59/wJMfUiWPYeym48PMrgY4rKooL5B29PI6eg7nc8gEERv 8WV8yPjPFj79MYvXOWjywtTVz78FT5184dtDFmxkBtk5m9GvlST1E9erzEPBlyrHVUeu iAu1qmMsGLoG+DoD4WnYQPmfB/hIGlgqBFCldNZMymn+H91e/YK60gTv7G5wl0n5PAMM DLoi9PLHv3Mk/aGF+cZZgKZs41ESKwGhZQbODZ9a0LtjbgDIlU2uIxC4k+3vIT3yIva6 HH7Q== X-Gm-Message-State: APjAAAVL7p3F/QR25jgqjE+kbYVdb2a9JcjK78+qejo5vTzuqEE0Zqwp HH4WQk49Xr4vG0cVPCt5tWCvfw== X-Received: by 2002:a63:ea42:: with SMTP id l2mr5875093pgk.19.1559265482268; Thu, 30 May 2019 18:18:02 -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 j20sm1819042pff.183.2019.05.30.18.18.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 18:18:01 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: Arun Kumar Neelakantam , Chris Lew , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 5/5] net: qrtr: Remove receive worker Date: Thu, 30 May 2019 18:17:53 -0700 Message-Id: <20190531011753.11840-6-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190531011753.11840-1-bjorn.andersson@linaro.org> References: <20190531011753.11840-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Rather than enqueuing messages and scheduling a worker to deliver them to the individual sockets we can now, thanks to the previous work, move this directly into the endpoint callback. This saves us a context switch per incoming message and removes the possibility of an opportunistic suspend to happen between the message is coming from the endpoint until it ends up in the socket's receive buffer. Signed-off-by: Bjorn Andersson --- Changes since v1: - None net/qrtr/qrtr.c | 54 ++++++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 37 deletions(-) -- 2.18.0 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 7f048b9e02fb..782a3e8c5f93 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -165,6 +165,8 @@ static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb, static int qrtr_bcast_enqueue(struct qrtr_node *node, struct sk_buff *skb, int type, struct sockaddr_qrtr *from, struct sockaddr_qrtr *to); +static struct qrtr_sock *qrtr_port_lookup(int port); +static void qrtr_port_put(struct qrtr_sock *ipc); /* Release node resources and free the node. * @@ -429,6 +431,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) struct qrtr_node *node = ep->node; const struct qrtr_hdr_v1 *v1; const struct qrtr_hdr_v2 *v2; + struct qrtr_sock *ipc; struct sk_buff *skb; struct qrtr_cb *cb; unsigned int size; @@ -493,8 +496,20 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) skb_put_data(skb, data + hdrlen, size); - skb_queue_tail(&node->rx_queue, skb); - schedule_work(&node->work); + qrtr_node_assign(node, cb->src_node); + + if (cb->type == QRTR_TYPE_RESUME_TX) { + qrtr_tx_resume(node, skb); + } else { + ipc = qrtr_port_lookup(cb->dst_port); + if (!ipc) + goto err; + + if (sock_queue_rcv_skb(&ipc->sk, skb)) + goto err; + + qrtr_port_put(ipc); + } return 0; @@ -529,40 +544,6 @@ static struct sk_buff *qrtr_alloc_ctrl_packet(struct qrtr_ctrl_pkt **pkt) return skb; } -static struct qrtr_sock *qrtr_port_lookup(int port); -static void qrtr_port_put(struct qrtr_sock *ipc); - -/* Handle and route a received packet. - * - * This will auto-reply with resume-tx packet as necessary. - */ -static void qrtr_node_rx_work(struct work_struct *work) -{ - struct qrtr_node *node = container_of(work, struct qrtr_node, work); - struct sk_buff *skb; - - while ((skb = skb_dequeue(&node->rx_queue)) != NULL) { - struct qrtr_sock *ipc; - struct qrtr_cb *cb = (struct qrtr_cb *)skb->cb; - - qrtr_node_assign(node, cb->src_node); - - if (cb->type == QRTR_TYPE_RESUME_TX) { - qrtr_tx_resume(node, skb); - } else { - ipc = qrtr_port_lookup(cb->dst_port); - if (!ipc) { - kfree_skb(skb); - } else { - if (sock_queue_rcv_skb(&ipc->sk, skb)) - kfree_skb(skb); - - qrtr_port_put(ipc); - } - } - } -} - /** * qrtr_endpoint_register() - register a new endpoint * @ep: endpoint to register @@ -582,7 +563,6 @@ int qrtr_endpoint_register(struct qrtr_endpoint *ep, unsigned int nid) if (!node) return -ENOMEM; - INIT_WORK(&node->work, qrtr_node_rx_work); kref_init(&node->ref); mutex_init(&node->ep_lock); skb_queue_head_init(&node->rx_queue);