From patchwork Mon Dec 21 14:23:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joyce Kong X-Patchwork-Id: 85604 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C2917A09EF; Mon, 21 Dec 2020 15:25:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 77ED0CB7B; Mon, 21 Dec 2020 15:23:59 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 2012ECC64 for ; Mon, 21 Dec 2020 15:23:58 +0100 (CET) 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 8F4CA1042; Mon, 21 Dec 2020 06:23:56 -0800 (PST) Received: from net-arm-thunderx2-03.shanghai.arm.com (net-arm-thunderx2-03.shanghai.arm.com [10.169.208.206]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6B2603F6CF; Mon, 21 Dec 2020 06:23:54 -0800 (PST) From: Joyce Kong To: maxime.coquelin@redhat.com, chenbo.xia@intel.com, honnappa.nagarahalli@arm.com, ruifeng.wang@arm.com Cc: dev@dpdk.org, nd@arm.com Date: Mon, 21 Dec 2020 22:23:21 +0800 Message-Id: <20201221142321.51606-5-joyce.kong@arm.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201221142321.51606-1-joyce.kong@arm.com> References: <20201221142321.51606-1-joyce.kong@arm.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 4/4] net/virtio: replace full barrier with thread fence 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" Replace the smp barriers with atomic thread fence for synchronization between different threads, if there are no load/store operations. Signed-off-by: Joyce Kong Reviewed-by: Ruifeng Wang Reviewed-by: Maxime Coquelin --- drivers/net/virtio/virtqueue.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h index ac3d9e750..d78b94344 100644 --- a/drivers/net/virtio/virtqueue.h +++ b/drivers/net/virtio/virtqueue.h @@ -26,7 +26,7 @@ struct rte_mbuf; /* * Per virtio_ring.h in Linux. * For virtio_pci on SMP, we don't need to order with respect to MMIO - * accesses through relaxed memory I/O windows, so smp_mb() et al are + * accesses through relaxed memory I/O windows, so thread_fence is * sufficient. * * For using virtio to talk to real devices (eg. vDPA) we do need real @@ -36,7 +36,7 @@ static inline void virtio_mb(uint8_t weak_barriers) { if (weak_barriers) - rte_smp_mb(); + rte_atomic_thread_fence(__ATOMIC_SEQ_CST); else rte_mb(); } @@ -45,7 +45,7 @@ static inline void virtio_rmb(uint8_t weak_barriers) { if (weak_barriers) - rte_smp_rmb(); + rte_atomic_thread_fence(__ATOMIC_ACQUIRE); else rte_io_rmb(); } @@ -54,7 +54,7 @@ static inline void virtio_wmb(uint8_t weak_barriers) { if (weak_barriers) - rte_smp_wmb(); + rte_atomic_thread_fence(__ATOMIC_RELEASE); else rte_io_wmb(); }