linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 v4 04/13] net: mana: swap queue sets in mana_set_ringparam
Date: Wed, 09 Sep 2026 03:29:44 +0000	[thread overview]
Message-ID: <20260909032945.2C3E41F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908032843.397667-5-longli@microsoft.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch introduces an ad-hoc locking pattern using a boolean flag (`apc->channel_changing`) to guard the reconfiguration critical section in `mana_set_ringparam`.
--

commit 40668ebf41a83bf44835ffb33803930c039ce405
Author: Long Li <longli@microsoft.com>

net: mana: swap queue sets in mana_set_ringparam

This commit replaces detach/attach operations in mana_set_ringparam() with
queue-set allocation and publication. Failed allocations now leave the
running queues and ring sizes unchanged instead of risking a detached port.

> diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
> --- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
[ ... ]
> @@ -774,32 +772,56 @@ static int mana_set_ringparam(struct net_device *ndev,
>  	netdev_info(ndev, "Using nearest power of 2 values for Txq:%d Rxq:%d\n",
>  		    new_tx, new_rx);
>  
> -	/* pre-allocating new buffers to prevent failures in mana_attach() later */
> -	apc->rx_queue_size = new_rx;
> -	err = mana_pre_alloc_rxbufs(apc, ndev->mtu, apc->num_queues);
> -	apc->rx_queue_size = old_rx;
> -	if (err) {
> -		netdev_err(ndev, "Insufficient memory for new allocations\n");
> -		return err;
> +	if (new_rx == apc->rx_queue_size && new_tx == apc->tx_queue_size)
> +		return 0;
> +
> +	if (!apc->port_is_up) {
> +		apc->rx_queue_size = new_rx;
> +		apc->tx_queue_size = new_tx;
> +		return 0;
>  	}
>  
> -	err = mana_detach(ndev, false);
> -	if (err) {
> -		netdev_err(ndev, "mana_detach failed: %d\n", err);
> -		goto out;
> +	/* Exclude RDMA through failure cleanup, which may release the vport. */
> +	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 ad-hoc locking pattern using the
apc->channel_changing boolean flag?

The networking drivers subsystem guidelines indicate that using a boolean
flag set on entry and cleared on exit to guard a reconfiguration critical
section bypasses lockdep and provides weaker synchronization guarantees than
using a proper lock.

Could a standard kernel synchronization primitive be used for this critical
section in mana_set_ringparam() instead of relying on the
apc->channel_changing flag?

[ ... ]
> +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/20260908032843.397667-1-longli@microsoft.com?part=4

  reply	other threads:[~2026-09-09  3:29 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  3:28 [PATCH net-next v4 00/13] net: mana: reconfigure by replacing the queue set Long Li
2026-09-08  3:28 ` [PATCH net-next v4 01/13] net: mana: add queue-set allocation and teardown helpers Long Li
2026-09-09  3:29   ` sashiko-bot
2026-09-08  3:28 ` [PATCH net-next v4 02/13] net: mana: share the EQ pool across a queue-set swap Long Li
2026-09-09  3:29   ` sashiko-bot
2026-09-08  3:28 ` [PATCH net-next v4 03/13] net: mana: swap queue sets in mana_set_channels Long Li
2026-09-09  3:29   ` sashiko-bot
2026-09-08  3:28 ` [PATCH net-next v4 04/13] net: mana: swap queue sets in mana_set_ringparam Long Li
2026-09-09  3:29   ` sashiko-bot [this message]
2026-09-09 23:25     ` [EXTERNAL] " Long Li
2026-09-08  3:28 ` [PATCH net-next v4 05/13] net: mana: swap queue sets in mana_set_priv_flags Long Li
2026-09-09  3:29   ` sashiko-bot
2026-09-08  3:28 ` [PATCH net-next v4 06/13] net: mana: swap queue sets in mana_change_mtu Long Li
2026-09-09  3:29   ` sashiko-bot
2026-09-08  3:28 ` [PATCH net-next v4 07/13] net: mana: swap queue sets in mana_xdp_set Long Li
2026-09-09  3:29   ` sashiko-bot
2026-09-08  3:28 ` [PATCH net-next v4 08/13] net: mana: do not bail out of mana_detach on dealloc failure Long Li
2026-09-09  3:29   ` sashiko-bot
2026-09-08  3:28 ` [PATCH net-next v4 09/13] net: mana: keep per-queue statistics in the port context Long Li
2026-09-09  3:29   ` sashiko-bot
2026-09-08  3:28 ` [PATCH net-next v4 10/13] net: mana: release EQs left idle by a channel-count reduction Long Li
2026-09-09  3:29   ` sashiko-bot
2026-09-08  3:28 ` [PATCH net-next v4 11/13] net: mana: keep a user-configured RSS table across a queue rebuild Long Li
2026-09-09  3:29   ` sashiko-bot
2026-09-08  3:28 ` [PATCH net-next v4 12/13] net: mana: keep the surviving queues when the channel count is reduced Long Li
2026-09-09  3:29   ` sashiko-bot
2026-09-08  3:28 ` [PATCH net-next v4 13/13] net: mana: keep the existing queues when the channel count is raised Long Li
2026-09-09  3:29   ` 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=20260909032945.2C3E41F00A3A@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;
as well as URLs for NNTP newsgroup(s).