diff mbox series

[v2,8/8] net/memif: move the barrier outside the loop

Message ID 20200928190334.40624-8-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
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@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 | 7 ++++---
 1 file changed, 4 insertions(+), 3 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 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);