🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25083

Re: [PATCH net-next v2 2/3] net: wangxun: expose queue stats via netdev-genl

#25083
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 08:36
218 lines
15640 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] wx_get_queue_stats_tx() and wx_get_base_stats() export TX
  stop/wake counters through netdev-genl, but the two counters are not…
- [Low] The commit message says the PF-only hardware counters left in
  ethtool -S "have no netdev-genl attribute" and names rdmdrop…
- [Low] wx_get_queue_stats_rx() and wx_get_base_stats() fill the netdev-
  genl rx-alloc-fail attribute from rx_stats.alloc_rx_buff_failed.

--

net: wangxun: expose queue stats via netdev-genl

This patch implements netdev_stat_ops in libwx and registers them for the
ngbe, ngbevf, txgbe and txgbevf netdevs. Per-queue packet, byte, RX
allocation failure, checksum and TX stop/wake counters become available
through netdev-genl. get_base_stats() reports the counters kept when a
queue vector is torn down.

> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> index 2868232792588..0502b5d8e96e8 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c

[ ... ]

> @@ -3193,6 +3194,95 @@ void wx_get_stats64(struct net_device *netdev,
>  }
>  EXPORT_SYMBOL(wx_get_stats64);
>  
> +static void wx_get_queue_stats_rx(struct net_device *dev, int idx,
> +				  struct netdev_queue_stats_rx *stats)
> +{

[ ... ]

> +	wx_ring_get_rx_stats(ring, &ring_stats);
> +	stats->packets = ring_stats.queue.packets;
> +	stats->bytes = ring_stats.queue.bytes;
> +	stats->alloc_fail = ring_stats.rx.alloc_rx_buff_failed;

[Severity: Low]
Does rx_stats.alloc_rx_buff_failed cover everything rx-alloc-fail is
defined to count?

netdev.yaml describes rx-alloc-fail as "Number of times skb or buffer
allocation failed on the Rx datapath". The only place that increments
alloc_rx_buff_failed is wx_clean_rx_irq(), when wx_build_skb() fails to
allocate an skb:

    skb = wx_build_skb(rx_ring, rx_buffer, rx_desc);

    /* exit if we failed to retrieve a buffer */
    if (!skb) {
        rx_stats.alloc_rx_buff_failed++;
        break;
    }

When a page pool refill fails in wx_alloc_mapped_page(), the function
returns without updating any counter:

    page = page_pool_dev_alloc_pages(rx_ring->page_pool);
    if (unlikely(!page))
        return false;

wx_alloc_rx_buffers() then just stops refilling.

Under memory pressure, could rx-alloc-fail read 0 while ring refills are
failing? wx_get_base_stats() exports the same counter through
qstats_base_rx_stats.alloc_rx_buff_failed. The rest of the series does
not change this.

> +	stats->csum_unnecessary = ring_stats.rx.csum_unnecessary_cnt;
> +	stats->csum_bad = ring_stats.rx.csum_err;
> +
> +out:
> +	rcu_read_unlock();
> +}
> +
> +static void wx_get_queue_stats_tx(struct net_device *dev, int idx,
> +				  struct netdev_queue_stats_tx *stats)
> +{

[ ... ]

> +	wx_ring_get_tx_stats(ring, &ring_stats);
> +	stats->packets = ring_stats.queue.packets;
> +	stats->bytes = ring_stats.queue.bytes;
> +	stats->stop = ring_stats.tx.stop;
> +	stats->wake = ring_stats.tx.wake;

[Severity: Medium]
Can tx-wake end up larger than tx-stop here?

wx_maybe_stop_tx() always stops the queue with netif_stop_subqueue().
However, it only increments stop_queue when the re-check still finds too
few descriptors. On the reprieve path it counts a restart but not the
stop that came just before it:

    netif_stop_subqueue(tx_ring->netdev, tx_ring->queue_index);
    ...
    if (likely(wx_desc_unused(tx_ring) < size)) {
        ...
        ++tx_ring->tx_stats.stop_queue;
        ...
        return -EBUSY;
    }

    /* A reprieve! - use start_queue because it doesn't call schedule */
    netif_start_subqueue(tx_ring->netdev, tx_ring->queue_index);
    ...
    ++tx_ring->tx_stats.restart_queue;

wx_ring_get_tx_stats() then reports:

    stats->tx.stop = ring->tx_stats.stop_queue;
    stats->tx.wake = ring->tx_stats.restart_queue +
                     restart_queue_napi;

A race with TX completion can make the gap larger:

CPU1 (xmit)                         CPU2 (NAPI)
wx_maybe_stop_tx()
  netif_stop_subqueue()
                                    wx_clean_tx_irq()
                                      __netif_subqueue_stopped()
                                      netif_wake_subqueue()
                                      ++restart_queue_napi
  wx_desc_unused() >= size
  netif_start_subqueue()
  ++restart_queue

That is one real pause, zero counted stops and two counted wakes.

netdev.yaml defines tx-stop as the number of times the driver paused
accepting packets and tx-wake as the number of times it restarted, so
consumers would expect wake <= stop. For comparison, gve_tx_dqo.c counts a
stop before the reprieve check and a wake on the reprieve.

The earlier "net: libwx: preserve queue stats across reconfiguration"
commit chose this deliberately ("the reprieve path only adds a wake").
Once the counters are mapped to the tx-stop/tx-wake uAPI, though, the
pair no longer balances.

Would it make sense to count the stop unconditionally after
netif_stop_subqueue() in wx_maybe_stop_tx()?

The retained totals that wx_get_base_stats() reports in tx->stop and
tx->wake have the same asymmetry. The later "net: wangxun: expose VF
stats through ndo_get_stats64" commit in the series does not touch
wx_maybe_stop_tx() or the stat_ops.

> +
> +out:
> +	rcu_read_unlock();
> +}
> +
> +static void wx_get_base_stats(struct net_device *dev,
> +			      struct netdev_queue_stats_rx *rx,
> +			      struct netdev_queue_stats_tx *tx)
> +{
> +	struct wx *wx = netdev_priv(dev);
> +
> +	/* Read the retained values the same way as wx_get_stats64(), so that
> +	 * they cannot be updated while they are being gathered.
> +	 */
> +	spin_lock(&wx->hw_stats_lock);
> +	rx->bytes = wx->qstats_base_rx.bytes;
> +	rx->packets = wx->qstats_base_rx.packets;
> +	rx->alloc_fail = wx->qstats_base_rx_stats.alloc_rx_buff_failed;
> +	rx->csum_unnecessary =
> +		wx->qstats_base_rx_stats.csum_unnecessary_cnt;
> +	rx->csum_bad = wx->qstats_base_rx_stats.csum_err;

[Severity: Low]
The commit message says:

    The PF-only hardware counters that have no netdev-genl attribute stay
    available through ethtool -S, among them rdmdrop, which the driver
    reports as rx_no_dma_resources;

Is that accurate for rdmdrop? wx_update_stats() adds in the
clear-on-read WX_RDM_DRP_PKT register:

    hwstats->rdmdrop += rd32(wx, WX_RDM_DRP_PKT);

ethtool -S labels this counter rx_no_dma_resources.

netdev.yaml defines rx-hw-drop-overruns as "Number of packets dropped
due to transient lack of resources, such as buffer space, host
descriptors etc.". rx-hw-drops also covers packets that entered the
device but never left it.

include/net/netdev_queues.h allows get_base_stats() to report
device-level counters that belong to no queue. sfc and bnge already
report similar counters as hw_drop_overruns.

Could wx_get_base_stats() fill rx->hw_drop_overruns from rdmdrop on the
PF (!wx->is_vf)?

WX_RDM_DRP_PKT may also count drops on VF pools when SR-IOV is enabled.
If that is the reason to leave it out, could the commit message say so
instead? The rest of the series does not change this.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130083407.78429-1-mengyuanlou%40net-swift.com
Technical Details
Message-ID: <179611418489.3146.4243252111245579894@kernel.org>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374850-linux-kernel-netdev=dewy.ru
References: <20261130083407.78429-3-mengyuanlou@net-swift.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374850-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 2/3] net: wangxun: expose queue stats via netdev-genl
Date: Tue, 01 Dec 2026 08:36:24 +0000
Organization: Usenet Network
Message-ID: <179611418489.3146.4243252111245579894@kernel.org>
References: <20261130083407.78429-3-mengyuanlou@net-swift.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1660908"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:lCQKAZqF9VSCR+r5wUpcTiml+qM= sha256:dZ99KKjwksb3TdBzItGAN/ehTKC6S3VNvUNB9RLcNGk=
	sha1:CYySOi5vkFRo0tht2c4npsyE1bE= sha256:0QbtDWCptbd2piuj49VAsWdzZs3fc1oqKkNll73HA8M=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 34BC11172CC; Tue,  1 Dec 2026 11:36:45 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 3Wqi1aYfF5se;
	Tue,  1 Dec 2026 11:36:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374850-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 38A3A1172A1; Tue,  1 Dec 2026 11:36:32 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id DD63F30D71; Tue,  1 Dec 2026 08:36:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796114187;
	b=LIWxg5/OxJiyxm9Al4tUSl8ajoljGKBHuk6kPLEKZTzob570kX9pqAU1+CQdbg3QgBqX
	 YhgpiVv0QDZXSfwV8zviIx4KJiY6n3NF9T3kInZEXOZGOa2ysAnFH3CuvC6Se6hutX0Tm
	 ddQAdHdJ2IbWfAhrLswSAES9oTATv5XoFV4r0phDysGRKUph7zsUX3Bp7dCW59SEq8HDq
	 gnl+VhNiy4qHSMClEJhhU/LbVDvG+G7cn5xjgrDU7lPLgssNYAAMBo5/yBRxmvLPY27Ik
	 5jhPHdpftCRjJzeqF0vHcOYwon724OmRTpwLvthSMhs8R4SYC+ccCu/o2nRI/PnExFg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796114187;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=u0xonTSjM8NEaOUJ6q3Xp0BgrTa2jE/xFcwXeLe47kY=;
	b=UHUU+TMn4fTbqsgxZdCOBlMijsptbBJnVAZD4eKkji0aEvmkSG/VZuR5kpv2d1m4IejF
	 4/I4wirYlEY9PosDpVzvBF60QzzEuJyC00KLitGG34fr/YY2GbYY1Zt6K6ujywAeeu6Mh
	 SmMnK68vaHn7QWCZ3SjgwfoXFl9icev7JNktXNmivb8gS6dQCNKkhE6aHxBwl7GF/iJ4d
	 u7Su8s7PF3a0j13aGwwhe8AC0I0U0CVNgtKO91RPMJhK99vyLDvC+GkO7pArlN1xJUm3v
	 qrbUawbJAOREvdlIPzmlUzvXvbZI0hDD8D7W5d7WADQ2WWv01EFd/VkYbuc4Z71976A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=P6jQ1MIJ;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 091C5606A338;
	Tue,  1 Dec 2026 08:36:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=P6jQ1MIJ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796114186;
	b=C4rOuxKXljrADHsA35Mq3EQBKqCsyq/HyezB2i/J/x/Gyb3t0efeYwkgORDEWeWA72iC
	 G3SEchdyKKAYwYpzh6STBVnikjnGbDTRxw/rF99Hal8KnYhwzFyJVWQdGFIA6ZxeBTnrP
	 T2EGmxVCFUJRRqRTOaJPDDl3IXUIoxBI1sLkzf6bWfJJy3gtlpT0kej8/6rkU9/qHrd9Z
	 WUxAd+uYpQ5B9lIfZd4Mj7kn3nJqVYuc4Rl4SvA7OwcQg8wXajuuO5+cvvtZZMXE1eahz
	 DqAz5IGfyw0NvtoynfQu5uNJ9effkR18FzvDsnuGqRnWT9grVEk8EdvVqALia0WZ+TQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796114186;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=u0xonTSjM8NEaOUJ6q3Xp0BgrTa2jE/xFcwXeLe47kY=;
	b=3Bfynsj1dAPYPfv4Ynxw+zNBLTF8XtVQsihL6hRYjT24pwodoxRLcfjPaHCPs6HNZZQU
	 DbdPHFEJOZ8Dqo7xWxibfQSKm/N1hUFvWtBd9IvxV2SW1xr4dVjvEBWYcS1lv58XKQTIX
	 48Gpse+w/32AyJyZzZhuntooM//2vnrg44YCVKQ5PYB6l/8xZJHo3HmDWrRJyUS4AW4ZC
	 nTTMdgvWRW/Wq1KxS9/dOf3wdq9uxnjZaN6KOACWKGjKHaLlzlsn82AFF/15mrlHcCtl4
	 HClLsHtOJyN3EE941tLr+iYExSp/nVuCObL2WKzqYm2xCBsb5paEH5gaB5riWEX7/oQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=P6jQ1MIJ;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AF61606A32F
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 08:36:26 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 605C61F0089C;
	Tue,  1 Dec 2026 08:36:25 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796114186;
	bh=u0xonTSjM8NEaOUJ6q3Xp0BgrTa2jE/xFcwXeLe47kY=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=P6jQ1MIJCJBq4ZuMPubm1T5Wa31fbgLZgxWHp/wlMWBO9u0xDHrA7VqlnKHidZtRL
	 QN95mgeslm1un3gL1VPmgbk6bJUSy69XvXMZQMqsPVCI+xQ2GtYPRgnUjOkgSENjqf
	 A/R+91J8lrGy5vTwP+fDR31SimMEKFH3iqKsAVhfDaNlsyJeE9xkgOYKeFIovBSYbC
	 yf7Q/vd2ngTp/fdjFTS+JiOryo/GOUIHazMHxxQuxZa3IIKaDTbIthYikyX9vksM4E
	 VeM8ypxc2lxHLLyMadwB4FwqWxVphy5Apne7CaLZUF7oVjhjjou0iwuU2jNsvo+CPL
	 5w5yGw/5KjZMw==
X-Cc: netdev@vger.kernel.org, jiawenwu@trustnetic.com,
 duanqiangwen@net-swift.com, linglingzhang@net-swift.com,
 andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
 kuba@kernel.org, pabeni@redhat.com
X-In-Reply-To: <20261130083407.78429-3-mengyuanlou@net-swift.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list