BPF 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 07/13] net: mana: swap queue sets in mana_change_mtu
Date: Sat, 10 Oct 2026 14:42:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-166667@kernel.org> (raw)
In-Reply-To: <e9524a67c6e157f2e110f4e9f51ec3c94293a64d.1790795005.git.weh@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Deadlock on 32-bit systems due to u64_stats_update_begin with preemption enabled
--

commit 9fbccd82cfbdb308859b32b732f45f8415ee4bd0
Author: Long Li <longli@microsoft.com>
net: mana: swap queue sets in mana_change_mtu

This commit carries the MTU in the queue set and replaces the RX buffers from
it. It swaps queue sets in mana_change_mtu by allocating a new scratch context,
publishing the new queue set, and cleaning up the old one upon success or
failure.

> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
[ ... ]
> @@ -4392,6 +4419,8 @@ int mana_publish_qset(struct mana_port_context *apc, struct mana_qset *newq,
>  	synchronize_net();
>  	mana_fold_qset_rx_stats(apc, out_old);
>  
> +	WRITE_ONCE(ndev->mtu, apc->configured_mtu);
> +
>  	/* Publish restored fields before reopening the gate, as on success. */
>  	smp_wmb();

[Severity: High]
Can this lead to a deadlock on 32-bit systems?

The mana_publish_qset function executes under the rtnl lock with preemption
enabled, which leads to this call chain:

mana_publish_qset()
  mana_fold_qset_rx_stats()
    mana_fold_rxq_stats() {
        u64_stats_update_begin(&dst->syncp);
        dst->packets += src->packets;
        dst->bytes += src->bytes;
        ...
        u64_stats_update_end(&dst->syncp);
    }

Because preemption is enabled, on 32-bit architectures, a reader such as
ndo_get_stats64() could preempt the writer while the sequence count is odd.
The reader would then spin forever in u64_stats_fetch_retry() waiting for
an even sequence count, starving the preempted writer and resulting in a
deadlock.

Should preemption or interrupts be disabled around this stats update to
ensure readers cannot preempt the writer?

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

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

Thread overview: 31+ 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
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 [this message]
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 14:42   ` sashiko-bot
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-166667@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