From patchwork Mon Nov 12 14:00:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 150835 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3174443ljp; Mon, 12 Nov 2018 06:00:39 -0800 (PST) X-Google-Smtp-Source: AJdET5e9vVQ9qplS671VQt3gUotODymqdZWpS4OUNLDj2feMrQq9Fh1yFmJ2sUL5jn/rzu+N1/KB X-Received: by 2002:a17:902:b03:: with SMTP id 3-v6mr1065193plq.233.1542031238941; Mon, 12 Nov 2018 06:00:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031238; cv=none; d=google.com; s=arc-20160816; b=FcpKD4sCxlUEi0ulpL5+d6xZd0wsFF4S9f4BqXUPIhke18jjrzfH47Sif+IGvuLv7M RIMF/5Co/XazD1DHXYe+yj2PtLNH7qYkmxVtkOIxCBCDNNNaA769Pkf/zM1o3Kk8LeKl WF2C4j0Eyt/qW1gYzwTS/XGT5qvwXrIW280miXwcyZMJNhmRH+MoaUDY2YVF80+p3zr0 fl/PXQ8tg2A/16Y2zyfFhTXuBvpRHNBXin+xhhjBEnONuEdlytKPkShGKTPXCYKEUdET Ykn26LyBjCIPzMUYQ2TpBHRwHWMhRU1wt7vin/4YuKYNSN1rYmgUHK1m4Dc7gmtppsy0 +CwQ== 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=ptTfOSQyCB/JKI5iUqiF7XIw7qg/C6KDpM/4pJWB2AA=; b=CBPbb6q0+PAwCV/6K8nQzWaT2QZVWmbDEnsZCrq3uuCBjo4gKxNjFck+mZxtz+k4de 7KkPZAf0ESyeu52+RSxBr9DekZAKTx0aelQyorLHw0vUxCWslaftYy/tH1vT2VL7ZzzJ uK8NrGkiiT59BiRLuOqAL1T5Nl1b9kdGNKVM55PreVpfQizj0lgEFAbu6211EglszbRY 9UJfHdcBum14S2UDjncR4liqAMgDZ1/dWh6l9Uif433U41spU+q0qsEa3YTx3G4vsv/u VyH8FOVggD9J1yNGOjD//sYvuY8PenfVQLayNmaoZQ+kQxeZcBvEoSxVV7HVf3ppn8Fp 5YhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=clmez9xx; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-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 p19si4869690pgj.375.2018.11.12.06.00.38; Mon, 12 Nov 2018 06:00:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-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=clmez9xx; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-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 S1729800AbeKLXx7 (ORCPT + 5 others); Mon, 12 Nov 2018 18:53:59 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:43566 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729797AbeKLXx6 (ORCPT ); Mon, 12 Nov 2018 18:53:58 -0500 Received: by mail-lj1-f194.google.com with SMTP id g26-v6so7678634lja.10 for ; Mon, 12 Nov 2018 06:00:34 -0800 (PST) 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=ptTfOSQyCB/JKI5iUqiF7XIw7qg/C6KDpM/4pJWB2AA=; b=clmez9xx5QWXWPD0lxnzvDNp2V1csaKIT3JNcZxCbncE2f2WaTt7yWQNdyP9DNN6ma tYo7kN/r+ngkY2f1WVvP9p1tgd/5pkA/xO3Fv4F7FhW86F4K7oau3Bzfooo0qmfqtDBr dPmk2aA6eS23KzkbXkZhTS2Kl3TBpMRhoWT8A= 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=ptTfOSQyCB/JKI5iUqiF7XIw7qg/C6KDpM/4pJWB2AA=; b=Jw81+4pnGsxQRpFNxJxmKNsPwkzj+ihsqtUAflLb1ql+O7rn6J4LSPAJhA+9uDhT24 +8Mibpxqpmq1Y2OCxXO2HdY69jChIAAvmytdAKvEoDlsU9gXGf67ewo+MB9OaidxMSRp IymwCax+9yB5/maDBSgxydYKLmgXbSp0Vjs7bRkQCM/VnTlbCRGnDBPwTIYVBL9j89D/ jaeAqT+tEORocJZ/RmENDGhau1jLMRdad4kYic+yi6Pt0xzPvYVXckE2fxM8chifwKzK BmcmsfIGajmKFxWh6olI/wAVENrkR2EzdUZGqoyJJN6OgG/oOzcqgUN2TExWRJhD2g4G 8XLA== X-Gm-Message-State: AGRZ1gJvNjHbwgiCnCpoG3ck9ngpJNtKraV7lcWWXD8ferLXXF+sssdO vrrS2zpSkGnRoHLuec3RlP7rGg== X-Received: by 2002:a2e:92:: with SMTP id e18-v6mr830728lji.130.1542031233740; Mon, 12 Nov 2018 06:00:33 -0800 (PST) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id 26-v6sm3546387lje.18.2018.11.12.06.00.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 06:00:32 -0800 (PST) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, davem@davemloft.net Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Ivan Khoronzhuk Subject: [PATCH net-next 2/4] net: ethernet: ti: cpts: purge staled skbs from txq Date: Mon, 12 Nov 2018 16:00:21 +0200 Message-Id: <20181112140023.12407-3-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181112140023.12407-1-ivan.khoronzhuk@linaro.org> References: <20181112140023.12407-1-ivan.khoronzhuk@linaro.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The overflow event is running with 1 jiffy in case if txq is not empty, but it can be emptied completely only if next tx event consumes skb or deletes staled skb from the txq. In case of staled skb, that can happen for some unpredictable reason (the ts event was lost or timed out), the overflow event can be generated quite long time consuming CPU w/o reason before next tx event happens. To avoid it, purge txq before increasing overflow event rate. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpts.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c index dac4c528a1ff..63232b35024e 100644 --- a/drivers/net/ethernet/ti/cpts.c +++ b/drivers/net/ethernet/ti/cpts.c @@ -86,6 +86,25 @@ static int cpts_purge_events(struct cpts *cpts) return removed ? 0 : -1; } +static void cpts_purge_txq(struct cpts *cpts) +{ + struct cpts_skb_cb_data *skb_cb; + struct sk_buff *skb, *tmp; + int removed = 0; + + skb_queue_walk_safe(&cpts->txq, skb, tmp) { + skb_cb = (struct cpts_skb_cb_data *)skb->cb; + if (time_after(jiffies, skb_cb->tmo)) { + __skb_unlink(skb, &cpts->txq); + dev_consume_skb_any(skb); + ++removed; + } + } + + if (removed) + dev_dbg(cpts->dev, "txq cleaned up %d\n", removed); +} + static bool cpts_match_tx_ts(struct cpts *cpts, struct cpts_event *event) { struct sk_buff *skb, *tmp; @@ -292,8 +311,11 @@ static long cpts_overflow_check(struct ptp_clock_info *ptp) spin_lock_irqsave(&cpts->lock, flags); ts = ns_to_timespec64(timecounter_read(&cpts->tc)); - if (!skb_queue_empty(&cpts->txq)) - delay = CPTS_SKB_TX_WORK_TIMEOUT; + if (!skb_queue_empty(&cpts->txq)) { + cpts_purge_txq(cpts); + if (!skb_queue_empty(&cpts->txq)) + delay = CPTS_SKB_TX_WORK_TIMEOUT; + } spin_unlock_irqrestore(&cpts->lock, flags); pr_debug("cpts overflow check at %lld.%09ld\n",