From: Honnappa Nagarahalli Date: Mon, 28 Sep 2020 19:03:34 +0000 (-0500) Subject: net/memif: move barrier outside loop X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=9ef7dc22f24c949a815beab54c83b2e85759d94b;p=dpdk.git net/memif: move barrier outside loop 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 Reviewed-by: Phil Yang Reviewed-by: Ruifeng Wang Reviewed-by: Jakub Grajciar --- diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index 68f3e602c8..03e0b662b1 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);