From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v3 2/2] latencystats: optimize locking on transmit
Date: Tue, 17 Jun 2025 08:00:17 -0700 [thread overview]
Message-ID: <20250617150252.814215-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20250617150252.814215-1-stephen@networkplumber.org>
If transmit callback is called, and there are no packets
in the burst with timestamp set, then the expensive operations
of locking and accessing TSC can be skipped.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/latencystats/rte_latencystats.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c
index 72a58d78d1..f61d5a273f 100644
--- a/lib/latencystats/rte_latencystats.c
+++ b/lib/latencystats/rte_latencystats.c
@@ -194,10 +194,17 @@ calc_latency(uint16_t pid __rte_unused,
{
unsigned int i;
uint64_t now, latency;
+ uint64_t ts_flags = 0;
static uint64_t prev_latency;
- now = rte_rdtsc();
+ for (i = 0; i < nb_pkts; i++)
+ ts_flags |= (pkts[i]->ol_flags & timestamp_dynflag);
+
+ /* no samples in this burst, skip locking */
+ if (likely(ts_flags == 0))
+ return nb_pkts;
+ now = rte_rdtsc();
rte_spinlock_lock(&glob_stats->lock);
for (i = 0; i < nb_pkts; i++) {
if (!(pkts[i]->ol_flags & timestamp_dynflag))
--
2.47.2
prev parent reply other threads:[~2025-06-17 15:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 0:34 [PATCH 0/2] Latencystat optimization and fix Stephen Hemminger
2025-06-13 0:34 ` [PATCH 1/2] latencystats: fix receive sample MP issues Stephen Hemminger
2025-06-13 0:34 ` [PATCH 2/2] latencystats: optimize locking on transmit Stephen Hemminger
2025-06-13 11:13 ` [PATCH 0/2] Latencystat optimization and fix Varghese, Vipin
2025-06-16 16:04 ` [PATCH v2 0/2] Latencystats optimizations " Stephen Hemminger
2025-06-16 16:04 ` [PATCH v2 1/2] latencystats: fix receive sample MP issues Stephen Hemminger
2025-06-16 16:04 ` [PATCH v2 2/2] latencystats: optimize locking on transmit Stephen Hemminger
2025-06-17 15:00 ` [PATCH v3 0/2] latencystats: fix receive sample MP issues Stephen Hemminger
2025-06-17 15:00 ` [PATCH v3 1/2] " Stephen Hemminger
2025-06-17 15:00 ` Stephen Hemminger [this message]
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=20250617150252.814215-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/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).