From: Jakub Kicinski <kuba@kernel.org>
To: xuanzhuo@linux.alibaba.com
Cc: Jakub Kicinski <kuba@kernel.org>,
davem@davemloft.net, netdev@vger.kernel.org, andrew@lunn.ch,
andrew+netdev@lunn.ch, dust.li@linux.alibaba.com,
pabeni@redhat.com, vadim.fedorenko@linux.dev, dong100@mucse.com,
guwen@linux.alibaba.com, lorenzo@kernel.org, edumazet@google.com,
lulie@linux.alibaba.com, lukas.bulwahn@redhat.com
Subject: Re: [net-next,v20,6/6] eea: introduce callback for ndo_get_stats64
Date: Mon, 19 Jan 2026 14:42:25 -0800 [thread overview]
Message-ID: <20260119224225.1363113-1-kuba@kernel.org> (raw)
In-Reply-To: <20260115031042.104164-7-xuanzhuo@linux.alibaba.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
eea: introduce callback for ndo_get_stats64
This commit adds ndo_get_stats64 support for the Alibaba Elastic Ethernet
Adapter driver. The eea_stats() function iterates over RX and TX queues
to collect packet and byte statistics using u64_stats_sync primitives.
> diff --git a/drivers/net/ethernet/alibaba/eea/eea_net.c b/drivers/net/ethernet/alibaba/eea/eea_net.c
> index 2eba43a82ebc..440f5f11e055 100644
> --- a/drivers/net/ethernet/alibaba/eea/eea_net.c
> +++ b/drivers/net/ethernet/alibaba/eea/eea_net.c
> @@ -269,6 +269,52 @@ static int eea_netdev_open(struct net_device *netdev)
> return err;
> }
>
> +static void eea_stats(struct net_device *netdev, struct rtnl_link_stats64 *tot)
> +{
> + struct eea_net *enet = netdev_priv(netdev);
> + u64 packets, bytes;
> + u32 start;
> + int i;
> +
> + /* This function is protected by RCU. Here uses enet->tx and enet->rx
> + * to check whether the TX and RX structures are safe to access. In
> + * eea_free_rxtx_q_mem, before freeing the TX and RX resources, enet->rx
> + * and enet->tx are set to NULL, and synchronize_net is called.
> + */
> +
> + if (enet->rx) {
> + for (i = 0; i < enet->cfg.rx_ring_num; i++) {
> + struct eea_net_rx *rx = enet->rx[i];
The comment states this function is protected by RCU, but enet->rx is read
without READ_ONCE() or rcu_dereference(). Since eea_free_rxtx_q_mem() can
set enet->rx to NULL concurrently (before calling synchronize_net()), should
the pointer be loaded with READ_ONCE() to prevent the compiler from
re-reading it between the NULL check and the array access?
Similarly, enet->tx below has the same pattern. The RCU documentation
recommends using rcu_dereference() for pointers that are accessed under
RCU protection and may be concurrently modified.
> +
> + do {
> + start = u64_stats_fetch_begin(&rx->stats.syncp);
> + packets = u64_stats_read(&rx->stats.packets);
> + bytes = u64_stats_read(&rx->stats.bytes);
> + } while (u64_stats_fetch_retry(&rx->stats.syncp,
> + start));
> +
> + tot->rx_packets += packets;
> + tot->rx_bytes += bytes;
> + }
> + }
> +
> + if (enet->tx) {
> + for (i = 0; i < enet->cfg.tx_ring_num; i++) {
> + struct eea_net_tx *tx = &enet->tx[i];
[ ... ]
prev parent reply other threads:[~2026-01-19 22:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 3:10 [PATCH net-next v20 0/6] eea: Add basic driver framework for Alibaba Elastic Ethernet Adaptor Xuan Zhuo
2026-01-15 3:10 ` [PATCH net-next v20 1/6] eea: introduce PCI framework Xuan Zhuo
2026-01-15 3:10 ` [PATCH net-next v20 2/6] eea: introduce ring and descriptor structures Xuan Zhuo
2026-01-15 3:10 ` [PATCH net-next v20 3/6] eea: probe the netdevice and create adminq Xuan Zhuo
2026-01-15 3:10 ` [PATCH net-next v20 4/6] eea: create/destroy rx,tx queues for netdevice open and stop Xuan Zhuo
2026-01-19 22:42 ` [net-next,v20,4/6] " Jakub Kicinski
2026-01-15 3:10 ` [PATCH net-next v20 5/6] eea: introduce ethtool support Xuan Zhuo
2026-01-15 3:10 ` [PATCH net-next v20 6/6] eea: introduce callback for ndo_get_stats64 Xuan Zhuo
2026-01-19 22:42 ` Jakub Kicinski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260119224225.1363113-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=dong100@mucse.com \
--cc=dust.li@linux.alibaba.com \
--cc=edumazet@google.com \
--cc=guwen@linux.alibaba.com \
--cc=lorenzo@kernel.org \
--cc=lukas.bulwahn@redhat.com \
--cc=lulie@linux.alibaba.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vadim.fedorenko@linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox