From patchwork Mon Mar 20 19:00: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: 125329 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 5EFA7427E5; Mon, 20 Mar 2023 20:01:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 362A8410D0; Mon, 20 Mar 2023 20:01:04 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 79C97410D0 for ; Mon, 20 Mar 2023 20:01:02 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id C977C20FB19F; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C977C20FB19F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338861; bh=jfgGaeq6VwTARjRJlGmJ3SSbvmi4ZFh+wNIM9ufQA+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bEB4HRf290s0CpcYmCvIod42xT55m5XSEEOkIMZyfpVoBJ78zxFMeM8C079TV8jo9 b1SRC4VyljQEkZhCiptSTbawSp/2c9ViGHvqX//OmyCH0HtIo7wIRahDP5W8j5VtPr RJqCTgUpxmQvxI2kF/CIR9SiSKMsaL8FUAQz90rA= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 01/16] app/test: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:21 -0700 Message-Id: <1679338836-21321-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00: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: 125330 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 9944E427E5; Mon, 20 Mar 2023 20:01:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 66D27427E9; Mon, 20 Mar 2023 20:01:05 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 808A0410EF for ; Mon, 20 Mar 2023 20:01:02 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id D616D20FB1AB; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D616D20FB1AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338861; bh=Rq6QMWjSc1qdahHm0YxM2Dte4k8vYs8NCkYASb23WBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BLZpQdkabHpga3UPipq4BzrW9SMhr6pzXAuGAtk9GTetsyXLMuwW6trX7rz4an2Jt BaMq213OsWr5uQabaS9EvD9z1vNF5lfNEMbEYe2xouQ4C4GZwYCIY50yLAazXIDkpa yaSBxOzCctTOIF/h9Zitw5JXLoDMjhGGpiIHs394= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 02/16] common/cnxk: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:22 -0700 Message-Id: <1679338836-21321-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00: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: 125333 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 BF7A5427E5; Mon, 20 Mar 2023 20:01:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C2B342C54; Mon, 20 Mar 2023 20:01:09 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 96752410F3 for ; Mon, 20 Mar 2023 20:01:02 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id E236120FB1B2; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E236120FB1B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338861; bh=7MtsXrm5aGlCAR057cFKAxXgAjohMLo6Xymq8eXlg/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WoTMJH9x3ohGiizP/QzSlcDiQVDE8APvHERh/wLmnQSZA2G0X87yUhiedzQ8FlRsN 6gmO1TQLffS04xgl5KKuAhURyQOm/FdzcwAI/8F7XWlsTx6MlU3zNEHhmpdCQKheo0 ysxPRMWoMQAIm4IZP+33uTNpThM5R/KRIIk69Dwg= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 03/16] common/mlx5: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:23 -0700 Message-Id: <1679338836-21321-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00: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: 125332 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 72242427E5; Mon, 20 Mar 2023 20:01:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1A2DF42BFE; Mon, 20 Mar 2023 20:01:08 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9AC1E41133 for ; Mon, 20 Mar 2023 20:01:02 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id EE37520FB1BC; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com EE37520FB1BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338861; bh=KwkIPukJhLJutuumpiLf0nkOHPZ3M576XBwAsmBTZ/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IRJTdcWvIoPQCH+jFXX7UjI1lUAVmEB3yVAYf3iX4TH/IIo6ZFZ5/1Ns5DVM96+qD 9Dybi2Aq94Vgo/eURoUsH/jNsNSI5E30hwJIRsVDGZ6Z36qWNXSqTBE+MmQ8zaAYA5 w35BApMHQ2F17R0S09OQFWR6SRMQ/LznYFP7GvJo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 04/16] drivers/event: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:24 -0700 Message-Id: <1679338836-21321-5-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00: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: 125335 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 EB52B427E5; Mon, 20 Mar 2023 20:01:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1F60C42D16; Mon, 20 Mar 2023 20:01:12 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 4022940A80 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 068ED20FB401; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 068ED20FB401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=FF/a3SqWmGjmfYjDOiuwZOqVho7SQGXeNopdH02GOQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pXlLB9lzBpvusGn/TlX1HKFE07xPlpCeq87Z5xUwe/d6CtaHYoNuQai1Hq8lZ1beP TMl1Q24i7b9M1XOqkeL/qMHK3/HL5Gi8GoI/zHAQsM0Db/chdJs63whGyM5zQGl5c4 YUsnBXaE1Ql5nke3k+wIp9+LxmwbsB/htDL/8Wgo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 05/16] net/af_xdp: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:25 -0700 Message-Id: <1679338836-21321-6-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00: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: 125336 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 2EE54427E5; Mon, 20 Mar 2023 20:01:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 80A5342D2C; Mon, 20 Mar 2023 20:01:13 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 45E28410EF for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 12C2820FB405; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 12C2820FB405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=p3kSYY434iotxhxJBRK1kyamDWjPGKcQpRcSQ82xaeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=la7SY5MSuXrBef+5PkMOkYPk6TksAQdUU+ItQD5vuiGluA8DFodF2q0zTTcZDdlua dwh0tQ7isYNdlzcc5S5NTQ8G9c96Zb/DHozZZL9kO1UNA2BevMRsDRbmcsQJ2oClGe A3KtQiTkD9+lBitvQ14GEp+y5vTQ4Q3fcyDAbJ28= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 06/16] net/cnxk: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:26 -0700 Message-Id: <1679338836-21321-7-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00: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: 125337 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 6BA6E427E5; Mon, 20 Mar 2023 20:01:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E244C42D32; Mon, 20 Mar 2023 20:01:14 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 4625B410F3 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 1F04B20FB40B; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1F04B20FB40B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=aLOIS8/CoN00asDKurAVjUxHQGOO7TmMrWuk1bN/Y0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oD+dLEX3uRJSW/KfJZsJlQctKlMYBVexXR18njkxsrGIuUD8U7Mt5uWuGonuoSTuz ZKO2+BuG2wgrDx5Lal0hnPlhFgAslNlaUdmOliOXXRSvXdbrgeDgbrHKSILreFya+I x3nXUz43iRSOvXI+PZoWsitD7nVXg4M+LV0yiRZY= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 07/16] net/cxgbe: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:27 -0700 Message-Id: <1679338836-21321-8-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00: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: 125334 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 95BB2427E5; Mon, 20 Mar 2023 20:01:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C135A42D0C; Mon, 20 Mar 2023 20:01:10 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 444EF410D0 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 2B57120FB40F; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2B57120FB40F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=fAPptoENiYpaSsjEfJQYA6MmcY92Ro6MWRnZgaHlVzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pvvi58G3h6ABMf0EnH1EmYQFlSiAT8JXrvQ8IN7AAD6RAbQHYrJzJqdVorS/v7/Ku TQBEggwyGFGO7j7meM8O1ayUlZx0huazR1zt8KYl9aFUJHr/owK+1R9ZCxS6nK1ZeL AhTslu0r+sKXWuBnqQdNdER6eSx3UlSwNluM6bm8= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 08/16] net/iavf: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:28 -0700 Message-Id: <1679338836-21321-9-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00: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: 125342 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 6AD72427E5; Mon, 20 Mar 2023 20:02:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 495D242D47; Mon, 20 Mar 2023 20:01:21 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 67B7941141 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 37ADD20FB411; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 37ADD20FB411 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=I7Fn0I1Vcl/rgt7s4W7767V5jxNjmcE3iMARipwE5cs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CtfsfxaS9WRHLuSvziBQJ8FoJsKrpwAPlLDzPcjr232qpJoHXAkJsgmPKuJmjg/8/ lQA786Uq1lqc/lUShPlO13XX00tAWkEy7BqFtD/WzTjxHgWOvHb8MH7RNP3ACjl+B1 Q+zk1sGiJLeHoordYg1/5amNtd3+bUjCQNm8RijQ= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 09/16] net/mlx5: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:29 -0700 Message-Id: <1679338836-21321-10-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 19f7f92..c742675 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); @@ -9746,9 +9746,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 @@ -11391,7 +11391,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 a4328a9..8882fc7 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; @@ -7726,8 +7726,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 Mon Mar 20 19:00: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: 125340 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 7C656427E5; Mon, 20 Mar 2023 20:02:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C77CB42D0B; Mon, 20 Mar 2023 20:01:18 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 6E0AF427F2 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4415820FB415; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4415820FB415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=dOAaypICp6EI6LeBJSbxozCiHpZ2PAX8QCUnrjuaPd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nqKSD9nS5dNEGaeSBmsevbhhJwNfSJ/IO+CvDh+u9a/XmhQCBNI6KC1fhE3gigh2f 2/4RTPoabPVPhaM7Gn/7UtpcnrfThHq0OH9Fj3Fm39XpanmbX2HhHlBSjEDVmfJZea WBJY4Fabrw/rLwqs0vhXBCwogVsB2FjCruXT9V08= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 10/16] net/octeontx: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:30 -0700 Message-Id: <1679338836-21321-11-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125338 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 E3A8D427E5; Mon, 20 Mar 2023 20:02:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3258542D37; Mon, 20 Mar 2023 20:01:16 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 5C92B41133 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 514FD20FB41B; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 514FD20FB41B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=ORKicTF3mgnPFsi9VVjPTkV+31TnBQ24n4Mh6rn/Jdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I5y3aZ1NLnh+F2jLet9GFC9kdHKsiPsEIFSuCKyxl7YIH4JOWWMZ8uw44Ts1Dut6y FOWOgskCuV+TxQvkjB4m7K7sp8AfK5CbyLv02/o6Xo9zOxj44xVF7L7ADNKF17nULD Y8GZ3+6b6gdMFXmXhd6dcWhK/X/t459IGICdu8mI= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 11/16] raw/ifpga: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:31 -0700 Message-Id: <1679338836-21321-12-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125339 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 1CD5B427E5; Mon, 20 Mar 2023 20:02:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 71E1F42D3C; Mon, 20 Mar 2023 20:01:17 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 6BAEC427E9 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 5DF6320FB41F; Mon, 20 Mar 2023 12:01:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5DF6320FB41F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=gvh7ulJiCEMCslGZsDcXJvg7jqGuKVaO3NMm0pj6kfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rX3vOJKAnhBD+N0saWLtGsdC5ygwl6nqpE26H+Hr5K9o2qJMB61bU5LVT+I0MHrxG mLIX7PmTY9f7skkWCWLisfzi81Cxj+EFy3r5T4PWFfQr9bjh/koJq5GvxZHudb3NIQ 2F7g9HIt+MKT9V06lFFgtXOdJyJ05AjUguZ1034g= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 12/16] bbdev: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:32 -0700 Message-Id: <1679338836-21321-13-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125343 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 B5EDD427E5; Mon, 20 Mar 2023 20:02:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77B0642D4F; Mon, 20 Mar 2023 20:01:22 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 84C204282D for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 6B81520FB424; Mon, 20 Mar 2023 12:01:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6B81520FB424 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=HrucMDVryp7Qcr9Q25BIN6le8KqS4zPyFfv+t38BGe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMV8QWYareM9tNu2ww4r2axTFuldwBmYXW+ILIomEuLl7TpstUtp8SFS4tCSYzezj dEh3Nj5FTOSdtEsjFJ0B4cPCljKhtxBi0Prugo59IjWBnizti3NJnffdehVa3mR5d+ zgC2LXCG5kiy6Ebi8dBi1AYTc8O9SLJeRMLbpYmc= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 13/16] eal: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:33 -0700 Message-Id: <1679338836-21321-14-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125341 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 9AA75427E5; Mon, 20 Mar 2023 20:02:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 127BC42D42; Mon, 20 Mar 2023 20:01:20 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 90E8842B71 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 7935820FB42B; Mon, 20 Mar 2023 12:01:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7935820FB42B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=HjIguY/SdyKE6hv8oNh49pLPoO2vkHoeHsBxKHnDD0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dl8MDiNJuoaCWKAuilKrZNIMW1HgVf+arGN2O/oFsrLX2rVuexbdYqBYMClMJgzSb 81EPidHKo4vZposRDcqEcLNkUqMZP7Odtu5VvXESjLvAFPhHX1s6pwyFCZ27vcoCFw otB+4DQ96gppSg7l0ywO/uWuLxC6dur7cZc/nxm0= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 14/16] ipsec: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:34 -0700 Message-Id: <1679338836-21321-15-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 Mon Mar 20 19:00:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125345 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 E64EE427E5; Mon, 20 Mar 2023 20:02:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D92142D52; Mon, 20 Mar 2023 20:01:25 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id AF67240A80 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 85BD920FB437; Mon, 20 Mar 2023 12:01:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 85BD920FB437 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=mpSF6toydLOaRcCI8rrJlK3A6g1p4Qo5bMr0DmGSxkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y9O5SzjedqzAlJAkyAk0h6SexLUOENGMBKfMwIwGJukWw9JkmGGeNfcTOsE0htNAP gxOY5N7QeNX8ggJh0Gc/xTTMVuE7VDUW/gkpZ+iAMgDtLGKZgZJ0MXLBEp1mMbabeD NCjEBumcdSc8g5ALSvYdt3TW5yZVJK61oEIWmF4s= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 15/16] mbuf: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:35 -0700 Message-Id: <1679338836-21321-16-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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 bc41eac..913c459 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, value, + __ATOMIC_ACQ_REL) + 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, value, + __ATOMIC_ACQ_REL) + 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, -1, + __ATOMIC_ACQ_REL) - 1)) return 1; /* Reinitialize counter before mbuf freeing. */ From patchwork Mon Mar 20 19:00:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125344 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 AA2FC427E5; Mon, 20 Mar 2023 20:02:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F228D42D4B; Mon, 20 Mar 2023 20:01:23 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id B0E92410D0 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 9249620FB43F; Mon, 20 Mar 2023 12:01:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9249620FB43F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=r9XDr4q7jR8mMosuaoVHBo+mE68sPCTx8WYzCPf8TaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZbhzhURkKPZqcSyj1Fj9EfBZVKmnLw9i7kSt9v9iNs9mwGFA9lPYuV6JVN920tNRB 21r99Ix4DNjWPr6QVbld1tmSQep5Ex0mhBfdngX/ABN/1L4YmdEEga335oY4PGH4Q4 WUiHKHVG9FZtkyd1KjYCNZh5DEq9OYL0qIxna6Qc= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 16/16] rcu: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:36 -0700 Message-Id: <1679338836-21321-17-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- 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; }