linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/3] mvpp2 improvements in rx path
@ 2019-10-24 17:24 Matteo Croce
  2019-10-24 17:24 ` [PATCH net-next v2 1/3] mvpp2: refactor frame drop routine Matteo Croce
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Matteo Croce @ 2019-10-24 17:24 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Antoine Tenart, Maxime Chevallier,
	Marcin Wojtas, Stefan Chulski, linux-kernel

Refactor some code in the RX path to allow prefetching some data from the
packet header. The first patch is only a refactor, the second one
reduces the data synced, while the third one adds the prefetch.

The packet rate improvement with the second patch is very small (1606 => 1620 kpps),
while the prefetch bumps it up by 14%: 1620 => 1853 kpps.

Matteo Croce (3):
  mvpp2: refactor frame drop routine
  mvpp2: sync only by the frame size
  mvpp2: prefetch frame header

 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   | 27 ++++++++++++-------
 1 file changed, 17 insertions(+), 10 deletions(-)

-- 
2.21.0


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

* [PATCH net-next v2 1/3] mvpp2: refactor frame drop routine
  2019-10-24 17:24 [PATCH net-next v2 0/3] mvpp2 improvements in rx path Matteo Croce
@ 2019-10-24 17:24 ` Matteo Croce
  2019-10-24 17:24 ` [PATCH net-next v2 2/3] mvpp2: sync only the received frame Matteo Croce
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Matteo Croce @ 2019-10-24 17:24 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Antoine Tenart, Maxime Chevallier,
	Marcin Wojtas, Stefan Chulski, linux-kernel

Move some code down to remove a backward goto.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 111b3b8239e1..33f327447b70 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -2957,14 +2957,8 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
 		 * by the hardware, and the information about the buffer is
 		 * comprised by the RX descriptor.
 		 */
-		if (rx_status & MVPP2_RXD_ERR_SUMMARY) {
-err_drop_frame:
-			dev->stats.rx_errors++;
-			mvpp2_rx_error(port, rx_desc);
-			/* Return the buffer to the pool */
-			mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
-			continue;
-		}
+		if (rx_status & MVPP2_RXD_ERR_SUMMARY)
+			goto err_drop_frame;
 
 		if (bm_pool->frag_size > PAGE_SIZE)
 			frag_size = 0;
@@ -2995,6 +2989,13 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
 		mvpp2_rx_csum(port, rx_status, skb);
 
 		napi_gro_receive(napi, skb);
+		continue;
+
+err_drop_frame:
+		dev->stats.rx_errors++;
+		mvpp2_rx_error(port, rx_desc);
+		/* Return the buffer to the pool */
+		mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
 	}
 
 	if (rcvd_pkts) {
-- 
2.21.0


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

* [PATCH net-next v2 2/3] mvpp2: sync only the received frame
  2019-10-24 17:24 [PATCH net-next v2 0/3] mvpp2 improvements in rx path Matteo Croce
  2019-10-24 17:24 ` [PATCH net-next v2 1/3] mvpp2: refactor frame drop routine Matteo Croce
