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 655C242C12; Fri, 2 Jun 2023 21:45:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A5AE942D3C; Fri, 2 Jun 2023 21:45:19 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id F097C406B8 for ; Fri, 2 Jun 2023 21:45:13 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 8FEE420B9C3E; Fri, 2 Jun 2023 12:45:12 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8FEE420B9C3E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1685735112; bh=AxpkL6p+DbCfKvPQq5pd0m+LPW41WW+sUGce3dUVbzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NMol7BV6ATG7bZOOG3uEFk3roTJ+JRqMSrNbti7miLB2cpPvK/89s/o8lHYmW0Vwd RH1DHXmvBGVip5sbCI2EgSckdJZ+LvIYcIzNgfr7m+66muHsn2khoQwR0/kV3ejLnf KqYiLoLptvYtJdxYc7pXuwwnyGbaR6rc+lMNwbwg= 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 5/6] net/null: replace rte atomics with GCC builtin atomics Date: Fri, 2 Jun 2023 12:45:06 -0700 Message-Id: <1685735107-19208-6-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 --- drivers/net/null/rte_eth_null.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 47d9554..31081af 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -37,8 +37,8 @@ struct null_queue { struct rte_mempool *mb_pool; struct rte_mbuf *dummy_packet; - rte_atomic64_t rx_pkts; - rte_atomic64_t tx_pkts; + uint64_t rx_pkts; + uint64_t tx_pkts; }; struct pmd_options { @@ -101,7 +101,8 @@ struct pmd_internals { bufs[i]->port = h->internals->port_id; } - rte_atomic64_add(&(h->rx_pkts), i); + /* NOTE: review for potential ordering optimization */ + __atomic_fetch_add(&h->rx_pkts, i, __ATOMIC_SEQ_CST); return i; } @@ -128,7 +129,8 @@ struct pmd_internals { bufs[i]->port = h->internals->port_id; } - rte_atomic64_add(&(h->rx_pkts), i); + /* NOTE: review for potential ordering optimization */ + __atomic_fetch_add(&h->rx_pkts, i, __ATOMIC_SEQ_CST); return i; } @@ -152,7 +154,8 @@ struct pmd_internals { for (i = 0; i < nb_bufs; i++) rte_pktmbuf_free(bufs[i]); - rte_atomic64_add(&(h->tx_pkts), i); + /* NOTE: review for potential ordering optimization */ + __atomic_fetch_add(&h->tx_pkts, i, __ATOMIC_SEQ_CST); return i; } @@ -174,7 +177,8 @@ struct pmd_internals { rte_pktmbuf_free(bufs[i]); } - rte_atomic64_add(&(h->tx_pkts), i); + /* NOTE: review for potential ordering optimization */ + __atomic_fetch_add(&h->tx_pkts, i, __ATOMIC_SEQ_CST); return i; } @@ -316,8 +320,9 @@ struct pmd_internals { RTE_MIN(dev->data->nb_rx_queues, RTE_DIM(internal->rx_null_queues))); for (i = 0; i < num_stats; i++) { + /* NOTE: review for atomic access */ igb_stats->q_ipackets[i] = - internal->rx_null_queues[i].rx_pkts.cnt; + internal->rx_null_queues[i].rx_pkts; rx_total += igb_stats->q_ipackets[i]; } @@ -325,8 +330,9 @@ struct pmd_internals { RTE_MIN(dev->data->nb_tx_queues, RTE_DIM(internal->tx_null_queues))); for (i = 0; i < num_stats; i++) { + /* NOTE: review for atomic access */ igb_stats->q_opackets[i] = - internal->tx_null_queues[i].tx_pkts.cnt; + internal->tx_null_queues[i].tx_pkts; tx_total += igb_stats->q_opackets[i]; } @@ -347,9 +353,11 @@ struct pmd_internals { internal = dev->data->dev_private; for (i = 0; i < RTE_DIM(internal->rx_null_queues); i++) - internal->rx_null_queues[i].rx_pkts.cnt = 0; + /* NOTE: review for atomic access */ + internal->rx_null_queues[i].rx_pkts = 0; for (i = 0; i < RTE_DIM(internal->tx_null_queues); i++) - internal->tx_null_queues[i].tx_pkts.cnt = 0; + /* NOTE: review for atomic access */ + internal->tx_null_queues[i].tx_pkts = 0; return 0; } -- 1.8.3.1