All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org, david.marchand@redhat.com
Cc: Olivier Matz <olivier.matz@6wind.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Kevin Laatz <kevin.laatz@intel.com>,
	Qiming Yang <qiming.yang@intel.com>,
	Qi Zhang <qi.z.zhang@intel.com>, Wenjun Wu <wenjun1.wu@intel.com>,
	Tetsuya Mukawa <mtetsuyah@gmail.com>,
	Honnappa.Nagarahalli@arm.com, thomas@monjalon.net,
	Tyler Retzlaff <roretzla@linux.microsoft.com>
Subject: [PATCH v4 6/6] net/ring: replace rte atomics with GCC builtin atomics
Date: Fri,  2 Jun 2023 12:45:07 -0700	[thread overview]
Message-ID: <1685735107-19208-7-git-send-email-roretzla@linux.microsoft.com> (raw)
In-Reply-To: <1685735107-19208-1-git-send-email-roretzla@linux.microsoft.com>

Replace the use of rte_atomic.h types and functions, instead use GCC
supplied C++11 memory model builtins.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 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_ring.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 = (uint16_t)rte_ring_dequeue_burst(r->rng,
 			ptrs, nb_bufs, NULL);
 	if (r->rng->flags & RING_F_SC_DEQ)
-		r->rx_pkts.cnt += nb_rx;
+		r->rx_pkts += 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 = (uint16_t)rte_ring_enqueue_burst(r->rng,
 			ptrs, nb_bufs, NULL);
 	if (r->rng->flags & RING_F_SP_ENQ)
-		r->tx_pkts.cnt += nb_tx;
+		r->tx_pkts += 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 = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
 			i < dev->data->nb_rx_queues; i++) {
-		stats->q_ipackets[i] = internal->rx_ring_queues[i].rx_pkts.cnt;
+		/* NOTE: review for atomic access */
+		stats->q_ipackets[i] = internal->rx_ring_queues[i].rx_pkts;
 		rx_total += stats->q_ipackets[i];
 	}
 
 	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
 			i < dev->data->nb_tx_queues; i++) {
-		stats->q_opackets[i] = internal->tx_ring_queues[i].tx_pkts.cnt;
+		/* NOTE: review for atomic access */
+		stats->q_opackets[i] = internal->tx_ring_queues[i].tx_pkts;
 		tx_total += stats->q_opackets[i];
 	}
 
@@ -207,9 +211,11 @@ struct pmd_internals {
 	struct pmd_internals *internal = dev->data->dev_private;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
-		internal->rx_ring_queues[i].rx_pkts.cnt = 0;
+		/* NOTE: review for atomic access */
+		internal->rx_ring_queues[i].rx_pkts = 0;
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
-		internal->tx_ring_queues[i].tx_pkts.cnt = 0;
+		/* NOTE: review for atomic access */
+		internal->tx_ring_queues[i].tx_pkts = 0;
 
 	return 0;
 }
-- 
1.8.3.1


  parent reply	other threads:[~2023-06-02 19:45 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 20:19 [PATCH 0/7] replace rte atomics with GCC builtin atomics Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 1/7] ring: " Tyler Retzlaff
