[dpdk-dev] [PATCH v2 8/8] net/memif: move the barrier outside the loop

Honnappa Nagarahalli honnappa.nagarahalli at arm.com
Mon Sep 28 21:03:34 CEST 2020


load-acquire memory order has a barrier. Loading it inside
the loop will result in a barrier in every iteration. Hence,
load the variable once outside the loop.

Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli at arm.com>
Reviewed-by: Phil Yang <phil.yang at arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang at arm.com>
---
 drivers/net/memif/rte_eth_memif.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index 704350022..c73cde8fd 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -249,16 +249,17 @@ memif_get_buffer(struct pmd_process_private *proc_private, memif_desc_t *d)
 static void
 memif_free_stored_mbufs(struct pmd_process_private *proc_private, struct memif_queue *mq)
 {
+	uint16_t cur_tail;
 	uint16_t mask = (1 << mq->log2_ring_size) - 1;
 	memif_ring_t *ring = memif_get_ring_from_queue(proc_private, mq);
 
 	/* FIXME: improve performance */
 	/* The ring->tail acts as a guard variable between Tx and Rx
 	 * threads, so using load-acquire pairs with store-release
-	 * to synchronize it between threads.
+	 * in function eth_memif_rx for S2M queues.
 	 */
-	while (mq->last_tail != __atomic_load_n(&ring->tail,
-						__ATOMIC_ACQUIRE)) {
+	cur_tail = __atomic_load_n(&ring->tail, __ATOMIC_ACQUIRE);
+	while (mq->last_tail != cur_tail) {
 		RTE_MBUF_PREFETCH_TO_FREE(mq->buffers[(mq->last_tail + 1) & mask]);
 		/* Decrement refcnt and free mbuf. (current segment) */
 		rte_mbuf_refcnt_update(mq->buffers[mq->last_tail & mask], -1);
-- 
2.17.1



More information about the dev mailing list