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: 10678671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7187A14BA for ; Mon, 12 Nov 2018 14:00:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60EB329C28 for ; Mon, 12 Nov 2018 14:00:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54E3129C47; Mon, 12 Nov 2018 14:00:39 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 BAB1429C28 for ; Mon, 12 Nov 2018 14:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729800AbeKLXx7 (ORCPT ); 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-Google-Smtp-Source: AJdET5cCAroILxLwDYlKvmkbiy5AgZtBV+shM1SBHykC5htNWgAef8Jg81ApNboM0+832JWVcc6nUQ== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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",