From patchwork Thu Mar 23 22:53:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125479 X-Patchwork-Delegate: david.marchand@redhat.com 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 595A642829; Thu, 23 Mar 2023 23:54:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A751542BFE; Thu, 23 Mar 2023 23:54:05 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 135EC4161A for ; Thu, 23 Mar 2023 23:54:00 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 3639320DEE39; Thu, 23 Mar 2023 15:53:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3639320DEE39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679612039; bh=tCa8X8S2f7jr678edWumHUvXPnyNRvkAJjw63wFt/VM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gadU7qfNL+DLjsEQzuPjpid1yK+IC/WGOm5UJRAVQKiRZaBHFir8o4d1u4mJzz4wa vadyZSBnCmzuuMegV1TmrIuJ2jpL2qQs1HLjh34tyh8UNQfC73dkb4d7w21ptxgbqD 0C8/wDG8FJiD6Omp2c2jJFzZisZhOiQvAcuZ1gJw= 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 v3 1/7] ring: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:53:50 -0700 Message-Id: <1679612036-30773-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679612036-30773-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679612036-30773-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..caa4c74 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:53:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125476 X-Patchwork-Delegate: david.marchand@redhat.com 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 6BAFF42829; Thu, 23 Mar 2023 23:54:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6EAB842686; Thu, 23 Mar 2023 23:54:02 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id EFE6140E09 for ; Thu, 23 Mar 2023 23:53:59 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 42CC120DEE3C; Thu, 23 Mar 2023 15:53:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 42CC120DEE3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679612039; bh=6++jzcy8PD8ElIlK93GYIyTWbn7BOT+8q2OTno2Kwds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oipmwRJa5Bd11nZogKB1TIxigAbPjm5mnm6Axztf0VDVGoCV4C8qJ/KLVP13PKPb+ dSLvEMKcHU2uMi18BYqmDQW26ZTO0ZkD4UvdNRdHr3+zfRPGzXghVqyEkMbn2ygqdF 9gcz2VTpg19KGLMq2w7/kz7Y4DvpnuY7JxN6vC9w= 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 v3 2/7] stack: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:53:51 -0700 Message-Id: <1679612036-30773-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679612036-30773-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679612036-30773-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..aad3747 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:53:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125477 X-Patchwork-Delegate: david.marchand@redhat.com 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 348A642829; Thu, 23 Mar 2023 23:54:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 71EE042B7E; Thu, 23 Mar 2023 23:54:03 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 054A64111C for ; Thu, 23 Mar 2023 23:53:59 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4ED5C20DEE45; Thu, 23 Mar 2023 15:53:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4ED5C20DEE45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679612039; bh=NzBmBBZ/5eE2h1wW5gmRrb2SHkhASTAXtcRNqJqtAOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ou/mxvXyuGvLmZSxYOtKZDv2P7yH76qy4PpedwFUyfB469epvaMYToap7zerKo9GV XeYlj4Wilvv7ebIyc0RS1wNFE3PX5EUqjFYWaIGi03ZrJGwW0hBBUGu0fnNPzHNoiR ybyBufK4gW0KdTlD0+xRBl4VcmaHG3vMyLyA2leo= 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 v3 3/7] dma/idxd: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:53:52 -0700 Message-Id: <1679612036-30773-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679612036-30773-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679612036-30773-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 Acked-by: Bruce Richardson Acked-by: Kevin Laatz --- 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..2de5d15 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:53:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125478 X-Patchwork-Delegate: david.marchand@redhat.com 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 9464442829; Thu, 23 Mar 2023 23:54:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8565F42670; Thu, 23 Mar 2023 23:54:04 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 08EF14114A for ; Thu, 23 Mar 2023 23:54:00 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 5B2A620DEE46; Thu, 23 Mar 2023 15:53:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5B2A620DEE46 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679612039; bh=QRQp/7AmseXnU3gQ9yG89pTwOXrz40wAK2qMcapE9s8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OmxEpbeqksuAABsjqlM9qtRuL39QS0WsaeUasw/JE09BZy3j5pgqMk5BnKl3ZC6Ky 8skaKOwChqJ0sq1i7rMhlCSaCr0ktwzEFJxT6oORS8kMujLCz3h1cwH//lvZSJYfzP 49YZzjJLbcAWoG7bnXlmkL4E5qeqTkkO46b9aDjs= 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 v3 4/7] net/ice: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:53:53 -0700 Message-Id: <1679612036-30773-5-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679612036-30773-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679612036-30773-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..a04fca8 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:53:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125482 X-Patchwork-Delegate: david.marchand@redhat.com 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 08B2742829; Thu, 23 Mar 2023 23:54:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D6D742D17; Thu, 23 Mar 2023 23:54:09 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id A1CD440E09 for ; Thu, 23 Mar 2023 23:54:00 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 67560208AC32; Thu, 23 Mar 2023 15:53:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 67560208AC32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679612039; bh=7YLe4VW0nZOm+WEy7Xm1aAU3iV1lNOLvDTA3l8Tyu04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U97KSl/qJuBUriae2Lt6lqWOgpEA+6gwLf5bEDaHpopV35JkF5UDtDSekLqFG1sKb SsD7znmKCRgTaGlSSSgsgSYlbxZBycvdmC6vdxE+G3d38VIOsdirGlitIErtTAttqP hWVJ4n7S3FZOItYemrbAaVJ7kel22zAeYDzQjvqM= 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 v3 5/7] net/ixgbe: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:53:54 -0700 Message-Id: <1679612036-30773-6-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679612036-30773-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679612036-30773-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..4bb85af 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:53:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125481 X-Patchwork-Delegate: david.marchand@redhat.com 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 2DD2C42829; Thu, 23 Mar 2023 23:54:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5C2442D13; Thu, 23 Mar 2023 23:54:07 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id A1B4440689 for ; Thu, 23 Mar 2023 23:54:00 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 73C1820E99CB; Thu, 23 Mar 2023 15:53:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 73C1820E99CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679612039; bh=J7i4DqZbDv5sne8urNPPLLcaOyNSlZIsnoYHc5HJ2jI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P+zMQBLfzfHP1OAohZrXDolFGotuPs6mvvpkEeall5wQ4sqSaV9PTuBvpPgD2xotd tDwWepqM/i2ETdB2EbcS04cuKmMjmJ/83Z6dSqwOBoa95iEh6yQnBKS8aisrx1tal0 O3KlIPbOzLR5hgE/uig9cGPT+26QfA59jGHlxgc4= 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 v3 6/7] net/null: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:53:55 -0700 Message-Id: <1679612036-30773-7-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679612036-30773-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679612036-30773-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..31081af 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:53:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125480 X-Patchwork-Delegate: david.marchand@redhat.com 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 5FA5B42829; Thu, 23 Mar 2023 23:54:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BEFD342C76; Thu, 23 Mar 2023 23:54:06 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id C0F5A4111C for ; Thu, 23 Mar 2023 23:54:00 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 8040820E9BEE; Thu, 23 Mar 2023 15:53:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8040820E9BEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679612039; bh=KViDwAAR+l7xoRWYf8oX82sY9+JCWiLFIblEfVFWy+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pF8d3CREwjO/dSJ5O3KLL76VjrDxFx5YvrGwGNOK3fPmjcdLrCldMNKjH+M6w85wg FROisZu+/8qGwYwo3UWJZ6o1EMazC+XhQIwOQyd43Bg+/8qPd9xhgbIbSKzy2izu6/ l9LhOMkpoK7OEPuYaajFf7uboQzKiH28F5nX8MpU= 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 v3 7/7] net/ring: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:53:56 -0700 Message-Id: <1679612036-30773-8-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679612036-30773-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679612036-30773-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 Acked-by: Bruce Richardson --- 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..43eb627 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; }