Skip to contentSkip to conversation

net/af_xdp: use single-prod-and-cons ring

PATCH Applied Xiao Wang 4 participants 4 messages Jan 8, 2020 – Jan 14, 2020 Network drivers

lore
Share & tools
lore

Xiao Wang

author
#0 lore raw

PATCH 1/1 net/af_xdp: use single-prod-and-cons ring

The ring is used only by af_xdp pmd itself, so no need to support multi-producer and multi-consumer mode. This patch changes the ring to single-producer and single-consumer mode, which could yield better performance for addr enqueue and dequeue.

---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +1 -1
index d903e6c28..683e2a559 100644
@@ -809,7 +809,7 @@ xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals,
 	umem->buf_ring = rte_ring_create(ring_name,
 					 ETH_AF_XDP_NUM_BUFFERS,
 					 rte_socket_id(),
-					 0x0);
+					 RING_F_SP_ENQ | RING_F_SC_DEQ);
 	if (umem->buf_ring == NULL) {
 		AF_XDP_LOG(ERR, "Failed to create rte_ring\n");
 		goto err;
Signature · 1 line
2.15.1
Tested-by on v1 1/1
#1 lore raw
Quoted 7 lines

The ring is used only by af_xdp pmd itself, so no need to support multi-producer and multi-consumer mode. This patch changes the ring to single-producer and single-consumer mode, which could yield better performance for addr enqueue and dequeue.

LGTM.

I ran some rough numbers and measured a +~6.8% improvement for single-core single-pmd testpmd loopback (IRQs pinned to app core) and +~15.9% for two core (IRQs and app pinned to separate cores).

Thanks,
Ciara

Quoted 22 lines
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +1 -1
index d903e6c28..683e2a559 100644
@@ -809,7 +809,7 @@ xsk_umem_info *xdp_umem_configure(struct
 pmd_internals *internals,
 	umem->buf_ring = rte_ring_create(ring_name,
 					 ETH_AF_XDP_NUM_BUFFERS,
 					 rte_socket_id(),
-					 0x0);
+					 RING_F_SP_ENQ |
 RING_F_SC_DEQ);
 	if (umem->buf_ring == NULL) {
drivers/net/af_xdp/rte_eth_af_xdp.c +0 -1
 		AF_XDP_LOG(ERR, "Failed to create rte_ring\n");
 		goto err;
--

2.15.1

Acked-by on v1 1/1
#2 lore raw
In reply to Xiao Wang
Quoted 26 lines · Xiao Wang

The ring is used only by af_xdp pmd itself, so no need to support multi-producer and multi-consumer mode. This patch changes the ring to single-producer and single-consumer mode, which could yield better performance for addr enqueue and dequeue.

---
drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +1 -1
index d903e6c28..683e2a559 100644
@@ -809,7 +809,7 @@ xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals,
 	umem->buf_ring = rte_ring_create(ring_name,
 					 ETH_AF_XDP_NUM_BUFFERS,
 					 rte_socket_id(),
-					 0x0);
+					 RING_F_SP_ENQ | RING_F_SC_DEQ);
 	if (umem->buf_ring == NULL) {
 		AF_XDP_LOG(ERR, "Failed to create rte_ring\n");
 		goto err;
Signature · 1 line
2.15.1
Applied
#3 lore raw
Quoted 21 lines · Ye Xiaolong
Quoted 20 lines · Xiao Wang

The ring is used only by af_xdp pmd itself, so no need to support multi-producer and multi-consumer mode. This patch changes the ring to single-producer and single-consumer mode, which could yield better performance for addr enqueue and dequeue.

---
drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +1 -1
index d903e6c28..683e2a559 100644
@@ -809,7 +809,7 @@ xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals,
 	umem->buf_ring = rte_ring_create(ring_name,
 					 ETH_AF_XDP_NUM_BUFFERS,
 					 rte_socket_id(),
-					 0x0);
+					 RING_F_SP_ENQ | RING_F_SC_DEQ);
Quoted 9 lines
Quoted 6 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +0 -0
 	if (umem->buf_ring == NULL) {
 		AF_XDP_LOG(ERR, "Failed to create rte_ring\n");
 		goto err;
Signature · 1 line
2.15.1

Applied to dpdk-next-net/master, thanks.