Netdev List
 help / color / mirror / Atom feed
* [PATCH] eth: bnxt: fix the agg page pool ring size on 64K-page kernels
@ 2026-11-25 16:29 Usama Arif
  2026-11-26 10:49 ` Björn Töpel
  2026-11-26 16:57 ` netdev-bot+sashiko
  0 siblings, 2 replies; 5+ messages in thread
From: Usama Arif @ 2026-11-25 16:29 UTC (permalink / raw)
  To: michael.chan, pavan.chebbi, kuba, asml.silence, andrew+netdev,
	davem, edumazet, pabeni, netdev
  Cc: Usama Arif

Commit f7dbedba6312 ("eth: bnxt: take page size into account for page
pool recycling rings") sized the recycle ring of the agg page pool in
pages, dividing the agg ring size by PAGE_SIZE / BNXT_RX_PAGE_SIZE.
Commit c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues
with larger buffers") replaced PAGE_SIZE in that divisor with
rx_page_size.

On 64K-page kernels rx_page_size can only be 32K, so the divisor is now
always 1. Each 64K page still holds two agg buffers and the page pool
recycles whole pages, so the recycle ring can cache twice as many pages
as the agg ring uses. With 1024 RX descriptors, the agg ring posts 2048
buffers in 1024 pages while the recycle ring holds up to 2048 pages, or
128 MiB per RX queue.

Divide by the larger of PAGE_SIZE and rx_page_size to restore the
original size. x86 with 4K base PAGE_SIZE and arm64 with 4K and 16K
PAGE_SIZE are unaffected, as rx_page_size is never smaller than PAGE_SIZE
there.

The ring only fills up when the stack releases agg pages faster than
the driver reuses them. On a 64K arm64 host with a BCM57508 (32 queues,
1024 RX descriptors), a TCP receiver that drained its sockets every
1.5 s left about 1.8 GiB less memory cached after the fix, 64 MiB per
busy queue.

Fixes: c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues with larger buffers")
Signed-off-by: Usama Arif <usama.arif@linux.dev>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 52606db3f7b4a8..ecc4848499c307 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -3948,7 +3948,8 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp,
 				   struct bnxt_rx_ring_info *rxr,
 				   int numa_node)
 {
-	unsigned int agg_size_fac = rxr->rx_page_size / BNXT_RX_PAGE_SIZE;
+	unsigned int agg_size_fac = max(PAGE_SIZE, rxr->rx_page_size) /
+				    BNXT_RX_PAGE_SIZE;
 	const unsigned int rx_size_fac = PAGE_SIZE / SZ_4K;
 	struct page_pool_params pp = { 0 };
 	struct page_pool *pool;
-- 
2.53.1-Meta


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] eth: bnxt: fix the agg page pool ring size on 64K-page kernels
  2026-11-25 16:29 [PATCH] eth: bnxt: fix the agg page pool ring size on 64K-page kernels Usama Arif
