From patchwork Fri Mar 10 22:15:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125017 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 297B141E6D; Fri, 10 Mar 2023 23:15:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0DEBA410D0; Fri, 10 Mar 2023 23:15:39 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 4874640A8B for ; Fri, 10 Mar 2023 23:15:36 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 880E52044724; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 880E52044724 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486535; bh=/5fy6oguua1WWLt4XN1PV1IHB4hKoXJ1bnogRG4odm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qfrjaPpXsBj7XmZXBTaeM0hD2jIP6jObUtV4dv+WDZb3JiCVaXSaMLafIy3p7/ZM/ 5agU6ewqB8ZswZqHe/DslYnCoBJ9jcpDi3srEHOeLlyBHrqeQTE1wGdgbQnxFDhRm1 dp4Eg/yK1UNcYH7gI3EhPzYIDKsMPuP5Fgjx3lFo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 01/16] app/test: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:15 -0800 Message-Id: <1678486530-20688-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- app/test/test_ring_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c index 2d8bb67..3972fd9 100644 --- a/app/test/test_ring_perf.c +++ b/app/test/test_ring_perf.c @@ -186,7 +186,7 @@ struct thread_params { void *burst = NULL; #ifdef RTE_USE_C11_MEM_MODEL - if (__atomic_add_fetch(&lcore_count, 1, __ATOMIC_RELAXED) != 2) + if (__atomic_fetch_add(&lcore_count, 1, __ATOMIC_RELAXED) + 1 != 2) #else if (__sync_add_and_fetch(&lcore_count, 1) != 2) #endif From patchwork Fri Mar 10 22:15:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125016 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 2E7ED41E6D; Fri, 10 Mar 2023 23:15:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E89040A8B; Fri, 10 Mar 2023 23:15:38 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 424F140685 for ; Fri, 10 Mar 2023 23:15:36 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 94B3E2044726; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 94B3E2044726 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486535; bh=hi8YITqo1Uqxht/1HZMWpeLbSbs5ROLyhI26l6ovbtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BTZ1KOzFLGc5woGqxFkaiihdpgQz4nhB9Vq0AZz8NBglMElBcsB96rorHjpp/XS3f /KyDpbLDgmQg6nTmsDo77hBEmTeht7Bun2gwduVyHCg4EFNK6n15cR3G6vs7FjsREn UuSD2ETbwyTV4Sjy6Q7eobmrhH338G70yMEYyJuk= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 02/16] common/cnxk: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:16 -0800 Message-Id: <1678486530-20688-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- drivers/common/cnxk/roc_ae.c | 2 +- drivers/common/cnxk/roc_ae_fpm_tables.c | 2 +- drivers/common/cnxk/roc_npa.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/common/cnxk/roc_ae.c b/drivers/common/cnxk/roc_ae.c index 929da05..336b927 100644 --- a/drivers/common/cnxk/roc_ae.c +++ b/drivers/common/cnxk/roc_ae.c @@ -203,6 +203,6 @@ struct ae_ec_grp_tbl { ec_grp = mz->addr; /* Decrement number of devices using EC grp table */ - if (__atomic_sub_fetch(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) == 0) + if (__atomic_fetch_sub(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0) plt_memzone_free(mz); } diff --git a/drivers/common/cnxk/roc_ae_fpm_tables.c b/drivers/common/cnxk/roc_ae_fpm_tables.c index afb2a50..f915702 100644 --- a/drivers/common/cnxk/roc_ae_fpm_tables.c +++ b/drivers/common/cnxk/roc_ae_fpm_tables.c @@ -1135,6 +1135,6 @@ struct ae_fpm_tbl { fpm = (struct ae_fpm_tbl *)mz->addr; /* Decrement number of devices using FPM table */ - if (__atomic_sub_fetch(&fpm->refcount, 1, __ATOMIC_SEQ_CST) == 0) + if (__atomic_fetch_sub(&fpm->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0) plt_memzone_free(mz); } diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c index 69c3d8d..20637fb 100644 --- a/drivers/common/cnxk/roc_npa.c +++ b/drivers/common/cnxk/roc_npa.c @@ -946,7 +946,7 @@ return NPA_ERR_ALLOC; /* Not the last PCI device */ - if (__atomic_sub_fetch(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) != 0) + if (__atomic_fetch_sub(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) - 1 != 0) return 0; npa_unregister_irqs(idev->npa); From patchwork Fri Mar 10 22:15:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125020 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 A8DCE41E6D; Fri, 10 Mar 2023 23:16:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 51B8142B7E; Fri, 10 Mar 2023 23:15:42 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 58E4F40ED9 for ; Fri, 10 Mar 2023 23:15:36 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id A11432044728; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A11432044728 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486535; bh=AiPSJbJTqUPb8O0FYv4kyX/7isrZ/oFbFet8HdS1saE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hztNO+v8q6YFzUTrlLQhi8r36wivr38Y0k14oUgnDbk943h1cuuXup9/v2l8ASO3V hJ0QZi1uaF7eNl37RIE96LMvrhYsupPPc81lZJHya1chL+qdFtABXP3pmgPVAjG5t7 9i3yLZF7EFZHvKinJMfJ8/jEc0A3g1bSB8nHKjv8= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 03/16] common/mlx5: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:17 -0800 Message-Id: <1678486530-20688-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- drivers/common/mlx5/linux/mlx5_nl.c | 2 +- drivers/common/mlx5/mlx5_common_mr.c | 8 ++++---- drivers/common/mlx5/mlx5_common_utils.c | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c index 5d04857..33670bb 100644 --- a/drivers/common/mlx5/linux/mlx5_nl.c +++ b/drivers/common/mlx5/linux/mlx5_nl.c @@ -178,7 +178,7 @@ struct mlx5_nl_port_info { uint32_t atomic_sn; /* Generate Netlink sequence number. */ -#define MLX5_NL_SN_GENERATE __atomic_add_fetch(&atomic_sn, 1, __ATOMIC_RELAXED) +#define MLX5_NL_SN_GENERATE (__atomic_fetch_add(&atomic_sn, 1, __ATOMIC_RELAXED) + 1) /** * Opens a Netlink socket. diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c index 0e1d243..037a4d8 100644 --- a/drivers/common/mlx5/mlx5_common_mr.c +++ b/drivers/common/mlx5/mlx5_common_mr.c @@ -58,8 +58,8 @@ struct mlx5_mempool_reg { if (__atomic_load_n(&buf->refcnt, __ATOMIC_RELAXED) == 1) { rte_mempool_put(buf->mp, buf); - } else if (unlikely(__atomic_sub_fetch(&buf->refcnt, 1, - __ATOMIC_RELAXED) == 0)) { + } else if (unlikely(__atomic_fetch_sub(&buf->refcnt, 1, + __ATOMIC_RELAXED) - 1 == 0)) { __atomic_store_n(&buf->refcnt, 1, __ATOMIC_RELAXED); rte_mempool_put(buf->mp, buf); } @@ -1665,8 +1665,8 @@ struct mlx5_mempool_get_extmem_data { bool ret = false; for (i = 0; i < mpr->mrs_n; i++) - ret |= __atomic_sub_fetch(&mpr->mrs[i].refcnt, 1, - __ATOMIC_RELAXED) == 0; + ret |= __atomic_fetch_sub(&mpr->mrs[i].refcnt, 1, + __ATOMIC_RELAXED) - 1 == 0; return ret; } diff --git a/drivers/common/mlx5/mlx5_common_utils.c b/drivers/common/mlx5/mlx5_common_utils.c index 58d744b..06b5b9b 100644 --- a/drivers/common/mlx5/mlx5_common_utils.c +++ b/drivers/common/mlx5/mlx5_common_utils.c @@ -81,8 +81,8 @@ struct mlx5_list * while (entry != NULL) { if (l_const->cb_match(l_const->ctx, entry, ctx) == 0) { if (reuse) { - ret = __atomic_add_fetch(&entry->ref_cnt, 1, - __ATOMIC_RELAXED) - 1; + ret = __atomic_fetch_add(&entry->ref_cnt, 1, + __ATOMIC_RELAXED); DRV_LOG(DEBUG, "mlx5 list %s entry %p ref: %u.", l_const->name, (void *)entry, entry->ref_cnt); @@ -285,7 +285,7 @@ struct mlx5_list_entry * { struct mlx5_list_entry *gentry = entry->gentry; - if (__atomic_sub_fetch(&entry->ref_cnt, 1, __ATOMIC_RELAXED) != 0) + if (__atomic_fetch_sub(&entry->ref_cnt, 1, __ATOMIC_RELAXED) - 1 != 0) return 1; if (entry->lcore_idx == (uint32_t)lcore_idx) { LIST_REMOVE(entry, next); @@ -303,7 +303,7 @@ struct mlx5_list_entry * l_const->name, (void *)entry); return 0; } - if (__atomic_sub_fetch(&gentry->ref_cnt, 1, __ATOMIC_RELAXED) != 0) + if (__atomic_fetch_sub(&gentry->ref_cnt, 1, __ATOMIC_RELAXED) - 1 != 0) return 1; rte_rwlock_write_lock(&l_inconst->lock); if (likely(gentry->ref_cnt == 0)) { From patchwork Fri Mar 10 22:15:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125019 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 513FB41E6D; Fri, 10 Mar 2023 23:15:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 441AE427E9; Fri, 10 Mar 2023 23:15:41 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 6615940EE1 for ; Fri, 10 Mar 2023 23:15:36 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id AD0B9204472A; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com AD0B9204472A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486535; bh=otE2sixznrKBFR/1eJAbIy8PCfBvHB3ehXXuIJxC4v8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jcFTAnyfkpVvLOV11WvbUqDSdzSJGMKfuslfjPK39nSQ8EsbsGTwiZCffKMNl6/gY V2t06QAZdJnh9tseBikXhXnWUdP07WM7rckPD+rQtdL3ju9BQIfvZxwKe2UzMmotxH hDcNQ0AmlV3/A6YwLfClKV5wNOQjnfUHkAqaWBjk= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 04/16] drivers/event: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:18 -0800 Message-Id: <1678486530-20688-5-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff Acked-by: Pavan Nikhilesh --- drivers/event/cnxk/cnxk_tim_worker.h | 2 +- drivers/event/dsw/dsw_event.c | 4 ++-- drivers/event/octeontx/timvf_worker.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/event/cnxk/cnxk_tim_worker.h b/drivers/event/cnxk/cnxk_tim_worker.h index a326d55..0bd66ec 100644 --- a/drivers/event/cnxk/cnxk_tim_worker.h +++ b/drivers/event/cnxk/cnxk_tim_worker.h @@ -123,7 +123,7 @@ const uint64_t v = ~(TIM_BUCKET_W1_M_NUM_ENTRIES << TIM_BUCKET_W1_S_NUM_ENTRIES); - return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL); + return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) & v; } static inline uint64_t diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c index 9932caf..cbdc03f 100644 --- a/drivers/event/dsw/dsw_event.c +++ b/drivers/event/dsw/dsw_event.c @@ -45,8 +45,8 @@ * allocation. */ new_total_on_loan = - __atomic_add_fetch(&dsw->credits_on_loan, acquired_credits, - __ATOMIC_RELAXED); + __atomic_fetch_add(&dsw->credits_on_loan, acquired_credits, + __ATOMIC_RELAXED) + acquired_credits; if (unlikely(new_total_on_loan > dsw->max_inflight)) { /* Some other port took the last credits */ diff --git a/drivers/event/octeontx/timvf_worker.h b/drivers/event/octeontx/timvf_worker.h index 3f1e77f..aa729f8 100644 --- a/drivers/event/octeontx/timvf_worker.h +++ b/drivers/event/octeontx/timvf_worker.h @@ -135,7 +135,7 @@ { const uint64_t v = ~(TIM_BUCKET_W1_M_NUM_ENTRIES << TIM_BUCKET_W1_S_NUM_ENTRIES); - return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL); + return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) & v; } static inline struct tim_mem_entry * From patchwork Fri Mar 10 22:15:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125026 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 B604041E6D; Fri, 10 Mar 2023 23:16:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4166942D3A; Fri, 10 Mar 2023 23:15:49 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 2FC3C40FAE for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id B9F28204472C; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B9F28204472C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486535; bh=7cgDgrLgK/5Yqsswjcs4EDe6KihylHqpm+0X5wjp9x4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YiyXgNtjYZx+B2mw+HXJNnvKProMlsZkXtFv1KIEtzyf1edNWgKc7aTfGwWuJZsRP c1FDqjYVOCjITMfu8SjbHlwzymWzwBzJuX1/UINXYALRIzw1jq5JbrWy0e1JrR4k6M gGxEGOAw/qTYxg9ImFcRccuWwIx1bFQLrdlQKpaw= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 05/16] net/af_xdp: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:19 -0800 Message-Id: <1678486530-20688-6-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- drivers/net/af_xdp/rte_eth_af_xdp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index 2a20a69..c7786cc 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -979,7 +979,7 @@ static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags) break; xsk_socket__delete(rxq->xsk); - if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) + if (__atomic_fetch_sub(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) - 1 == 0) { (void)xsk_umem__delete(rxq->umem->umem); xdp_umem_destroy(rxq->umem); @@ -1710,7 +1710,7 @@ struct msg_internal { out_xsk: xsk_socket__delete(rxq->xsk); out_umem: - if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) == 0) + if (__atomic_fetch_sub(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) - 1 == 0) xdp_umem_destroy(rxq->umem); return ret; From patchwork Fri Mar 10 22:15:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125021 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 AEF5841E6D; Fri, 10 Mar 2023 23:16:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 66BF442C24; Fri, 10 Mar 2023 23:15:43 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 0A88340685 for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id C62F82044730; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C62F82044730 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486535; bh=HPmDdwWJgwj1Bjb/R8rMoKaO5aX76IFD9G/N8ykbgzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FeOEiBh6Yt68/gG9IOzIfISPHuS0zr+RemKUFUMliKTruf6BRCp98pLcRTmp6IX8c vOMp5ZFRfVaH1IyI/HgSPI0tcbe1Gd/TTVG8AgAARn+gOJxHHVJD3t8lD8fX7wv3k6 +ZOAuqKQoyicr2yrlYpJ35r3rkcAhUtgRk8LXHpQ= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 06/16] net/cnxk: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:20 -0800 Message-Id: <1678486530-20688-7-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff Acked-by: Nithin Dabilpuram --- drivers/net/cnxk/cn10k_tx.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/cnxk/cn10k_tx.h b/drivers/net/cnxk/cn10k_tx.h index a72a803..c9ec01c 100644 --- a/drivers/net/cnxk/cn10k_tx.h +++ b/drivers/net/cnxk/cn10k_tx.h @@ -108,7 +108,7 @@ retry: while (__atomic_load_n(&txq->fc_cache_pkts, __ATOMIC_RELAXED) < 0) ; - cached = __atomic_sub_fetch(&txq->fc_cache_pkts, req, __ATOMIC_ACQUIRE); + cached = __atomic_fetch_sub(&txq->fc_cache_pkts, req, __ATOMIC_ACQUIRE) - req; /* Check if there is enough space, else update and retry. */ if (cached < 0) { /* Check if we have space else retry. */ @@ -302,7 +302,7 @@ again: fc_sw = txq->cpt_fc_sw; - val = __atomic_sub_fetch(fc_sw, nb_pkts, __ATOMIC_RELAXED); + val = __atomic_fetch_sub(fc_sw, nb_pkts, __ATOMIC_RELAXED) - nb_pkts; if (likely(val >= 0)) return; From patchwork Fri Mar 10 22:15:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125025 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 B7E6241E6D; Fri, 10 Mar 2023 23:16:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5DF042D2D; Fri, 10 Mar 2023 23:15:47 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 2259640EE1 for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id D2AEF2044732; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D2AEF2044732 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486535; bh=7j7D8kUfuBK/jldRhy5nYO2hqi/yb9RGamw2+sYAs+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJeSjLcWY3LwWSLeyjYQy9hM6D8DhUhYUfZYJvtOSm5yTaQPXxvFNMDAnCaskOyao 59i73JVOL2MFK0b5M4WQdscrG4Muy8zumpqc6fFueZvrGwv8UzEMlTk3/PoIHG1rYH gWM2/i9+hZPA4wqFVo95/e8CImzs4aUmWae3SpFM= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 07/16] net/cxgbe: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:21 -0800 Message-Id: <1678486530-20688-8-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- drivers/net/cxgbe/clip_tbl.c | 2 +- drivers/net/cxgbe/mps_tcam.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/cxgbe/clip_tbl.c b/drivers/net/cxgbe/clip_tbl.c index 072fc74..f64b922 100644 --- a/drivers/net/cxgbe/clip_tbl.c +++ b/drivers/net/cxgbe/clip_tbl.c @@ -55,7 +55,7 @@ void cxgbe_clip_release(struct rte_eth_dev *dev, struct clip_entry *ce) int ret; t4_os_lock(&ce->lock); - if (__atomic_sub_fetch(&ce->refcnt, 1, __ATOMIC_RELAXED) == 0) { + if (__atomic_fetch_sub(&ce->refcnt, 1, __ATOMIC_RELAXED) - 1 == 0) { ret = clip6_release_mbox(dev, ce->addr); if (ret) dev_debug(adap, "CLIP FW DEL CMD failed: %d", ret); diff --git a/drivers/net/cxgbe/mps_tcam.c b/drivers/net/cxgbe/mps_tcam.c index abbf06e..c7cdf29 100644 --- a/drivers/net/cxgbe/mps_tcam.c +++ b/drivers/net/cxgbe/mps_tcam.c @@ -195,7 +195,7 @@ int cxgbe_mpstcam_remove(struct port_info *pi, u16 idx) entry->mask, idx, 1, pi->port_id, false); else - ret = __atomic_sub_fetch(&entry->refcnt, 1, __ATOMIC_RELAXED); + ret = __atomic_fetch_sub(&entry->refcnt, 1, __ATOMIC_RELAXED) - 1; if (ret == 0) { reset_mpstcam_entry(entry); From patchwork Fri Mar 10 22:15:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125022 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 A41B841E6D; Fri, 10 Mar 2023 23:16:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B4E1042D16; Fri, 10 Mar 2023 23:15:44 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 0EC7E40A8B for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id DEAA92044734; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DEAA92044734 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486535; bh=NGeD/kktCtxHao+11pGy3/7JGaXKOT/dp1Jpsw1eEbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QYSmt362cdWWwSWRa4mmupFm8/cfa3xgqW09YaLbIbrmuEFVLdeW0aeTBI24sA/aT fPfToT1Y6BXr2jkloZpCX3gei2PJFQ3Y190SE8cqVHLeUTXsTksocZCzWWSCpzMjAH sDFS7QEIKLlnzpmfAmr+SeSCDWTmhhNdT4ZRmT/E= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 08/16] net/iavf: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:22 -0800 Message-Id: <1678486530-20688-9-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- drivers/net/iavf/iavf_vchnl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index 9adaadb..51d4fc7 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -120,7 +120,7 @@ struct iavf_event_handler { { struct iavf_event_handler *handler = &event_handler; - if (__atomic_add_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 1) + if (__atomic_fetch_add(&handler->ndev, 1, __ATOMIC_RELAXED) + 1 != 1) return 0; #if defined(RTE_EXEC_ENV_IS_WINDOWS) && RTE_EXEC_ENV_IS_WINDOWS != 0 int err = _pipe(handler->fd, MAX_EVENT_PENDING, O_BINARY); @@ -149,7 +149,7 @@ struct iavf_event_handler { { struct iavf_event_handler *handler = &event_handler; - if (__atomic_sub_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 0) + if (__atomic_fetch_sub(&handler->ndev, 1, __ATOMIC_RELAXED) - 1 != 0) return; int unused = pthread_cancel(handler->tid); @@ -533,8 +533,8 @@ struct iavf_event_handler { /* read message and it's expected one */ if (msg_opc == vf->pend_cmd) { uint32_t cmd_count = - __atomic_sub_fetch(&vf->pend_cmd_count, - 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&vf->pend_cmd_count, + 1, __ATOMIC_RELAXED) - 1; if (cmd_count == 0) _notify_cmd(vf, msg_ret); } else { From patchwork Fri Mar 10 22:15:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125028 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 BD53F41E6D; Fri, 10 Mar 2023 23:16:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6A58442D36; Fri, 10 Mar 2023 23:15:51 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 1412240DD8 for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id EAEB22044735; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com EAEB22044735 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486535; bh=gfoZyEjJutfqnPQMIgbsZMuiF73RQDd48uZHDY6KFxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KBWQxQpUFRtM2z8tLD0lCsofX4Q9BEyMExJESTwZlGe9uV7WIrAIxFkehTHYl+IJu PxnhEdNYQbYLrv6+ecqc+wBnNFzB9Lri2XOk13/CVsMigXq6fLbCKBUDhMr+boo0tN /fqaZ3KbgxMzsB5yjex2rXsZPqQO2cEcadvqiLeU= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 09/16] net/mlx5: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:23 -0800 Message-Id: <1678486530-20688-10-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- drivers/net/mlx5/linux/mlx5_verbs.c | 2 +- drivers/net/mlx5/mlx5.c | 4 ++-- drivers/net/mlx5/mlx5_flow.c | 8 ++++---- drivers/net/mlx5/mlx5_flow_dv.c | 12 ++++++------ drivers/net/mlx5/mlx5_flow_hw.c | 14 +++++++------- drivers/net/mlx5/mlx5_hws_cnt.c | 4 ++-- drivers/net/mlx5/mlx5_rxq.c | 6 +++--- drivers/net/mlx5/mlx5_txq.c | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c index 67a7bec..ee5d072 100644 --- a/drivers/net/mlx5/linux/mlx5_verbs.c +++ b/drivers/net/mlx5/linux/mlx5_verbs.c @@ -1183,7 +1183,7 @@ if (!priv->lb_used) return; MLX5_ASSERT(__atomic_load_n(&sh->self_lb.refcnt, __ATOMIC_RELAXED)); - if (!(__atomic_sub_fetch(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED))) { + if (!(__atomic_fetch_sub(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED) - 1)) { if (sh->self_lb.qp) { claim_zero(mlx5_glue->destroy_qp(sh->self_lb.qp)); sh->self_lb.qp = NULL; diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 41b1b12..044012d 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1068,7 +1068,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list = DRV_LOG(ERR, "Dynamic flex parser is not supported"); return -ENOTSUP; } - if (__atomic_add_fetch(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) > 1) + if (__atomic_fetch_add(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) + 1 > 1) return 0; node.header_length_mode = MLX5_GRAPH_NODE_LEN_FIELD; @@ -1123,7 +1123,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list = struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_internal_flex_parser_profile *fp = &priv->sh->srh_flex_parser; - if (__atomic_sub_fetch(&fp->refcnt, 1, __ATOMIC_RELAXED)) + if (__atomic_fetch_sub(&fp->refcnt, 1, __ATOMIC_RELAXED) - 1) return; if (fp->fp) mlx5_devx_cmd_destroy(fp->fp); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 75f7d87..0bf527e 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7833,7 +7833,7 @@ struct rte_flow * tunnel = mlx5_find_tunnel_id(dev, flow->tunnel_id); RTE_VERIFY(tunnel); - if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED)) + if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1)) mlx5_flow_tunnel_free(dev, tunnel); } flow_mreg_del_copy_action(dev, flow); @@ -9742,9 +9742,9 @@ struct mlx5_flow_workspace* __ATOMIC_RELAXED); continue; } - if (__atomic_add_fetch(&age_param->sec_since_last_hit, + if (__atomic_fetch_add(&age_param->sec_since_last_hit, time_delta, - __ATOMIC_RELAXED) <= age_param->timeout) + __ATOMIC_RELAXED) + time_delta <= age_param->timeout) continue; /** * Hold the lock first, or if between the @@ -11387,7 +11387,7 @@ struct tunnel_db_element_release_ctx { { struct tunnel_db_element_release_ctx *ctx = x; ctx->ret = 0; - if (!__atomic_sub_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED)) + if (!(__atomic_fetch_sub(&tunnel->refctn, 1, __ATOMIC_RELAXED) - 1)) mlx5_flow_tunnel_free(dev, tunnel); } diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index ca26f39..f04160e 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -6723,8 +6723,8 @@ struct mlx5_list_entry * * indirect action API, shared info is 1 before the reduction, * so this condition is failed and function doesn't return here. */ - if (__atomic_sub_fetch(&cnt->shared_info.refcnt, 1, - __ATOMIC_RELAXED)) + if (__atomic_fetch_sub(&cnt->shared_info.refcnt, 1, + __ATOMIC_RELAXED) - 1) return; } cnt->pool = pool; @@ -12797,7 +12797,7 @@ struct mlx5_list_entry * struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_aso_age_mng *mng = priv->sh->aso_age_mng; struct mlx5_aso_age_action *age = flow_aso_age_get_by_idx(dev, age_idx); - uint32_t ret = __atomic_sub_fetch(&age->refcnt, 1, __ATOMIC_RELAXED); + uint32_t ret = __atomic_fetch_sub(&age->refcnt, 1, __ATOMIC_RELAXED) - 1; if (!ret) { flow_dv_aso_age_remove_from_age(dev, age); @@ -13193,7 +13193,7 @@ struct mlx5_list_entry * /* Cannot release when CT is in the ASO SQ. */ if (state == ASO_CONNTRACK_WAIT || state == ASO_CONNTRACK_QUERY) return -1; - ret = __atomic_sub_fetch(&ct->refcnt, 1, __ATOMIC_RELAXED); + ret = __atomic_fetch_sub(&ct->refcnt, 1, __ATOMIC_RELAXED) - 1; if (!ret) { if (ct->dr_action_orig) { #ifdef HAVE_MLX5_DR_ACTION_ASO_CT @@ -15582,8 +15582,8 @@ struct mlx5_list_entry * sh->geneve_tlv_option_resource; rte_spinlock_lock(&sh->geneve_tlv_opt_sl); if (geneve_opt_resource) { - if (!(__atomic_sub_fetch(&geneve_opt_resource->refcnt, 1, - __ATOMIC_RELAXED))) { + if (!(__atomic_fetch_sub(&geneve_opt_resource->refcnt, 1, + __ATOMIC_RELAXED) - 1)) { claim_zero(mlx5_devx_cmd_destroy (geneve_opt_resource->obj)); mlx5_free(sh->geneve_tlv_option_resource); diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 9392727..109aab1 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -458,7 +458,7 @@ static int flow_hw_translate_group(struct rte_eth_dev *dev, } if (acts->mark) - if (!__atomic_sub_fetch(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED)) + if (!(__atomic_fetch_sub(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED) - 1)) flow_hw_rxq_flag_set(dev, false); if (acts->jump) { @@ -3268,8 +3268,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions) rte_errno = EINVAL; goto it_error; } - ret = __atomic_add_fetch(&item_templates[i]->refcnt, 1, - __ATOMIC_RELAXED); + ret = __atomic_fetch_add(&item_templates[i]->refcnt, 1, + __ATOMIC_RELAXED) + 1; if (ret <= 1) { rte_errno = EINVAL; goto it_error; @@ -3282,8 +3282,8 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions) for (i = 0; i < nb_action_templates; i++) { uint32_t ret; - ret = __atomic_add_fetch(&action_templates[i]->refcnt, 1, - __ATOMIC_RELAXED); + ret = __atomic_fetch_add(&action_templates[i]->refcnt, 1, + __ATOMIC_RELAXED) + 1; if (ret <= 1) { rte_errno = EINVAL; goto at_error; @@ -7624,8 +7624,8 @@ void flow_hw_clear_tags_set(struct rte_eth_dev *dev) { uint32_t refcnt; - refcnt = __atomic_sub_fetch(&mlx5_flow_hw_flow_metadata_config_refcnt, 1, - __ATOMIC_RELAXED); + refcnt = __atomic_fetch_sub(&mlx5_flow_hw_flow_metadata_config_refcnt, 1, + __ATOMIC_RELAXED) - 1; if (refcnt > 0) return; mlx5_flow_hw_flow_metadata_esw_en = 0; diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c index d6a017a..d98df68 100644 --- a/drivers/net/mlx5/mlx5_hws_cnt.c +++ b/drivers/net/mlx5/mlx5_hws_cnt.c @@ -192,8 +192,8 @@ } param->accumulator_hits = 0; } - if (__atomic_add_fetch(¶m->sec_since_last_hit, time_delta, - __ATOMIC_RELAXED) <= + if (__atomic_fetch_add(¶m->sec_since_last_hit, time_delta, + __ATOMIC_RELAXED) + time_delta <= __atomic_load_n(¶m->timeout, __ATOMIC_RELAXED)) continue; /* Prepare the relevant ring for this AGE parameter */ diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 6e99c4d..ad8fd13 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -2042,7 +2042,7 @@ struct mlx5_rxq_priv * if (rxq == NULL) return 0; - return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED); + return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1; } /** @@ -2141,7 +2141,7 @@ struct mlx5_external_rxq * { struct mlx5_external_rxq *rxq = mlx5_ext_rxq_get(dev, idx); - return __atomic_sub_fetch(&rxq->refcnt, 1, __ATOMIC_RELAXED); + return __atomic_fetch_sub(&rxq->refcnt, 1, __ATOMIC_RELAXED) - 1; } /** @@ -2462,7 +2462,7 @@ struct mlx5_ind_table_obj * unsigned int ret; rte_rwlock_write_lock(&priv->ind_tbls_lock); - ret = __atomic_sub_fetch(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED); + ret = __atomic_fetch_sub(&ind_tbl->refcnt, 1, __ATOMIC_RELAXED) - 1; if (!ret) LIST_REMOVE(ind_tbl, next); rte_rwlock_write_unlock(&priv->ind_tbls_lock); diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index 1e0e61a..8cb52b0 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -1203,7 +1203,7 @@ struct mlx5_txq_ctrl * if (priv->txqs == NULL || (*priv->txqs)[idx] == NULL) return 0; txq_ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq); - if (__atomic_sub_fetch(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) > 1) + if (__atomic_fetch_sub(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) - 1 > 1) return 1; if (txq_ctrl->obj) { priv->obj_ops.txq_obj_release(txq_ctrl->obj); From patchwork Fri Mar 10 22:15:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125024 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 CD33E41E6D; Fri, 10 Mar 2023 23:16:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C000542D29; Fri, 10 Mar 2023 23:15:46 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 195BE40ED9 for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 02EF02044736; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 02EF02044736 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486536; bh=yih9w3s1MaYWceV5z99Nk1kNmThi86opCjssIuPTuWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JKmwKq0+opsjG9GFgBiTGEXvzhbUXRi+cdQ4eJRuFh6fmYQtNrrTzPoSieftvEmw/ dYoYGWVFpQe7PnxXWA0r3WiNyTu/T2+l+HMsBSf244gOJgpz1C1W08/GJNsX96boeR IC4U574iO0y6EaUc10jF+sfdfiY1uaGDJZTfdzNU= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 10/16] net/octeontx: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:24 -0800 Message-Id: <1678486530-20688-11-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- drivers/net/octeontx/octeontx_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index d52a3e7..a21ed80 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -559,7 +559,7 @@ enum octeontx_link_speed { return 0; /* Stopping/closing event device once all eth ports are closed. */ - if (__atomic_sub_fetch(&evdev_refcnt, 1, __ATOMIC_ACQUIRE) == 0) { + if (__atomic_fetch_sub(&evdev_refcnt, 1, __ATOMIC_ACQUIRE) - 1 == 0) { rte_event_dev_stop(nic->evdev); rte_event_dev_close(nic->evdev); } From patchwork Fri Mar 10 22:15:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125023 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 23B1641E6D; Fri, 10 Mar 2023 23:16:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B167442D0D; Fri, 10 Mar 2023 23:15:45 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 316A7410D0 for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 0F7FA2044738; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0F7FA2044738 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486536; bh=l5DHQhGSz5WOGqseAA5itL7h2u6vc9IgEAwWpebd87k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B4YIXhPlpH+lDtZac6V8B2U2z2njP8AC3MaEy1p/iFMVtl+Vh0kRwadrojANGhdtC /RI3Pt92EcZv7nrvqryz3QNFGfXMTRN08IHZeUyfYtTL+giuv1TFf21SznLkBb+BuZ S7LwJBzrOKPJF+fbtmcP//dUyJh68q+2FQzQ/RHk= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 11/16] raw/ifpga: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:25 -0800 Message-Id: <1678486530-20688-12-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- drivers/raw/ifpga/ifpga_rawdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index 1020adc..ae3f79d 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -573,7 +573,7 @@ static int set_surprise_link_check_aer( dev->poll_enabled = 0; - if (!__atomic_sub_fetch(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED) && + if (!(__atomic_fetch_sub(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED) - 1) && ifpga_monitor_start_thread) { ret = pthread_cancel(ifpga_monitor_start_thread); if (ret) From patchwork Fri Mar 10 22:15:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125027 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 21BC741E6D; Fri, 10 Mar 2023 23:16:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 56BA942D3E; Fri, 10 Mar 2023 23:15:50 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 3656C4113C for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 1BA40204473A; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1BA40204473A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486536; bh=iuHJ0StecZ9Raltf9LtwKbKGPzFt503WEpiLM/1aHZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EmMqmcK+ufntgQ5toa88niWh55MpaugNZ+PPZ+DEEUThzwFsUOAMMyGZW/ZNTgFT0 ieB6G06QlIoou1qH7wJdzw7yfBdU5pgN2CnIDGo52WrvhXM/NFSEpVvjHJOHx3BHv3 xKsy3JUlaJX8CU/Ji20OcQ/dwNVm+UcY63r2ENA4= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 12/16] bbdev: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:26 -0800 Message-Id: <1678486530-20688-13-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- lib/bbdev/rte_bbdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c index 1521cdb..9df0837 100644 --- a/lib/bbdev/rte_bbdev.c +++ b/lib/bbdev/rte_bbdev.c @@ -250,8 +250,8 @@ struct rte_bbdev * } /* clear shared BBDev Data if no process is using the device anymore */ - if (__atomic_sub_fetch(&bbdev->data->process_cnt, 1, - __ATOMIC_RELAXED) == 0) + if (__atomic_fetch_sub(&bbdev->data->process_cnt, 1, + __ATOMIC_RELAXED) - 1 == 0) memset(bbdev->data, 0, sizeof(*bbdev->data)); memset(bbdev, 0, sizeof(*bbdev)); From patchwork Fri Mar 10 22:15:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125031 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 693F041E6D; Fri, 10 Mar 2023 23:17:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 91ED042D4D; Fri, 10 Mar 2023 23:15:54 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 46B5F4113D for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 27B4D20C32D1; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 27B4D20C32D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486536; bh=WRyPi+Y0K7PVxL8pIDxajZYQd0JEu7UkGRD/uC7eQNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eYbRiW/8SiBeH/92GiRDAfjTjU9PQTiGlxYezLyNuWQ4oU/8A8H/qBhIH52yWWCkR Dqbi0A9auqaj73GUkKizL01nHdL6IqbRVNmDKHJQPVMZeue2oiUejPvEC1HlYbSEs0 e/XS+govGcKY81Y815VCraGjlQtXNsDCu+RkLL9s= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 13/16] eal: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:27 -0800 Message-Id: <1678486530-20688-14-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- lib/eal/include/generic/rte_rwlock.h | 8 ++++---- lib/eal/ppc/include/rte_atomic.h | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/eal/include/generic/rte_rwlock.h b/lib/eal/include/generic/rte_rwlock.h index d45c22c..71e2d8d 100644 --- a/lib/eal/include/generic/rte_rwlock.h +++ b/lib/eal/include/generic/rte_rwlock.h @@ -97,8 +97,8 @@ rte_pause(); /* Try to get read lock */ - x = __atomic_add_fetch(&rwl->cnt, RTE_RWLOCK_READ, - __ATOMIC_ACQUIRE); + x = __atomic_fetch_add(&rwl->cnt, RTE_RWLOCK_READ, + __ATOMIC_ACQUIRE) + RTE_RWLOCK_READ; /* If no writer, then acquire was successful */ if (likely(!(x & RTE_RWLOCK_MASK))) @@ -134,8 +134,8 @@ return -EBUSY; /* Try to get read lock */ - x = __atomic_add_fetch(&rwl->cnt, RTE_RWLOCK_READ, - __ATOMIC_ACQUIRE); + x = __atomic_fetch_add(&rwl->cnt, RTE_RWLOCK_READ, + __ATOMIC_ACQUIRE) + RTE_RWLOCK_READ; /* Back out if writer raced in */ if (unlikely(x & RTE_RWLOCK_MASK)) { diff --git a/lib/eal/ppc/include/rte_atomic.h b/lib/eal/ppc/include/rte_atomic.h index 663b4d3..ffabd98 100644 --- a/lib/eal/ppc/include/rte_atomic.h +++ b/lib/eal/ppc/include/rte_atomic.h @@ -71,12 +71,12 @@ static inline int rte_atomic16_test_and_set(rte_atomic16_t *v) static inline int rte_atomic16_inc_and_test(rte_atomic16_t *v) { - return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0; + return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0; } static inline int rte_atomic16_dec_and_test(rte_atomic16_t *v) { - return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0; + return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0; } static inline uint16_t @@ -113,12 +113,12 @@ static inline int rte_atomic32_test_and_set(rte_atomic32_t *v) static inline int rte_atomic32_inc_and_test(rte_atomic32_t *v) { - return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0; + return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0; } static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v) { - return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0; + return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0; } static inline uint32_t @@ -181,23 +181,23 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v) static inline int64_t rte_atomic64_add_return(rte_atomic64_t *v, int64_t inc) { - return __atomic_add_fetch(&v->cnt, inc, __ATOMIC_ACQUIRE); + return __atomic_fetch_add(&v->cnt, inc, __ATOMIC_ACQUIRE) + inc; } static inline int64_t rte_atomic64_sub_return(rte_atomic64_t *v, int64_t dec) { - return __atomic_sub_fetch(&v->cnt, dec, __ATOMIC_ACQUIRE); + return __atomic_fetch_sub(&v->cnt, dec, __ATOMIC_ACQUIRE) - dec; } static inline int rte_atomic64_inc_and_test(rte_atomic64_t *v) { - return __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0; + return __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE) + 1 == 0; } static inline int rte_atomic64_dec_and_test(rte_atomic64_t *v) { - return __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0; + return __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE) - 1 == 0; } static inline int rte_atomic64_test_and_set(rte_atomic64_t *v) From patchwork Fri Mar 10 22:15:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125029 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 4261C41E6D; Fri, 10 Mar 2023 23:17:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6679742D43; Fri, 10 Mar 2023 23:15:52 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 4BDAF41140 for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 344A320C343B; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 344A320C343B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486536; bh=KKXpezy0RTy1XbTqtcwBZBfX5NMfLLP22hCi67WeG8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PE8Pr0cTZvUr3SQ0xERAJZY2NNe/2NOGxD0E2XLVmepwm3iEItRItbn2D8i3lfNVW EjDhr/FRcrPllFOZmpYT9VNUg0wjKRZYlP4+oubHulCxcmO1qdyo72fjKWki9ep6n9 j947rO7mYVSm1dGenMj3U2xPLvB9YyH9dU/J/ruw= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 14/16] ipsec: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:28 -0800 Message-Id: <1678486530-20688-15-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- lib/ipsec/ipsec_sqn.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ipsec/ipsec_sqn.h b/lib/ipsec/ipsec_sqn.h index 2636cb1..505950e 100644 --- a/lib/ipsec/ipsec_sqn.h +++ b/lib/ipsec/ipsec_sqn.h @@ -128,7 +128,7 @@ n = *num; if (SQN_ATOMIC(sa)) - sqn = __atomic_add_fetch(&sa->sqn.outb, n, __ATOMIC_RELAXED); + sqn = __atomic_fetch_add(&sa->sqn.outb, n, __ATOMIC_RELAXED) + n; else { sqn = sa->sqn.outb + n; sa->sqn.outb = sqn; From patchwork Fri Mar 10 22:15:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125030 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 7426441E6D; Fri, 10 Mar 2023 23:17:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7436542D48; Fri, 10 Mar 2023 23:15:53 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 7AE6240685 for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4089A20C343F; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4089A20C343F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486536; bh=EvTRhZ/G3hZiE8a8339jFsa+CvgSNFF3uTPKvIElqVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dI8nG+9o1IiWJ+Toi5RVBA1IhzXpSJyhDiwq9k90jVAqJGJGO4qs/j8iaVAOPym42 lLiyk7Sm2ZUfTLZysWNSpQ2ZU/+XtxOwYzN9CJtpNLYmpbfmaR5NHd/3SMVNbfX/sM QAfUIMgTi2jQjrD3RaoCr7SksxcrZgC0af5XJxZc= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 15/16] mbuf: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:29 -0800 Message-Id: <1678486530-20688-16-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- lib/mbuf/rte_mbuf.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h index 3a82eb1..5da4cbe 100644 --- a/lib/mbuf/rte_mbuf.h +++ b/lib/mbuf/rte_mbuf.h @@ -381,8 +381,8 @@ struct rte_pktmbuf_pool_private { static inline uint16_t __rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value) { - return __atomic_add_fetch(&m->refcnt, (uint16_t)value, - __ATOMIC_ACQ_REL); + return __atomic_fetch_add(&m->refcnt, (uint16_t)value, + __ATOMIC_ACQ_REL) + (uint16_t)value; } /** @@ -502,8 +502,8 @@ struct rte_pktmbuf_pool_private { return (uint16_t)value; } - return __atomic_add_fetch(&shinfo->refcnt, (uint16_t)value, - __ATOMIC_ACQ_REL); + return __atomic_fetch_add(&shinfo->refcnt, (uint16_t)value, + __ATOMIC_ACQ_REL) + (uint16_t)value; } /** Mbuf prefetch */ @@ -1315,8 +1315,8 @@ static inline int __rte_pktmbuf_pinned_extbuf_decref(struct rte_mbuf *m) * Direct usage of add primitive to avoid * duplication of comparing with one. */ - if (likely(__atomic_add_fetch(&shinfo->refcnt, (uint16_t)-1, - __ATOMIC_ACQ_REL))) + if (likely(__atomic_fetch_add(&shinfo->refcnt, (uint16_t)-1, + __ATOMIC_ACQ_REL) + (uint16_t)-1)) return 1; /* Reinitialize counter before mbuf freeing. */ From patchwork Fri Mar 10 22:15:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125032 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 54A2041E6D; Fri, 10 Mar 2023 23:17:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FC9140685; Fri, 10 Mar 2023 23:15:55 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 7D18240A8B for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4E8A7204473C; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4E8A7204473C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486536; bh=D2OhwtWXrWhki0EXrqAyNa2IoqlxwsgoXFSVqla3t7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=glCKxV1h4P0JdY+o/rI/oX3zgsvxQ+IPQ9MxYoiqUcscqtaoF5KF7qBXuBND/VOkE 6enkq96808UjjKF6s2jDc3AIgGPc2I3zNYdQQUckOa5Gx/0kVYQcVNXNLHYbk07oQw GauVTIkr6HgyiIO/nUnUNO7uo3yEl59PSBoY5BNA= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 16/16] rcu: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:30 -0800 Message-Id: <1678486530-20688-17-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- lib/rcu/rte_rcu_qsbr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h index ccae5d5..1aa078e 100644 --- a/lib/rcu/rte_rcu_qsbr.h +++ b/lib/rcu/rte_rcu_qsbr.h @@ -462,7 +462,7 @@ struct rte_rcu_qsbr_dq_parameters { * structure are visible to the workers before the token * update is visible. */ - t = __atomic_add_fetch(&v->token, 1, __ATOMIC_RELEASE); + t = __atomic_fetch_add(&v->token, 1, __ATOMIC_RELEASE) + 1; return t; }