From patchwork Thu Mar 23 22:34:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125467 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7AF342829; Thu, 23 Mar 2023 23:34:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E4F64161A; Thu, 23 Mar 2023 23:34:44 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8AC5540E09 for ; Thu, 23 Mar 2023 23:34:43 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id DA92220DEE39; Thu, 23 Mar 2023 15:34:42 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DA92220DEE39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679610882; bh=QDZ173vXnv0+sWe7FNjO42Kygh5EkFKz+2z4o/ZJHgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iLeZw7BChEpgzqNlKGQbVOxRjMH+nzOfpfrBUyzpULwmtQ/bAgTdWPZEJVSx3T45t +obNAZDyxJhL4dyooc2HA2zIzzajELr5G468Ez+EOcfkXlmzY6M0B5hniT+YMGxqSq ERYeTfc3th1twKwWRgcwPurIIDnu1f6Zr2vO00II= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, stephen@networkplumber.org, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH v2 1/7] ring: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:34:35 -0700 Message-Id: <1679610881-25997-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace the use of rte_atomic.h types and functions, instead use GCC supplied C++11 memory model builtins. Signed-off-by: Tyler Retzlaff --- lib/ring/rte_ring_core.h | 1 - lib/ring/rte_ring_generic_pvt.h | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/ring/rte_ring_core.h b/lib/ring/rte_ring_core.h index 82b2370..b9c7860 100644 --- a/lib/ring/rte_ring_core.h +++ b/lib/ring/rte_ring_core.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/ring/rte_ring_generic_pvt.h b/lib/ring/rte_ring_generic_pvt.h index 5acb6e5..c284040 100644 --- a/lib/ring/rte_ring_generic_pvt.h +++ b/lib/ring/rte_ring_generic_pvt.h @@ -92,8 +92,10 @@ if (is_sp) r->prod.head = *new_head, success = 1; else - success = rte_atomic32_cmpset(&r->prod.head, - *old_head, *new_head); + // NOTE: review for potential ordering optimization + success = __atomic_compare_exchange_n(&r->prod.head, + old_head, *new_head, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } while (unlikely(success == 0)); return n; } @@ -162,8 +164,10 @@ rte_smp_rmb(); success = 1; } else { - success = rte_atomic32_cmpset(&r->cons.head, *old_head, - *new_head); + // NOTE: review for potential ordering optimization + success = __atomic_compare_exchange_n(&r->cons.head, + old_head, *new_head, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } } while (unlikely(success == 0)); return n; From patchwork Thu Mar 23 22:34:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125469 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 80ACC42829; Thu, 23 Mar 2023 23:34:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A32BE42B7E; Thu, 23 Mar 2023 23:34:46 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id A17394111C for ; Thu, 23 Mar 2023 23:34:43 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id E6E0320DEE3C; Thu, 23 Mar 2023 15:34:42 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E6E0320DEE3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679610882; bh=TqXnesmaBxjdKF6DG3ykxoKllgcb0eTh9BOuIYQigRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tAVahbcTl2viIr1gR8RZ9NdovKqW2H8SkGU1gpehK5MLPlrJVgmWNMGrAMM1Ew+bu k4vpDSlw86W164enCSj+a6dxptA1ustV/Rhs4g0HoAXCuZ/y6DLHMGG/Fujorm2erI h7RYEQV9pHddeHB74bw+ecaH4u59wuuDDVwrztMo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, stephen@networkplumber.org, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH v2 2/7] stack: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:34:36 -0700 Message-Id: <1679610881-25997-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace the use of rte_atomic.h types and functions, instead use GCC supplied C++11 memory model builtins. Signed-off-by: Tyler Retzlaff --- lib/stack/rte_stack_lf_generic.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/stack/rte_stack_lf_generic.h b/lib/stack/rte_stack_lf_generic.h index 7fa29ce..ffed2bf 100644 --- a/lib/stack/rte_stack_lf_generic.h +++ b/lib/stack/rte_stack_lf_generic.h @@ -26,8 +26,8 @@ * elements. If the mempool is near-empty to the point that this is a * concern, the user should consider increasing the mempool size. */ - return (unsigned int)rte_atomic64_read((rte_atomic64_t *) - &s->stack_lf.used.len); + // NOTE: review for potential ordering optimization + return __atomic_load_n(&s->stack_lf.used.len, __ATOMIC_SEQ_CST); } static __rte_always_inline void @@ -67,8 +67,8 @@ 1, __ATOMIC_RELEASE, __ATOMIC_RELAXED); } while (success == 0); - - rte_atomic64_add((rte_atomic64_t *)&list->len, num); + // NOTE: review for potential ordering optimization + __atomic_fetch_add(&list->len, num, __ATOMIC_SEQ_CST); } static __rte_always_inline struct rte_stack_lf_elem * @@ -82,14 +82,16 @@ /* Reserve num elements, if available */ while (1) { - uint64_t len = rte_atomic64_read((rte_atomic64_t *)&list->len); + // NOTE: review for potential ordering optimization + uint64_t len = __atomic_load_n(&list->len, __ATOMIC_SEQ_CST); /* Does the list contain enough elements? */ if (unlikely(len < num)) return NULL; - if (rte_atomic64_cmpset((volatile uint64_t *)&list->len, - len, len - num)) + // NOTE: review for potential ordering optimization + if (__atomic_compare_exchange_n(&list->len, &len, len - num, + 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) break; } From patchwork Thu Mar 23 22:34:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125470 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0D22F4280D; Thu, 23 Mar 2023 23:35:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DF80342BC9; Thu, 23 Mar 2023 23:34:47 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id AD9924114A for ; Thu, 23 Mar 2023 23:34:43 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id F369F20DEE45; Thu, 23 Mar 2023 15:34:42 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com F369F20DEE45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679610883; bh=o6ZZC5bffHHNKK0QYPFCV1co9ql5yoVol/qPfM8ZGFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B1oYogunj0bFygr8v/xl7ZK5Uu/qtNwviAPkBv6M17IrVYbX7ru2ClcTEYI9f6zUz f41mv1eaTI0dZeQDAvsAxQyxa3h5hgzKP6wMKwjtbG7zQBmoNjd6KVEwxs1e41XDUR wjjZ6B7NpWT9WzUDBMG00wpCTH77olILAcuz2mUk= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, stephen@networkplumber.org, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH v2 3/7] dma/idxd: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:34:37 -0700 Message-Id: <1679610881-25997-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace the use of rte_atomic.h types and functions, instead use GCC supplied C++11 memory model builtins. Signed-off-by: Tyler Retzlaff --- drivers/dma/idxd/idxd_internal.h | 3 +-- drivers/dma/idxd/idxd_pci.c | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/dma/idxd/idxd_internal.h b/drivers/dma/idxd/idxd_internal.h index 180a858..cd41777 100644 --- a/drivers/dma/idxd/idxd_internal.h +++ b/drivers/dma/idxd/idxd_internal.h @@ -7,7 +7,6 @@ #include #include -#include #include "idxd_hw_defs.h" @@ -34,7 +33,7 @@ struct idxd_pci_common { rte_spinlock_t lk; uint8_t wq_cfg_sz; - rte_atomic16_t ref_count; + uint16_t ref_count; volatile struct rte_idxd_bar0 *regs; volatile uint32_t *wq_regs_base; volatile struct rte_idxd_grpcfg *grp_regs; diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c index 781fa02..89cce1d 100644 --- a/drivers/dma/idxd/idxd_pci.c +++ b/drivers/dma/idxd/idxd_pci.c @@ -6,7 +6,6 @@ #include #include #include -#include #include "idxd_internal.h" @@ -136,7 +135,9 @@ /* if this is the last WQ on the device, disable the device and free * the PCI struct */ - is_last_wq = rte_atomic16_dec_and_test(&idxd->u.pci->ref_count); + // NOTE: review for potential ordering optimization + is_last_wq = __atomic_fetch_sub(&idxd->u.pci->ref_count, 1, + __ATOMIC_SEQ_CST) - 1 == 0; if (is_last_wq) { /* disable the device */ err_code = idxd_pci_dev_command(idxd, idxd_disable_dev); @@ -350,7 +351,8 @@ free(idxd.u.pci); return ret; } - rte_atomic16_inc(&idxd.u.pci->ref_count); + // NOTE: review for potential ordering optimization + __atomic_fetch_add(&idxd.u.pci->ref_count, 1, __ATOMIC_SEQ_CST); } return 0; From patchwork Thu Mar 23 22:34:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125471 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 288164280D; Thu, 23 Mar 2023 23:35:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0980342C54; Thu, 23 Mar 2023 23:34:49 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id B0DFF4161A for ; Thu, 23 Mar 2023 23:34:43 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 0C81B20DEE46; Thu, 23 Mar 2023 15:34:42 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0C81B20DEE46 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679610883; bh=NZUoL5B2q5Grwd+P/y25x3Mjz5Wjc8owPOQWGiUp0oY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Exr55Rerz14BP9FUcl+khRYPAapmkKbHud0tZ+E+yMkdi18VnvZmQ9TusR3sxfL66 85PekWXzldHuF2duWpeo4OOctpB9jNI1mtExz8VK58nJEh/GGC/pPcCYuw4CUCUsLS QslL0Vrty5fm6V7Sk+fyTS3DW8U5DxDpl9kSUiy8= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, stephen@networkplumber.org, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH v2 4/7] net/ice: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:34:38 -0700 Message-Id: <1679610881-25997-5-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace the use of rte_atomic.h types and functions, instead use GCC supplied C++11 memory model builtins. Signed-off-by: Tyler Retzlaff --- drivers/net/ice/ice_dcf.c | 1 - drivers/net/ice/ice_dcf_ethdev.c | 1 - drivers/net/ice/ice_ethdev.c | 12 ++++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c index 1c3d22a..80d2cbd 100644 --- a/drivers/net/ice/ice_dcf.c +++ b/drivers/net/ice/ice_dcf.c @@ -14,7 +14,6 @@ #include #include -#include #include #include #include diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index dcbf2af..13ff245 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 9a88cf9..5608f6a 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -3927,8 +3927,10 @@ static int ice_init_rss(struct ice_pf *pf) struct rte_eth_link *dst = link; struct rte_eth_link *src = &dev->data->dev_link; - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) + // NOTE: review for potential ordering optimization + if (!__atomic_compare_exchange_n((uint64_t *)dst, + (uint64_t *)dst, *(uint64_t *)src, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) return -1; return 0; @@ -3941,8 +3943,10 @@ static int ice_init_rss(struct ice_pf *pf) struct rte_eth_link *dst = &dev->data->dev_link; struct rte_eth_link *src = link; - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) + // NOTE: review for potential ordering optimization + if (!__atomic_compare_exchange_n((uint64_t *)dst, + (uint64_t *)dst, *(uint64_t *)src, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) return -1; return 0; From patchwork Thu Mar 23 22:34:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125472 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B0014280D; Thu, 23 Mar 2023 23:35:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A6B942D0E; Thu, 23 Mar 2023 23:34:50 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 4CAF540689 for ; Thu, 23 Mar 2023 23:34:44 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 19F4120E99CB; Thu, 23 Mar 2023 15:34:42 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 19F4120E99CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679610883; bh=8sFZdnAp9Cch9BFmthu2aOK0kRrABoXYXDzHTiURWkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SUSVDwVCo7ls+lL7iqxuXbDqKIwldA02jjvCx0qrX95E4BQxC8Xhxsw1dp1imeu3J LauhWtoofcBcu+feP9faPx2aWzKtLOFfJ23myUCAtSln4OAX3k7326BBXcsw2S/xWZ 5Zj538NRFRdURBnZuuaGn80Yv+c/RE0qxsyXHDgc= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, stephen@networkplumber.org, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH v2 5/7] net/ixgbe: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:34:39 -0700 Message-Id: <1679610881-25997-6-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace the use of rte_atomic.h types and functions, instead use GCC supplied C++11 memory model builtins. Signed-off-by: Tyler Retzlaff --- drivers/net/ixgbe/ixgbe_bypass.c | 1 - drivers/net/ixgbe/ixgbe_ethdev.c | 18 ++++++++++++------ drivers/net/ixgbe/ixgbe_ethdev.h | 3 ++- drivers/net/ixgbe/ixgbe_flow.c | 1 - drivers/net/ixgbe/ixgbe_rxtx.c | 1 - 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_bypass.c b/drivers/net/ixgbe/ixgbe_bypass.c index 94f34a2..f615d18 100644 --- a/drivers/net/ixgbe/ixgbe_bypass.c +++ b/drivers/net/ixgbe/ixgbe_bypass.c @@ -3,7 +3,6 @@ */ #include -#include #include #include "ixgbe_ethdev.h" #include "ixgbe_bypass_api.h" diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 88118bc..2d575f5 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -1127,7 +1127,8 @@ struct rte_ixgbe_xstats_name_off { return 0; } - rte_atomic32_clear(&ad->link_thread_running); + // NOTE: review for potential ordering optimization + __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST); ixgbe_parse_devargs(eth_dev->data->dev_private, pci_dev->device.devargs); rte_eth_copy_pci_info(eth_dev, pci_dev); @@ -1625,7 +1626,8 @@ static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev) return 0; } - rte_atomic32_clear(&ad->link_thread_running); + // NOTE: review for potential ordering optimization + __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST); ixgbevf_parse_devargs(eth_dev->data->dev_private, pci_dev->device.devargs); @@ -4186,7 +4188,8 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, struct ixgbe_adapter *ad = dev->data->dev_private; uint32_t timeout = timeout_ms ? timeout_ms : WARNING_TIMEOUT; - while (rte_atomic32_read(&ad->link_thread_running)) { + // NOTE: review for potential ordering optimization + while (__atomic_load_n(&ad->link_thread_running, __ATOMIC_SEQ_CST)) { msec_delay(1); timeout--; @@ -4222,7 +4225,8 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, ixgbe_setup_link(hw, speed, true); intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; - rte_atomic32_clear(&ad->link_thread_running); + // NOTE: review for potential ordering optimization + __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST); return NULL; } @@ -4317,7 +4321,8 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, if (link_up == 0) { if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) { ixgbe_dev_wait_setup_link_complete(dev, 0); - if (rte_atomic32_test_and_set(&ad->link_thread_running)) { + // NOTE: review for potential ordering optimization + if (__atomic_test_and_set(&ad->link_thread_running, __ATOMIC_SEQ_CST)) { /* To avoid race condition between threads, set * the IXGBE_FLAG_NEED_LINK_CONFIG flag only * when there is no link thread running. @@ -4330,7 +4335,8 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, dev) < 0) { PMD_DRV_LOG(ERR, "Create link thread failed!"); - rte_atomic32_clear(&ad->link_thread_running); + // NOTE: review for potential ordering optimization + __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST); } } else { PMD_DRV_LOG(ERR, diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index 48290af..2ca6998 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -6,6 +6,7 @@ #define _IXGBE_ETHDEV_H_ #include +#include #include #include "base/ixgbe_type.h" @@ -510,7 +511,7 @@ struct ixgbe_adapter { */ uint8_t pflink_fullchk; uint8_t mac_ctrl_frame_fwd; - rte_atomic32_t link_thread_running; + bool link_thread_running; pthread_t link_thread_tid; }; diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index eac81ee..687341c 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index c9d6ca9..8d7251d 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include From patchwork Thu Mar 23 22:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125474 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CE9634280D; Thu, 23 Mar 2023 23:35:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7472842D2D; Thu, 23 Mar 2023 23:34:52 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 7CF3240E09 for ; Thu, 23 Mar 2023 23:34:44 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 267AB20E9BEE; Thu, 23 Mar 2023 15:34:42 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 267AB20E9BEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679610883; bh=ZT6l0o+ssAGv2zFHrbpg7Va8iMBklMOM7tV6qMhChYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PZwtIHCNUQrNq9zqhcQpcOiXLRw8uP0z9CyrVOmNY/ruZZ8uwz3+0HDTUxaRmKRAI aBs8vWd4VNwXu1f/0xfmBn5GGlikPVyC6gMCakVLS+zQLtHCuDka3nuEJZLpf7tJhe K77qrc/00Llkb1ACMz8+w5HGBJtu40X/j7Pn4EKc= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, stephen@networkplumber.org, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH v2 6/7] net/null: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:34:40 -0700 Message-Id: <1679610881-25997-7-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace the use of rte_atomic.h types and functions, instead use GCC supplied C++11 memory model builtins. Signed-off-by: Tyler Retzlaff --- drivers/net/null/rte_eth_null.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 47d9554..6a115f8 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -37,8 +37,8 @@ struct null_queue { struct rte_mempool *mb_pool; struct rte_mbuf *dummy_packet; - rte_atomic64_t rx_pkts; - rte_atomic64_t tx_pkts; + uint64_t rx_pkts; + uint64_t tx_pkts; }; struct pmd_options { @@ -101,7 +101,8 @@ struct pmd_internals { bufs[i]->port = h->internals->port_id; } - rte_atomic64_add(&(h->rx_pkts), i); + // NOTE: review for potential ordering optimization + __atomic_fetch_add(&h->rx_pkts, i, __ATOMIC_SEQ_CST); return i; } @@ -128,7 +129,8 @@ struct pmd_internals { bufs[i]->port = h->internals->port_id; } - rte_atomic64_add(&(h->rx_pkts), i); + // NOTE: review for potential ordering optimization + __atomic_fetch_add(&h->rx_pkts, i, __ATOMIC_SEQ_CST); return i; } @@ -152,7 +154,8 @@ struct pmd_internals { for (i = 0; i < nb_bufs; i++) rte_pktmbuf_free(bufs[i]); - rte_atomic64_add(&(h->tx_pkts), i); + // NOTE: review for potential ordering optimization + __atomic_fetch_add(&h->tx_pkts, i, __ATOMIC_SEQ_CST); return i; } @@ -174,7 +177,8 @@ struct pmd_internals { rte_pktmbuf_free(bufs[i]); } - rte_atomic64_add(&(h->tx_pkts), i); + // NOTE: review for potential ordering optimization + __atomic_fetch_add(&h->tx_pkts, i, __ATOMIC_SEQ_CST); return i; } @@ -316,8 +320,9 @@ struct pmd_internals { RTE_MIN(dev->data->nb_rx_queues, RTE_DIM(internal->rx_null_queues))); for (i = 0; i < num_stats; i++) { + // NOTE: review for atomic access igb_stats->q_ipackets[i] = - internal->rx_null_queues[i].rx_pkts.cnt; + internal->rx_null_queues[i].rx_pkts; rx_total += igb_stats->q_ipackets[i]; } @@ -325,8 +330,9 @@ struct pmd_internals { RTE_MIN(dev->data->nb_tx_queues, RTE_DIM(internal->tx_null_queues))); for (i = 0; i < num_stats; i++) { + // NOTE: review for atomic access igb_stats->q_opackets[i] = - internal->tx_null_queues[i].tx_pkts.cnt; + internal->tx_null_queues[i].tx_pkts; tx_total += igb_stats->q_opackets[i]; } @@ -347,9 +353,11 @@ struct pmd_internals { internal = dev->data->dev_private; for (i = 0; i < RTE_DIM(internal->rx_null_queues); i++) - internal->rx_null_queues[i].rx_pkts.cnt = 0; + // NOTE: review for atomic access + internal->rx_null_queues[i].rx_pkts = 0; for (i = 0; i < RTE_DIM(internal->tx_null_queues); i++) - internal->tx_null_queues[i].tx_pkts.cnt = 0; + // NOTE: review for atomic access + internal->tx_null_queues[i].tx_pkts = 0; return 0; } From patchwork Thu Mar 23 22:34:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125473 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3B0AF4280D; Thu, 23 Mar 2023 23:35:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D50E42D1A; Thu, 23 Mar 2023 23:34:51 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 7F1474111C for ; Thu, 23 Mar 2023 23:34:44 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 32F2020E9F9E; Thu, 23 Mar 2023 15:34:43 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 32F2020E9F9E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679610883; bh=smVolcQzad/WEOm3idwUe+y2tDRssjCa8Da1AcKGZm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HpOyUehyALfsoj+zx3Oesg+3H8ncmguqm71OtKwHEuCsB8/DPsDUUg7mmYLJlAs23 xkiLS8IYKd1pTKWCCBTQOxdwg0UU552woBcIYL+Qh0guV57R4KCZS5y/R8LoezZ8TC 0MqMweyqFt9Log9nkGRGgXQh3js1ECnc1UVRY7kA= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, stephen@networkplumber.org, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH v2 7/7] net/ring: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:34:41 -0700 Message-Id: <1679610881-25997-8-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace the use of rte_atomic.h types and functions, instead use GCC supplied C++11 memory model builtins. Signed-off-by: Tyler Retzlaff --- drivers/net/ring/rte_eth_ring.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index e8bc9b6..fb7f0a0 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -44,8 +44,8 @@ enum dev_action { struct ring_queue { struct rte_ring *rng; - rte_atomic64_t rx_pkts; - rte_atomic64_t tx_pkts; + uint64_t rx_pkts; + uint64_t tx_pkts; }; struct pmd_internals { @@ -80,9 +80,10 @@ struct pmd_internals { const uint16_t nb_rx = (uint16_t)rte_ring_dequeue_burst(r->rng, ptrs, nb_bufs, NULL); if (r->rng->flags & RING_F_SC_DEQ) - r->rx_pkts.cnt += nb_rx; + r->rx_pkts += nb_rx; else - rte_atomic64_add(&(r->rx_pkts), nb_rx); + // NOTE: review for potential ordering optimization + __atomic_fetch_add(&r->rx_pkts, nb_rx, __ATOMIC_SEQ_CST); return nb_rx; } @@ -94,9 +95,10 @@ struct pmd_internals { const uint16_t nb_tx = (uint16_t)rte_ring_enqueue_burst(r->rng, ptrs, nb_bufs, NULL); if (r->rng->flags & RING_F_SP_ENQ) - r->tx_pkts.cnt += nb_tx; + r->tx_pkts += nb_tx; else - rte_atomic64_add(&(r->tx_pkts), nb_tx); + // NOTE: review for potential ordering optimization + __atomic_fetch_add(&r->tx_pkts, nb_tx, __ATOMIC_SEQ_CST); return nb_tx; } @@ -184,13 +186,15 @@ struct pmd_internals { for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < dev->data->nb_rx_queues; i++) { - stats->q_ipackets[i] = internal->rx_ring_queues[i].rx_pkts.cnt; + // NOTE: review for atomic access + stats->q_ipackets[i] = internal->rx_ring_queues[i].rx_pkts; rx_total += stats->q_ipackets[i]; } for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < dev->data->nb_tx_queues; i++) { - stats->q_opackets[i] = internal->tx_ring_queues[i].tx_pkts.cnt; + // NOTE: review for atomic access + stats->q_opackets[i] = internal->tx_ring_queues[i].tx_pkts; tx_total += stats->q_opackets[i]; } @@ -207,9 +211,11 @@ struct pmd_internals { struct pmd_internals *internal = dev->data->dev_private; for (i = 0; i < dev->data->nb_rx_queues; i++) - internal->rx_ring_queues[i].rx_pkts.cnt = 0; + // NOTE: review for atomic access + internal->rx_ring_queues[i].rx_pkts = 0; for (i = 0; i < dev->data->nb_tx_queues; i++) - internal->tx_ring_queues[i].tx_pkts.cnt = 0; + // NOTE: review for atomic access + internal->tx_ring_queues[i].tx_pkts = 0; return 0; }