@ 2019-10-24 17:24 ` Matteo Croce
  2019-10-24 17:24 ` [PATCH net-next v2 3/3] mvpp2: prefetch frame header Matteo Croce
  2019-10-28 20:54 ` [PATCH net-next v2 0/3] mvpp2 improvements in rx path David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Matteo Croce @ 2019-10-24 17:24 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Antoine Tenart, Maxime Chevallier,
	Marcin Wojtas, Stefan Chulski, linux-kernel

In the RX path we always sync against the maximum frame size for that pool.
Do the DMA sync and the unmap separately, so we can only sync by the
size of the received frame.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 33f327447b70..15818e1d6b04 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -2960,6 +2960,10 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
 		if (rx_status & MVPP2_RXD_ERR_SUMMARY)
 			goto err_drop_frame;
 
+		dma_sync_single_for_cpu(dev->dev.parent, dma_addr,
+					rx_bytes + MVPP2_MH_SIZE,
+					DMA_FROM_DEVICE);
+
 		if (bm_pool->frag_size > PAGE_SIZE)
 			frag_size = 0;
 		else
@@ -2977,8 +2981,9 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
 			goto err_drop_frame;
 		}
 
-		dma_unmap_single(dev->dev.parent, dma_addr,
-				 bm_pool->buf_size, DMA_FROM_DEVICE);
+		dma_unmap_single_attrs(dev->dev.parent, dma_addr,
+				       bm_pool->buf_size, DMA_FROM_DEVICE,
+				       DMA_ATTR_SKIP_CPU_SYNC);
 
 		rcvd_pkts++;
 		rcvd_bytes += rx_bytes;
-- 
2.21.0


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

* [PATCH net-next v2 3/3] mvpp2: prefetch frame header
  2019-10-24 17:24 [PATCH net-next v2 0/3] mvpp2 improvements in rx path Matteo Croce
  2019-10-24 17:24 ` [PATCH net-next v2 1/3] mvpp2: refactor frame drop routine Matteo Croce
  2019-10-24 17:24 ` [PATCH net-next v2 2/3] mvpp2: sync only the received frame Matteo Croce
@ 2019-10-24 17:24 ` Matteo Croce
  2019-10-28 20:54 ` [PATCH net-next v2 0/3] mvpp2 improvements in rx path David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Matteo Croce @ 2019-10-24 17:24 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Antoine Tenart, Maxime Chevallier,
	Marcin Wojtas, Stefan Chulski, linux-kernel

When receiving traffic, eth_type_trans() is high up on the perf top list,
because it's the first function which access the packet data.

Move the DMA unmap a bit higher, and put a prefetch just after it, so we
have more time to load the data into the cache.

The packet rate increase is about 14% with a tc drop test: 1620 => 1853 kpps

Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 15818e1d6b04..a55de943d5cb 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -2963,6 +2963,7 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
 		dma_sync_single_for_cpu(dev->dev.parent, dma_addr,
 					rx_bytes + MVPP2_MH_SIZE,
 					DMA_FROM_DEVICE);
+		prefetch(data);
 
 		if (bm_pool->frag_size > PAGE_SIZE)
 			frag_size = 0;
-- 
2.21.0


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

* Re: [PATCH net-next v2 0/3] mvpp2 improvements in rx path
  2019-10-24 17:24 [PATCH net-next v2 0/3] mvpp2 improvements in rx path Matteo Croce
                   ` (2 preceding siblings ...)
  2019-10-24 17:24 ` [PATCH net-next v2 3/3] mvpp2: prefetch frame header Matteo Croce
@ 2019-10-28 20:54 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2019-10-28 20:54 UTC (permalink / raw)
  To: mcroce
  Cc: netdev, antoine.tenart, maxime.chevallier, mw, stefanc, linux-kernel

From: Matteo Croce <mcroce@redhat.com>
Date: Thu, 24 Oct 2019 19:24:55 +0200

> Refactor some code in the RX path to allow prefetching some data from the
> packet header. The first patch is only a refactor, the second one
> reduces the data synced, while the third one adds the prefetch.
> 
> The packet rate improvement with the second patch is very small (1606 => 1620 kpps),
> while the prefetch bumps it up by 14%: 1620 => 1853 kpps.

Series applied to net-next, thanks Matteo.

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

end of thread, other threads:[~2019-10-28 20:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24 17:24 [PATCH net-next v2 0/3] mvpp2 improvements in rx path Matteo Croce
2019-10-24 17:24 ` [PATCH net-next v2 1/3] mvpp2: refactor frame drop routine Matteo Croce
2019-10-24 17:24 ` [PATCH net-next v2 2/3] mvpp2: sync only the received frame Matteo Croce
2019-10-24 17:24 ` [PATCH net-next v2 3/3] mvpp2: prefetch frame header Matteo Croce
2019-10-28 20:54 ` [PATCH net-next v2 0/3] mvpp2 improvements in rx path David Miller

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).