Linux-HyperV List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wei Hu" <weh@linux.microsoft.com>
Cc: linux-rdma@vger.kernel.org, linux-hyperv@vger.kernel.org,
	bpf@vger.kernel.org
Subject: Re: [PATCH net-next v6 04/13] net: mana: swap queue sets in mana_set_channels
Date: Sat, 10 Oct 2026 14:42:10 +0000	[thread overview]
Message-ID: <sashiko-outbox-166665@kernel.org> (raw)
In-Reply-To: <a4bef0e79343469ce47507a44d0094d63e7bc131.1790795005.git.weh@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] networking: u64_stats_sync writer in mana_fold_rxq_stats does not disable preemption/BH
--

commit 93d72a1c224b35993067fa6f5051dfe42f90cf43
Author: Long Li <longli@microsoft.com>

net: mana: swap queue sets in mana_set_channels

Build a replacement queue set before quiescing TX. After closing the
TX/XDP gate and draining its readers, wait up to 120 seconds for ALL
old TX queues before changing pointers, queue counts or RSS.

> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index 02cd5f7656ed8..10225c09f5b7f 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c

[ ... ]

> @@ -1094,6 +1132,58 @@ static void mana_free_queue_stats(struct mana_port_context *apc)
>  	apc->txq_stats = NULL;
>  }
>  
> +/* Fold under RTNL after drain_stats writers quiesce. Clear drain_stats to
> + * prevent double counting on rollback.
> + */
> +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);

[Severity: High]
Does this code expose a sequence counter race window to lockless readers?

The mana_fold_rxq_stats() function runs in process context under RTNL, but
it calls u64_stats_update_begin() without first disabling preemption or
bottom-halves (softirqs).

The u64_stats_sync API strictly requires writers to run with preemption
disabled, and BH disabled if readers can be in softirq context. On 32-bit
architectures, this macro increments a sequence counter.

If a reader (like ndo_get_stats64 invoked via dev_get_stats() from a
softirq or another thread) preempts the writer on the same CPU while the
sequence counter is odd, the reader could spin infinitely in
u64_stats_fetch_retry() waiting for it to become even, causing a hard
deadlock.

Should the update be wrapped in local_bh_disable() and local_bh_enable(),
or use the _irqsave variant?

> +	dst->packets		+= src->packets;
> +	dst->bytes		+= src->bytes;
> +	dst->xdp_drop		+= src->xdp_drop;
> +	dst->xdp_tx		+= src->xdp_tx;
> +	dst->xdp_redirect	+= src->xdp_redirect;
> +	dst->pkt_len0_err	+= src->pkt_len0_err;
> +	for (i = 0; i < ARRAY_SIZE(dst->coalesced_cqe); i++)
> +		dst->coalesced_cqe[i] += src->coalesced_cqe[i];
> +	u64_stats_update_end(&dst->syncp);
> +
> +	src->packets		= 0;
> +	src->bytes		= 0;
> +	src->xdp_drop		= 0;
> +	src->xdp_tx		= 0;
> +	src->xdp_redirect	= 0;
> +	src->pkt_len0_err	= 0;
> +	for (i = 0; i < ARRAY_SIZE(src->coalesced_cqe); i++)
> +		src->coalesced_cqe[i] = 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1790795005.git.weh@linux.microsoft.com?part=4

  reply	other threads:[~2026-10-10 14:42 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 14:41 [PATCH net-next v6 00/13] net: mana: reconfigure by replacing the queue set Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 01/13] net: mana: add queue-set allocation and teardown helpers Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 02/13] net: mana: share the EQ pool across a queue-set swap Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 03/13] net: mana: keep per-queue statistics in the port context Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-13 10:26     ` [EXTERNAL] " Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 04/13] net: mana: swap queue sets in mana_set_channels Wei Hu
2026-10-10 14:42   ` sashiko-bot [this message]
2026-10-13 10:39     ` [EXTERNAL] " Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 05/13] net: mana: swap queue sets in mana_set_ringparam Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 06/13] net: mana: swap queue sets in mana_set_priv_flags Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 07/13] net: mana: swap queue sets in mana_change_mtu Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-13 11:11     ` [EXTERNAL] " Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 08/13] net: mana: swap queue sets in mana_xdp_set Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 09/13] net: mana: do not bail out of mana_detach on dealloc failure Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 10/13] net: mana: release EQs left idle by a channel-count reduction Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 11/13] net: mana: keep a user-configured RSS table across a queue rebuild Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 12/13] net: mana: keep the surviving queues when the channel count is reduced Wei Hu
2026-10-10 14:42   ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 13/13] net: mana: keep the existing queues when the channel count is raised Wei Hu
2026-10-10 16:28 ` [PATCH net-next v6 00/13] net: mana: reconfigure by replacing the queue set Simon Horman

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=sashiko-outbox-166665@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=weh@linux.microsoft.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