From patchwork Thu Mar 2 00:47: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: 124620 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 E278641DAF; Thu, 2 Mar 2023 01:48:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 17CB34282D; Thu, 2 Mar 2023 01:48:04 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9B8C24021F for ; Thu, 2 Mar 2023 01:48:02 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id EAEE1209FE0C; Wed, 1 Mar 2023 16:48:01 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com EAEE1209FE0C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718081; bh=Go/gyhX55ybw6sMZBbocLMoEkOP0sfqdzvee+SF4pYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e7DxfcvDj/+nwlZH4yC9mNxYTJqCHZ7h73zkOPY1nfZAh9IoVZOGetxCXz1EJpG2s pmvcYDB5PGjRRxSBe0TsZEdg4E3Ab7oZB2EiBCJbYn3iyPM2WlQx3ISospTA1IJOfP Ut8UD8EYsxbhsITBkOR/h3QBwErL7PPwV/HbIo8c= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 01/17] vhost: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:32 -0800 Message-Id: <1677718068-2412-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff Reviewed-by: Maxime Coquelin --- lib/vhost/virtio_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index 51dc3c9..dc49a54 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -298,7 +298,7 @@ vhost_log_cache_sync(dev, vq); - __atomic_add_fetch(&vq->used->idx, vq->shadow_used_idx, + __atomic_fetch_add(&vq->used->idx, vq->shadow_used_idx, __ATOMIC_RELEASE); vq->shadow_used_idx = 0; vhost_log_used_vring(dev, vq, offsetof(struct vring_used, idx), @@ -2311,7 +2311,7 @@ vhost_vring_call_packed(dev, vq); } else { write_back_completed_descs_split(vq, n_descs); - __atomic_add_fetch(&vq->used->idx, n_descs, __ATOMIC_RELEASE); + __atomic_fetch_add(&vq->used->idx, n_descs, __ATOMIC_RELEASE); vhost_vring_call_split(dev, vq); } } else { @@ -3683,7 +3683,7 @@ vhost_vring_call_packed(dev, vq); } else { write_back_completed_descs_split(vq, nr_cpl_pkts); - __atomic_add_fetch(&vq->used->idx, nr_cpl_pkts, __ATOMIC_RELEASE); + __atomic_fetch_add(&vq->used->idx, nr_cpl_pkts, __ATOMIC_RELEASE); vhost_vring_call_split(dev, vq); } vq->async->pkts_inflight_n -= nr_cpl_pkts; From patchwork Thu Mar 2 00:47: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: 124621 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 7D63341DAF; Thu, 2 Mar 2023 01:48:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 68E344114B; Thu, 2 Mar 2023 01:48:05 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id A1C7F40E2D for ; Thu, 2 Mar 2023 01:48:02 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 0426A209FE0F; Wed, 1 Mar 2023 16:48:01 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0426A209FE0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=WAymalLmXCHQeCD3o4VXTvgzQGb7pJMgV91cFnILjHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BIgblWidzRCMMeGD4Fm8jBDKpdUJzW9lWzzRwYIkoiuPyhdWCvuU2J8t0fqNZeI1C 77p6dSPGvDc8a6ncBu12Kr9MlbQ/42VJlb75JiWvqpctmxTShh1oDYsdC4ZY2kyYIk 0F/ujraeemBEloi6Ou3CMeKNYuJFjjLciPe0yRLw= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 02/17] telemetry: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:33 -0800 Message-Id: <1677718068-2412-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff Acked-by: Bruce Richardson --- lib/telemetry/telemetry.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 7bceadc..deba7f3 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -391,7 +391,7 @@ struct socket { bytes = read(s, buffer, sizeof(buffer) - 1); } close(s); - __atomic_sub_fetch(&v2_clients, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&v2_clients, 1, __ATOMIC_RELAXED); return NULL; } @@ -414,7 +414,7 @@ struct socket { close(s_accepted); continue; } - __atomic_add_fetch(s->num_clients, 1, + __atomic_fetch_add(s->num_clients, 1, __ATOMIC_RELAXED); } rc = pthread_create(&th, NULL, s->fn, @@ -424,7 +424,7 @@ struct socket { strerror(rc)); close(s_accepted); if (s->num_clients != NULL) - __atomic_sub_fetch(s->num_clients, 1, + __atomic_fetch_sub(s->num_clients, 1, __ATOMIC_RELAXED); continue; } From patchwork Thu Mar 2 00:47: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: 124623 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 88B0A41DAF; Thu, 2 Mar 2023 01:48:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B825142B8B; Thu, 2 Mar 2023 01:48:07 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id C248140EE3 for ; Thu, 2 Mar 2023 01:48:02 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 0FF42209FE12; Wed, 1 Mar 2023 16:48:01 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0FF42209FE12 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=Q26ZsikVWyZYf9icOLt0Erhc1HuvuvZ81/0zXAW006w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kLAVB/G1+CcNs87UCLj/fY/wwiTpOk8yKVy4SoLIrJlRphCqX7iDF+hK2TpcHIeZU RnRCMkdkljvOUFbiqJH/b433TW7Py/HszP7k6fFHIiuDE6brQP9Lrer1y5orcK+Ee0 DvN0g8AcFf1fk2FxTP1tAS7nFwZqeCv8VGD9yZtA= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 03/17] stack: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:34 -0800 Message-Id: <1677718068-2412-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- lib/stack/rte_stack_lf_c11.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stack/rte_stack_lf_c11.h b/lib/stack/rte_stack_lf_c11.h index 8403196..687a6f6 100644 --- a/lib/stack/rte_stack_lf_c11.h +++ b/lib/stack/rte_stack_lf_c11.h @@ -66,7 +66,7 @@ /* Ensure the stack modifications are not reordered with respect * to the LIFO len update. */ - __atomic_add_fetch(&list->len, num, __ATOMIC_RELEASE); + __atomic_fetch_add(&list->len, num, __ATOMIC_RELEASE); } static __rte_always_inline struct rte_stack_lf_elem * From patchwork Thu Mar 2 00:47: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: 124624 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 D4C0941DAF; Thu, 2 Mar 2023 01:48:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF78942BC9; Thu, 2 Mar 2023 01:48:08 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id C564E4114B for ; Thu, 2 Mar 2023 01:48:02 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 1C53A20B9C3D; Wed, 1 Mar 2023 16:48:01 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1C53A20B9C3D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=v7bX/IZDWji7zuUvfdgDI1zNnPd7EEraibw3/SQnAZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E4PCQXjM2qCcshoLC4BsGTxVns0KNV9S1QodMJMvB7JGmLtfpu/dwjqPfqoR3IWmp 89XtfBj2xkPhyn9Tnliphgm36/2+nZaL9JRd+y6dhm6fSm1YoBa7RjRUgRTxpcy+7B jqnoTpPetILjKBrrjiqBbkw8TkgVQq4IQZleHDTU= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 04/17] eal: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:35 -0800 Message-Id: <1677718068-2412-5-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- lib/eal/common/eal_common_trace.c | 8 ++++---- lib/eal/common/rte_service.c | 8 ++++---- lib/eal/ppc/include/rte_atomic.h | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c index 75162b7..cb980af 100644 --- a/lib/eal/common/eal_common_trace.c +++ b/lib/eal/common/eal_common_trace.c @@ -103,10 +103,10 @@ struct trace_point_head * trace_mode_set(rte_trace_point_t *t, enum rte_trace_mode mode) { if (mode == RTE_TRACE_MODE_OVERWRITE) - __atomic_and_fetch(t, ~__RTE_TRACE_FIELD_ENABLE_DISCARD, + __atomic_fetch_and(t, ~__RTE_TRACE_FIELD_ENABLE_DISCARD, __ATOMIC_RELEASE); else - __atomic_or_fetch(t, __RTE_TRACE_FIELD_ENABLE_DISCARD, + __atomic_fetch_or(t, __RTE_TRACE_FIELD_ENABLE_DISCARD, __ATOMIC_RELEASE); } @@ -155,7 +155,7 @@ rte_trace_mode rte_trace_mode_get(void) prev = __atomic_fetch_or(t, __RTE_TRACE_FIELD_ENABLE_MASK, __ATOMIC_RELEASE); if ((prev & __RTE_TRACE_FIELD_ENABLE_MASK) == 0) - __atomic_add_fetch(&trace.status, 1, __ATOMIC_RELEASE); + __atomic_fetch_add(&trace.status, 1, __ATOMIC_RELEASE); return 0; } @@ -169,7 +169,7 @@ rte_trace_mode rte_trace_mode_get(void) prev = __atomic_fetch_and(t, ~__RTE_TRACE_FIELD_ENABLE_MASK, __ATOMIC_RELEASE); if ((prev & __RTE_TRACE_FIELD_ENABLE_MASK) != 0) - __atomic_sub_fetch(&trace.status, 1, __ATOMIC_RELEASE); + __atomic_fetch_sub(&trace.status, 1, __ATOMIC_RELEASE); return 0; } diff --git a/lib/eal/common/rte_service.c b/lib/eal/common/rte_service.c index 42ca1d0..7ab48f2 100644 --- a/lib/eal/common/rte_service.c +++ b/lib/eal/common/rte_service.c @@ -464,11 +464,11 @@ struct core_state { /* Increment num_mapped_cores to reflect that this core is * now mapped capable of running the service. */ - __atomic_add_fetch(&s->num_mapped_cores, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&s->num_mapped_cores, 1, __ATOMIC_RELAXED); int ret = service_run(id, cs, UINT64_MAX, s, serialize_mt_unsafe); - __atomic_sub_fetch(&s->num_mapped_cores, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&s->num_mapped_cores, 1, __ATOMIC_RELAXED); return ret; } @@ -638,12 +638,12 @@ struct core_state { if (*set && !lcore_mapped) { lcore_states[lcore].service_mask |= sid_mask; - __atomic_add_fetch(&rte_services[sid].num_mapped_cores, + __atomic_fetch_add(&rte_services[sid].num_mapped_cores, 1, __ATOMIC_RELAXED); } if (!*set && lcore_mapped) { lcore_states[lcore].service_mask &= ~(sid_mask); - __atomic_sub_fetch(&rte_services[sid].num_mapped_cores, + __atomic_fetch_sub(&rte_services[sid].num_mapped_cores, 1, __ATOMIC_RELAXED); } } diff --git a/lib/eal/ppc/include/rte_atomic.h b/lib/eal/ppc/include/rte_atomic.h index 663b4d3..2ab735b 100644 --- a/lib/eal/ppc/include/rte_atomic.h +++ b/lib/eal/ppc/include/rte_atomic.h @@ -60,13 +60,13 @@ static inline int rte_atomic16_test_and_set(rte_atomic16_t *v) static inline void rte_atomic16_inc(rte_atomic16_t *v) { - __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE); + __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE); } static inline void rte_atomic16_dec(rte_atomic16_t *v) { - __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE); + __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE); } static inline int rte_atomic16_inc_and_test(rte_atomic16_t *v) @@ -102,13 +102,13 @@ static inline int rte_atomic32_test_and_set(rte_atomic32_t *v) static inline void rte_atomic32_inc(rte_atomic32_t *v) { - __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE); + __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE); } static inline void rte_atomic32_dec(rte_atomic32_t *v) { - __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE); + __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE); } static inline int rte_atomic32_inc_and_test(rte_atomic32_t *v) @@ -157,25 +157,25 @@ static inline int rte_atomic32_dec_and_test(rte_atomic32_t *v) static inline void rte_atomic64_add(rte_atomic64_t *v, int64_t inc) { - __atomic_add_fetch(&v->cnt, inc, __ATOMIC_ACQUIRE); + __atomic_fetch_add(&v->cnt, inc, __ATOMIC_ACQUIRE); } static inline void rte_atomic64_sub(rte_atomic64_t *v, int64_t dec) { - __atomic_sub_fetch(&v->cnt, dec, __ATOMIC_ACQUIRE); + __atomic_fetch_sub(&v->cnt, dec, __ATOMIC_ACQUIRE); } static inline void rte_atomic64_inc(rte_atomic64_t *v) { - __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE); + __atomic_fetch_add(&v->cnt, 1, __ATOMIC_ACQUIRE); } static inline void rte_atomic64_dec(rte_atomic64_t *v) { - __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE); + __atomic_fetch_sub(&v->cnt, 1, __ATOMIC_ACQUIRE); } static inline int64_t From patchwork Thu Mar 2 00:47: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: 124626 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 A10F941DAF; Thu, 2 Mar 2023 01:48:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0BA7942D0B; Thu, 2 Mar 2023 01:48:11 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 6C64F40DFB for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 28A8020B9C3E; Wed, 1 Mar 2023 16:48:01 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 28A8020B9C3E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=AqnZY5l2+yPYsMACL2klO8iL2TX6L2qcZhv5Uj7ufd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=roW5W0Ul/WWtJh1wg+cq9M4B9z7kA1A26EbqHbvCuqhv9OQ0Eadhh9LmHstWIoWb6 UTsKKb43fWLK9RHNa6CYQzbCaAmRycFOcuC9R00x8B9zkkgYb1VhyrWTSCrH90rvkW XWZBkYRX1DbxaI+UzgUJf8L2HDpAHkFUH7pr5jfU= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 05/17] distributor: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:36 -0800 Message-Id: <1677718068-2412-6-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- lib/distributor/rte_distributor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/distributor/rte_distributor.c b/lib/distributor/rte_distributor.c index 3969b2e..68840ce 100644 --- a/lib/distributor/rte_distributor.c +++ b/lib/distributor/rte_distributor.c @@ -200,7 +200,7 @@ * we won't read any mbufs from there even if GET_BUF is set. * This allows distributor to retrieve in-flight already sent packets. */ - __atomic_or_fetch(&(buf->bufptr64[0]), RTE_DISTRIB_RETURN_BUF, + __atomic_fetch_or(&(buf->bufptr64[0]), RTE_DISTRIB_RETURN_BUF, __ATOMIC_ACQ_REL); /* set the RETURN_BUF on retptr64 even if we got no returns. From patchwork Thu Mar 2 00:47:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124627 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 9DF0B41DAF; Thu, 2 Mar 2023 01:48:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 173D742BB1; Thu, 2 Mar 2023 01:48:12 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 681814021F for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 3498F20B9C3F; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3498F20B9C3F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=NgrRmXAtFFPS0Qg/CZqo11R32oxUWCsQq1n7CNdAj8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XlX+rGJLBKUA5u6b7RPQWNsIKXIqVqzfO6Vbz/5bfE3VMLwyFP4MZo816sv7P0M6U SqFpuOujoPC82LuOumWn4ZucUlMMNwpyUxxrUBP7bAfi3dLW/4SW3mCAarUGCZ/xtj UYGUrkh5WeOzPQfcAfzqHgHSg7ZajhNIRyaSrms8= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 06/17] bbdev: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:37 -0800 Message-Id: <1677718068-2412-7-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- lib/bbdev/rte_bbdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c index 1521cdb..69e099d 100644 --- a/lib/bbdev/rte_bbdev.c +++ b/lib/bbdev/rte_bbdev.c @@ -208,7 +208,7 @@ struct rte_bbdev * return NULL; } - __atomic_add_fetch(&bbdev->data->process_cnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&bbdev->data->process_cnt, 1, __ATOMIC_RELAXED); bbdev->data->dev_id = dev_id; bbdev->state = RTE_BBDEV_INITIALIZED; From patchwork Thu Mar 2 00:47:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124629 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 E505E41DAF; Thu, 2 Mar 2023 01:48:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C38542C76; Thu, 2 Mar 2023 01:48:14 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 6F15C40EE3 for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4076A20B4713; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4076A20B4713 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=EKUNywuXkHOLDgzd/JggM6Tbd1lb5BvKgrQTR+G7GSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i28Mepm0qAz4WJvqfQ5eDc4BV0MmIGbpmewxRn987YrRlowKMQKwhvSynaBjdLJMk J8w2b7557+12CGaTgmu1A0dSiFJwoKGV+gTj+OH+GxWGsn49v3CpU+GFUKbD0O340I LkwzwJa+hS/VGGl3fBXtd+9R1p4gWvxb010ciCN8= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 07/17] examples/vhost: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:38 -0800 Message-Id: <1677718068-2412-8-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff Reviewed-by: Maxime Coquelin --- examples/vhost/main.c | 12 ++++++------ examples/vhost/virtio_net.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 42e53a0..bfe466f 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -1048,9 +1048,9 @@ static unsigned check_ports_num(unsigned nb_ports) } if (enable_stats) { - __atomic_add_fetch(&dst_vdev->stats.rx_total_atomic, 1, + __atomic_fetch_add(&dst_vdev->stats.rx_total_atomic, 1, __ATOMIC_SEQ_CST); - __atomic_add_fetch(&dst_vdev->stats.rx_atomic, ret, + __atomic_fetch_add(&dst_vdev->stats.rx_atomic, ret, __ATOMIC_SEQ_CST); src_vdev->stats.tx_total++; src_vdev->stats.tx += ret; @@ -1068,9 +1068,9 @@ static unsigned check_ports_num(unsigned nb_ports) ret = vdev_queue_ops[vdev->vid].enqueue_pkt_burst(vdev, VIRTIO_RXQ, m, nr_xmit); if (enable_stats) { - __atomic_add_fetch(&vdev->stats.rx_total_atomic, nr_xmit, + __atomic_fetch_add(&vdev->stats.rx_total_atomic, nr_xmit, __ATOMIC_SEQ_CST); - __atomic_add_fetch(&vdev->stats.rx_atomic, ret, + __atomic_fetch_add(&vdev->stats.rx_atomic, ret, __ATOMIC_SEQ_CST); } @@ -1400,9 +1400,9 @@ static void virtio_tx_offload(struct rte_mbuf *m) } if (enable_stats) { - __atomic_add_fetch(&vdev->stats.rx_total_atomic, rx_count, + __atomic_fetch_add(&vdev->stats.rx_total_atomic, rx_count, __ATOMIC_SEQ_CST); - __atomic_add_fetch(&vdev->stats.rx_atomic, enqueue_count, + __atomic_fetch_add(&vdev->stats.rx_atomic, enqueue_count, __ATOMIC_SEQ_CST); } diff --git a/examples/vhost/virtio_net.c b/examples/vhost/virtio_net.c index 1d4737f..514c8e0 100644 --- a/examples/vhost/virtio_net.c +++ b/examples/vhost/virtio_net.c @@ -231,7 +231,7 @@ rte_prefetch0(&vr->desc[desc_indexes[i+1]]); } - __atomic_add_fetch(&vr->used->idx, count, __ATOMIC_RELEASE); + __atomic_fetch_add(&vr->used->idx, count, __ATOMIC_RELEASE); queue->last_used_idx += count; rte_vhost_vring_call(dev->vid, queue_id); @@ -442,7 +442,7 @@ queue->last_avail_idx += i; queue->last_used_idx += i; - __atomic_add_fetch(&vr->used->idx, i, __ATOMIC_ACQ_REL); + __atomic_fetch_add(&vr->used->idx, i, __ATOMIC_ACQ_REL); rte_vhost_vring_call(dev->vid, queue_id); From patchwork Thu Mar 2 00:47:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124625 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 0C6B641DAF; Thu, 2 Mar 2023 01:48:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E0F5842BFE; Thu, 2 Mar 2023 01:48:09 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 6C76840E2D for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4C78B209FE15; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4C78B209FE15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=NMcYIDTNOcbAX+mlTAfmxMO+x6cqllbobyHEVh4V0eU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lfqAuMblPFGZaMKDTSVEbgKQpyyXJGRfaYvZ7EGRLIMfP4MZ1FjloBwuwcfYZ26UC 27F9PtS4I1JSGcj+I9IaRwGXm7XuRS0mLet+lCZTdCbHf8H0vJrWdTC13992sxpb6D lQsPpn46CPbpSZDuO7GkIMNqo3VKwLmCt8SjeFck= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 08/17] net/virtio: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:39 -0800 Message-Id: <1677718068-2412-9-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff Reviewed-by: Maxime Coquelin --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index f46a131..2b4607a 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -1025,7 +1025,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) uep->id = desc_idx; uep->len = n_descs; - __atomic_add_fetch(&vring->used->idx, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&vring->used->idx, 1, __ATOMIC_RELAXED); } } From patchwork Thu Mar 2 00:47:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124628 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 209FB41DAF; Thu, 2 Mar 2023 01:48:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 21DF740EE3; Thu, 2 Mar 2023 01:48:13 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8615341151 for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 585FA209FE18; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 585FA209FE18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=b/ZWTqZOimNSo2xBbdBtViiX6lqxoqG/3rYUog3nlzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U1t0075BlUNkZmC0TzJ10Q7ndptwqLN8nuXlvob5Scyz28leaOrn4H42GUTxZbKv3 Wfs0Sn6OCh/KCQ6n2xaP6anBE00tLre+MUcq0+4vEIZ/+GS9V2UtBo1oZBL+2EnIL8 g7bn9bKeH3IAAZ0QaQDdj94jm9LVQs1PEVHepowA= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 09/17] net/octeontx: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:40 -0800 Message-Id: <1677718068-2412-10-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. 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..e00298e 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -1581,7 +1581,7 @@ static void build_xstat_names(struct rte_eth_xstat_name *xstat_names) nic->pko_vfid = pko_vfid; nic->port_id = port; nic->evdev = evdev; - __atomic_add_fetch(&evdev_refcnt, 1, __ATOMIC_ACQUIRE); + __atomic_fetch_add(&evdev_refcnt, 1, __ATOMIC_ACQUIRE); res = octeontx_port_open(nic); if (res < 0) From patchwork Thu Mar 2 00:47:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124636 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 16A1141DAF; Thu, 2 Mar 2023 01:49:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1BE4F42D3B; Thu, 2 Mar 2023 01:48:22 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 920A841156 for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 649B720BBF92; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 649B720BBF92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=HY8ilW01qnKduRPYqlNbTXC0gqtafSQMDA2hCR+8S1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XvPZ5PcDqkJ56aQNj1pqaFgZG6bIaJrpxqsSVMhLfgGbJ5eUYZ3aexpOZumtOCO9T KcIQ9/Ip3Wco0SAm9Tk6RckSkKj3rOw+FBBBlnOEsxoQLM3whKpTqMlPNk5ZNiH+9Z BNIGirjsXqFiUWAVlDhiG3cvlqVViM+es8YKB8ek= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 10/17] net/mlx5: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:41 -0800 Message-Id: <1677718068-2412-11-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- drivers/net/mlx5/linux/mlx5_verbs.c | 2 +- drivers/net/mlx5/mlx5_flow.c | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 4 ++-- drivers/net/mlx5/mlx5_flow_flex.c | 6 +++--- drivers/net/mlx5/mlx5_flow_hw.c | 10 +++++----- drivers/net/mlx5/mlx5_flow_meter.c | 20 ++++++++++---------- drivers/net/mlx5/mlx5_rx.h | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c index 67a7bec..c722613 100644 --- a/drivers/net/mlx5/linux/mlx5_verbs.c +++ b/drivers/net/mlx5/linux/mlx5_verbs.c @@ -1159,7 +1159,7 @@ claim_zero(mlx5_glue->destroy_cq(sh->self_lb.ibv_cq)); sh->self_lb.ibv_cq = NULL; } - (void)__atomic_sub_fetch(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&sh->self_lb.refcnt, 1, __ATOMIC_RELAXED); return -rte_errno; #else RTE_SET_USED(dev); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index a6a426c..1c51b29 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4451,7 +4451,7 @@ struct mlx5_translated_action_handle { shared_rss = mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS], idx); - __atomic_add_fetch(&shared_rss->refcnt, 1, + __atomic_fetch_add(&shared_rss->refcnt, 1, __ATOMIC_RELAXED); return idx; default: @@ -7295,7 +7295,7 @@ struct mlx5_list_entry * if (tunnel) { flow->tunnel = 1; flow->tunnel_id = tunnel->tunnel_id; - __atomic_add_fetch(&tunnel->refctn, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&tunnel->refctn, 1, __ATOMIC_RELAXED); mlx5_free(default_miss_ctx.queue); } mlx5_flow_pop_thread_workspace(); @@ -7306,7 +7306,7 @@ struct mlx5_list_entry * flow_mreg_del_copy_action(dev, flow); flow_drv_destroy(dev, flow); if (rss_desc->shared_rss) - __atomic_sub_fetch(&((struct mlx5_shared_action_rss *) + __atomic_fetch_sub(&((struct mlx5_shared_action_rss *) mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS], rss_desc->shared_rss))->refcnt, 1, __ATOMIC_RELAXED); diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index f93dd40..0233cde 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -15143,7 +15143,7 @@ struct mlx5_list_entry * shared_rss = mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS], srss); - __atomic_sub_fetch(&shared_rss->refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&shared_rss->refcnt, 1, __ATOMIC_RELAXED); } void @@ -15734,7 +15734,7 @@ struct mlx5_list_entry * /* Update queue with indirect table queue memoyr. */ origin->queue = shared_rss->ind_tbl->queues; rte_spinlock_init(&shared_rss->action_rss_sl); - __atomic_add_fetch(&shared_rss->refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&shared_rss->refcnt, 1, __ATOMIC_RELAXED); rte_spinlock_lock(&priv->shared_act_sl); ILIST_INSERT(priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS], &priv->rss_shared_actions, idx, shared_rss, next); diff --git a/drivers/net/mlx5/mlx5_flow_flex.c b/drivers/net/mlx5/mlx5_flow_flex.c index 35f2a99..a825274 100644 --- a/drivers/net/mlx5/mlx5_flow_flex.c +++ b/drivers/net/mlx5/mlx5_flow_flex.c @@ -301,7 +301,7 @@ return ret; } if (acquire) - __atomic_add_fetch(&flex->refcnt, 1, __ATOMIC_RELEASE); + __atomic_fetch_add(&flex->refcnt, 1, __ATOMIC_RELEASE); return ret; } @@ -336,7 +336,7 @@ rte_errno = -EINVAL; return -EINVAL; } - __atomic_sub_fetch(&flex->refcnt, 1, __ATOMIC_RELEASE); + __atomic_fetch_sub(&flex->refcnt, 1, __ATOMIC_RELEASE); return 0; } @@ -1220,7 +1220,7 @@ struct rte_flow_item_flex_handle * } flex->devx_fp = container_of(ent, struct mlx5_flex_parser_devx, entry); /* Mark initialized flex item valid. */ - __atomic_add_fetch(&flex->refcnt, 1, __ATOMIC_RELEASE); + __atomic_fetch_add(&flex->refcnt, 1, __ATOMIC_RELEASE); return (struct rte_flow_item_flex_handle *)flex; error: diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index a9c7045..159ebb5 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -1406,7 +1406,7 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions) goto err; acts->rule_acts[action_pos].action = priv->hw_tag[!!attr->group]; - __atomic_add_fetch(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&priv->hws_mark_refcnt, 1, __ATOMIC_RELAXED); flow_hw_rxq_flag_set(dev, true); break; case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN: @@ -3162,13 +3162,13 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions) at_error: while (i--) { __flow_hw_action_template_destroy(dev, &tbl->ats[i].acts); - __atomic_sub_fetch(&action_templates[i]->refcnt, + __atomic_fetch_sub(&action_templates[i]->refcnt, 1, __ATOMIC_RELAXED); } i = nb_item_templates; it_error: while (i--) - __atomic_sub_fetch(&item_templates[i]->refcnt, + __atomic_fetch_sub(&item_templates[i]->refcnt, 1, __ATOMIC_RELAXED); error: err = rte_errno; @@ -3361,11 +3361,11 @@ static rte_be32_t vlan_hdr_to_be32(const struct rte_flow_action *actions) } LIST_REMOVE(table, next); for (i = 0; i < table->nb_item_templates; i++) - __atomic_sub_fetch(&table->its[i]->refcnt, + __atomic_fetch_sub(&table->its[i]->refcnt, 1, __ATOMIC_RELAXED); for (i = 0; i < table->nb_action_templates; i++) { __flow_hw_action_template_destroy(dev, &table->ats[i].acts); - __atomic_sub_fetch(&table->ats[i].action_template->refcnt, + __atomic_fetch_sub(&table->ats[i].action_template->refcnt, 1, __ATOMIC_RELAXED); } mlx5dr_matcher_destroy(table->matcher); diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 08f8aad..cb26a12 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -1788,7 +1788,7 @@ struct mlx5_flow_meter_policy * NULL, "Meter profile id not valid."); /* Meter policy must exist. */ if (params->meter_policy_id == priv->sh->mtrmng->def_policy_id) { - __atomic_add_fetch + __atomic_fetch_add (&priv->sh->mtrmng->def_policy_ref_cnt, 1, __ATOMIC_RELAXED); domain_bitmap = MLX5_MTR_ALL_DOMAIN_BIT; @@ -1870,7 +1870,7 @@ struct mlx5_flow_meter_policy * fm->is_enable = params->meter_enable; fm->shared = !!shared; fm->color_aware = !!params->use_prev_mtr_color; - __atomic_add_fetch(&fm->profile->ref_cnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&fm->profile->ref_cnt, 1, __ATOMIC_RELAXED); if (params->meter_policy_id == priv->sh->mtrmng->def_policy_id) { fm->def_policy = 1; fm->flow_ipool = mlx5_ipool_create(&flow_ipool_cfg); @@ -1899,7 +1899,7 @@ struct mlx5_flow_meter_policy * } fm->active_state = params->meter_enable; if (mtr_policy) - __atomic_add_fetch(&mtr_policy->ref_cnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&mtr_policy->ref_cnt, 1, __ATOMIC_RELAXED); return 0; error: mlx5_flow_destroy_mtr_tbls(dev, fm); @@ -1994,8 +1994,8 @@ struct mlx5_flow_meter_policy * RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL, "Failed to create devx meter."); fm->active_state = params->meter_enable; - __atomic_add_fetch(&fm->profile->ref_cnt, 1, __ATOMIC_RELAXED); - __atomic_add_fetch(&policy->ref_cnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&fm->profile->ref_cnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&policy->ref_cnt, 1, __ATOMIC_RELAXED); return 0; } @@ -2017,7 +2017,7 @@ struct mlx5_flow_meter_policy * if (fmp == NULL) return -1; /* Update dependencies. */ - __atomic_sub_fetch(&fmp->ref_cnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&fmp->ref_cnt, 1, __ATOMIC_RELAXED); fm->profile = NULL; /* Remove from list. */ if (!priv->sh->meter_aso_en) { @@ -2035,14 +2035,14 @@ struct mlx5_flow_meter_policy * } mlx5_flow_destroy_mtr_tbls(dev, fm); if (fm->def_policy) - __atomic_sub_fetch(&priv->sh->mtrmng->def_policy_ref_cnt, + __atomic_fetch_sub(&priv->sh->mtrmng->def_policy_ref_cnt, 1, __ATOMIC_RELAXED); if (priv->sh->meter_aso_en) { if (!fm->def_policy) { mtr_policy = mlx5_flow_meter_policy_find(dev, fm->policy_id, NULL); if (mtr_policy) - __atomic_sub_fetch(&mtr_policy->ref_cnt, + __atomic_fetch_sub(&mtr_policy->ref_cnt, 1, __ATOMIC_RELAXED); fm->policy_id = 0; } @@ -2146,12 +2146,12 @@ struct mlx5_flow_meter_policy * RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL, "Meter object is being used."); /* Destroy the meter profile. */ - __atomic_sub_fetch(&fm->profile->ref_cnt, + __atomic_fetch_sub(&fm->profile->ref_cnt, 1, __ATOMIC_RELAXED); /* Destroy the meter policy. */ policy = mlx5_flow_meter_policy_find(dev, fm->policy_id, NULL); - __atomic_sub_fetch(&policy->ref_cnt, + __atomic_fetch_sub(&policy->ref_cnt, 1, __ATOMIC_RELAXED); memset(fm, 0, sizeof(struct mlx5_flow_meter_info)); return 0; diff --git a/drivers/net/mlx5/mlx5_rx.h b/drivers/net/mlx5/mlx5_rx.h index 6b42e27..ba62398 100644 --- a/drivers/net/mlx5/mlx5_rx.h +++ b/drivers/net/mlx5/mlx5_rx.h @@ -539,7 +539,7 @@ uint16_t mlx5_rx_burst_mprq_vec(void *dpdk_rxq, struct rte_mbuf **pkts, void *buf_addr; /* Increment the refcnt of the whole chunk. */ - __atomic_add_fetch(&buf->refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&buf->refcnt, 1, __ATOMIC_RELAXED); MLX5_ASSERT(__atomic_load_n(&buf->refcnt, __ATOMIC_RELAXED) <= strd_n + 1); buf_addr = RTE_PTR_SUB(addr, RTE_PKTMBUF_HEADROOM); From patchwork Thu Mar 2 00:47:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124630 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 57C0D41DAF; Thu, 2 Mar 2023 01:49:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D78442D3C; Thu, 2 Mar 2023 01:48:15 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9774241181 for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 70D2920BC5E7; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 70D2920BC5E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=ASMRWJdn838sjBWZbfjcoLnSyNnQA5QEmvBapHrJeVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TV8/tdCNo7LNgxCnMTH01ne+fH6lL8BOT6l0AUKB8TppxANIY8pABwBZwmLuoUfVg Gg39rzpf5ife+H50/W9E8iHceSBfJouzV4IOFAoDd4qSC6jWR+G8qZ9lpIZuhfXfUh ZWaGHIfjhxd8YYPXugJl4E1XhTQ93dNdSgMDKLU0= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 11/17] net/iavf: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:42 -0800 Message-Id: <1677718068-2412-12-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- drivers/net/iavf/iavf_vchnl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index 9adaadb..73875d7 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -128,7 +128,7 @@ struct iavf_event_handler { int err = pipe(handler->fd); #endif if (err != 0) { - __atomic_sub_fetch(&handler->ndev, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&handler->ndev, 1, __ATOMIC_RELAXED); return -1; } @@ -137,7 +137,7 @@ struct iavf_event_handler { if (rte_ctrl_thread_create(&handler->tid, "iavf-event-thread", NULL, iavf_dev_event_handle, NULL)) { - __atomic_sub_fetch(&handler->ndev, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&handler->ndev, 1, __ATOMIC_RELAXED); return -1; } @@ -533,7 +533,7 @@ 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, + __atomic_fetch_sub(&vf->pend_cmd_count, 1, __ATOMIC_RELAXED); if (cmd_count == 0) _notify_cmd(vf, msg_ret); From patchwork Thu Mar 2 00:47:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124632 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 3F06341DAF; Thu, 2 Mar 2023 01:49:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ABF3442D47; Thu, 2 Mar 2023 01:48:17 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9AD3941611 for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 7D13520BC5E8; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7D13520BC5E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=IhPtZx8nkaW8sXtaOz9D/aNblfi28Oe/GY8Fv6BqTkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VxIWs0V/5+w6EWHDsvEVq+buTMnQURjyF6VAIAXBQuO5VJmUzkjrWvDEU2BXUZkE5 JlxBjJ8MP6QlWMbpivLH16TPDl7QVdoOFot8N/3ismdlHiBVD1Iq00GI2IY+IrDIkp D+wgvepLhoIKVbmLYl5b2ysqW2AWSckJNpsotsj0= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 12/17] net/cxgbe: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:43 -0800 Message-Id: <1677718068-2412-13-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- drivers/net/cxgbe/clip_tbl.c | 2 +- drivers/net/cxgbe/cxgbe_main.c | 12 ++++++------ drivers/net/cxgbe/l2t.c | 4 ++-- drivers/net/cxgbe/mps_tcam.c | 2 +- drivers/net/cxgbe/smt.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/cxgbe/clip_tbl.c b/drivers/net/cxgbe/clip_tbl.c index 072fc74..ce715f2 100644 --- a/drivers/net/cxgbe/clip_tbl.c +++ b/drivers/net/cxgbe/clip_tbl.c @@ -129,7 +129,7 @@ static struct clip_entry *t4_clip_alloc(struct rte_eth_dev *dev, ce->type = FILTER_TYPE_IPV4; } } else { - __atomic_add_fetch(&ce->refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&ce->refcnt, 1, __ATOMIC_RELAXED); } t4_os_unlock(&ce->lock); } diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c index f8dd833..c479454 100644 --- a/drivers/net/cxgbe/cxgbe_main.c +++ b/drivers/net/cxgbe/cxgbe_main.c @@ -418,14 +418,14 @@ void cxgbe_remove_tid(struct tid_info *t, unsigned int chan, unsigned int tid, if (t->tid_tab[tid]) { t->tid_tab[tid] = NULL; - __atomic_sub_fetch(&t->conns_in_use, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&t->conns_in_use, 1, __ATOMIC_RELAXED); if (t->hash_base && tid >= t->hash_base) { if (family == FILTER_TYPE_IPV4) - __atomic_sub_fetch(&t->hash_tids_in_use, 1, + __atomic_fetch_sub(&t->hash_tids_in_use, 1, __ATOMIC_RELAXED); } else { if (family == FILTER_TYPE_IPV4) - __atomic_sub_fetch(&t->tids_in_use, 1, + __atomic_fetch_sub(&t->tids_in_use, 1, __ATOMIC_RELAXED); } } @@ -448,15 +448,15 @@ void cxgbe_insert_tid(struct tid_info *t, void *data, unsigned int tid, t->tid_tab[tid] = data; if (t->hash_base && tid >= t->hash_base) { if (family == FILTER_TYPE_IPV4) - __atomic_add_fetch(&t->hash_tids_in_use, 1, + __atomic_fetch_add(&t->hash_tids_in_use, 1, __ATOMIC_RELAXED); } else { if (family == FILTER_TYPE_IPV4) - __atomic_add_fetch(&t->tids_in_use, 1, + __atomic_fetch_add(&t->tids_in_use, 1, __ATOMIC_RELAXED); } - __atomic_add_fetch(&t->conns_in_use, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&t->conns_in_use, 1, __ATOMIC_RELAXED); } /** diff --git a/drivers/net/cxgbe/l2t.c b/drivers/net/cxgbe/l2t.c index 66f5789..21f4019 100644 --- a/drivers/net/cxgbe/l2t.c +++ b/drivers/net/cxgbe/l2t.c @@ -15,7 +15,7 @@ void cxgbe_l2t_release(struct l2t_entry *e) { if (__atomic_load_n(&e->refcnt, __ATOMIC_RELAXED) != 0) - __atomic_sub_fetch(&e->refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&e->refcnt, 1, __ATOMIC_RELAXED); } /** @@ -162,7 +162,7 @@ static struct l2t_entry *t4_l2t_alloc_switching(struct rte_eth_dev *dev, dev_debug(adap, "Failed to write L2T entry: %d", ret); } else { - __atomic_add_fetch(&e->refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&e->refcnt, 1, __ATOMIC_RELAXED); } t4_os_unlock(&e->lock); } diff --git a/drivers/net/cxgbe/mps_tcam.c b/drivers/net/cxgbe/mps_tcam.c index abbf06e..017741f 100644 --- a/drivers/net/cxgbe/mps_tcam.c +++ b/drivers/net/cxgbe/mps_tcam.c @@ -76,7 +76,7 @@ int cxgbe_mpstcam_alloc(struct port_info *pi, const u8 *eth_addr, t4_os_write_lock(&mpstcam->lock); entry = cxgbe_mpstcam_lookup(adap->mpstcam, eth_addr, mask); if (entry) { - __atomic_add_fetch(&entry->refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&entry->refcnt, 1, __ATOMIC_RELAXED); t4_os_write_unlock(&mpstcam->lock); return entry->idx; } diff --git a/drivers/net/cxgbe/smt.c b/drivers/net/cxgbe/smt.c index 810c757..4e14a73 100644 --- a/drivers/net/cxgbe/smt.c +++ b/drivers/net/cxgbe/smt.c @@ -170,7 +170,7 @@ static struct smt_entry *t4_smt_alloc_switching(struct rte_eth_dev *dev, e->state = SMT_STATE_SWITCHING; __atomic_store_n(&e->refcnt, 1, __ATOMIC_RELAXED); } else { - __atomic_add_fetch(&e->refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&e->refcnt, 1, __ATOMIC_RELAXED); } t4_os_unlock(&e->lock); } @@ -196,7 +196,7 @@ struct smt_entry *cxgbe_smt_alloc_switching(struct rte_eth_dev *dev, u8 *smac) void cxgbe_smt_release(struct smt_entry *e) { if (__atomic_load_n(&e->refcnt, __ATOMIC_RELAXED) != 0) - __atomic_sub_fetch(&e->refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&e->refcnt, 1, __ATOMIC_RELAXED); } /** From patchwork Thu Mar 2 00:47:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124637 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 B68D941DAF; Thu, 2 Mar 2023 01:49:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 33E1D42D65; Thu, 2 Mar 2023 01:48:23 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 1331C427F5 for ; Thu, 2 Mar 2023 01:48:04 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 893C220BC5EA; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 893C220BC5EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=klgKtzzR/RFrB4MS2zydqM0SZXjwsNfTQgacclab/uU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OeI+4eUUCKdfIfp7mQ5t7mp2+YFDXP8kcfjtL0uB307jieNclwsLJWlXaXaVKOcbq AyYX+50RXvhA2LYgsJxAyRRkwkm3eIxxlAeBv7GRLiKbxAGolhqWiY9K7dSaxe9At2 64e5kmXo7fH+I6oLeUF65IK2yCz9JQZzkOuzQ49U= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 13/17] drivers/event: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:44 -0800 Message-Id: <1677718068-2412-14-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- drivers/event/cnxk/cnxk_eventdev_selftest.c | 12 ++++++------ drivers/event/cnxk/cnxk_tim_worker.h | 6 +++--- drivers/event/dsw/dsw_event.c | 6 +++--- drivers/event/octeontx/timvf_worker.h | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/event/cnxk/cnxk_eventdev_selftest.c b/drivers/event/cnxk/cnxk_eventdev_selftest.c index 577c99b..95c0f1b 100644 --- a/drivers/event/cnxk/cnxk_eventdev_selftest.c +++ b/drivers/event/cnxk/cnxk_eventdev_selftest.c @@ -554,7 +554,7 @@ typedef int (*validate_event_cb)(uint32_t index, uint8_t port, ret = validate_event(&ev); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to validate event"); rte_pktmbuf_free(ev.mbuf); - __atomic_sub_fetch(total_events, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(total_events, 1, __ATOMIC_RELAXED); } return 0; @@ -916,7 +916,7 @@ typedef int (*validate_event_cb)(uint32_t index, uint8_t port, if (seqn_list_update(seqn) == 0) { rte_pktmbuf_free(ev.mbuf); - __atomic_sub_fetch(total_events, 1, + __atomic_fetch_sub(total_events, 1, __ATOMIC_RELAXED); } else { plt_err("Failed to update seqn_list"); @@ -1072,7 +1072,7 @@ typedef int (*validate_event_cb)(uint32_t index, uint8_t port, if (seqn_list_update(seqn) == 0) { rte_pktmbuf_free(ev.mbuf); - __atomic_sub_fetch(total_events, 1, + __atomic_fetch_sub(total_events, 1, __ATOMIC_RELAXED); } else { plt_err("Failed to update seqn_list"); @@ -1217,7 +1217,7 @@ typedef int (*validate_event_cb)(uint32_t index, uint8_t port, if (ev.sub_event_type == MAX_STAGES) { /* last stage */ rte_pktmbuf_free(ev.mbuf); - __atomic_sub_fetch(total_events, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(total_events, 1, __ATOMIC_RELAXED); } else { ev.event_type = RTE_EVENT_TYPE_CPU; ev.sub_event_type++; @@ -1293,7 +1293,7 @@ typedef int (*validate_event_cb)(uint32_t index, uint8_t port, if (ev.queue_id == nr_queues - 1) { /* last stage */ rte_pktmbuf_free(ev.mbuf); - __atomic_sub_fetch(total_events, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(total_events, 1, __ATOMIC_RELAXED); } else { ev.event_type = RTE_EVENT_TYPE_CPU; ev.queue_id++; @@ -1338,7 +1338,7 @@ typedef int (*validate_event_cb)(uint32_t index, uint8_t port, if (ev.queue_id == nr_queues - 1) { /* Last stage */ rte_pktmbuf_free(ev.mbuf); - __atomic_sub_fetch(total_events, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(total_events, 1, __ATOMIC_RELAXED); } else { ev.event_type = RTE_EVENT_TYPE_CPU; ev.queue_id++; diff --git a/drivers/event/cnxk/cnxk_tim_worker.h b/drivers/event/cnxk/cnxk_tim_worker.h index a326d55..c087fe5 100644 --- a/drivers/event/cnxk/cnxk_tim_worker.h +++ b/drivers/event/cnxk/cnxk_tim_worker.h @@ -102,19 +102,19 @@ static inline void cnxk_tim_bkt_inc_nent(struct cnxk_tim_bkt *bktp) { - __atomic_add_fetch(&bktp->nb_entry, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&bktp->nb_entry, 1, __ATOMIC_RELAXED); } static inline void cnxk_tim_bkt_add_nent_relaxed(struct cnxk_tim_bkt *bktp, uint32_t v) { - __atomic_add_fetch(&bktp->nb_entry, v, __ATOMIC_RELAXED); + __atomic_fetch_add(&bktp->nb_entry, v, __ATOMIC_RELAXED); } static inline void cnxk_tim_bkt_add_nent(struct cnxk_tim_bkt *bktp, uint32_t v) { - __atomic_add_fetch(&bktp->nb_entry, v, __ATOMIC_RELEASE); + __atomic_fetch_add(&bktp->nb_entry, v, __ATOMIC_RELEASE); } static inline uint64_t diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c index 9932caf..89badca 100644 --- a/drivers/event/dsw/dsw_event.c +++ b/drivers/event/dsw/dsw_event.c @@ -50,7 +50,7 @@ if (unlikely(new_total_on_loan > dsw->max_inflight)) { /* Some other port took the last credits */ - __atomic_sub_fetch(&dsw->credits_on_loan, acquired_credits, + __atomic_fetch_sub(&dsw->credits_on_loan, acquired_credits, __ATOMIC_RELAXED); return false; } @@ -77,7 +77,7 @@ port->inflight_credits = leave_credits; - __atomic_sub_fetch(&dsw->credits_on_loan, return_credits, + __atomic_fetch_sub(&dsw->credits_on_loan, return_credits, __ATOMIC_RELAXED); DSW_LOG_DP_PORT(DEBUG, port->id, @@ -527,7 +527,7 @@ struct dsw_queue_flow_burst { target_qfs[*targets_len] = *candidate_qf; (*targets_len)++; - __atomic_add_fetch(&dsw->ports[candidate_port_id].immigration_load, + __atomic_fetch_add(&dsw->ports[candidate_port_id].immigration_load, candidate_flow_load, __ATOMIC_RELAXED); return true; diff --git a/drivers/event/octeontx/timvf_worker.h b/drivers/event/octeontx/timvf_worker.h index 3f1e77f..ad98ca0 100644 --- a/drivers/event/octeontx/timvf_worker.h +++ b/drivers/event/octeontx/timvf_worker.h @@ -108,7 +108,7 @@ static inline void timr_bkt_dec_lock(struct tim_mem_bucket *bktp) { - __atomic_add_fetch(&bktp->lock, 0xff, __ATOMIC_ACQ_REL); + __atomic_fetch_add(&bktp->lock, 0xff, __ATOMIC_ACQ_REL); } static inline uint32_t @@ -121,13 +121,13 @@ static inline void timr_bkt_inc_nent(struct tim_mem_bucket *bktp) { - __atomic_add_fetch(&bktp->nb_entry, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&bktp->nb_entry, 1, __ATOMIC_RELAXED); } static inline void timr_bkt_add_nent(struct tim_mem_bucket *bktp, uint32_t v) { - __atomic_add_fetch(&bktp->nb_entry, v, __ATOMIC_RELAXED); + __atomic_fetch_add(&bktp->nb_entry, v, __ATOMIC_RELAXED); } static inline uint64_t From patchwork Thu Mar 2 00:47:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124635 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 08F6641DAF; Thu, 2 Mar 2023 01:49:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12A8B42D4B; Thu, 2 Mar 2023 01:48:21 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id BCE4A4114B for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 9570220BC5EF; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9570220BC5EF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=to20R8gDo9G7r4nJzV65b2KJH1zEYNMkomne70mQ5aQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DdgqPqXPxoHPCDzfnUCb3Dzr45VoK1DQdezfOJQ5s6eAEUhmh/uvLmX7xrGM3W8J9 52DKmd6tLgzfBGqEb2syOQp94lrQy1DC5mzES4j7ZAv2MNPyzGMuUUqJwQyXBwTAm8 VpSZTT/UZpEaFt7KTHaB/bc3QJlkvXlvsQaRTbYw= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 14/17] dma/skeleton: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:45 -0800 Message-Id: <1677718068-2412-15-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- drivers/dma/skeleton/skeleton_dmadev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c index 9b6da65..43e7052 100644 --- a/drivers/dma/skeleton/skeleton_dmadev.c +++ b/drivers/dma/skeleton/skeleton_dmadev.c @@ -77,7 +77,7 @@ hw->zero_req_count = 0; rte_memcpy(desc->dst, desc->src, desc->len); - __atomic_add_fetch(&hw->completed_count, 1, __ATOMIC_RELEASE); + __atomic_fetch_add(&hw->completed_count, 1, __ATOMIC_RELEASE); (void)rte_ring_enqueue(hw->desc_completed, (void *)desc); } From patchwork Thu Mar 2 00:47:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124633 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 43A8C41DAF; Thu, 2 Mar 2023 01:49:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B80C942D4F; Thu, 2 Mar 2023 01:48:18 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E6B2A427EE for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id A15BA20BC5F0; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A15BA20BC5F0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=MzKmYk5JmvrwSyVoDIHINoxiTSLeg2r7NfOum45qy/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Knnu6sPvQ+8R4jOUQpt0xsG2Pc3Qr+mk2g4mADi2bUjNJBfUY7l+WhRMynPAfe2Nw IvFsO+NFHIjjdHNYt6ICD+apN3dQ5PyDqTufvQ88WRYFVT4GioKZPX04OAEZr2W8H6 lrRVB/J8HjHlDq5JDJs6lb0hPTOiCP+XavBfTBRo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 15/17] drivers/common: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:46 -0800 Message-Id: <1677718068-2412-16-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- drivers/common/cnxk/roc_nix_inl_dev.c | 2 +- drivers/common/mlx5/mlx5_common_mr.c | 2 +- drivers/common/mlx5/mlx5_common_utils.c | 10 +++++----- drivers/common/mlx5/mlx5_malloc.c | 16 ++++++++-------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/common/cnxk/roc_nix_inl_dev.c b/drivers/common/cnxk/roc_nix_inl_dev.c index 6f60961..45d6f62 100644 --- a/drivers/common/cnxk/roc_nix_inl_dev.c +++ b/drivers/common/cnxk/roc_nix_inl_dev.c @@ -741,7 +741,7 @@ inl_dev->work_cb(&tmp, sa, (port_id << 8) | 0x1); __atomic_store_n(ring_base + tail_l + 1, 0ULL, __ATOMIC_RELAXED); - __atomic_add_fetch((uint32_t *)ring_base, 1, + __atomic_fetch_add((uint32_t *)ring_base, 1, __ATOMIC_ACQ_REL); } else plt_err("Invalid SA"); diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c index 0e1d243..9ebe398 100644 --- a/drivers/common/mlx5/mlx5_common_mr.c +++ b/drivers/common/mlx5/mlx5_common_mr.c @@ -1650,7 +1650,7 @@ struct mlx5_mempool_get_extmem_data { unsigned int i; for (i = 0; i < mpr->mrs_n; i++) - __atomic_add_fetch(&mpr->mrs[i].refcnt, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&mpr->mrs[i].refcnt, 1, __ATOMIC_RELAXED); } /** diff --git a/drivers/common/mlx5/mlx5_common_utils.c b/drivers/common/mlx5/mlx5_common_utils.c index 58d744b..915a317 100644 --- a/drivers/common/mlx5/mlx5_common_utils.c +++ b/drivers/common/mlx5/mlx5_common_utils.c @@ -217,7 +217,7 @@ struct mlx5_list_entry * entry->lcore_idx = (uint32_t)lcore_index; LIST_INSERT_HEAD(&l_inconst->cache[lcore_index]->h, entry, next); - __atomic_add_fetch(&l_inconst->count, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&l_inconst->count, 1, __ATOMIC_RELAXED); DRV_LOG(DEBUG, "MLX5 list %s c%d entry %p new: %u.", l_const->name, lcore_index, (void *)entry, entry->ref_cnt); @@ -254,7 +254,7 @@ struct mlx5_list_entry * l_inconst->gen_cnt++; rte_rwlock_write_unlock(&l_inconst->lock); LIST_INSERT_HEAD(&l_inconst->cache[lcore_index]->h, local_entry, next); - __atomic_add_fetch(&l_inconst->count, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&l_inconst->count, 1, __ATOMIC_RELAXED); DRV_LOG(DEBUG, "mlx5 list %s entry %p new: %u.", l_const->name, (void *)entry, entry->ref_cnt); return local_entry; @@ -294,11 +294,11 @@ struct mlx5_list_entry * else l_const->cb_remove(l_const->ctx, entry); } else { - __atomic_add_fetch(&l_inconst->cache[entry->lcore_idx]->inv_cnt, + __atomic_fetch_add(&l_inconst->cache[entry->lcore_idx]->inv_cnt, 1, __ATOMIC_RELAXED); } if (!l_const->lcores_share) { - __atomic_sub_fetch(&l_inconst->count, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&l_inconst->count, 1, __ATOMIC_RELAXED); DRV_LOG(DEBUG, "mlx5 list %s entry %p removed.", l_const->name, (void *)entry); return 0; @@ -310,7 +310,7 @@ struct mlx5_list_entry * LIST_REMOVE(gentry, next); rte_rwlock_write_unlock(&l_inconst->lock); l_const->cb_remove(l_const->ctx, gentry); - __atomic_sub_fetch(&l_inconst->count, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&l_inconst->count, 1, __ATOMIC_RELAXED); DRV_LOG(DEBUG, "mlx5 list %s entry %p removed.", l_const->name, (void *)gentry); return 0; diff --git a/drivers/common/mlx5/mlx5_malloc.c b/drivers/common/mlx5/mlx5_malloc.c index cef3b88..c58c41d 100644 --- a/drivers/common/mlx5/mlx5_malloc.c +++ b/drivers/common/mlx5/mlx5_malloc.c @@ -99,7 +99,7 @@ struct mlx5_sys_mem { rte_mem_virt2memseg_list(addr), __ATOMIC_RELAXED); #ifdef RTE_LIBRTE_MLX5_DEBUG - __atomic_add_fetch(&mlx5_sys_mem.msl_update, 1, + __atomic_fetch_add(&mlx5_sys_mem.msl_update, 1, __ATOMIC_RELAXED); #endif } @@ -126,7 +126,7 @@ struct mlx5_sys_mem { if (!rte_mem_virt2memseg_list(addr)) return false; #ifdef RTE_LIBRTE_MLX5_DEBUG - __atomic_add_fetch(&mlx5_sys_mem.msl_miss, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(&mlx5_sys_mem.msl_miss, 1, __ATOMIC_RELAXED); #endif } return true; @@ -185,7 +185,7 @@ struct mlx5_sys_mem { mlx5_mem_update_msl(addr); #ifdef RTE_LIBRTE_MLX5_DEBUG if (addr) - __atomic_add_fetch(&mlx5_sys_mem.malloc_rte, 1, + __atomic_fetch_add(&mlx5_sys_mem.malloc_rte, 1, __ATOMIC_RELAXED); #endif return addr; @@ -199,7 +199,7 @@ struct mlx5_sys_mem { addr = malloc(size); #ifdef RTE_LIBRTE_MLX5_DEBUG if (addr) - __atomic_add_fetch(&mlx5_sys_mem.malloc_sys, 1, + __atomic_fetch_add(&mlx5_sys_mem.malloc_sys, 1, __ATOMIC_RELAXED); #endif return addr; @@ -233,7 +233,7 @@ struct mlx5_sys_mem { mlx5_mem_update_msl(new_addr); #ifdef RTE_LIBRTE_MLX5_DEBUG if (new_addr) - __atomic_add_fetch(&mlx5_sys_mem.realloc_rte, 1, + __atomic_fetch_add(&mlx5_sys_mem.realloc_rte, 1, __ATOMIC_RELAXED); #endif return new_addr; @@ -246,7 +246,7 @@ struct mlx5_sys_mem { new_addr = realloc(addr, size); #ifdef RTE_LIBRTE_MLX5_DEBUG if (new_addr) - __atomic_add_fetch(&mlx5_sys_mem.realloc_sys, 1, + __atomic_fetch_add(&mlx5_sys_mem.realloc_sys, 1, __ATOMIC_RELAXED); #endif return new_addr; @@ -259,13 +259,13 @@ struct mlx5_sys_mem { return; if (!mlx5_mem_is_rte(addr)) { #ifdef RTE_LIBRTE_MLX5_DEBUG - __atomic_add_fetch(&mlx5_sys_mem.free_sys, 1, + __atomic_fetch_add(&mlx5_sys_mem.free_sys, 1, __ATOMIC_RELAXED); #endif mlx5_os_free(addr); } else { #ifdef RTE_LIBRTE_MLX5_DEBUG - __atomic_add_fetch(&mlx5_sys_mem.free_rte, 1, + __atomic_fetch_add(&mlx5_sys_mem.free_rte, 1, __ATOMIC_RELAXED); #endif rte_free(addr); From patchwork Thu Mar 2 00:47:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124634 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 5B9F641DAF; Thu, 2 Mar 2023 01:49:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1260D42D5D; Thu, 2 Mar 2023 01:48:20 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E67E24161A for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id ADA7E20BC5F3; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com ADA7E20BC5F3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=7keIDftaQzbL3Tp7yP2VJJZYWoQ+dvutVmw3kQx+mnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SHd/e7PVzgFZ7KfEONCRth06BFE/eaDWAlcs5EIlPvSjm3WDmzHV0Q25pr/zSUsnX qafumMqxPxfesuHhwkZI1PVQ5lQpBsMLIXBoPo1RAdViWg3Jd0CH66M1CQhbfRqQsS NndphgfRvWQ8ILviJfFdWSevOfetdixFUt1C7Moc= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 16/17] app/test: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:47 -0800 Message-Id: <1677718068-2412-17-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- app/test/test_lcores.c | 2 +- app/test/test_service_cores.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c index 5b43aa5..2c945b0 100644 --- a/app/test/test_lcores.c +++ b/app/test/test_lcores.c @@ -40,7 +40,7 @@ static uint32_t thread_loop(void *arg) t->state = Thread_ERROR; } /* Report register happened to the control thread. */ - __atomic_add_fetch(t->registered_count, 1, __ATOMIC_RELEASE); + __atomic_fetch_add(t->registered_count, 1, __ATOMIC_RELEASE); /* Wait for release from the control thread. */ while (__atomic_load_n(t->registered_count, __ATOMIC_ACQUIRE) != 0) diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c index 637fcd7..9175736 100644 --- a/app/test/test_service_cores.c +++ b/app/test/test_service_cores.c @@ -751,12 +751,12 @@ static int32_t dummy_mt_safe_cb(void *args) uint32_t *lock = ¶ms[1]; while (!*done) { - __atomic_add_fetch(lock, 1, __ATOMIC_RELAXED); + __atomic_fetch_add(lock, 1, __ATOMIC_RELAXED); rte_delay_us(500); if (__atomic_load_n(lock, __ATOMIC_RELAXED) > 1) /* pass: second core has simultaneously incremented */ *done = 1; - __atomic_sub_fetch(lock, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(lock, 1, __ATOMIC_RELAXED); } return 0; From patchwork Thu Mar 2 00:47:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124631 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 2F8A841DAF; Thu, 2 Mar 2023 01:49:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C0CB42D2C; Thu, 2 Mar 2023 01:48:16 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E69B6427E9 for ; Thu, 2 Mar 2023 01:48:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id B9BEB20BC5F4; Wed, 1 Mar 2023 16:48:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B9BEB20BC5F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718082; bh=to9l92+D8cNrm2Iv3jh+V+7N5U6IhuqoNrrLXMKesko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qFRZMVZlmuBla0SrpZdJAIb22k7tegO2keLSvaO8xpelyIpQhlF19PfC0Q8+q7UTR ehkhBW32DXTdEZWT3loU4m0kMcQI59nQncZu7ejKdBsbBREifRq3P/neAYSUtCA2H8 Crq47dAqI+gKu59r1Hc/YEuQq2bSacMQOnWU2TcA= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 17/17] test-eventdev: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:48 -0800 Message-Id: <1677718068-2412-18-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-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 when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff --- app/test-eventdev/test_order_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-eventdev/test_order_common.h b/app/test-eventdev/test_order_common.h index 92781d9..1507265 100644 --- a/app/test-eventdev/test_order_common.h +++ b/app/test-eventdev/test_order_common.h @@ -113,7 +113,7 @@ struct test_order { */ expected_flow_seq[flow]++; rte_pktmbuf_free(ev->mbuf); - __atomic_sub_fetch(outstand_pkts, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(outstand_pkts, 1, __ATOMIC_RELAXED); } static __rte_always_inline void