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);