2023-03-17 20:36   ` Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 2/7] stack: " Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 3/7] dma/idxd: " Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 4/7] net/ice: " Tyler Retzlaff
2023-03-17 20:41   ` Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 5/7] net/ixgbe: " Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 6/7] net/null: " Tyler Retzlaff
2023-03-17 20:44   ` Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 7/7] net/ring: " Tyler Retzlaff
2023-03-17 21:42 ` [PATCH 0/7] " Stephen Hemminger
2023-03-17 21:49   ` Tyler Retzlaff
2023-03-22 11:28     ` Morten Brørup
2023-03-22 14:21       ` Tyler Retzlaff
2023-03-22 14:58         ` Morten Brørup
2023-03-22 15:29           ` Tyler Retzlaff
2023-03-22 16:13             ` Morten Brørup
2023-03-22 16:40               ` Honnappa Nagarahalli
2023-03-22 17:07                 ` Morten Brørup
2023-03-22 17:38                   ` Honnappa Nagarahalli
2023-03-22 18:06                     ` Tyler Retzlaff
2023-05-02  3:37                       ` Tyler Retzlaff
2023-05-02  4:31                         ` Honnappa Nagarahalli
2023-03-23 22:34 ` [PATCH v2 " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 1/7] ring: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 2/7] stack: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 3/7] dma/idxd: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 4/7] net/ice: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 5/7] net/ixgbe: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 6/7] net/null: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 7/7] net/ring: " Tyler Retzlaff
2023-03-24  7:07   ` [PATCH v2 0/7] " Morten Brørup
2023-03-23 22:53 ` [PATCH v3 " Tyler Retzlaff
2023-03-23 22:53   ` [PATCH v3 1/7] ring: " Tyler Retzlaff
2023-03-23 22:53   ` [PATCH v3 2/7] stack: " Tyler Retzlaff
2023-05-24 20:08     ` David Marchand
2023-03-23 22:53   ` [PATCH v3 3/7] dma/idxd: " Tyler Retzlaff
2023-05-24 20:09     ` David Marchand
2023-05-25  8:41       ` Bruce Richardson
2023-05-25 13:59         ` Morten Brørup
2023-05-25 12:57     ` Kevin Laatz
2023-03-23 22:53   ` [PATCH v3 4/7] net/ice: " Tyler Retzlaff
2023-05-24 20:10     ` David Marchand
2023-03-23 22:53   ` [PATCH v3 5/7] net/ixgbe: " Tyler Retzlaff
2023-05-24 20:11     ` David Marchand
2023-03-23 22:53   ` [PATCH v3 6/7] net/null: " Tyler Retzlaff
2023-05-24 20:13     ` David Marchand
2023-03-23 22:53   ` [PATCH v3 7/7] net/ring: " Tyler Retzlaff
2023-05-24 20:12     ` David Marchand
2023-05-25  8:44       ` Bruce Richardson
2023-03-24  7:09   ` [PATCH v3 0/7] " Morten Brørup
2023-03-24 19:22     ` Tyler Retzlaff
2023-05-24 12:40   ` David Marchand
2023-05-24 15:47     ` Tyler Retzlaff
2023-05-24 20:06       ` David Marchand
2023-05-24 22:50         ` Tyler Retzlaff
2023-05-24 22:56           ` Honnappa Nagarahalli
2023-05-25  0:02             ` Tyler Retzlaff
2023-05-25  7:50               ` Morten Brørup
2023-06-02 19:45 ` [PATCH v4 0/6] " Tyler Retzlaff
2023-06-02 19:45   ` [PATCH v4 1/6] stack: " Tyler Retzlaff
2023-06-02 19:45   ` [PATCH v4 2/6] dma/idxd: " Tyler Retzlaff
2023-06-02 19:45   ` [PATCH v4 3/6] net/ice: " Tyler Retzlaff
2023-06-02 19:45   ` [PATCH v4 4/6] net/ixgbe: " Tyler Retzlaff
2023-06-02 19:45   ` [PATCH v4 5/6] net/null: " Tyler Retzlaff
2023-06-02 19:45   ` Tyler Retzlaff [this message]
2023-06-05  8:27     ` [PATCH v4 6/6] net/ring: " Olivier Matz
2023-06-06 21:45 ` [PATCH v5 0/6] " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 1/6] stack: " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 2/6] dma/idxd: " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 3/6] net/ice: " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 4/6] net/ixgbe: " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 5/6] net/null: " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 6/6] net/ring: " Tyler Retzlaff
2023-06-09 15:01   ` [PATCH v5 0/6] " David Marchand
2023-06-09 15:13     ` Tyler Retzlaff
2023-06-22 19:59       ` Patrick Robb
2023-06-23  8:53         ` David Marchand
2023-06-23 21:37           ` Tyler Retzlaff
2023-06-28 14:01             ` Patrick Robb
2023-06-28 14:49               ` David Marchand
2023-06-23 21:35         ` Tyler Retzlaff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1685735107-19208-7-git-send-email-roretzla@linux.microsoft.com \
    --to=roretzla@linux.microsoft.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=kevin.laatz@intel.com \
    --cc=mtetsuyah@gmail.com \
    --cc=olivier.matz@6wind.com \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=thomas@monjalon.net \
    --cc=wenjun1.wu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.