Message ID | 20231116114150.48639-1-huangjie.albert@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp3149181vqg; Thu, 16 Nov 2023 03:42:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGw0XLpg0w2lISNM3ZYs8HdllpoXu/eG2cqboOKIp8KoCTl7y0p7KDcKTfmscTMPE4SLjX X-Received: by 2002:a05:6a20:a10b:b0:187:7ca4:c71f with SMTP id q11-20020a056a20a10b00b001877ca4c71fmr1510356pzk.28.1700134946336; Thu, 16 Nov 2023 03:42:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700134946; cv=none; d=google.com; s=arc-20160816; b=vuGq2yrlD7pRwyoMWsokeVK4hIeC0QQfVMyVaMLEVEnZBfn/69sezGgOf4csoZNMPC IWN7LpErn69a2qXeuMt6xsMYBDz/4URFEw0Eq/v4yPJXNhj9Kk3Zxwd4Q8TjGNPhHr9F QPhT4c1P8FuBvHy5/CcBUg/4wqVvIVUr+wUwOtXy5FBDuMKnw11sQmPMbL59lcPC8z9K qFXTvLxAnh5VJyejvAJzdGPn0yG/oB7ih8UPJJRzPMPfUnKrGDBNi2AxG/tTU5aBnME5 8OyNkvg4BWLyrsH9xwAqC7Z/72IApVm4SY43GRYz64SnXKzfF4dGdPs8J7E7D/y2xbdt I3dA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=6Y3a3I6T3ynb1aD8/N7le6GGs5vGQafrGkelqcFRqTs=; fh=Bwt4kv6BJ9u2fPkpQxP7os129mCe642PthAGePgwUsY=; b=Zs9tP1rxyCAE16EGyKgIKAzjOtZyPYKCMk6u4k345ssa/681VEQ6phnjSRnPksoW9K B04vV4jbB5eXuO1Z5/m1NZeKZoj8utp5MqfY7DCMjm3FatkZtR5DraAKDuZeChK0N11I 8c8MoxLws/YWN9J/wCvNuQhhhnYN8OpCQIkcW9vF5vGeS3yWvzaLIXvWi7OWuH6HeKry zMBYDieLmqvONh/BWGxNT85TdznBZimWdEa5Jp7l8u2tadWc5c8kTPg4BKC3P2sFRDOL WZZtNiLgLOHG5EdtLmMtmJ9KD3mFlNdKYM+lLmeIhG/qLA1At8mOCZe3yVhMO1+G5PH+ Iffw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Ca+HDLgo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id z22-20020a63c056000000b005b881b4ea84si12176405pgi.428.2023.11.16.03.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 03:42:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Ca+HDLgo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3473F8183EC8; Thu, 16 Nov 2023 03:42:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230414AbjKPLmI (ORCPT <rfc822;jaysivo@gmail.com> + 29 others); Thu, 16 Nov 2023 06:42:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbjKPLmI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 16 Nov 2023 06:42:08 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0CE7181 for <linux-kernel@vger.kernel.org>; Thu, 16 Nov 2023 03:42:04 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6bd73395bceso543183b3a.0 for <linux-kernel@vger.kernel.org>; Thu, 16 Nov 2023 03:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700134924; x=1700739724; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6Y3a3I6T3ynb1aD8/N7le6GGs5vGQafrGkelqcFRqTs=; b=Ca+HDLgo+cQwnOIdBisEWKsCjU41bJd9t9FseQmE5DCKHyFgClUT8PfQ6w2aM7bXNq MGUGKZDes8uS1XWZhvjWbVSeOnQAaWeXsgwvJyLYhXg49NOVuDTRMEE8ghXn0h7j9fUJ cIqNQO+9mIweWgiB2VmdFf7UUHhB/JdwFgd5Cm0N6126+UQdp10iXXDUJsxQwu+xrZb/ LTLWEHL2ON6SRyn4fNC8lNjUMC69xV070ZzjkeM3g5R2MVyk23n+gbSU9cbzoevxsjJG XDbEqSMs42LI10oOiofHW+VhwTXYTYsco5R43bMrBZW23/cfPWIrfbydQUxzhkxil3yp yNzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700134924; x=1700739724; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6Y3a3I6T3ynb1aD8/N7le6GGs5vGQafrGkelqcFRqTs=; b=dAKrRsm36QGNKmkXNryIVY8P3Bkbmd6o9LbwfgPIPR5sjJZiICAqQ8g5La5j0TT5O0 LhQRJ6A5FUvXIdASOOHGk1XV9sR4sgwGxFlY1BL3EVgR3IdP9nmP5k8RP1tuQ8t44K3i t+BqWybWDgoiId8H2JFXrAiJvMUeUPUGIZtiTptFmGuOag9HMJg6PikeyIo8MlBc9j9T ZGjPWFvECIj4cbKqqMCKCLuHrtGSsc0Bpe/1vJOeYs+Vif47ARmd2sj1Dc8ecTBHuKiO A++5WWT0KUC3lIH7I9ecNQoAw0UXvmoTCkd6MAwDf2EvHa7B9fuwlOZTHJBLs4InJZhg xpJA== X-Gm-Message-State: AOJu0Yxg2UXE4UYjA3JRE4wehYc99rMRsRa8eqblhWhuybs+HbsXiymp +8m68Edn2j2HK6TZibKZVbMIQiF7Pohq4wNqJFo= X-Received: by 2002:a05:6a00:1304:b0:6c3:415a:5c05 with SMTP id j4-20020a056a00130400b006c3415a5c05mr2353312pfu.14.1700134924154; Thu, 16 Nov 2023 03:42:04 -0800 (PST) Received: from C02FG34NMD6R.bytedance.net ([2001:c10:ff04:0:1000:0:1:7]) by smtp.gmail.com with ESMTPSA id e3-20020aa78c43000000b006c4d4d5a197sm4440457pfd.171.2023.11.16.03.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 03:42:03 -0800 (PST) From: Albert Huang <huangjie.albert@bytedance.com> To: Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: Albert Huang <huangjie.albert@bytedance.com>, "David S. Miller" <davem@davemloft.net>, Toshiaki Makita <toshiaki.makita1@gmail.com>, Lorenzo Bianconi <lorenzo@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net] veth: fix ethtool statistical errors Date: Thu, 16 Nov 2023 19:41:50 +0800 Message-Id: <20231116114150.48639-1-huangjie.albert@bytedance.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Thu, 16 Nov 2023 03:42:24 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782720701589246990 X-GMAIL-MSGID: 1782720701589246990 |
Series |
[net] veth: fix ethtool statistical errors
|
|
Commit Message
黄杰
Nov. 16, 2023, 11:41 a.m. UTC
if peer->real_num_rx_queues > 1, the ethtool -s command for
veth network device will display some error statistical values.
The value of tx_idx is reset with each iteration, so even if
peer->real_num_rx_queues is greater than 1, the value of tx_idx
will remain constant. This results in incorrect statistical values.
To fix this issue, assign the value of pp_idx to tx_idx.
Fixes: 5fe6e56776ba ("veth: rely on peer veth_rq for ndo_xdp_xmit accounting")
Signed-off-by: Albert Huang <huangjie.albert@bytedance.com>
---
drivers/net/veth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
> if peer->real_num_rx_queues > 1, the ethtool -s command for > veth network device will display some error statistical values. > The value of tx_idx is reset with each iteration, so even if > peer->real_num_rx_queues is greater than 1, the value of tx_idx > will remain constant. This results in incorrect statistical values. > To fix this issue, assign the value of pp_idx to tx_idx. > > Fixes: 5fe6e56776ba ("veth: rely on peer veth_rq for ndo_xdp_xmit accounting") > Signed-off-by: Albert Huang <huangjie.albert@bytedance.com> > --- > drivers/net/veth.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > index 0deefd1573cf..3a8e3fc5eeb5 100644 > --- a/drivers/net/veth.c > +++ b/drivers/net/veth.c > @@ -225,7 +225,7 @@ static void veth_get_ethtool_stats(struct net_device *dev, > for (i = 0; i < peer->real_num_rx_queues; i++) { > const struct veth_rq_stats *rq_stats = &rcv_priv->rq[i].stats; > const void *base = (void *)&rq_stats->vs; > - unsigned int start, tx_idx = idx; > + unsigned int start, tx_idx = pp_idx; > size_t offset; > > tx_idx += (i % dev->real_num_tx_queues) * VETH_TQ_STATS_LEN; > -- > 2.20.1 > Hi Albert, Can you please provide more details about the issue you are facing? In particular, what is the number of configured tx and rx queues for both peers? tx_idx is the index of the current (local) tx queue and it must restart from idx in each iteration otherwise we will have an issue when peer->real_num_rx_queues is greater than dev->real_num_tx_queues. Regards, Lorenzo
Lorenzo Bianconi <lorenzo@kernel.org> 于2023年11月17日周五 17:26写道: > > > if peer->real_num_rx_queues > 1, the ethtool -s command for > > veth network device will display some error statistical values. > > The value of tx_idx is reset with each iteration, so even if > > peer->real_num_rx_queues is greater than 1, the value of tx_idx > > will remain constant. This results in incorrect statistical values. > > To fix this issue, assign the value of pp_idx to tx_idx. > > > > Fixes: 5fe6e56776ba ("veth: rely on peer veth_rq for ndo_xdp_xmit accounting") > > Signed-off-by: Albert Huang <huangjie.albert@bytedance.com> > > --- > > drivers/net/veth.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > > index 0deefd1573cf..3a8e3fc5eeb5 100644 > > --- a/drivers/net/veth.c > > +++ b/drivers/net/veth.c > > @@ -225,7 +225,7 @@ static void veth_get_ethtool_stats(struct net_device *dev, > > for (i = 0; i < peer->real_num_rx_queues; i++) { > > const struct veth_rq_stats *rq_stats = &rcv_priv->rq[i].stats; > > const void *base = (void *)&rq_stats->vs; > > - unsigned int start, tx_idx = idx; > > + unsigned int start, tx_idx = pp_idx; > > size_t offset; > > > > tx_idx += (i % dev->real_num_tx_queues) * VETH_TQ_STATS_LEN; > > -- > > 2.20.1 > > > > Hi Albert, > > Can you please provide more details about the issue you are facing? > In particular, what is the number of configured tx and rx queues for both > peers? Hi, Lorenzo I found this because I wanted to add more echo information in ethttool(for veth, but I found that the information was incorrect. That's why I paid attention here. > tx_idx is the index of the current (local) tx queue and it must restart from > idx in each iteration otherwise we will have an issue when > peer->real_num_rx_queues is greater than dev->real_num_tx_queues. > OK. I don't know if this is a known issue. BR Albert > Regards, > Lorenzo
> Lorenzo Bianconi <lorenzo@kernel.org> 于2023年11月17日周五 17:26写道: > > > > > if peer->real_num_rx_queues > 1, the ethtool -s command for > > > veth network device will display some error statistical values. > > > The value of tx_idx is reset with each iteration, so even if > > > peer->real_num_rx_queues is greater than 1, the value of tx_idx > > > will remain constant. This results in incorrect statistical values. > > > To fix this issue, assign the value of pp_idx to tx_idx. > > > > > > Fixes: 5fe6e56776ba ("veth: rely on peer veth_rq for ndo_xdp_xmit accounting") > > > Signed-off-by: Albert Huang <huangjie.albert@bytedance.com> > > > --- > > > drivers/net/veth.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > > > index 0deefd1573cf..3a8e3fc5eeb5 100644 > > > --- a/drivers/net/veth.c > > > +++ b/drivers/net/veth.c > > > @@ -225,7 +225,7 @@ static void veth_get_ethtool_stats(struct net_device *dev, > > > for (i = 0; i < peer->real_num_rx_queues; i++) { > > > const struct veth_rq_stats *rq_stats = &rcv_priv->rq[i].stats; > > > const void *base = (void *)&rq_stats->vs; > > > - unsigned int start, tx_idx = idx; > > > + unsigned int start, tx_idx = pp_idx; > > > size_t offset; > > > > > > tx_idx += (i % dev->real_num_tx_queues) * VETH_TQ_STATS_LEN; > > > -- > > > 2.20.1 > > > > > > > Hi Albert, > > > > Can you please provide more details about the issue you are facing? > > In particular, what is the number of configured tx and rx queues for both > > peers? > > Hi, Lorenzo > I found this because I wanted to add more echo information in ethttool(for veth, > but I found that the information was incorrect. That's why I paid > attention here. ack. Could you please share the veth pair tx/rx queue configuration? Rergards, Lorenzo > > > tx_idx is the index of the current (local) tx queue and it must restart from > > idx in each iteration otherwise we will have an issue when > > peer->real_num_rx_queues is greater than dev->real_num_tx_queues. > > > OK. I don't know if this is a known issue. > > BR > Albert > > > > Regards, > > Lorenzo
Lorenzo Bianconi <lorenzo@kernel.org> 于2023年11月20日周一 17:52写道: > > > Lorenzo Bianconi <lorenzo@kernel.org> 于2023年11月17日周五 17:26写道: > > > > > > > if peer->real_num_rx_queues > 1, the ethtool -s command for > > > > veth network device will display some error statistical values. > > > > The value of tx_idx is reset with each iteration, so even if > > > > peer->real_num_rx_queues is greater than 1, the value of tx_idx > > > > will remain constant. This results in incorrect statistical values. > > > > To fix this issue, assign the value of pp_idx to tx_idx. > > > > > > > > Fixes: 5fe6e56776ba ("veth: rely on peer veth_rq for ndo_xdp_xmit accounting") > > > > Signed-off-by: Albert Huang <huangjie.albert@bytedance.com> > > > > --- > > > > drivers/net/veth.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > > > > index 0deefd1573cf..3a8e3fc5eeb5 100644 > > > > --- a/drivers/net/veth.c > > > > +++ b/drivers/net/veth.c > > > > @@ -225,7 +225,7 @@ static void veth_get_ethtool_stats(struct net_device *dev, > > > > for (i = 0; i < peer->real_num_rx_queues; i++) { > > > > const struct veth_rq_stats *rq_stats = &rcv_priv->rq[i].stats; > > > > const void *base = (void *)&rq_stats->vs; > > > > - unsigned int start, tx_idx = idx; > > > > + unsigned int start, tx_idx = pp_idx; > > > > size_t offset; > > > > > > > > tx_idx += (i % dev->real_num_tx_queues) * VETH_TQ_STATS_LEN; > > > > -- > > > > 2.20.1 > > > > > > > > > > Hi Albert, > > > > > > Can you please provide more details about the issue you are facing? > > > In particular, what is the number of configured tx and rx queues for both > > > peers? > > > > Hi, Lorenzo > > I found this because I wanted to add more echo information in ethttool(for veth, > > but I found that the information was incorrect. That's why I paid > > attention here. > > ack. Could you please share the veth pair tx/rx queue configuration? > dev: tx --->4. rx--->4 peer: tx--->1 rx---->1 Could the following code still be problematic? pp_idx not updated correctly. page_pool_stats: veth_get_page_pool_stats(dev, &data[pp_idx]); BR Albert > Rergards, > Lorenzo > > > > > > tx_idx is the index of the current (local) tx queue and it must restart from > > > idx in each iteration otherwise we will have an issue when > > > peer->real_num_rx_queues is greater than dev->real_num_tx_queues. > > > > > OK. I don't know if this is a known issue. > > > > BR > > Albert > > > > > > > Regards, > > > Lorenzo
> Lorenzo Bianconi <lorenzo@kernel.org> 于2023年11月20日周一 17:52写道: > > > > > Lorenzo Bianconi <lorenzo@kernel.org> 于2023年11月17日周五 17:26写道: > > > > > > > > > if peer->real_num_rx_queues > 1, the ethtool -s command for > > > > > veth network device will display some error statistical values. > > > > > The value of tx_idx is reset with each iteration, so even if > > > > > peer->real_num_rx_queues is greater than 1, the value of tx_idx > > > > > will remain constant. This results in incorrect statistical values. > > > > > To fix this issue, assign the value of pp_idx to tx_idx. > > > > > > > > > > Fixes: 5fe6e56776ba ("veth: rely on peer veth_rq for ndo_xdp_xmit accounting") > > > > > Signed-off-by: Albert Huang <huangjie.albert@bytedance.com> > > > > > --- > > > > > drivers/net/veth.c | 2 +- > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > > > > > index 0deefd1573cf..3a8e3fc5eeb5 100644 > > > > > --- a/drivers/net/veth.c > > > > > +++ b/drivers/net/veth.c > > > > > @@ -225,7 +225,7 @@ static void veth_get_ethtool_stats(struct net_device *dev, > > > > > for (i = 0; i < peer->real_num_rx_queues; i++) { > > > > > const struct veth_rq_stats *rq_stats = &rcv_priv->rq[i].stats; > > > > > const void *base = (void *)&rq_stats->vs; > > > > > - unsigned int start, tx_idx = idx; > > > > > + unsigned int start, tx_idx = pp_idx; > > > > > size_t offset; > > > > > > > > > > tx_idx += (i % dev->real_num_tx_queues) * VETH_TQ_STATS_LEN; > > > > > -- > > > > > 2.20.1 > > > > > > > > > > > > > Hi Albert, > > > > > > > > Can you please provide more details about the issue you are facing? > > > > In particular, what is the number of configured tx and rx queues for both > > > > peers? > > > > > > Hi, Lorenzo > > > I found this because I wanted to add more echo information in ethttool(for veth, > > > but I found that the information was incorrect. That's why I paid > > > attention here. > > > > ack. Could you please share the veth pair tx/rx queue configuration? > > > > dev: tx --->4. rx--->4 > peer: tx--->1 rx---->1 > > Could the following code still be problematic? pp_idx not updated correctly. > page_pool_stats: > veth_get_page_pool_stats(dev, &data[pp_idx]); Thx for pointing this out. This part is a bit tricky but I think I can see the issue now. Since we have just one peer rx queue, when we run ndo_xdp_xmit pointer on dev, we will squash all dev xmit queues on the single peer rx one (where we do do the accounting) [0]. The issue is ethtool will display all dev xmit queues so we need to set pp_idx properly in veth_get_ethtool_stats(). Can you please take a look to the patch below? Regards, Lorenzo [0] https://github.com/LorenzoBianconi/net-next/blob/master/drivers/net/veth.c#L417 diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 9980517ed8b0..8607eb8cf458 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -236,8 +236,8 @@ static void veth_get_ethtool_stats(struct net_device *dev, data[tx_idx + j] += *(u64 *)(base + offset); } } while (u64_stats_fetch_retry(&rq_stats->syncp, start)); - pp_idx = tx_idx + VETH_TQ_STATS_LEN; } + pp_idx = idx + dev->real_num_tx_queues * VETH_TQ_STATS_LEN; page_pool_stats: veth_get_page_pool_stats(dev, &data[pp_idx]); > > BR > Albert > > > Rergards, > > Lorenzo > > > > > > > > > tx_idx is the index of the current (local) tx queue and it must restart from > > > > idx in each iteration otherwise we will have an issue when > > > > peer->real_num_rx_queues is greater than dev->real_num_tx_queues. > > > > > > > OK. I don't know if this is a known issue. > > > > > > BR > > > Albert > > > > > > > > > > Regards, > > > > Lorenzo
黄杰 <huangjie.albert@bytedance.com> 于2023年11月20日周一 18:02写道: > > Lorenzo Bianconi <lorenzo@kernel.org> 于2023年11月20日周一 17:52写道: > > > > > Lorenzo Bianconi <lorenzo@kernel.org> 于2023年11月17日周五 17:26写道: > > > > > > > > > if peer->real_num_rx_queues > 1, the ethtool -s command for > > > > > veth network device will display some error statistical values. > > > > > The value of tx_idx is reset with each iteration, so even if > > > > > peer->real_num_rx_queues is greater than 1, the value of tx_idx > > > > > will remain constant. This results in incorrect statistical values. > > > > > To fix this issue, assign the value of pp_idx to tx_idx. > > > > > > > > > > Fixes: 5fe6e56776ba ("veth: rely on peer veth_rq for ndo_xdp_xmit accounting") > > > > > Signed-off-by: Albert Huang <huangjie.albert@bytedance.com> > > > > > --- > > > > > drivers/net/veth.c | 2 +- > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > > > > > index 0deefd1573cf..3a8e3fc5eeb5 100644 > > > > > --- a/drivers/net/veth.c > > > > > +++ b/drivers/net/veth.c > > > > > @@ -225,7 +225,7 @@ static void veth_get_ethtool_stats(struct net_device *dev, > > > > > for (i = 0; i < peer->real_num_rx_queues; i++) { > > > > > const struct veth_rq_stats *rq_stats = &rcv_priv->rq[i].stats; > > > > > const void *base = (void *)&rq_stats->vs; > > > > > - unsigned int start, tx_idx = idx; > > > > > + unsigned int start, tx_idx = pp_idx; > > > > > size_t offset; > > > > > > > > > > tx_idx += (i % dev->real_num_tx_queues) * VETH_TQ_STATS_LEN; > > > > > -- > > > > > 2.20.1 > > > > > > > > > > > > > Hi Albert, > > > > > > > > Can you please provide more details about the issue you are facing? > > > > In particular, what is the number of configured tx and rx queues for both > > > > peers? > > > > > > Hi, Lorenzo > > > I found this because I wanted to add more echo information in ethttool(for veth, > > > but I found that the information was incorrect. That's why I paid > > > attention here. > > > > ack. Could you please share the veth pair tx/rx queue configuration? > > > > dev: tx --->4. rx--->4 > peer: tx--->1 rx---->1 > > Could the following code still be problematic? pp_idx not updated correctly. > page_pool_stats: > veth_get_page_pool_stats(dev, &data[pp_idx]); I did the test locally and there is no problem with this place. I didn't fully understand this piece of code before thanks. BR Albert. > > BR > Albert > > > Rergards, > > Lorenzo > > > > > > > > > tx_idx is the index of the current (local) tx queue and it must restart from > > > > idx in each iteration otherwise we will have an issue when > > > > peer->real_num_rx_queues is greater than dev->real_num_tx_queues. > > > > > > > OK. I don't know if this is a known issue. > > > > > > BR > > > Albert > > > > > > > > > > Regards, > > > > Lorenzo
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 0deefd1573cf..3a8e3fc5eeb5 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -225,7 +225,7 @@ static void veth_get_ethtool_stats(struct net_device *dev, for (i = 0; i < peer->real_num_rx_queues; i++) { const struct veth_rq_stats *rq_stats = &rcv_priv->rq[i].stats; const void *base = (void *)&rq_stats->vs; - unsigned int start, tx_idx = idx; + unsigned int start, tx_idx = pp_idx; size_t offset; tx_idx += (i % dev->real_num_tx_queues) * VETH_TQ_STATS_LEN;