patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v3] latencystats: fix timestamp marking and latency calculation
       [not found] <1537545703-9599-1-git-send-email-reshma.pattan@intel.com>
@ 2018-09-25 14:51 ` Reshma Pattan
  2018-10-25  8:31   ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Reshma Pattan @ 2018-09-25 14:51 UTC (permalink / raw)
  To: longtb5, konstantin.ananyev, dev; +Cc: stable, Reshma Pattan

Latency calculation logic is not correct for the case where
packets gets dropped before TX. As for the dropped packets,
the timestamp is not cleared, and such packets still gets
counted for latency calculation in next runs, that will result
in inaccurate latency measurement.

So fix this issue as below,

Before setting timestamp in mbuf, check mbuf don't have
any prior valid time stamp flag set and after marking
the timestamp, set mbuf flags to indicate timestamp is
valid.

Before calculating timestamp check mbuf flags are set to
indicate timestamp is valid.

With the above logic it is guaranteed that correct timestamps
have been used.

Fixes: 5cd3cac9ed ("latency: added new library for latency stats")

CC: stable@dpdk.org

Reported-by: Bao-Long Tran <longtb5@viettel.com.vn>
Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
Tested-by: Bao-Long Tran <longtb5@viettel.com.vn>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

---
v3: style related fix
v2: remove check for mbuf->timestamp
---
 lib/librte_latencystats/rte_latencystats.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/librte_latencystats/rte_latencystats.c b/lib/librte_latencystats/rte_latencystats.c
index 1fdec68e3..5715549e4 100644
--- a/lib/librte_latencystats/rte_latencystats.c
+++ b/lib/librte_latencystats/rte_latencystats.c
@@ -125,8 +125,11 @@ add_time_stamps(uint16_t pid __rte_unused,
 	for (i = 0; i < nb_pkts; i++) {
 		diff_tsc = now - prev_tsc;
 		timer_tsc += diff_tsc;
-		if (timer_tsc >= samp_intvl) {
+
+		if ((pkts[i]->ol_flags & PKT_RX_TIMESTAMP) == 0
+				&& (timer_tsc >= samp_intvl)) {
 			pkts[i]->timestamp = now;
+			pkts[i]->ol_flags |= PKT_RX_TIMESTAMP;
 			timer_tsc = 0;
 		}
 		prev_tsc = now;
@@ -156,7 +159,7 @@ calc_latency(uint16_t pid __rte_unused,
 
 	now = rte_rdtsc();
 	for (i = 0; i < nb_pkts; i++) {
-		if (pkts[i]->timestamp)
+		if (pkts[i]->ol_flags & PKT_RX_TIMESTAMP)
 			latency[cnt++] = now - pkts[i]->timestamp;
 	}
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH v3] latencystats: fix timestamp marking and latency calculation
  2018-09-25 14:51 ` [dpdk-stable] [PATCH v3] latencystats: fix timestamp marking and latency calculation Reshma Pattan
@ 2018-10-25  8:31   ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2018-10-25  8:31 UTC (permalink / raw)
  To: Reshma Pattan; +Cc: dev, longtb5, konstantin.ananyev, stable

25/09/2018 16:51, Reshma Pattan:
> Latency calculation logic is not correct for the case where
> packets gets dropped before TX. As for the dropped packets,
> the timestamp is not cleared, and such packets still gets
> counted for latency calculation in next runs, that will result
> in inaccurate latency measurement.
> 
> So fix this issue as below,
> 
> Before setting timestamp in mbuf, check mbuf don't have
> any prior valid time stamp flag set and after marking
> the timestamp, set mbuf flags to indicate timestamp is
> valid.
> 
> Before calculating timestamp check mbuf flags are set to
> indicate timestamp is valid.
> 
> With the above logic it is guaranteed that correct timestamps
> have been used.
> 
> Fixes: 5cd3cac9ed ("latency: added new library for latency stats")
> 
> CC: stable@dpdk.org
> 
> Reported-by: Bao-Long Tran <longtb5@viettel.com.vn>
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> Tested-by: Bao-Long Tran <longtb5@viettel.com.vn>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> 
> ---
> v3: style related fix
> v2: remove check for mbuf->timestamp
> ---

Applied, thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-25  8:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1537545703-9599-1-git-send-email-reshma.pattan@intel.com>
2018-09-25 14:51 ` [dpdk-stable] [PATCH v3] latencystats: fix timestamp marking and latency calculation Reshma Pattan
2018-10-25  8:31   ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon

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).