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 7672242B91; Wed, 24 May 2023 22:12:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 681CD4067E; Wed, 24 May 2023 22:12:59 +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 8598E40156 for ; Wed, 24 May 2023 22:12:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684959178; 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=MqngXJw8GbTFGdS9RBWEaLIaQs5PZQywQQ35QhMH2PM=; b=dicapAil6zgpdqHb1VhfmdeAlxFdFOr9HmwqeDOE6N/0E7DWeGzajdJNUlRd9BIGDtuTpo zrpdNYhKoxriYK9RzJYLn4MwLxBAsu603FCZIXzyB5BKy2ziN96DgTfZQiSu5eKf4zLVq5 HxbeWMHeczBC9M2Pe9yabOOsoPMzJ1U= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-HcZCZkjnPBWiBdzmLS_1NA-1; Wed, 24 May 2023 16:12:56 -0400 X-MC-Unique: HcZCZkjnPBWiBdzmLS_1NA-1 Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-528ab71c95cso413255a12.0 for ; Wed, 24 May 2023 13:12:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684959176; x=1687551176; 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=MqngXJw8GbTFGdS9RBWEaLIaQs5PZQywQQ35QhMH2PM=; b=cT+4Ahd/fOs6Y+LlDGL87G4sWOGCCqEjwmdZLHAMr3GjIHS75z9vKfmCiHwQorvf3T pdKPP3gj9IxA+pNzd8/EqGer7bZJL/F4z3mjfO/jFUrk40T5iO125RYkgPxYApNhdZ4c YbQr+b4+bBMSoeB2ZjxigurKy8LCIj83MNsqhpNbRjByhdpU9YveteiRrBIxMs4agkQB 24Uh4xQ/y+5itkc7Y/DAYBvzFvL/tFW38rztZKXYUB7WEooAX+w1G8vJOX9Mp48sUICz uXDvw9HDjRL6OSa9/4n+zeqxbey6SgTWCj8JqREZ0zetu+GLttoumT9V7pXJe9zfIM5O 11OA== X-Gm-Message-State: AC+VfDyQ8F0Qk8wS8kYkYWx4hklfzZ6d/8gb2C3LxLhy5cpKXBB+kOWo VM79CwTbSZYay5amR9mrzy7SxO6jCUB/Vxeep+SePeI7h2Cg/vVXzg+Uf60QoOjPZJohNv9sQc3 tNHrpooEnvPJmQBcVQfg= X-Received: by 2002:a17:902:f391:b0:1af:b049:b32e with SMTP id f17-20020a170902f39100b001afb049b32emr8400346ple.56.1684959175924; Wed, 24 May 2023 13:12:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7TmvBidtJoF7ZUy3+O/fCTMSW37Ybaa59+G3Vgk47KjWNUr8hT69OXxynjgeXafj0CsAkoCBruL/oi/z794FU= X-Received: by 2002:a17:902:f391:b0:1af:b049:b32e with SMTP id f17-20020a170902f39100b001afb049b32emr8400334ple.56.1684959175650; Wed, 24 May 2023 13:12:55 -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-8-git-send-email-roretzla@linux.microsoft.com> In-Reply-To: <1679612036-30773-8-git-send-email-roretzla@linux.microsoft.com> From: David Marchand Date: Wed, 24 May 2023 22:12:44 +0200 Message-ID: Subject: Re: [PATCH v3 7/7] net/ring: replace rte atomics with GCC builtin atomics To: Bruce Richardson 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 Bruce, For you again, 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 > --- > drivers/net/ring/rte_eth_ring.c | 26 ++++++++++++++++---------- > 1 file changed, 16 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_r= ing.c > index e8bc9b6..43eb627 100644 > --- a/drivers/net/ring/rte_eth_ring.c > +++ b/drivers/net/ring/rte_eth_ring.c > @@ -44,8 +44,8 @@ enum dev_action { > > struct ring_queue { > struct rte_ring *rng; > - rte_atomic64_t rx_pkts; > - rte_atomic64_t tx_pkts; > + uint64_t rx_pkts; > + uint64_t tx_pkts; > }; > > struct pmd_internals { > @@ -80,9 +80,10 @@ struct pmd_internals { > const uint16_t nb_rx =3D (uint16_t)rte_ring_dequeue_burst(r->rng, > ptrs, nb_bufs, NULL); > if (r->rng->flags & RING_F_SC_DEQ) > - r->rx_pkts.cnt +=3D nb_rx; > + r->rx_pkts +=3D nb_rx; > else > - rte_atomic64_add(&(r->rx_pkts), nb_rx); > + /* NOTE: review for potential ordering optimization */ > + __atomic_fetch_add(&r->rx_pkts, nb_rx, __ATOMIC_SEQ_CST); > return nb_rx; > } > > @@ -94,9 +95,10 @@ struct pmd_internals { > const uint16_t nb_tx =3D (uint16_t)rte_ring_enqueue_burst(r->rng, > ptrs, nb_bufs, NULL); > if (r->rng->flags & RING_F_SP_ENQ) > - r->tx_pkts.cnt +=3D nb_tx; > + r->tx_pkts +=3D nb_tx; > else > - rte_atomic64_add(&(r->tx_pkts), nb_tx); > + /* NOTE: review for potential ordering optimization */ > + __atomic_fetch_add(&r->tx_pkts, nb_tx, __ATOMIC_SEQ_CST); > return nb_tx; > } > > @@ -184,13 +186,15 @@ struct pmd_internals { > > for (i =3D 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && > i < dev->data->nb_rx_queues; i++) { > - stats->q_ipackets[i] =3D internal->rx_ring_queues[i].rx_p= kts.cnt; > + /* NOTE: review for atomic access */ > + stats->q_ipackets[i] =3D internal->rx_ring_queues[i].rx_p= kts; > rx_total +=3D stats->q_ipackets[i]; > } > > for (i =3D 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && > i < dev->data->nb_tx_queues; i++) { > - stats->q_opackets[i] =3D internal->tx_ring_queues[i].tx_p= kts.cnt; > + /* NOTE: review for atomic access */ > + stats->q_opackets[i] =3D internal->tx_ring_queues[i].tx_p= kts; > tx_total +=3D stats->q_opackets[i]; > } > > @@ -207,9 +211,11 @@ struct pmd_internals { > struct pmd_internals *internal =3D dev->data->dev_private; > > for (i =3D 0; i < dev->data->nb_rx_queues; i++) > - internal->rx_ring_queues[i].rx_pkts.cnt =3D 0; > + /* NOTE: review for atomic access */ > + internal->rx_ring_queues[i].rx_pkts =3D 0; > for (i =3D 0; i < dev->data->nb_tx_queues; i++) > - internal->tx_ring_queues[i].tx_pkts.cnt =3D 0; > + /* NOTE: review for atomic access */ > + internal->tx_ring_queues[i].tx_pkts =3D 0; > > return 0; > } > -- > 1.8.3.1 > --=20 David Marchand