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 B7AF342829; Thu, 23 Mar 2023 23:34:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E4F64161A; Thu, 23 Mar 2023 23:34:44 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8AC5540E09 for ; Thu, 23 Mar 2023 23:34:43 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id DA92220DEE39; Thu, 23 Mar 2023 15:34:42 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DA92220DEE39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679610882; bh=QDZ173vXnv0+sWe7FNjO42Kygh5EkFKz+2z4o/ZJHgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iLeZw7BChEpgzqNlKGQbVOxRjMH+nzOfpfrBUyzpULwmtQ/bAgTdWPZEJVSx3T45t +obNAZDyxJhL4dyooc2HA2zIzzajELr5G468Ez+EOcfkXlmzY6M0B5hniT+YMGxqSq ERYeTfc3th1twKwWRgcwPurIIDnu1f6Zr2vO00II= 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 v2 1/7] ring: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:34:35 -0700 Message-Id: <1679610881-25997-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679610881-25997-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679610881-25997-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..c284040 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