Message ID | 20231018123550.27110-3-ansuelsmth@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4756992vqb; Wed, 18 Oct 2023 05:36:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6CqvzOKV9oV1sRq6h48TEG3QxuBYlPws158iHfsfLkfuzTTSJCLyJVekKXXAi021k5XnU X-Received: by 2002:a17:903:30c4:b0:1c3:a4f2:7c99 with SMTP id s4-20020a17090330c400b001c3a4f27c99mr4932377plc.4.1697632590682; Wed, 18 Oct 2023 05:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697632590; cv=none; d=google.com; s=arc-20160816; b=xv/V9lPIVP3EE6t53nj67wkKL8NAmXdsp00AKmKrRL82fQnxQOHyByZgdqewuOeuje NDhIPor/JDj77dsv6N0V5Ykgs1yKjtbb1zKSbg8HorWsBbtyM34cMy59egxX+nczrGLv wg1sAf7KMFRZe4+5/WWfWi6EGDhkwuPbIVfUr0eJbRx3M44VuxJHTEj0MOUUuZ+hQsyB OU0XV3e2616on/xL1+9XvHmVKYPXtq1RX7aWmnICENduzQHwjjPFBDl9hgBJmk81WcI3 JwyMsXX+G3/xC3mVbVLC0ptax6LLQTY1ydA8NoE6/ZsDBpPCKnSySmQlGxHjWuZRhKEg RS0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zIsjeim7XUbQUze6bD56uxG9gvOx0giE5m3S+sNf+CI=; fh=jvZ7yAidasmFREPdFLzcn6X72yjJtrVlKHskOtM6Gso=; b=cdz2+00rI/C/DAOxgSoTZNhpfB4Pe1DP0ZFwMqcyi+inI/FJxogm6o1XUAfFVYmreM RCV5ZAkAftvXLsCEO9dUY86E00m9Fb3IbooTtr/z9wV/9zPLsZ3CqMy2AsycMwWpkK0R MHwo03J35eJA4DbYN4FKTK9sDgfjE7cwzpwb5/E6Cy0BdXGlETYkU4180IHuazu2iTBh E3H85VfpAe0dxwjfYA0PGtb5ApVKEsd1kZooSohR7tSkzyH+G5249FFDXSVL4gikvIfs /rOzYUbnxCsNP/95wgLbhflvvd27U6+sKozwBtP7JHeXgJJo5QxiPjMvRcXkBah5O/79 cgRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NZQ1dopM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l9-20020a170902d34900b001c8920e3021si3899374plk.539.2023.10.18.05.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 05:36:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NZQ1dopM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E07C8802F31B; Wed, 18 Oct 2023 05:36:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344679AbjJRMgL (ORCPT <rfc822;zwp10758@gmail.com> + 23 others); Wed, 18 Oct 2023 08:36:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344655AbjJRMgE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 18 Oct 2023 08:36:04 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E71A113; Wed, 18 Oct 2023 05:36:01 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-32daeed7771so2965132f8f.3; Wed, 18 Oct 2023 05:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697632560; x=1698237360; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zIsjeim7XUbQUze6bD56uxG9gvOx0giE5m3S+sNf+CI=; b=NZQ1dopMzs9JBX0+XB3sQ6lqbTyB33OMzYXljCwQ0mYNN9X/zEDi4R3pKmC1ir4L7o 94xs61bTzdulUcu8Gh34TeN2qs9OOikpBvEDeLGVjFK+BoYvPaG0ui1cqKpV0BgB/FuT QPG0AZM3zRKWnRqE7S+v4wIGXzyLiKHyoEisoSIdxOfPz/JuOktzsylDFdUU2fojQ2Qw GCjcbyDNEhG2h36VHbyXSp4/tSVOq30AqHRZzzfRknrjf6jAuNa2HhEeBlteF17g5mR3 F/GFodtliymRE2yN85Rir5yZo0LUU0KBSLTlRis0GS9mDsbg/1w0BjdFZkeXA9v+G2s0 sAiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697632560; x=1698237360; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zIsjeim7XUbQUze6bD56uxG9gvOx0giE5m3S+sNf+CI=; b=lgeabj2bfYukeWNDzVtBTvlqjCY2C3dxdsdxBYotG9yoALmsvBq/naMgQ13pDoHJHs Sw0tqoFYjLEizDof5qc2HAB/U7PyzvjDy06/c1qgVC0QIM644WQske56ac3oQNNNjMm0 tgpUTRDegspBmH7HI/ISicfpOcD022RsgYEZcJhdxbbv3+HG/zlRwSgzQlEeYAcQyvl7 WZLBWJuGz+WwAD+Oh/8TN89Y5LsmjfrKFhFO2bjhFwmECm4AzOuvDYTl0fEm8L30laXz Z5BbG1/fNT6QZAkZDfvxN2T+FFlbrvrRl+62Kiw18tAV1hl0ljNdVeEp9cMX67YzSTJE StZA== X-Gm-Message-State: AOJu0Yxl89f7Eyf9Srpfar38RlABJvD0e1bkbuJS9LjLWBV+z3xrrH3M QhHUmBHpenhbYg6wOqN51D+SPJnLNhQ= X-Received: by 2002:adf:e8c6:0:b0:32d:9d6b:ac99 with SMTP id k6-20020adfe8c6000000b0032d9d6bac99mr4372102wrn.31.1697632559722; Wed, 18 Oct 2023 05:35:59 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id q28-20020adfab1c000000b003248a490e3asm2048211wrc.39.2023.10.18.05.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 05:35:59 -0700 (PDT) From: Christian Marangi <ansuelsmth@gmail.com> To: Raju Rangoju <rajur@chelsio.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Alexandre Torgue <alexandre.torgue@foss.st.com>, Jose Abreu <joabreu@synopsys.com>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Ping-Ke Shih <pkshih@realtek.com>, Kalle Valo <kvalo@kernel.org>, Simon Horman <horms@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Jiri Pirko <jiri@resnulli.us>, Hangbin Liu <liuhangbin@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org Cc: Christian Marangi <ansuelsmth@gmail.com> Subject: [net-next PATCH v4 2/4] net: stmmac: improve TX timer arm logic Date: Wed, 18 Oct 2023 14:35:48 +0200 Message-Id: <20231018123550.27110-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018123550.27110-1-ansuelsmth@gmail.com> References: <20231018123550.27110-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 18 Oct 2023 05:36:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780096791495174148 X-GMAIL-MSGID: 1780096791495174148 |
Series |
net: stmmac: improve tx timer logic
|
|
Commit Message
Christian Marangi
Oct. 18, 2023, 12:35 p.m. UTC
There is currently a problem with the TX timer getting armed multiple
unnecessary times causing big performance regression on some device that
suffer from heavy handling of hrtimer rearm.
The use of the TX timer is an old implementation that predates the napi
implementation and the interrupt enable/disable handling.
Due to stmmac being a very old code, the TX timer was never evaluated
again with this new implementation and was kept there causing
performance regression. The performance regression started to appear
with kernel version 4.19 with 8fce33317023 ("net: stmmac: Rework coalesce
timer and fix multi-queue races") where the timer was reduced to 1ms
causing it to be armed 40 times more than before.
Decreasing the timer made the problem more present and caused the
regression in the other of 600-700mbps on some device (regression where
this was notice is ipq806x).
The problem is in the fact that handling the hrtimer on some target is
expensive and recent kernel made the timer armed much more times.
A solution that was proposed was reverting the hrtimer change and use
mod_timer but such solution would still hide the real problem in the
current implementation.
To fix the regression, apply some additional logic and skip arming the
timer when not needed.
Arm the timer ONLY if a napi is not already scheduled. Running the timer
is redundant since the same function (stmmac_tx_clean) will run in the
napi TX poll. Also try to cancel any timer if a napi is scheduled to
prevent redundant run of TX call.
With the following new logic the original performance are restored while
keeping using the hrtimer.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index bb1dbf4c9f6c..5124ee87286c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2996,13 +2996,25 @@ static void stmmac_tx_timer_arm(struct stmmac_priv *priv, u32 queue) { struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue]; u32 tx_coal_timer = priv->tx_coal_timer[queue]; + struct stmmac_channel *ch; + struct napi_struct *napi; if (!tx_coal_timer) return; - hrtimer_start(&tx_q->txtimer, - STMMAC_COAL_TIMER(tx_coal_timer), - HRTIMER_MODE_REL); + ch = &priv->channel[tx_q->queue_index]; + napi = tx_q->xsk_pool ? &ch->rxtx_napi : &ch->tx_napi; + + /* Arm timer only if napi is not already scheduled. + * Try to cancel any timer if napi is scheduled, timer will be armed + * again in the next scheduled napi. + */ + if (unlikely(!napi_is_scheduled(napi))) + hrtimer_start(&tx_q->txtimer, + STMMAC_COAL_TIMER(tx_coal_timer), + HRTIMER_MODE_REL); + else + hrtimer_try_to_cancel(&tx_q->txtimer); } /**