Skip to contentSkip to conversation

net/memif: replace memcpy() with rte_memcpy() to improve perf

PATCH In review David Christensen 4 participants 6 messages Jun 23, 2021 – Jul 1, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/memif: replace memcpy() with rte_memcpy() to improve perf

Replacing memcpy() with rte_memcpy() improved 64 byte packet performance by 33% on a POWER9 system and by 10% on an x86_64 system.

---
 drivers/net/memif/rte_eth_memif.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/memif/rte_eth_memif.c +4 -3
index d17222c612..330c9c2fd6 100644
@@ -384,8 +384,8 @@ eth_memif_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 				rte_pktmbuf_pkt_len(mbuf_head) += cp_len;
 
 			rte_memcpy(rte_pktmbuf_mtod_offset(mbuf, void *, dst_off),
-			       (uint8_t *)memif_get_buffer(proc_private, d0) + src_off,
-			       cp_len);
+			       (uint8_t *)memif_get_buffer(proc_private, d0)
+			       + src_off, cp_len);
 
 			src_off += cp_len;
 			dst_off += cp_len;
@@ -644,7 +644,8 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			}
 			cp_len = RTE_MIN(dst_len, src_len);
 
-			rte_memcpy((uint8_t *)memif_get_buffer(proc_private, d0) + dst_off,
+			rte_memcpy((uint8_t *)
+			       memif_get_buffer(proc_private, d0) + dst_off,
 			       rte_pktmbuf_mtod_offset(mbuf, void *, src_off),
 			       cp_len);
 
Signature · 1 line
2.27.0
#1 lore raw
Quoted 3 lines · On Wed, 23 Jun 2021 09:49:35 -0700 David Christensen <[email protected]>…

Replacing memcpy() with rte_memcpy() improved 64 byte packet performance by 33% on a POWER9 system and by 10% on an x86_64 system.

I see rte_memcpy was already used in the patch diff

Quoted 10 lines
---
 drivers/net/memif/rte_eth_memif.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/memif/rte_eth_memif.c +0 -0
index d17222c612..330c9c2fd6 100644

drivers/net/memif/rte_eth_memif.c eth_memif_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 388

Quoted 7 lines
drivers/net/memif/rte_eth_memif.c +2 -2
@@ -384,8 +384,8 @@ eth_memif_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 				rte_pktmbuf_pkt_len(mbuf_head) += cp_len;
 
 			rte_memcpy(rte_pktmbuf_mtod_offset(mbuf, void *, dst_off),
-			       (uint8_t *)memif_get_buffer(proc_private, d0) + src_off,
-			       cp_len);
+			       (uint8_t *)memif_get_buffer(proc_private, d0)
+			       + src_off, cp_len);

This just changes line break for no good reason.

drivers/net/memif/rte_eth_memif.c eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 651

Quoted 13 lines
drivers/net/memif/rte_eth_memif.c +2 -1
 			src_off += cp_len;
 			dst_off += cp_len;
@@ -644,7 +644,8 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			}
 			cp_len = RTE_MIN(dst_len, src_len);
 
-			rte_memcpy((uint8_t *)memif_get_buffer(proc_private, d0) + dst_off,
+			rte_memcpy((uint8_t *)
+			       memif_get_buffer(proc_private, d0) + dst_off,
 			       rte_pktmbuf_mtod_offset(mbuf, void *, src_off),
 			       cp_len);
 

ditto.

Look like this patch is confused, the description does not match the code.

#3 lore raw

PATCH 1/1 net/memif: replace memcpy() with rte_memcpy() to improve perf

In reply to David Christensen

Replacing memcpy() with rte_memcpy() improved 64 byte packet performance by 33% on a POWER9 system and by 10% on an x86_64 system.

---
v2: Fixed last patch which was bungled due to a bad local git squash

 drivers/net/memif/rte_eth_memif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/memif/rte_eth_memif.c +2 -2
index da7195783f..d17222c612 100644
@@ -383,7 +383,7 @@ eth_memif_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			if (mbuf != mbuf_head)
 				rte_pktmbuf_pkt_len(mbuf_head) += cp_len;
 
-			memcpy(rte_pktmbuf_mtod_offset(mbuf, void *, dst_off),
+			rte_memcpy(rte_pktmbuf_mtod_offset(mbuf, void *, dst_off),
 			       (uint8_t *)memif_get_buffer(proc_private, d0) + src_off,
 			       cp_len);
 
@@ -644,7 +644,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			}
 			cp_len = RTE_MIN(dst_len, src_len);
 
-			memcpy((uint8_t *)memif_get_buffer(proc_private, d0) + dst_off,
+			rte_memcpy((uint8_t *)memif_get_buffer(proc_private, d0) + dst_off,
 			       rte_pktmbuf_mtod_offset(mbuf, void *, src_off),
 			       cp_len);
 

--
2.27.0

#2 lore raw
In reply to Stephen Hemminger
Quoted 44 lines · Stephen Hemminger
Quoted 3 lines · On Wed, 23 Jun 2021 09:49:35 -0700 David Christensen <[email protected]>…

Replacing memcpy() with rte_memcpy() improved 64 byte packet performance by 33% on a POWER9 system and by 10% on an x86_64 system.

I see rte_memcpy was already used in the patch diff

Quoted 10 lines
---
 drivers/net/memif/rte_eth_memif.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/memif/rte_eth_memif.c +0 -0
index d17222c612..330c9c2fd6 100644

drivers/net/memif/rte_eth_memif.c eth_memif_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 388

Quoted 7 lines
drivers/net/memif/rte_eth_memif.c +2 -2
@@ -384,8 +384,8 @@ eth_memif_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 				rte_pktmbuf_pkt_len(mbuf_head) += cp_len;
 
 			rte_memcpy(rte_pktmbuf_mtod_offset(mbuf, void *, dst_off),
-			       (uint8_t *)memif_get_buffer(proc_private, d0) + src_off,
-			       cp_len);
+			       (uint8_t *)memif_get_buffer(proc_private, d0)
+			       + src_off, cp_len);

This just changes line break for no good reason.

drivers/net/memif/rte_eth_memif.c eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 651

Quoted 13 lines
drivers/net/memif/rte_eth_memif.c +2 -1
 			src_off += cp_len;
 			dst_off += cp_len;
@@ -644,7 +644,8 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			}
 			cp_len = RTE_MIN(dst_len, src_len);
 
-			rte_memcpy((uint8_t *)memif_get_buffer(proc_private, d0) + dst_off,
+			rte_memcpy((uint8_t *)
+			       memif_get_buffer(proc_private, d0) + dst_off,
 			       rte_pktmbuf_mtod_offset(mbuf, void *, src_off),
 			       cp_len);
 

ditto.

Quoted 2 lines

Look like this patch is confused, the description does not match the code.

I guess it was a patch on top of [1]. Marking this one as rejected since I've applied style fixes before applying it.

[1]
https://patches.dpdk.org/project/dpdk/patch/[email protected]/