From: sashiko-bot@kernel.org
To: "Long Li" <longli@microsoft.com>
Cc: linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: Re: [PATCH net-next v5 09/13] net: mana: keep per-queue statistics in the port context
Date: Thu, 10 Sep 2026 22:25:24 +0000 [thread overview]
Message-ID: <20260910222524.8596D1F0089E@smtp.kernel.org> (raw)
In-Reply-To: <20260909222416.884246-10-longli@microsoft.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] u64_stats_update_begin called with preemption enabled causes potential deadlock.
Pre-existing issues:
- [High] Missing Mutual Exclusion on tx_stats updates between mana_xdp_xmit and mana_start_xmit.
--
commit 45f5d2a315921074d282869dd20e8233e5bb463b
Author: Long Li <longli@microsoft.com>
Subject: net: mana: keep per-queue statistics in the port context
Move RX/TX counters into port-lifetime arrays so queue rebuilds do not
reset them. Sum all max_queues slots for ndo_get_stats64(), keep the
current queue count for ethtool, and fold retiring RX queues count into
private drain_stats upon destruction.
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_bpf.c b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
> index debf0e7765862..2060e08d82277 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_bpf.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
[ ... ]
> @@ -73,7 +73,7 @@ int mana_xdp_xmit(struct net_device *ndev, int n, struct xdp_frame **frames,
> count++;
> }
>
> - tx_stats = &apc->tx_qp[q_idx]->txq.stats;
> + tx_stats = apc->tx_qp[q_idx]->txq.stats;
>
> u64_stats_update_begin(&tx_stats->syncp);
> tx_stats->xdp_xmit += count;
> u64_stats_update_end(&tx_stats->syncp);
[Severity: High]
This is a pre-existing issue, but is there a missing mutual exclusion
between mana_xdp_xmit() and mana_start_xmit() when updating tx_stats->syncp?
mana_xdp_xmit() bypasses the qdisc HARD_TX_LOCK and maps q_idx using
smp_processor_id(). As a result, it can run concurrently with
mana_start_xmit() which uses the skb's queue mapping. Because the skb
queue mapping could map to the same queue from another CPU, both
functions might run simultaneously on different CPUs and call
u64_stats_update_begin() on the same syncp. This would corrupt the
sequence counter.
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index 5752e3745ccc6..98007bb3ef7ca 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
[ ... ]
> @@ -575,7 +575,7 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> /* Populated the packet and bytes counters based on post GSO packet
> * calculations
> */
> - tx_stats = &txq->stats;
> + tx_stats = txq->stats;
> u64_stats_update_begin(&tx_stats->syncp);
> tx_stats->packets += num_gso_seg;
> tx_stats->bytes += len + ((num_gso_seg - 1) * gso_hs);
[Severity: High]
This is a pre-existing issue, but this is the primary packet transmission
path that can run concurrently with the XDP transmission path in
mana_xdp_xmit() mentioned above, contributing to the lost updates on the
shared tx_stats struct.
[ ... ]
> +static void mana_fold_rxq_stats(struct mana_port_context *apc,
> + struct mana_rxq *rxq)
> +{
> + struct mana_stats_rx *src = &rxq->drain_stats;
> + struct mana_stats_rx *dst;
> + unsigned int i;
> +
> + ASSERT_RTNL();
> +
> + if (!apc->rxq_stats_ret || rxq->rxq_idx >= apc->max_queues)
> + return;
> +
> + dst = &apc->rxq_stats_ret[rxq->rxq_idx];
> +
> + u64_stats_update_begin(&dst->syncp);
> + dst->packets += src->packets;
> + dst->bytes += src->bytes;
[Severity: High]
Does mana_fold_rxq_stats() need to disable preemption or bottom halves
before acquiring the sequence lock here?
This function executes in process context holding the RTNL lock, but it
calls u64_stats_update_begin() with preemption enabled. On 32-bit systems,
if the thread is preempted or interrupted by a softirq on the same CPU that
subsequently reads the stats via mana_get_stats64(), the reader could spin
infinitely waiting for the sequence lock to become even.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909222416.884246-1-longli@microsoft.com?part=9
next prev parent reply other threads:[~2026-09-10 22:25 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 22:24 [PATCH net-next v5 00/13] net: mana: reconfigure by replacing the queue set Long Li
2026-09-09 22:24 ` [PATCH net-next v5 01/13] net: mana: add queue-set allocation and teardown helpers Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 02/13] net: mana: share the EQ pool across a queue-set swap Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 03/13] net: mana: swap queue sets in mana_set_channels Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 04/13] net: mana: swap queue sets in mana_set_ringparam Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 05/13] net: mana: swap queue sets in mana_set_priv_flags Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 06/13] net: mana: swap queue sets in mana_change_mtu Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 07/13] net: mana: swap queue sets in mana_xdp_set Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 08/13] net: mana: do not bail out of mana_detach on dealloc failure Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 09/13] net: mana: keep per-queue statistics in the port context Long Li
2026-09-10 22:25 ` sashiko-bot [this message]
2026-09-09 22:24 ` [PATCH net-next v5 10/13] net: mana: release EQs left idle by a channel-count reduction Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 11/13] net: mana: keep a user-configured RSS table across a queue rebuild Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 12/13] net: mana: keep the surviving queues when the channel count is reduced Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 13/13] net: mana: keep the existing queues when the channel count is raised Long Li
2026-09-10 22:25 ` sashiko-bot
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=20260910222524.8596D1F0089E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=sashiko-reviews@lists.linux.dev \
/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