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 v7 06/13] net: mana: swap queue sets in mana_set_priv_flags
Date: Sat, 17 Oct 2026 15:39:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-175606@kernel.org> (raw)
In-Reply-To: <c1a2032792858ac0234807bbb5b26b81af4d10b1.1791710735.git.weh@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] net: mana: ad-hoc trylock using channel_changing flag
--
commit 1135b1db29f999b173b293508a85336e600ae80e
Author: Long Li <longli@microsoft.com>
net: mana: swap queue sets in mana_set_priv_flags
Rebuild queues through the swap path when USE_FULL_PAGE_RXBUF changes
the RX layout. Carry priv_flags with the queue set so allocation failure
leaves the live configuration unchanged and rollback restores the flags.
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
> index a643a8cc81e00..9c7c9879d0aa4 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
> @@ -891,54 +892,50 @@ static int mana_set_priv_flags(struct net_device *ndev, u32 priv_flags)
> if (priv_flags & ~GENMASK(MANA_PRIV_FLAG_MAX - 1, 0))
> return -EINVAL;
>
> - apc->priv_flags = priv_flags;
> -
> - if (changed & BIT(MANA_PRIV_FLAG_USE_FULL_PAGE_RXBUF)) {
> - if (!apc->port_is_up)
> - return 0;
> -
> - /* If XDP is attached or the MTU already forces one buffer per
> - * page, single-buffer-per-page is used regardless of this
> - * flag. Skip the expensive detach/attach cycle since nothing
> - * changes.
> - */
> - if (mana_single_rxbuf_per_page_forced(apc, ndev->mtu))
> - return 0;
> + /* No rebuild is needed if the RX buffer flag is unchanged, the port is
> + * down, or full-page RX buffers are already required by MTU or XDP.
> + */
> + if (!(changed & BIT(MANA_PRIV_FLAG_USE_FULL_PAGE_RXBUF)) ||
> + !apc->port_is_up ||
> + mana_single_rxbuf_per_page_forced(apc, ndev->mtu)) {
> + apc->priv_flags = priv_flags;
> + return 0;
> + }
>
> - /* Block RDMA from grabbing the vport during detach/attach */
> - mutex_lock(&apc->vport_mutex);
> - apc->channel_changing = true;
> + mutex_lock(&apc->vport_mutex);
> + if (apc->channel_changing) {
> mutex_unlock(&apc->vport_mutex);
> + return -EBUSY;
> + }
> + apc->channel_changing = true;
> + mutex_unlock(&apc->vport_mutex);
[Severity: Medium]
Does this code introduce an open-coded trylock pattern?
Setting a flag on entry and clearing it on exit to prevent concurrent execution,
and returning -EBUSY to skip the work, appears to act as an ad-hoc lock
substitute for the queue rebuild section. Could a proper lock or synchronization
primitive be used instead to guard this state?
>
> - err = mana_pre_alloc_rxbufs(apc, ndev->mtu, apc->num_queues);
> - if (err) {
> - netdev_err(ndev,
> - "Insufficient memory for new allocations\n");
> - apc->priv_flags = old_priv_flags;
> - goto clear_flag;
> - }
> + scratch = mana_qset_scratch_alloc(apc);
> + if (!scratch) {
> + err = -ENOMEM;
> + goto clear_flag;
> + }
>
> - err = mana_detach(ndev, false);
> - if (err) {
> - netdev_err(ndev, "mana_detach failed: %d\n", err);
> - apc->priv_flags = old_priv_flags;
> - goto out;
> - }
> + err = mana_alloc_qset(apc, scratch, apc->num_queues, apc->rx_queue_size,
> + apc->tx_queue_size, priv_flags, &newq);
> + if (err)
> + goto free_scratch;
>
> - err = mana_attach(ndev);
> - if (err) {
> - netdev_err(ndev, "mana_attach failed: %d\n", err);
> - apc->priv_flags = old_priv_flags;
> - }
> + err = mana_publish_qset(apc, &newq, &oldq);
> + if (err) {
> + mana_free_qset(scratch, &newq);
> + goto free_scratch;
> }
>
> -out:
> - mana_pre_dealloc_rxbufs(apc);
> + mana_free_qset(scratch, &oldq);
> +
> +free_scratch:
> + mana_publish_close_if_needed(apc);
> + mana_qset_scratch_free(scratch);
> clear_flag:
> mutex_lock(&apc->vport_mutex);
> apc->channel_changing = false;
> mutex_unlock(&apc->vport_mutex);
> -
> return err;
> }
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791710735.git.weh@linux.microsoft.com?part=6
next prev parent reply other threads:[~2026-10-17 15:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
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 01/13] net: mana: add queue-set allocation and teardown helpers Wei Hu
2026-10-16 15:38 ` [PATCH net-next v7 02/13] net: mana: share the EQ pool across a queue-set swap Wei Hu
2026-10-17 15:39 ` sashiko-bot
2026-10-16 15:38 ` [PATCH net-next v7 03/13] net: mana: keep per-queue statistics in the port context Wei Hu
2026-10-17 15:39 ` sashiko-bot
2026-10-16 15:38 ` [PATCH net-next v7 04/13] net: mana: swap queue sets in mana_set_channels Wei Hu
2026-10-17 15:39 ` sashiko-bot
2026-10-16 15:38 ` [PATCH net-next v7 05/13] net: mana: swap queue sets in mana_set_ringparam Wei Hu
2026-10-16 15:38 ` [PATCH net-next v7 06/13] net: mana: swap queue sets in mana_set_priv_flags Wei Hu
2026-10-17 15:39 ` sashiko-bot [this message]
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-16 15:38 ` [PATCH net-next v7 08/13] net: mana: swap queue sets in mana_xdp_set Wei Hu
2026-10-16 15:38 ` [PATCH net-next v7 09/13] net: mana: do not bail out of mana_detach on dealloc failure Wei Hu
2026-10-16 15:38 ` [PATCH net-next v7 10/13] net: mana: release EQs left idle by a channel-count reduction Wei Hu
2026-10-16 15:38 ` [PATCH net-next v7 11/13] net: mana: keep a user-configured RSS table across a queue rebuild Wei Hu
2026-10-17 15:39 ` sashiko-bot
2026-10-16 15:38 ` [PATCH net-next v7 12/13] net: mana: keep the surviving queues when the channel count is reduced Wei Hu
2026-10-16 15:38 ` [PATCH net-next v7 13/13] net: mana: keep the existing queues when the channel count is raised 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=sashiko-outbox-175606@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