@ 2026-11-26 10:49 ` Björn Töpel
  2026-11-26 15:16   ` Usama Arif
  2026-11-26 16:57 ` netdev-bot+sashiko
  1 sibling, 1 reply; 5+ messages in thread
From: Björn Töpel @ 2026-11-26 10:49 UTC (permalink / raw)
  To: Usama Arif, michael.chan, pavan.chebbi, kuba, asml.silence,
	andrew+netdev, davem, edumazet, pabeni, netdev
  Cc: Usama Arif

Usama Arif <usama.arif@linux.dev> writes:

> Commit f7dbedba6312 ("eth: bnxt: take page size into account for page
> pool recycling rings") sized the recycle ring of the agg page pool in
> pages, dividing the agg ring size by PAGE_SIZE / BNXT_RX_PAGE_SIZE.
> Commit c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues
> with larger buffers") replaced PAGE_SIZE in that divisor with
> rx_page_size.
>
> On 64K-page kernels rx_page_size can only be 32K, so the divisor is now
> always 1. Each 64K page still holds two agg buffers and the page pool
> recycles whole pages, so the recycle ring can cache twice as many pages
> as the agg ring uses. With 1024 RX descriptors, the agg ring posts 2048
> buffers in 1024 pages while the recycle ring holds up to 2048 pages, or
> 128 MiB per RX queue.
>
> Divide by the larger of PAGE_SIZE and rx_page_size to restore the
> original size. x86 with 4K base PAGE_SIZE and arm64 with 4K and 16K
> PAGE_SIZE are unaffected, as rx_page_size is never smaller than PAGE_SIZE
> there.
>
> The ring only fills up when the stack releases agg pages faster than
> the driver reuses them. On a 64K arm64 host with a BCM57508 (32 queues,
> 1024 RX descriptors), a TCP receiver that drained its sockets every
> 1.5 s left about 1.8 GiB less memory cached after the fix, 64 MiB per
> busy queue.
>
> Fixes: c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues with larger buffers")
> Signed-off-by: Usama Arif <usama.arif@linux.dev>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 52606db3f7b4a8..ecc4848499c307 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -3948,7 +3948,8 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp,
>  				   struct bnxt_rx_ring_info *rxr,
>  				   int numa_node)
>  {
> -	unsigned int agg_size_fac = rxr->rx_page_size / BNXT_RX_PAGE_SIZE;
> +	unsigned int agg_size_fac = max(PAGE_SIZE, rxr->rx_page_size) /
> +				    BNXT_RX_PAGE_SIZE;

Hmm, shouldn't the denominator be rxr->rx_page_size rather than
BNXT_RX_PAGE_SIZE?

bnxt_rx_agg_ring_fill_level() already accounts for larger RX buffers, so
using the default buffer size here seems to account for the override
twice.

IIUC, the purpose of agg_size_fac is to convert the number of posted RX
buffers into the number of recyclable backing allocations.

E.g. an iouring 16K override would result in a smaller (too small?)
pool.

This patch had me thinking; The default agg pool buffer size is 32K on
64K systems. That's quite a step up from the default 4K on 4K systems.
8x more RX buffer memory as an effect of using a system with larger
pages... maybe there's a need for a system knob? That's pretty wasteful,
unless the workload is really HWGRO friendly.


Björn

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] eth: bnxt: fix the agg page pool ring size on 64K-page kernels
  2026-11-26 10:49 ` Björn Töpel
@ 2026-11-26 15:16   ` Usama Arif
  2026-11-26 17:28     ` Björn Töpel
  0 siblings, 1 reply; 5+ messages in thread
From: Usama Arif @ 2026-11-26 15:16 UTC (permalink / raw)
  To: Björn Töpel, michael.chan, pavan.chebbi, kuba,
	asml.silence, andrew+netdev, davem, edumazet, pabeni, netdev



On 26/11/2026 02:49, Björn Töpel wrote:
> Usama Arif <usama.arif@linux.dev> writes:
> 
>> Commit f7dbedba6312 ("eth: bnxt: take page size into account for page
>> pool recycling rings") sized the recycle ring of the agg page pool in
>> pages, dividing the agg ring size by PAGE_SIZE / BNXT_RX_PAGE_SIZE.
>> Commit c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues
>> with larger buffers") replaced PAGE_SIZE in that divisor with
>> rx_page_size.
>>
>> On 64K-page kernels rx_page_size can only be 32K, so the divisor is now
>> always 1. Each 64K page still holds two agg buffers and the page pool
>> recycles whole pages, so the recycle ring can cache twice as many pages
>> as the agg ring uses. With 1024 RX descriptors, the agg ring posts 2048
>> buffers in 1024 pages while the recycle ring holds up to 2048 pages, or
>> 128 MiB per RX queue.
>>
>> Divide by the larger of PAGE_SIZE and rx_page_size to restore the
>> original size. x86 with 4K base PAGE_SIZE and arm64 with 4K and 16K
>> PAGE_SIZE are unaffected, as rx_page_size is never smaller than PAGE_SIZE
>> there.
>>
>> The ring only fills up when the stack releases agg pages faster than
>> the driver reuses them. On a 64K arm64 host with a BCM57508 (32 queues,
>> 1024 RX descriptors), a TCP receiver that drained its sockets every
>> 1.5 s left about 1.8 GiB less memory cached after the fix, 64 MiB per
>> busy queue.
>>
>> Fixes: c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues with larger buffers")
>> Signed-off-by: Usama Arif <usama.arif@linux.dev>
>> ---
>>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>> index 52606db3f7b4a8..ecc4848499c307 100644
>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>> @@ -3948,7 +3948,8 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp,
>>  				   struct bnxt_rx_ring_info *rxr,
>>  				   int numa_node)
>>  {
>> -	unsigned int agg_size_fac = rxr->rx_page_size / BNXT_RX_PAGE_SIZE;
>> +	unsigned int agg_size_fac = max(PAGE_SIZE, rxr->rx_page_size) /
>> +				    BNXT_RX_PAGE_SIZE;
> 
> Hmm, shouldn't the denominator be rxr->rx_page_size rather than
> BNXT_RX_PAGE_SIZE?
> 

Ummm, yes, you are right :) With rx_page_size as the denominator,
agg_size_fac is the number of buffers per page pool allocation, which
is what f7dbedba6312 intended. I think the proper fix is below:


