Netdev List
 help / color / mirror / Atom feed
From: mingming cao <mmc@linux.ibm.com>
To: netdev-bot+sashiko@kernel.org
Cc: netdev@vger.kernel.org, maddy@linux.ibm.com, mpe@ellerman.id.au,
	npiggin@gmail.com, chleroy@kernel.org, ritesh.list@gmail.com,
	sshegde@linux.ibm.com, nnac123@linux.ibm.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com,
	linuxppc-dev@lists.ozlabs.org, horms@kernel.org,
	davemarq@linux.ibm.com, haren@linux.ibm.com,
	ricklind@linux.ibm.com, bjking1@linux.ibm.com,
	shaik.abdulla1@ibm.com
Subject: Re: [PATCH net-next v2 3/8] ibmveth: Refactor buffer pool management for per-queue MQ RX
Date: Tue, 24 Nov 2026 11:10:32 -0800	[thread overview]
Message-ID: <80e75016-67c0-46c0-a934-f9455d975178@linux.ibm.com> (raw)
In-Reply-To: <179551045236.3135.13521842784287344413@kernel.org>


On 11/24/26 12:54 AM, netdev-bot+sashiko@kernel.org wrote:
> 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] ibmveth: persistent pool deactivation in
>    ibmveth_alloc_queue_buffer_pools()
>
> --
>
>> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
>> --- a/drivers/net/ethernet/ibm/ibmveth.c
>> +++ b/drivers/net/ethernet/ibm/ibmveth.c
>> @@ -660,6 +660,100 @@ static void ibmveth_rxq_no_skb(struct ibmveth_adapter *adapter,
>>   	schedule_work(&adapter->work);
>>   }
>>   
>> +/**
>> + * ibmveth_free_queue_buffer_pools - Free buffer pools for a single queue
>> + * @adapter: ibmveth adapter structure
>> + * @queue: queue index
>> + *
>> + * Frees every pool on @queue regardless of the active flag;
>> + * ibmveth_free_buffer_pool() skips what was never allocated.
>> + */
>> +static void ibmveth_free_queue_buffer_pools(struct ibmveth_adapter *adapter,
>> +					    int queue)
>> +{
>> +	int i;
>> +
>> +	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
>> +		ibmveth_free_buffer_pool(adapter,
>> +					 &adapter->rx_buff_pool[queue][i]);
>> +}
>> +
>> +/**
>> + * ibmveth_alloc_queue_buffer_pools - Allocate buffer pools for a single queue
>> + * @adapter: ibmveth adapter structure
>> + * @queue: queue index
>> + *
>> + * Allocates backing storage for each active pool on @queue.
>> + *
>> + * Return: 0 on success, -ENOMEM on failure
>> + */
>> +static int ibmveth_alloc_queue_buffer_pools(struct ibmveth_adapter *adapter,
>> +					    int queue)
>> +{
>> +	struct net_device *netdev = adapter->netdev;
>> +	int i;
>> +
>> +	for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
>> +		struct ibmveth_buff_pool *bpool =
>> +			&adapter->rx_buff_pool[queue][i];
>> +
>> +		if (!bpool->active)
>> +			continue;
>> +
>> +		if (ibmveth_alloc_buffer_pool(bpool)) {
>> +			netdev_err(netdev,
>> +				   "queue %d pool %d alloc failed (size=%u count=%u)\n",
>> +				   queue, i,
>> +				   bpool->buff_size,
>> +				   bpool->size);
>> +			bpool->active = 0;
>> +			/* Undo the pools this queue already allocated; the
>> +			 * failed one freed its own partial allocation.
>> +			 */
>> +			ibmveth_free_queue_buffer_pools(adapter, queue);
>> +			return -ENOMEM;
>> +		}
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +/**
>> + * ibmveth_alloc_buffer_pools - Allocate buffer pools for all queues
>> + * @adapter: ibmveth adapter structure
>> + *
>> + * Return: 0 on success, -ENOMEM on failure
>> + */
>> +static int
>> +ibmveth_alloc_buffer_pools(struct ibmveth_adapter *adapter)
>> +{
>> +	int q, rc;
>> +
>> +	for (q = 0; q < adapter->num_rx_queues; q++) {
>> +		rc = ibmveth_alloc_queue_buffer_pools(adapter, q);
>> +		if (rc) {
>> +			while (--q >= 0)
>> +				ibmveth_free_queue_buffer_pools(adapter, q);
>> +			return rc;
>> +		}
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +/**
>> + * ibmveth_free_buffer_pools - Free buffer pools for all queues
>> + * @adapter: ibmveth adapter structure
>> + */
>> +static void
>> +ibmveth_free_buffer_pools(struct ibmveth_adapter *adapter)
>> +{
>> +	int q;
>> +
>> +	for (q = 0; q < adapter->num_rx_queues; q++)
>> +		ibmveth_free_queue_buffer_pools(adapter, q);
>> +}
>> +
>>   /**
>>    * ibmveth_remove_buffer_from_pool - remove a buffer from a pool
>>    * @adapter: adapter instance
> [Severity: Medium]
> Now that ibmveth_free_queue_buffer_pools() frees every pool on the
> queue regardless of the active flag, is there still a reason to clear
> bpool->active here?
>
> The active flag is the pool's persistent configuration. It comes from
> pool_active[] at probe, is turned on by ibmveth_change_mtu() for large
> MTUs and toggled through veth_pool_store(), and ibmveth_close() leaves
> it alone so the same pools come back on the next open. Clearing it on
> a transient ibmveth_alloc_buffer_pool() failure has two effects. A
> later ibmveth_open() quietly skips that pool, and it can succeed
> without a pool large enough for mtu + IBMVETH_BUFF_OH.
>
> None of the callers of ibmveth_open() put the flag back.
> veth_pool_store() only restores oldactive for the pool it is editing.
> The ndo_open path, ibmveth_change_mtu(), ibmveth_set_csum_offload(),
> ibmveth_set_tso() and ibmveth_reset() do not touch it at all.
>
> The old single-queue loop did the same thing. With per-queue pools,
> though, a failure on one queue also leaves rx_buff_pool[q][i].active
> different between queues for the same pool index.
>
> Can this line simply be dropped, since the unwind no longer depends on
> it?

Yes — the clear is not needed for unwind. It is also not new here: it
dates back to 860f242eb534 ("[PATCH] ibmveth change buffer pools
dynamically"), and this patch keeps it so the refactor does not change
behaviour.

I am dropping it in the multi-queue series that follows, not in an s1
respin. With one RX queue (this series and base), the only effect is
that later opens skip that pool. Once there are several RX queues, the
same clear can leave queues with different active sets, or disable the
pool on every queue when queue 0's template is cleared. That is where
the footgun shows up, so the fix belongs with that series (first
patch: drop `bpool->active = 0`, retry the pool on the next open).
Until then this prep series just prepares the helpers and leaves the
pre-existing clear alone.

Thanks,

Mingming


  reply	other threads:[~2026-11-24 19:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  7:51 [PATCH net-next v2 0/8] ibmveth: prepare the RX path for multi-queue Mingming Cao
2026-11-23  7:51 ` [PATCH net-next v2 1/8] ibmveth: Prepare MQ RX adapter data structures Mingming Cao
2026-11-23  7:51 ` [PATCH net-next v2 2/8] ibmveth: Refactor RX resource allocation for MQ RX bring-up Mingming Cao
2026-11-23  7:51 ` [PATCH net-next v2 3/8] ibmveth: Refactor buffer pool management for per-queue MQ RX Mingming Cao
2026-11-24  8:54   ` netdev-bot+sashiko
2026-11-24 19:10     ` mingming cao [this message]
2026-11-23  7:51 ` [PATCH net-next v2 4/8] ibmveth: Refactor RX interrupt control for MQ RX queues Mingming Cao
2026-11-23  7:51 ` [PATCH net-next v2 5/8] ibmveth: Refactor TX resource allocation in open/close paths Mingming Cao
2026-11-24  8:54   ` netdev-bot+sashiko
2026-11-24 19:15     ` mingming cao
2026-11-23  7:51 ` [PATCH net-next v2 6/8] ibmveth: Add RX queue register helpers for MQ Mingming Cao
2026-11-23  7:51 ` [PATCH net-next v2 7/8] ibmveth: Pass the RX queue index through replenish and poll Mingming Cao
2026-11-23  7:51 ` [PATCH net-next v2 8/8] ibmveth: Split RX poll into per-slot helpers for MQ Mingming Cao

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=80e75016-67c0-46c0-a934-f9455d975178@linux.ibm.com \
    --to=mmc@linux.ibm.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjking1@linux.ibm.com \
    --cc=chleroy@kernel.org \
    --cc=davem@davemloft.net \
    --cc=davemarq@linux.ibm.com \
    --cc=edumazet@kernel.org \
    --cc=haren@linux.ibm.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nnac123@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=ricklind@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=shaik.abdulla1@ibm.com \
    --cc=sshegde@linux.ibm.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