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 6E21942B91; Wed, 24 May 2023 22:08:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 28BF94067E; Wed, 24 May 2023 22:08:38 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 44AEA40156 for ; Wed, 24 May 2023 22:08:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684958916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iuGmF4zeauN9D7awAglWcLpq+JE3npq9NqvNYgcI9FA=; b=BYnbrWH6cUUCZQWNAXFNT8FIPv0yySaha6NR+5Q6S1PCa+y+eG6D09kI2Cb54fpNYgv+T1 y+FDLGoECrvcJmD5zQevpG0TyxmSPC0YwB0mYOzLCPXcMy824w7S7GlEvCQmk3W4GSQEwW toJsjrhv3cQXojfSObGCWSyOg82rnok= Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-19-_nceIV2GPf-hvl8g4iC9vg-1; Wed, 24 May 2023 16:08:35 -0400 X-MC-Unique: _nceIV2GPf-hvl8g4iC9vg-1 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-1ae6112de56so6297675ad.2 for ; Wed, 24 May 2023 13:08:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684958914; x=1687550914; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iuGmF4zeauN9D7awAglWcLpq+JE3npq9NqvNYgcI9FA=; b=QgN4A9mkWedsI8P4vQS2xjEwG94Ul1zbeFPOw6BMCCLta9QJGQAgUH4GBIw06QFY+W bazz9n76UNCFH3tWM0PKoQPAYRkuQTQtesBTIilMnsMn4LWit7QRFD6NDY3hJz+fjAU0 gcxOgTqS6cWu+s9xad+g9YijTNzRtrm+2vSZDXWpAEMmibj7LOa5s0XZOMyIar03lwAW 0U6uD2vnrZCTUpGyVHF713NtV5xXOMFpgO+WbSLvV+0ITLrWoWgKZueN8KroSj0YoETq Oy5q1ZLI8EIVSW+phlb/DXAbfSW4hdM1BqBiUszjaCTJOfAVqlEDete6x/pwKjH3egcX GzSg== X-Gm-Message-State: AC+VfDzA8L/aSq6YvIWbpWtz7Pv2tLzdz6abKvT4/6Hu6oaYd//uENV5 b55hV1UwzJvNDMiMsPLzzdxs15LLGb2f8Z9fp5Esz7MXVmY+nxaoEgnO9+cS0gjGTe8NT8MdknO HOBhy3rbuh/80fJLNg9k= X-Received: by 2002:a17:902:ecd0:b0:1a5:2540:729 with SMTP id a16-20020a170902ecd000b001a525400729mr20142382plh.56.1684958914344; Wed, 24 May 2023 13:08:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5UQhCLpcygsSguh9CMrT2KizmBlBoE+daLU4PhROoEFEI57CNhsm0TDDfYJGNrw5mTnUjKshDqtvnVqUaN7Xg= X-Received: by 2002:a17:902:ecd0:b0:1a5:2540:729 with SMTP id a16-20020a170902ecd000b001a525400729mr20142365plh.56.1684958914084; Wed, 24 May 2023 13:08:34 -0700 (PDT) MIME-Version: 1.0 References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679612036-30773-1-git-send-email-roretzla@linux.microsoft.com> <1679612036-30773-3-git-send-email-roretzla@linux.microsoft.com> In-Reply-To: <1679612036-30773-3-git-send-email-roretzla@linux.microsoft.com> From: David Marchand Date: Wed, 24 May 2023 22:08:22 +0200 Message-ID: Subject: Re: [PATCH v3 2/7] stack: replace rte atomics with GCC builtin atomics To: Olivier Matz Cc: dev@dpdk.org, Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, stephen@networkplumber.org, mb@smartsharesystems.com, Tyler Retzlaff X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Hello Olivier, Review please. On Thu, Mar 23, 2023 at 11:54=E2=80=AFPM 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/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_ge= neric.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 =3D=3D 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 =3D rte_atomic64_read((rte_atomic64_t *)&lis= t->len); > + /* NOTE: review for potential ordering optimization */ > + uint64_t len =3D __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 - n= um, > + 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) > break; > } > > -- > 1.8.3.1 > --=20 David Marchand