From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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)) { -- 1.8.3.1