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 BC5AE41EC0; Fri, 17 Mar 2023 21:36:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C08942FD8; Fri, 17 Mar 2023 21:36:15 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 21B0042F98 for ; Fri, 17 Mar 2023 21:36:14 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 5FE892057676; Fri, 17 Mar 2023 13:36:13 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5FE892057676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679085373; bh=nsdvLde5xlkZj7R+2Is6fAZQ1FgzB7wzympua9DZJFU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FB4IsjH+It6jgnEy1OsAGnTt1bjkWeZ0v3a11cmPosWGBWjTX9qQy4DD1Mue9g1iM oLy30sOjy7yFyXHjPFh2jsPHTw5A81rUvl8YauoMN59YVKIEHdLIOjb/OnepeeP7Bl 476zDeR1dwFPRGIa6kCGm75r/SyGLvi0YIeLYFDY= Date: Fri, 17 Mar 2023 13:36:13 -0700 From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net Subject: Re: [PATCH 1/7] ring: replace rte atomics with GCC builtin atomics Message-ID: <20230317203613.GA30723@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679084388-19267-2-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1679084388-19267-2-git-send-email-roretzla@linux.microsoft.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Fri, Mar 17, 2023 at 01:19:42PM -0700, Tyler Retzlaff wrote: > 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 | 10 ++++++---- > 2 files changed, 6 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..f9a15b6 100644 > --- a/lib/ring/rte_ring_generic_pvt.h > +++ b/lib/ring/rte_ring_generic_pvt.h > @@ -92,8 +92,9 @@ > if (is_sp) > r->prod.head = *new_head, success = 1; > else > - success = rte_atomic32_cmpset(&r->prod.head, > - *old_head, *new_head); > + 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 +163,9 @@ > rte_smp_rmb(); > success = 1; > } else { > - success = rte_atomic32_cmpset(&r->cons.head, *old_head, > - *new_head); > + 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; just something i noticed and not related to this change. i note that old_head for both __rte_ring_move_prod_head and __rte_ring_move_con_head are performing a non-atomic load to initialize `*old_head` probably not the best idea.