diff mbox series

[v2,7/8] net/memif: relax the load of ring head pointer for S2M zc ring

Message ID 20200928190334.40624-7-honnappa.nagarahalli@arm.com
State New
Headers show
Series [v2,1/8] net/memif: do not update local copy of tail in tx function | expand

Commit Message

Honnappa Nagarahalli Sept. 28, 2020, 7:03 p.m. UTC
For zero-copy S2M rings, ring->head is updated by the sender and
eth_memif_tx_zc function is called in the context of sending thread.
The loads in the sender do not need to synchronize with its own stores.

Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

Reviewed-by: Phil Yang <phil.yang@arm.com>

Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>

---
 drivers/net/memif/rte_eth_memif.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index 9babd073a..704350022 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -752,11 +752,13 @@  eth_memif_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	memif_free_stored_mbufs(proc_private, mq);
 
 	/* ring type always MEMIF_RING_S2M */
-	/* The ring->head acts as a guard variable between Tx and Rx
-	 * threads, so using load-acquire pairs with store-release
-	 * to synchronize it between threads.
+	/* For S2M queues ring->head is updated by the sender and
+	 * this function is called in the context of sending thread.
+	 * The loads in the sender do not need to synchronize with
+	 * its own stores. Hence, the following load can be a
+	 * relaxed load.
 	 */
-	slot = __atomic_load_n(&ring->head, __ATOMIC_ACQUIRE);
+	slot = __atomic_load_n(&ring->head, __ATOMIC_RELAXED);
 	n_free = ring_size - slot + mq->last_tail;
 
 	int used_slots;
@@ -812,6 +814,10 @@  eth_memif_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 no_free_slots:
 	/* ring type always MEMIF_RING_S2M */
+	/* The ring->head acts as a guard variable between Tx and Rx
+	 * threads, so using store-release pairs with load-acquire
+	 * in function eth_memif_rx for S2M rings.
+	 */
 	__atomic_store_n(&ring->head, slot, __ATOMIC_RELEASE);
 
 	/* Send interrupt, if enabled. */