From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 64989A04DB; Mon, 28 Sep 2020 21:06:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3D8741D66B; Mon, 28 Sep 2020 21:04:20 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 072D31D5D8 for ; Mon, 28 Sep 2020 21:04:10 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 770E5113E; Mon, 28 Sep 2020 12:04:08 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.12.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 670073F70D; Mon, 28 Sep 2020 12:04:08 -0700 (PDT) From: Honnappa Nagarahalli To: dev@dpdk.org, honnappa.nagarahalli@arm.com, phil.yang@arm.com, jgrajcia@cisco.com, ferruh.yigit@intel.com Cc: nd@arm.com Date: Mon, 28 Sep 2020 14:03:34 -0500 Message-Id: <20200928190334.40624-8-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928190334.40624-1-honnappa.nagarahalli@arm.com> References: <20200921192254.20560-1-honnappa.nagarahalli@arm.com> <20200928190334.40624-1-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH v2 8/8] net/memif: move the barrier outside the loop X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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