]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
eth: bnxt: take page size into account for page pool recycling rings
authorJakub Kicinski <kuba@kernel.org>
Thu, 26 Jun 2025 16:54:41 +0000 (09:54 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Aug 2025 16:41:14 +0000 (18:41 +0200)
[ Upstream commit f7dbedba63124256feb9d9fcf36e8a2e43858d1e ]

The Rx rings are filled with Rx buffers. Which are supposed to fit
packet headers (or MTU if HW-GRO is disabled). The aggregation buffers
are filled with "device pages". Adjust the sizes of the page pool
recycling ring appropriately, based on ratio of the size of the
buffer on given ring vs system page size. Otherwise on a system
with 64kB pages we end up with >700MB of memory sitting in every
single page pool cache.

Correct the size calculation for the head_pool. Since the buffers
there are always small I'm pretty sure I meant to cap the size
at 1k, rather than make it the lowest possible size. With 64k pages
1k cache with a 1k ring is 64x larger than we need.

Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20250626165441.4125047-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index e165490af6ac4c64967dd3620239fbe634ac37b1..25681c2343fb461c77963cf01409b7dd5d8dae6c 100644 (file)
@@ -3809,12 +3809,14 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp,
                                   struct bnxt_rx_ring_info *rxr,
                                   int numa_node)
 {
+       const unsigned int agg_size_fac = 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;
 
-       pp.pool_size = bp->rx_agg_ring_size;
+       pp.pool_size = bp->rx_agg_ring_size / agg_size_fac;
        if (BNXT_RX_PAGE_MODE(bp))
-               pp.pool_size += bp->rx_ring_size;
+               pp.pool_size += bp->rx_ring_size / rx_size_fac;
        pp.nid = numa_node;
        pp.netdev = bp->dev;
        pp.dev = &bp->pdev->dev;
@@ -3831,7 +3833,7 @@ static int bnxt_alloc_rx_page_pool(struct bnxt *bp,
 
        rxr->need_head_pool = page_pool_is_unreadable(pool);
        if (bnxt_separate_head_pool(rxr)) {
-               pp.pool_size = max(bp->rx_ring_size, 1024);
+               pp.pool_size = min(bp->rx_ring_size / rx_size_fac, 1024);
                pp.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV;
                pool = page_pool_create(&pp);
                if (IS_ERR(pool))