From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Tetsuya Mukawa <mtetsuyah@gmail.com>
Subject: [PATCH 3/4] net/null: optimize Rx
Date: Wed, 26 Mar 2025 14:35:27 -0700 [thread overview]
Message-ID: <20250326213608.581345-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20250326213608.581345-1-stephen@networkplumber.org>
No other rx_burst function checks args, remove it.
Since rx_burst can only safely be called by a single thread
at a time, there is no need for atomic operations on statistics.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/null/rte_eth_null.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index baae81c572..7ac29b3f81 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -37,7 +37,7 @@ struct null_queue {
struct rte_mempool *mb_pool;
void *dummy_packet;
- RTE_ATOMIC(uint64_t) rx_pkts;
+ uint64_t rx_pkts;
RTE_ATOMIC(uint64_t) tx_pkts;
};
@@ -88,9 +88,6 @@ eth_null_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
struct null_queue *h = q;
unsigned int packet_size;
- if ((q == NULL) || (bufs == NULL))
- return 0;
-
packet_size = h->internals->packet_size;
if (rte_pktmbuf_alloc_bulk(h->mb_pool, bufs, nb_bufs) != 0)
return 0;
@@ -101,10 +98,8 @@ eth_null_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
bufs[i]->port = h->internals->port_id;
}
- /* NOTE: review for potential ordering optimization */
- rte_atomic_fetch_add_explicit(&h->rx_pkts, i, rte_memory_order_seq_cst);
-
- return i;
+ h->rx_pkts += nb_bufs;
+ return nb_bufs;
}
static uint16_t
@@ -114,9 +109,6 @@ eth_null_copy_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
struct null_queue *h = q;
unsigned int packet_size;
- if ((q == NULL) || (bufs == NULL))
- return 0;
-
packet_size = h->internals->packet_size;
if (rte_pktmbuf_alloc_bulk(h->mb_pool, bufs, nb_bufs) != 0)
return 0;
@@ -129,10 +121,8 @@ eth_null_copy_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
bufs[i]->port = h->internals->port_id;
}
- /* NOTE: review for potential ordering optimization */
- rte_atomic_fetch_add_explicit(&h->rx_pkts, i, rte_memory_order_seq_cst);
-
- return i;
+ h->rx_pkts += nb_bufs;
+ return nb_bufs;
}
static uint16_t
@@ -326,7 +316,6 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)
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;
rx_total += igb_stats->q_ipackets[i];
@@ -360,7 +349,6 @@ eth_stats_reset(struct rte_eth_dev *dev)
internal = dev->data->dev_private;
for (i = 0; i < RTE_DIM(internal->rx_null_queues); i++)
- /* 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 = 0;
--
2.47.2
next prev parent reply other threads:[~2025-03-26 21:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 21:35 [PATCH 0/4] net/null optimizations Stephen Hemminger
2025-03-26 21:35 ` [PATCH 1/4] net/null: Tx optimizations Stephen Hemminger
2025-03-26 21:35 ` [PATCH 2/4] net/null: fix packet copy Stephen Hemminger
2025-03-26 21:35 ` Stephen Hemminger [this message]
2025-03-26 21:35 ` [PATCH 4/4] net/null: count all queues Stephen Hemminger
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=20250326213608.581345-4-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=mtetsuyah@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).