Skip to contentSkip to conversation

page_pool: Clamp pool size to max 16K pages

PATCH Applied Dragos Tatulea 3 participants 3 messages Sep 26, 2025 – Sep 30, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 page_pool: Clamp pool size to max 16K pages

page_pool_init() returns E2BIG when the page_pool size goes above 32K pages. As some drivers are configuring the page_pool size according to the MTU and ring size, there are cases where this limit is exceeded and the queue creation fails.

The page_pool size doesn't have to cover a full queue, especially for larger ring size. So clamp the size instead of returning an error. Do this in the core to avoid having each driver do the clamping.

The current limit was deemed to high [1] so it was reduced to 16K to avoid page waste.

[1] https://lore.kernel.org/all/[email protected]/

---
Changes since v1 [1]:
- Switched to clamping in page_pool. (Jakub)
- Reduced 32K -> 16K limit. (Jakub)
- Dropped mlx5 patch. (Jakub)

[1] https://lore.kernel.org/all/[email protected]/

---
 net/core/page_pool.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
net/core/page_pool.c +1 -5
index ba70569bd4b0..054a1c38e698 100644
@@ -211,11 +211,7 @@ static int page_pool_init(struct page_pool *pool,
 		return -EINVAL;
 
 	if (pool->p.pool_size)
-		ring_qsize = pool->p.pool_size;
-
-	/* Sanity limit mem that can be pinned down */
-	if (ring_qsize > 32768)
-		return -E2BIG;
+		ring_qsize = min(pool->p.pool_size, 16384);
 
 	/* DMA direction is either DMA_FROM_DEVICE or DMA_BIDIRECTIONAL.
 	 * DMA_BIDIRECTIONAL is for allowing page used for DMA sending,
Signature · 1 line
2.50.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 14 lines · Dragos Tatulea

page_pool_init() returns E2BIG when the page_pool size goes above 32K pages. As some drivers are configuring the page_pool size according to the MTU and ring size, there are cases where this limit is exceeded and the queue creation fails.

The page_pool size doesn't have to cover a full queue, especially for larger ring size. So clamp the size instead of returning an error. Do this in the core to avoid having each driver do the clamping.

The current limit was deemed to high [1] so it was reduced to 16K to avoid page waste.

[1] https://lore.kernel.org/all/[email protected]/

Quoted 8 lines

---
Changes since v1 [1]:
- Switched to clamping in page_pool. (Jakub)
- Reduced 32K -> 16K limit. (Jakub)
- Dropped mlx5 patch. (Jakub)

[1] https://lore.kernel.org/all/[email protected]/

#2 lore raw
In reply to Dragos Tatulea
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Fri, 26 Sep 2025 16:16:05 +0300 you wrote:

page_pool_init() returns E2BIG when the page_pool size goes above 32K pages. As some drivers are configuring the page_pool size according to the MTU and ring size, there are cases where this limit is exceeded and the queue creation fails.

The page_pool size doesn't have to cover a full queue, especially for larger ring size. So clamp the size instead of returning an error. Do this in the core to avoid having each driver do the clamping.

[...]

Here is the summary with links:
- [net-next,v2] page_pool: Clamp pool size to max 16K pages

    https://git.kernel.org/netdev/net-next/c/a1b501a8c6a8

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html