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 66BBB42C12; Fri, 2 Jun 2023 21:45:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 55D654161A; Fri, 2 Jun 2023 21:45:14 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 14DA2406B8 for ; Fri, 2 Jun 2023 21:45:13 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 5A43820520BB; Fri, 2 Jun 2023 12:45:12 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5A43820520BB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1685735112; bh=tNjsjmgyVpQS4YZksCdikAWkG/+NSrX4VAAyh33yl24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KbxpaQWOPr+YdTJNOOTCIwcBxODEJSLJ1NEi16lrPl1by8xrhKf0J3ugaX1MCSmxS x8I/YRtCsgts+sWfxCJLKK+1xiyp/+JyBaFFrhH3O2ftbV1RLIs851qhshfE+Y86Ag oo4Mjl5yqMPGxuagYyW1UI81r0dVlBoYBqTINH0s= From: Tyler Retzlaff To: dev@dpdk.org, david.marchand@redhat.com Cc: Olivier Matz , Bruce Richardson , Kevin Laatz , Qiming Yang , Qi Zhang , Wenjun Wu , Tetsuya Mukawa , Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH v4 1/6] stack: replace rte atomics with GCC builtin atomics Date: Fri, 2 Jun 2023 12:45:02 -0700 Message-Id: <1685735107-19208-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1685735107-19208-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1685735107-19208-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Acked-by: Morten Brørup --- lib/stack/rte_stack_lf_generic.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/stack/rte_stack_lf_generic.h b/lib/stack/rte_stack_lf_generic.h index 7fa29ce..aad3747 100644 --- a/lib/stack/rte_stack_lf_generic.h +++ b/lib/stack/rte_stack_lf_generic.h @@ -26,8 +26,8 @@ * elements. If the mempool is near-empty to the point that this is a * concern, the user should consider increasing the mempool size. */ - return (unsigned int)rte_atomic64_read((rte_atomic64_t *) - &s->stack_lf.used.len); + /* NOTE: review for potential ordering optimization */ + return __atomic_load_n(&s->stack_lf.used.len, __ATOMIC_SEQ_CST); } static __rte_always_inline void @@ -67,8 +67,8 @@ 1, __ATOMIC_RELEASE, __ATOMIC_RELAXED); } while (success == 0); - - rte_atomic64_add((rte_atomic64_t *)&list->len, num); + /* NOTE: review for potential ordering optimization */ + __atomic_fetch_add(&list->len, num, __ATOMIC_SEQ_CST); } static __rte_always_inline struct rte_stack_lf_elem * @@ -82,14 +82,16 @@ /* Reserve num elements, if available */ while (1) { - uint64_t len = rte_atomic64_read((rte_atomic64_t *)&list->len); + /* NOTE: review for potential ordering optimization */ + uint64_t len = __atomic_load_n(&list->len, __ATOMIC_SEQ_CST); /* Does the list contain enough elements? */ if (unlikely(len < num)) return NULL; - if (rte_atomic64_cmpset((volatile uint64_t *)&list->len, - len, len - num)) + /* NOTE: review for potential ordering optimization */ + if (__atomic_compare_exchange_n(&list->len, &len, len - num, + 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) break; } -- 1.8.3.1