netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: Fix page pool size
@ 2019-09-20 17:01 Thierry Reding
  2019-09-22 22:31 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Thierry Reding @ 2019-09-20 17:01 UTC (permalink / raw)
  To: David S . Miller
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Florian Fainelli, Jon Hunter, Bitan Biswas, netdev, linux-tegra

From: Thierry Reding <treding@nvidia.com>

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.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index ecd461207dbc..f8c90dba6db8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -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;
-- 
2.23.0


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

* Re: [PATCH] net: stmmac: Fix page pool size
  2019-09-20 17:01 [PATCH] net: stmmac: Fix page pool size Thierry Reding
@ 2019-09-22 22:31 ` Jakub Kicinski
  2019-09-23  8:09   ` Jose Abreu
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2019-09-22 22:31 UTC (permalink / raw)
  To: Thierry Reding
  Cc: David S . Miller, Giuseppe Cavallaro, Alexandre Torgue,
	Jose Abreu, Florian Fainelli, Jon Hunter, Bitan Biswas, netdev,
	linux-tegra

On Fri, 20 Sep 2019 19:01:27 +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> 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.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>

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

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

* RE: [PATCH] net: stmmac: Fix page pool size
  2019-09-22 22:31 ` Jakub Kicinski
@ 2019-09-23  8:09   ` Jose Abreu
  0 siblings, 0 replies; 3+ messages in thread
From: Jose Abreu @ 2019-09-23  8:09 UTC (permalink / raw)
  To: Jakub Kicinski, Thierry Reding
  Cc: David S . Miller, Giuseppe Cavallaro, Alexandre Torgue,
	Florian Fainelli, Jon Hunter, Bitan Biswas, netdev, linux-tegra

From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Sep/22/2019, 23:31:32 (UTC+00:00)

> On Fri, 20 Sep 2019 19:01:27 +0200, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > 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.
> > 
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> 
> 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

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

end of thread, other threads:[~2019-09-23  8:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20 17:01 [PATCH] net: stmmac: Fix page pool size Thierry Reding
2019-09-22 22:31 ` Jakub Kicinski
2019-09-23  8:09   ` Jose Abreu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).