From f52ae7fc048695de1fdf5cb3282a90036e4eca5e Mon Sep 17 00:00:00 2001
From: Usama Arif <usama.arif@linux.dev>
Date: Mon, 23 Nov 2026 17:24:04 -0800
Subject: [PATCH] eth: bnxt: fix the agg page pool recycle ring size
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit f7dbedba6312 ("eth: bnxt: take page size into account for page
pool recycling rings") sized the recycle ring of the agg page pool in
pages, dividing the agg ring size by the number of agg buffers per page.
Commit c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues
with larger buffers") changed the divisor to rx_page_size /
BNXT_RX_PAGE_SIZE, which is wrong in two cases:

- On 64K-page kernels rx_page_size can only be 32K, so the divisor is
  1, although each 64K page holds two agg buffers. With 1024 RX
  descriptors the agg ring posts 2048 buffers in 1024 pages, while the
  recycle ring can cache 2048 pages, or 128 MiB per RX queue.

- When a memory provider sets rx_page_size above PAGE_SIZE, each buffer
  is its own allocation and the fill level is already divided by
  rx_page_size / BNXT_RX_PAGE_SIZE. Dividing again gives a 4K kernel
  with 16K buffers a 256-entry ring for 1024 posted buffers.

Divide the fill level by the number of buffers per allocation,
max(PAGE_SIZE, rx_page_size) / rx_page_size. Nothing changes for
kernels with pages of 32K or less that use the default buffer size.

On a 64K arm64 host with a BCM57508 (32 queues, 1024 RX descriptors), a
TCP receiver that drained its sockets every 1.5 s left about 1.8 GiB
less memory in the agg page pools after the fix, 64 MiB per busy queue.

Fixes: c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues with larger buffers")
Suggested-by: Björn Töpel <bjorn@kernel.org>
Signed-off-by: Usama Arif <usama.arif@linux.dev>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 52606db3f7b4a8..85ce4b2e297ecb 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -3948,7 +3948,8 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp,
 				   struct bnxt_rx_ring_info *rxr,
 				   int numa_node)
 {
-	unsigned int agg_size_fac = rxr->rx_page_size / BNXT_RX_PAGE_SIZE;
+	unsigned int agg_size_fac = max(PAGE_SIZE, rxr->rx_page_size) /
+				    rxr->rx_page_size;
 	const unsigned int rx_size_fac = PAGE_SIZE / SZ_4K;
 	struct page_pool_params pp = { 0 };
 	struct page_pool *pool;
-- 
2.53.1-Meta




> bnxt_rx_agg_ring_fill_level() already accounts for larger RX buffers, so
> using the default buffer size here seems to account for the override
> twice.
> 

Ack

> IIUC, the purpose of agg_size_fac is to convert the number of posted RX
> buffers into the number of recyclable backing allocations.
> 
> E.g. an iouring 16K override would result in a smaller (too small?)
> pool.
> 
> This patch had me thinking; The default agg pool buffer size is 32K on
> 64K systems. That's quite a step up from the default 4K on 4K systems.
> 8x more RX buffer memory as an effect of using a system with larger
> pages... maybe there's a need for a system knob? That's pretty wasteful,
> unless the workload is really HWGRO friendly.
> 

Letting rx-buf-len go below 32K on 64K kernels would be one way to do
it maybe? Although I guess that is something for net-next and not a fix.

Thanks for the review!
Usama

> 
> Björn


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] eth: bnxt: fix the agg page pool ring size on 64K-page kernels
  2026-11-25 16:29 [PATCH] eth: bnxt: fix the agg page pool ring size on 64K-page kernels Usama Arif
  2026-11-26 10:49 ` Björn Töpel
@ 2026-11-26 16:57 ` netdev-bot+sashiko
  1 sibling, 0 replies; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-11-26 16:57 UTC (permalink / raw)
  To: usama.arif
  Cc: michael.chan, pavan.chebbi, kuba, asml.silence, andrew+netdev,
	davem, edumazet, pabeni, netdev

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] In `bnxt_alloc_rx_page_pool()`
  (drivers/net/ethernet/broadcom/bnxt/bnxt.c), the new `agg_size_fac =…

--

eth: bnxt: fix the agg page pool ring size on 64K-page kernels

This commit changes how bnxt_alloc_rx_page_pool() sizes the recycle ring
of the agg page pool. The ring size is now divided by
max(PAGE_SIZE, rx_page_size) / BNXT_RX_PAGE_SIZE. On 64K-page kernels
rx_page_size is always 32K, and with this change the ring again matches
the number of pages the agg ring uses.

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 52606db3f7b4a..ecc4848499c30 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -3948,7 +3948,8 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp,
>  				   struct bnxt_rx_ring_info *rxr,
>  				   int numa_node)
>  {
> -	unsigned int agg_size_fac = rxr->rx_page_size / BNXT_RX_PAGE_SIZE;
> +	unsigned int agg_size_fac = max(PAGE_SIZE, rxr->rx_page_size) /
> +				    BNXT_RX_PAGE_SIZE;

[Severity: Medium]

Should the divisor here be rxr->rx_page_size instead of BNXT_RX_PAGE_SIZE?

The two values are equal only when rx_page_size == BNXT_RX_PAGE_SIZE.
That is always true on 64K kernels, which is why the 64K case is fixed.

On 4K and 16K kernels with rx_page_size > PAGE_SIZE, the fill level is
already divided by this factor in bnxt_rx_agg_ring_fill_level():

	if (rxr->rx_page_size > BNXT_RX_PAGE_SIZE)
		fill_level /= rxr->rx_page_size / BNXT_RX_PAGE_SIZE;

When rx_page_size >= PAGE_SIZE, __bnxt_alloc_rx_netmem() also uses one
whole pool unit per agg buffer:

	} else {
		netmem = page_pool_alloc_netmems(rxr->page_pool, gfp);

So doesn't this line:

	pp.pool_size = bnxt_rx_agg_ring_fill_level(bp, rxr) / agg_size_fac;

apply the rx_page_size / BNXT_RX_PAGE_SIZE factor twice?

Two examples with 32K buffers:

  4K kernel: the agg ring posts rx_agg_ring_size / 8 pool units, but
  pool_size is rx_agg_ring_size / 64, which is 8x too small.

  16K kernel: the agg ring posts rx_agg_ring_size / 2 pool units, but
  pool_size is rx_agg_ring_size / 4, which is 2x too small.

This setup can be reached when a memory provider sets rx_page_size, either
through devmem NETDEV_A_DMABUF_RX_PAGE_SIZE or through io_uring zcrx
rx_buf_len. __netdev_queue_config() copies that value into the queue
config, and bnxt_validate_qcfg() accepts values up to
BNXT_MAX_RX_PAGE_SIZE on P5+ chips. Recycled net_iovs that don't fit in
the ptr_ring then go back to the provider through mp_ops->release_netmem()
and are not cached.

Would max(PAGE_SIZE, rxr->rx_page_size) / rxr->rx_page_size fix both the
64K oversizing and this undersizing?

On the same point, the commit message says:

> x86 with 4K base PAGE_SIZE and arm64 with 4K and 16K
> PAGE_SIZE are unaffected, as rx_page_size is never smaller than PAGE_SIZE
> there.

This patch does leave those configurations unchanged. However, the divisor
from c55bf90a2112, the commit in the Fixes tag, is still wrong there when
rx_page_size > PAGE_SIZE. Could the commit message say so?

>  	const unsigned int rx_size_fac = PAGE_SIZE / SZ_4K;
>  	struct page_pool_params pp = { 0 };
>  	struct page_pool *pool;

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125162916.1743123-1-usama.arif%40linux.dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] eth: bnxt: fix the agg page pool ring size on 64K-page kernels
  2026-11-26 15:16   ` Usama Arif
