]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
page_pool: Clamp pool size to max 16K pages
authorDragos Tatulea <dtatulea@nvidia.com>
Fri, 26 Sep 2025 13:16:05 +0000 (16:16 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Dec 2025 11:45:14 +0000 (12:45 +0100)
[ Upstream commit a1b501a8c6a87c9265fd03bd004035199e2e8128 ]

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/1758532715-820422-3-git-send-email-tariqt@nvidia.com/

Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20250926131605.2276734-2-dtatulea@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/core/page_pool.c

index dbe0489e4603518df62199c538cc498b80aec6a6..305e348e1d7b3c3b90d6d72d471820cb0ef45202 100644 (file)
@@ -33,11 +33,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,