Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1853001pxb; Thu, 16 Sep 2021 17:59:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2OtaVF3OCcZMn4ZzSfcO79Sa7gTpfoEsOKHRUlqT2K8s8lpkLb57MZIsPWQaHHgYmRg/t X-Received: by 2002:a92:3012:: with SMTP id x18mr5918401ile.249.1631840340762; Thu, 16 Sep 2021 17:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631840340; cv=none; d=google.com; s=arc-20160816; b=Bmz3rlbNlV9r8a7dZuAlR8NlDRWd2ijcsWP5fj6JknENi5yy51gsnRG9HpplWxSODA TTkogHuHDqlySJ0lY9FO2AdAEN2PXt1dRlTT8tcF+24rIpBC85/oPX91J29j2/RMlix3 xxrmVepDhUqFdBDNyLvTjNF/iTJMQP3Gom620PSSTBYpPlmCZggYMaMias4q25L+iYxn ssg1M1CuJzvzUfJi38oQ6+CGws/c4vdkCAXE1T1zO7sdekN29kvT/X/vHM08j0n+jEsA jQ7tlreqRfKmT3fsNSnXvn295aPEwHhZslEyWFiMRswBV2slyLl8MWXC58qsM4Ii76x/ 8gCQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DqSaXcCJHD3uosMxqfab2rele2A4Q1zNqSkwBbni14k=; b=LsiPBr9mSgsvtb3gQhp6T03+/HUyuBFgZ5Ueh6oh+hYH6YZ8DRJBUnHbfI/LSWXmJX i8BFe+xYLIxUA5+NhazRPEnk7BS3GfMJmLRN/HFgUqv56E0y9ZBdb/Q0mfHMNrDC9OL2 VCONL4bfueTz92es0En4O6YMc6V8n5217n3pkPiBnEoGFO/naWJL5GQckkyGgxUE5luR +4hYnziGNxjKaibzvC62yHzujdkIZuE2CqHkwysX5mvyUNVYsqCO5nf088QXwnVXOl9+ yoZDqwQg2B9YezMz4ygNrP/pPk9kZJkPl1tYzOwM5Zovki87onEZGGGhjx/BrKuPcjJu xZ3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LAss+mCR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v8si73028ilj.145.2021.09.16.17.58.49; Thu, 16 Sep 2021 17:59:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LAss+mCR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349625AbhIPRGc (ORCPT + 99 others); Thu, 16 Sep 2021 13:06:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:34012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348385AbhIPRCo (ORCPT ); Thu, 16 Sep 2021 13:02:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4F95D61AFE; Thu, 16 Sep 2021 16:33:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810014; bh=oFoImvO9b21cT3FaDk9/kBnRacy5Lv/626L1KiGlNNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LAss+mCR7evSbiKdyW0RR/Um27uUYG5khNj6msg3tJfyyValH0t+4j11JCyFXYkQg RaR8WMaUYMCX+OWYSBctO2PWomDsz9EZZABzfY8NqtBIN8hTJk80jHpOdgIkO65Qco UTdajTYmpWpWoJgrCjr2Z1D5hT7IwgWVocTbMT1E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ong Boon Leong , Song Yoong Siang , "David S. Miller" Subject: [PATCH 5.13 367/380] net: stmmac: Fix overall budget calculation for rxtx_napi Date: Thu, 16 Sep 2021 18:02:04 +0200 Message-Id: <20210916155816.532440089@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Song Yoong Siang commit 81d0885d68ec427e62044cf46a400c9958ea0092 upstream. tx_done is not used for napi_complete_done(). Thus, NAPI busy polling mechanism by gro_flush_timeout and napi_defer_hard_irqs will not able be triggered after a packet is transmitted when there is no receive packet. Fix this by taking the maximum value between tx_done and rx_done as overall budget completed by the rxtx NAPI poll to ensure XDP Tx ZC operation is continuously polling for next Tx frame. This gives benefit of lower packet submission processing latency and jitter under XDP Tx ZC mode. Performance of tx-only using xdp-sock on Intel ADL-S platform is the same with and without this patch. root@intel-corei7-64:~# ./xdpsock -i enp0s30f4 -t -z -q 1 -n 10 sock0@enp0s30f4:1 txonly xdp-drv pps pkts 10.00 rx 0 0 tx 511630 8659520 sock0@enp0s30f4:1 txonly xdp-drv pps pkts 10.00 rx 0 0 tx 511625 13775808 sock0@enp0s30f4:1 txonly xdp-drv pps pkts 10.00 rx 0 0 tx 511619 18892032 Fixes: 132c32ee5bc0 ("net: stmmac: Add TX via XDP zero-copy socket") Cc: # 5.13.x Co-developed-by: Ong Boon Leong Signed-off-by: Ong Boon Leong Signed-off-by: Song Yoong Siang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5358,7 +5358,7 @@ static int stmmac_napi_poll_rxtx(struct struct stmmac_channel *ch = container_of(napi, struct stmmac_channel, rxtx_napi); struct stmmac_priv *priv = ch->priv_data; - int rx_done, tx_done; + int rx_done, tx_done, rxtx_done; u32 chan = ch->index; priv->xstats.napi_poll++; @@ -5368,14 +5368,16 @@ static int stmmac_napi_poll_rxtx(struct rx_done = stmmac_rx_zc(priv, budget, chan); + rxtx_done = max(tx_done, rx_done); + /* If either TX or RX work is not complete, return budget * and keep pooling */ - if (tx_done >= budget || rx_done >= budget) + if (rxtx_done >= budget) return budget; /* all work done, exit the polling mode */ - if (napi_complete_done(napi, rx_done)) { + if (napi_complete_done(napi, rxtx_done)) { unsigned long flags; spin_lock_irqsave(&ch->lock, flags); @@ -5386,7 +5388,7 @@ static int stmmac_napi_poll_rxtx(struct spin_unlock_irqrestore(&ch->lock, flags); } - return min(rx_done, budget - 1); + return min(rxtx_done, budget - 1); } /**