@ 2026-11-26 17:28     ` Björn Töpel
  0 siblings, 0 replies; 5+ messages in thread
From: Björn Töpel @ 2026-11-26 17:28 UTC (permalink / raw)
  To: Usama Arif, michael.chan, pavan.chebbi, kuba, asml.silence,
	andrew+netdev, davem, edumazet, pabeni, netdev

Usama Arif <usama.arif@linux.dev> writes:

> On 26/11/2026 02:49, Björn Töpel wrote:
>> Usama Arif <usama.arif@linux.dev> writes:
>> 
>>> Commit f7dbedba6312 ("eth: bnxt: take page size into account for page
>>> pool recycling rings") sized the recycle ring of the agg page pool in
>>> pages, dividing the agg ring size by PAGE_SIZE / BNXT_RX_PAGE_SIZE.
>>> Commit c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues
>>> with larger buffers") replaced PAGE_SIZE in that divisor with
>>> rx_page_size.
>>>
>>> On 64K-page kernels rx_page_size can only be 32K, so the divisor is now
>>> always 1. Each 64K page still holds two agg buffers and the page pool
>>> recycles whole pages, so the recycle ring can cache twice as many pages
>>> as the agg ring uses. With 1024 RX descriptors, the agg ring posts 2048
>>> buffers in 1024 pages while the recycle ring holds up to 2048 pages, or
>>> 128 MiB per RX queue.
>>>
>>> Divide by the larger of PAGE_SIZE and rx_page_size to restore the
>>> original size. x86 with 4K base PAGE_SIZE and arm64 with 4K and 16K
>>> PAGE_SIZE are unaffected, as rx_page_size is never smaller than PAGE_SIZE
>>> there.
>>>
>>> The ring only fills up when the stack releases agg pages faster than
>>> the driver reuses them. On a 64K arm64 host with a BCM57508 (32 queues,
>>> 1024 RX descriptors), a TCP receiver that drained its sockets every
>>> 1.5 s left about 1.8 GiB less memory cached after the fix, 64 MiB per
>>> busy queue.
>>>
>>> Fixes: c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues with larger buffers")
>>> Signed-off-by: Usama Arif <usama.arif@linux.dev>
>>> ---
>>>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>>> index 52606db3f7b4a8..ecc4848499c307 100644
>>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>>> @@ -3948,7 +3948,8 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp,
>>>  				   struct bnxt_rx_ring_info *rxr,
>>>  				   int numa_node)
>>>  {
>>> -	unsigned int agg_size_fac = rxr->rx_page_size / BNXT_RX_PAGE_SIZE;
>>> +	unsigned int agg_size_fac = max(PAGE_SIZE, rxr->rx_page_size) /
>>> +				    BNXT_RX_PAGE_SIZE;
>> 
>> Hmm, shouldn't the denominator be rxr->rx_page_size rather than
>> BNXT_RX_PAGE_SIZE?
>> 
>
> Ummm, yes, you are right :) With rx_page_size as the denominator,
> agg_size_fac is the number of buffers per page pool allocation, which
> is what f7dbedba6312 intended. I think the proper fix is below:
>
>
> From f52ae7fc048695de1fdf5cb3282a90036e4eca5e Mon Sep 17 00:00:00 2001
> From: Usama Arif <usama.arif@linux.dev>
> Date: Mon, 23 Nov 2026 17:24:04 -0800
> Subject: [PATCH] eth: bnxt: fix the agg page pool recycle ring size
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> Commit f7dbedba6312 ("eth: bnxt: take page size into account for page
> pool recycling rings") sized the recycle ring of the agg page pool in
> pages, dividing the agg ring size by the number of agg buffers per page.
> Commit c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues
> with larger buffers") changed the divisor to rx_page_size /
> BNXT_RX_PAGE_SIZE, which is wrong in two cases:
>
> - On 64K-page kernels rx_page_size can only be 32K, so the divisor is
>   1, although each 64K page holds two agg buffers. With 1024 RX
>   descriptors the agg ring posts 2048 buffers in 1024 pages, while the
>   recycle ring can cache 2048 pages, or 128 MiB per RX queue.
>
> - When a memory provider sets rx_page_size above PAGE_SIZE, each buffer
>   is its own allocation and the fill level is already divided by
>   rx_page_size / BNXT_RX_PAGE_SIZE. Dividing again gives a 4K kernel
>   with 16K buffers a 256-entry ring for 1024 posted buffers.
>
> Divide the fill level by the number of buffers per allocation,
> max(PAGE_SIZE, rx_page_size) / rx_page_size. Nothing changes for
> kernels with pages of 32K or less that use the default buffer size.
>
> On a 64K arm64 host with a BCM57508 (32 queues, 1024 RX descriptors), a
> TCP receiver that drained its sockets every 1.5 s left about 1.8 GiB
> less memory in the agg page pools after the fix, 64 MiB per busy queue.
>
> Fixes: c55bf90a2112 ("eth: bnxt: adjust the fill level of agg queues with larger buffers")
> Suggested-by: Björn Töpel <bjorn@kernel.org>
> Signed-off-by: Usama Arif <usama.arif@linux.dev>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 52606db3f7b4a8..85ce4b2e297ecb 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -3948,7 +3948,8 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp,
>  				   struct bnxt_rx_ring_info *rxr,
>  				   int numa_node)
>  {
> -	unsigned int agg_size_fac = rxr->rx_page_size / BNXT_RX_PAGE_SIZE;
> +	unsigned int agg_size_fac = max(PAGE_SIZE, rxr->rx_page_size) /
> +				    rxr->rx_page_size;
>  	const unsigned int rx_size_fac = PAGE_SIZE / SZ_4K;
>  	struct page_pool_params pp = { 0 };
>  	struct page_pool *pool;
> -- 
> 2.53.1-Meta
>
>
>
>
>> bnxt_rx_agg_ring_fill_level() already accounts for larger RX buffers, so
>> using the default buffer size here seems to account for the override
>> twice.
>> 
>
> Ack
>
>> IIUC, the purpose of agg_size_fac is to convert the number of posted RX
>> buffers into the number of recyclable backing allocations.
>> 
>> E.g. an iouring 16K override would result in a smaller (too small?)
>> pool.
>> 
>> This patch had me thinking; The default agg pool buffer size is 32K on
>> 64K systems. That's quite a step up from the default 4K on 4K systems.
>> 8x more RX buffer memory as an effect of using a system with larger
>> pages... maybe there's a need for a system knob? That's pretty wasteful,
>> unless the workload is really HWGRO friendly.
>> 
>
> Letting rx-buf-len go below 32K on 64K kernels would be one way to do
> it maybe? Although I guess that is something for net-next and not a fix.

Yeah, this was mostly me thinking out loud! :-)

Thanks for doing the change! The patch above looks good, feel free to
add:

Reviewed-by: Björn Töpel <bjorn@kernel.org>


Cheers,
Björn

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-26 17:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 16:29 [PATCH] eth: bnxt: fix the agg page pool ring size on 64K-page kernels Usama Arif
2026-11-26 10:49 ` Björn Töpel
2026-11-26 15:16   ` Usama Arif
2026-11-26 17:28     ` Björn Töpel
2026-11-26 16:57 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox