From: netdev-bot+sashiko@kernel.org
To: weh@linux.microsoft.com
Cc: longli@kernel.org, kotaranov@microsoft.com, kuba@kernel.org,
davem@davemloft.net, pabeni@redhat.com, edumazet@google.com,
andrew+netdev@lunn.ch, jgg@ziepe.ca, leon@kernel.org,
haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
shradhagupta@linux.microsoft.com, horms@kernel.org,
ernis@linux.microsoft.com, stephen@networkplumber.org,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, sdf@fomichev.me, daniel@iogearbox.net,
hawk@kernel.org, ast@kernel.org, john.fastabend@gmail.com,
weh@microsoft.com, edumazet@kernel.org
Subject: Re: [PATCH net-next v7 07/13] net: mana: swap queue sets in mana_change_mtu
Date: Tue, 20 Oct 2026 16:47:51 +0000 [thread overview]
Message-ID: <179251487177.3135.3241052074893563065@kernel.org> (raw)
In-Reply-To: <87e016ed7479a33be87128b01bb07d2e1807c87d.1791710735.git.weh@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
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] mana_change_mtu() adds a new use of the boolean
channel_changing as an ad-hoc lock.
--
net: mana: swap queue sets in mana_change_mtu
With this patch, mana_change_mtu() builds a full replacement queue set
sized for the new MTU and swaps it in. It no longer does a detach and
attach. The MTU is carried in the queue set as configured_mtu, and
ndev->mtu is published only after RSS configuration succeeds.
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index c80a06ffbe508..c1ff4d9b8d45f 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> @@ -956,32 +956,52 @@ int mana_pre_alloc_rxbufs(struct mana_port_context *mpc, int new_mtu, int num_qu
> static int mana_change_mtu(struct net_device *ndev, int new_mtu)
> {
[ ... ]
> + /* Fail-close may release the Ethernet vport reference. */
> + mutex_lock(&mpc->vport_mutex);
> + if (mpc->channel_changing) {
> + mutex_unlock(&mpc->vport_mutex);
> + return -EBUSY;
> + }
> + mpc->channel_changing = true;
> + mutex_unlock(&mpc->vport_mutex);
> +
> + scratch = mana_qset_scratch_alloc(mpc);
> + if (!scratch) {
> + err = -ENOMEM;
> + goto clear_flag;
> }
>
> - WRITE_ONCE(ndev->mtu, new_mtu);
> + err = mana_alloc_qset(mpc, scratch, mpc->num_queues,
> + mpc->rx_queue_size, mpc->tx_queue_size,
> + mpc->priv_flags, new_mtu, &newq);
> + if (err)
> + goto free_scratch;
>
> - err = mana_attach(ndev);
> + err = mana_publish_qset(mpc, &newq, &oldq);
> if (err) {
> - netdev_err(ndev, "mana_attach failed: %d\n", err);
> - WRITE_ONCE(ndev->mtu, old_mtu);
> + mana_free_qset(scratch, &newq);
> + goto free_scratch;
> }
>
> -out:
> - mana_pre_dealloc_rxbufs(mpc);
> + mana_free_qset(scratch, &oldq);
> +
> +free_scratch:
> + mana_publish_close_if_needed(mpc);
> + mana_qset_scratch_free(scratch);
> +clear_flag:
> + mutex_lock(&mpc->vport_mutex);
> + mpc->channel_changing = false;
> + mutex_unlock(&mpc->vport_mutex);
> return err;
> }
[Severity: Medium]
Here, channel_changing seems to act as a lock around a code section rather
than as a record of object state. Is that the intent?
The flag is set under vport_mutex, and then the mutex is dropped. The whole
sleeping replacement runs after that: mana_qset_scratch_alloc(),
mana_alloc_qset(), mana_publish_qset(), mana_free_qset(),
mana_publish_close_if_needed() and mana_qset_scratch_free(). The flag is
cleared again at clear_flag.
The only reader is on the RDMA side, and it fails instead of waiting:
mana_cfg_vport() {
...
mutex_lock(&apc->vport_mutex);
if (apc->vport_use_count > 0 ||
(check_channel_changing && apc->channel_changing)) {
mutex_unlock(&apc->vport_mutex);
return -EBUSY;
}
...
}
As a result, RAW-QP creation gets a transient -EBUSY during any MTU change
on a running port. Lockdep also cannot see this exclusion.
vport_mutex probably can't just be held across the region, because the
fail-close path takes it itself:
mana_publish_close_if_needed()
-> mana_dealloc_queues()
-> mana_destroy_vport()
-> mana_uncfg_vport()
-> mutex_lock(&apc->vport_mutex)
Can the -EBUSY check at the top of mana_change_mtu() ever trigger? Every
writer of channel_changing holds RTNL for its whole region, and RDMA only
reads the flag. The writers are mana_change_mtu(), the queue reset work,
the set_channels, set_ringparam and set_priv_flags handlers, and the XDP
setup path.
The same pattern already exists in the queue reset work,
mana_set_channels() and mana_set_priv_flags(). This patch extends it to
the MTU path, and it is still there at the end of the series. Could a real
lock, or some way for RDMA admission to wait, be used here?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1791710735.git.weh%40linux.microsoft.com
next reply other threads:[~2026-10-20 16:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 16:47 netdev-bot+sashiko [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-10-16 15:38 [PATCH net-next v7 00/13] net: mana: reconfigure by replacing the queue set Wei Hu
2026-10-16 15:38 ` [PATCH net-next v7 07/13] net: mana: swap queue sets in mana_change_mtu Wei Hu
2026-10-17 15:39 ` sashiko-bot
2026-10-20 4:30 ` Wei Hu
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=179251487177.3135.3241052074893563065@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=edumazet@kernel.org \
--cc=ernis@linux.microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=jgg@ziepe.ca \
--cc=john.fastabend@gmail.com \
--cc=kotaranov@microsoft.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=shradhagupta@linux.microsoft.com \
--cc=stephen@networkplumber.org \
--cc=weh@linux.microsoft.com \
--cc=weh@microsoft.com \
--cc=wei.liu@kernel.org \
/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