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 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 --- 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; } -- 1.8.3.1