Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mmc@linux.ibm.com
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, willemb@google.com
Subject: Re: [PATCH net-next v9 05/13] ibmveth: Register subordinate RX queues
Date: Sat, 05 Dec 2026 19:42:35 +0000	[thread overview]
Message-ID: <179649975501.3148.9601292630063618554@kernel.org> (raw)
In-Reply-To: <20261201190216.62407-6-mmc@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

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] In MQ mode, ibmveth_free_all_queues()
  (drivers/net/ethernet/ibm/ibmveth.c) calls ibmveth_leak_rx_memory()…
- [Low] ibmveth_leak_rx_memory() in drivers/net/ethernet/ibm/ibmveth.c
  prints adapter->num_rx_queues, which struct ibmveth_adapter declares…

--

ibmveth: Register subordinate RX queues

This patch prepares for multi-queue RX. In multi-queue mode it registers
RX queues 1..N-1 with H_REG_LOGICAL_LAN_QUEUE after queue 0 and maps each
queue's interrupt. It also leaks the RX memory, instead of freeing it,
when H_FREE_LOGICAL_LAN fails with anything other than H_PARAMETER.

> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> index 236992ded33a9..5783c0ce34a35 100644
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c

[ ... ]

> @@ -1228,12 +1258,49 @@ static long ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
>  	return rc;
>  }
>  
> +/**
> + * ibmveth_leak_rx_memory - Keep the RX memory PHYP may still own
> + * @adapter: ibmveth adapter structure
> + *
> + * Forgets each queue's ring, buffer list and pool buffers and the filter
> + * list without unmapping or freeing them, so the free paths skip them
> + * and their TCEs are not reused by later mappings.
> + */
> +static void ibmveth_leak_rx_memory(struct ibmveth_adapter *adapter)
> +{
> +	struct ibmveth_buff_pool *pool;
> +	int i, j;
> +
> +	netdev_err(adapter->netdev, "leaking RX memory of %d queues\n",
> +		   adapter->num_rx_queues);

[Severity: Low]
This isn't a bug, but num_rx_queues is declared as unsigned int in struct
ibmveth_adapter. Should this be %u instead of %d?

> +
> +	for (i = 0; i < adapter->num_rx_queues; i++) {
> +		adapter->rx_queue[i].queue_addr = NULL;
> +		adapter->buffer_list_addr[i] = NULL;
> +		adapter->buffer_list_dma[i] = 0;
> +		for (j = 0; j < IBMVETH_NUM_BUFF_POOLS; j++) {
> +			pool = &adapter->rx_buff_pool[i][j];
> +			pool->free_map = NULL;
> +			pool->dma_addr = NULL;
> +			pool->skbuff = NULL;
> +		}
> +	}
> +	adapter->filter_list_addr = NULL;
> +	adapter->filter_list_dma = 0;
> +}

[ ... ]

> @@ -1243,6 +1310,68 @@ static void ibmveth_free_all_queues(struct ibmveth_adapter *adapter)
>  	if (lpar_rc != H_SUCCESS)
>  		netdev_err(adapter->netdev,
>  			   "h_free_logical_lan failed: %ld\n", lpar_rc);
> +
> +	if (lpar_rc != H_SUCCESS && lpar_rc != H_PARAMETER &&
> +	    adapter->multi_queue)
> +		ibmveth_leak_rx_memory(adapter);
> +}

[Severity: Medium]
Can this abandoned RX memory ever be reclaimed?

ibmveth_leak_rx_memory() clears these fields:

  - rx_queue[i].queue_addr
  - buffer_list_addr[i] and buffer_list_dma[i]
  - each pool's free_map, dma_addr and skbuff arrays
  - filter_list_addr and filter_list_dma

The driver keeps no other record of them. The rings, buffer list pages,
filter page and every pool skb therefore stay allocated and DMA mapped
until reboot.

On the next open(), ibmveth_register_logical_lan() fails against the
still-registered LAN, so it frees the LAN and retries:

	if (rc != H_SUCCESS && try_again) {
		rc = ibmveth_free_logical_lan(adapter);

		try_again = 0;
		goto retry;
	}

If that free succeeds, PHYP no longer owns the old memory. Nothing goes
back to unmap and free it.

Could these leaks also pile up?

ibmveth_close() calls ibmveth_free_all_queues() on every close/open pair.
These pairs come from ibmveth_reset(), the MTU change, pool sysfs,
set_csum and set_tso paths. The open() error paths (err_unregister and
out_unregister_queues) call it too.

Each later H_FREE_LOGICAL_LAN failure would abandon another full set of RX
memory, and nothing limits the total. Once "ibmveth: Enable multi-queue
RX" is applied, that commit's message puts this at about 270 MB for 8
queues. The held TCEs would also shrink the space left for later
dma_map_single() calls in replenish and TX LTB setup.

The commit message says PHYP fails H_FREE_LOGICAL_LAN only with
H_PARAMETER. If so, this path is dead, but the driver cannot check that.
multi_queue is not set in this commit, so the path only becomes reachable
later in the series. The logic is the same at the end of the series.

The commit message says the leak is intended:

  MQ mode then leaks the RX memory, still mapped, so whatever PHYP still
  writes lands in memory nothing else uses.

Should it also say that this memory is never reclaimed and that repeated
close/open cycles can leak more sets?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201190216.62407-1-mmc%40linux.ibm.com

  reply	other threads:[~2026-12-05 19:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 19:02 [PATCH net-next v9 00/13] ibmveth: Add multi-queue RX support Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 01/13] ibmveth: Keep a buffer pool enabled after its allocation fails Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 02/13] ibmveth: Keep TX statistics per queue Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 03/13] powerpc/pseries: Add hcall numbers for multi-queue virtual ethernet Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 04/13] ibmveth: Add RX queue handles Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 05/13] ibmveth: Register subordinate RX queues Mingming Cao
2026-12-05 19:42   ` netdev-bot+sashiko [this message]
2026-12-01 19:02 ` [PATCH net-next v9 06/13] ibmveth: Add subordinate RX queue interrupt control Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 07/13] ibmveth: Add the MQ RX buffer submit hypercall Mingming Cao
2026-12-05 19:42   ` netdev-bot+sashiko
2026-12-01 19:02 ` [PATCH net-next v9 08/13] ibmveth: Start every RX queue on open and resume Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 09/13] ibmveth: Keep RX statistics per queue Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 10/13] ibmveth: Keep rx_no_buffer across ifdown/up Mingming Cao
2026-12-05 19:42   ` netdev-bot+sashiko
2026-12-01 19:02 ` [PATCH net-next v9 11/13] ibmveth: Report per-queue statistics through netdev_stat_ops Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 12/13] ibmveth: Enable multi-queue RX Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 13/13] ibmveth: Allow changing the RX queue count Mingming Cao
2026-12-05 19:42   ` netdev-bot+sashiko

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=179649975501.3148.9601292630063618554@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --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=mmc@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --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 \
    --cc=willemb@google.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