Skip to contentSkip to conversation

net: stmmac: Fix page pool size

PATCH In review Thierry Reding 3 participants 3 messages Sep 20, 2019 – Sep 23, 2019

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

PATCH 1/1 net: stmmac: Fix page pool size

From: Thierry Reding <[email protected]>

The size of individual pages in the page pool in given by an order. The order is the binary logarithm of the number of pages that make up one of the pages in the pool. However, the driver currently passes the number of pages rather than the order, so it ends up wasting quite a bit of memory.

Fix this by taking the binary logarithm and passing that in the order field.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -1
index ecd461207dbc..f8c90dba6db8 100644
@@ -1550,13 +1550,15 @@ static int alloc_dma_rx_desc_resources(struct stmmac_priv *priv)
 	for (queue = 0; queue < rx_count; queue++) {
 		struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue];
 		struct page_pool_params pp_params = { 0 };
+		unsigned int num_pages;
 
 		rx_q->queue_index = queue;
 		rx_q->priv_data = priv;
 
 		pp_params.flags = PP_FLAG_DMA_MAP;
 		pp_params.pool_size = DMA_RX_SIZE;
-		pp_params.order = DIV_ROUND_UP(priv->dma_buf_sz, PAGE_SIZE);
+		num_pages = DIV_ROUND_UP(priv->dma_buf_sz, PAGE_SIZE);
+		pp_params.order = ilog2(num_pages);
 		pp_params.nid = dev_to_node(priv->device);
 		pp_params.dev = priv->device;
 		pp_params.dma_dir = DMA_FROM_DEVICE;
Signature · 1 line
2.23.0
#1 lore raw
Quoted 8 lines · Thierry Reding

From: Thierry Reding <[email protected]>

The size of individual pages in the page pool in given by an order. The order is the binary logarithm of the number of pages that make up one of the pages in the pool. However, the driver currently passes the number of pages rather than the order, so it ends up wasting quite a bit of memory.

Quoted 4 lines

Fix this by taking the binary logarithm and passing that in the order field.

Since this is a fix could we get a Fixes tag pointing to the commit which introduced the regression?

#2 lore raw

From: Jakub Kicinski <[email protected]>
Date: Sep/22/2019, 23:31:32 (UTC+00:00)

Quoted 9 lines · Thierry Reding
Quoted 8 lines

From: Thierry Reding <[email protected]>

The size of individual pages in the page pool in given by an order. The order is the binary logarithm of the number of pages that make up one of the pages in the pool. However, the driver currently passes the number of pages rather than the order, so it ends up wasting quite a bit of memory.

Quoted 7 lines
Quoted 4 lines

Fix this by taking the binary logarithm and passing that in the order field.

Since this is a fix could we get a Fixes tag pointing to the commit which introduced the regression?

This would be:

2af6106ae949 ("net: stmmac: Introducing support for Page Pool")

Can you please resubmit Thierry ?

---
Thanks,
Jose Miguel Abreu