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