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 595A642829; Thu, 23 Mar 2023 23:54:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A751542BFE; Thu, 23 Mar 2023 23:54:05 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 135EC4161A for ; Thu, 23 Mar 2023 23:54:00 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 3639320DEE39; Thu, 23 Mar 2023 15:53:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3639320DEE39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679612039; bh=tCa8X8S2f7jr678edWumHUvXPnyNRvkAJjw63wFt/VM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gadU7qfNL+DLjsEQzuPjpid1yK+IC/WGOm5UJRAVQKiRZaBHFir8o4d1u4mJzz4wa vadyZSBnCmzuuMegV1TmrIuJ2jpL2qQs1HLjh34tyh8UNQfC73dkb4d7w21ptxgbqD 0C8/wDG8FJiD6Omp2c2jJFzZisZhOiQvAcuZ1gJw= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, stephen@networkplumber.org, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH v3 1/7] ring: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:53:50 -0700 Message-Id: <1679612036-30773-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679612036-30773-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679612036-30773-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 Replace the use of rte_atomic.h types and functions, instead use GCC supplied C++11 memory model builtins. Signed-off-by: Tyler Retzlaff --- lib/ring/rte_ring_core.h | 1 - lib/ring/rte_ring_generic_pvt.h | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/ring/rte_ring_core.h b/lib/ring/rte_ring_core.h index 82b2370..b9c7860 100644 --- a/lib/ring/rte_ring_core.h +++ b/lib/ring/rte_ring_core.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/ring/rte_ring_generic_pvt.h b/lib/ring/rte_ring_generic_pvt.h index 5acb6e5..caa4c74 100644 --- a/lib/ring/rte_ring_generic_pvt.h +++ b/lib/ring/rte_ring_generic_pvt.h @@ -92,8 +92,10 @@ if (is_sp) r->prod.head = *new_head, success = 1; else - success = rte_atomic32_cmpset(&r->prod.head, - *old_head, *new_head); + /* NOTE: review for potential ordering optimization */ + success = __atomic_compare_exchange_n(&r->prod.head, + old_head, *new_head, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } while (unlikely(success == 0)); return n; } @@ -162,8 +164,10 @@ rte_smp_rmb(); success = 1; } else { - success = rte_atomic32_cmpset(&r->cons.head, *old_head, - *new_head); + /* NOTE: review for potential ordering optimization */ + success = __atomic_compare_exchange_n(&r->cons.head, + old_head, *new_head, 0, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } } while (unlikely(success == 0)); return n; -- 1.8.3.1