summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorReshma Pattan <reshma.pattan@intel.com>2018-09-25 15:51:26 +0100
committerThomas Monjalon <thomas@monjalon.net>2018-10-25 10:30:13 +0200
commit77b7485af7f63f7d528f614ce27a5ce014cfd2c7 (patch)
tree1a81631d805eacfb3f687437424580a8fe7f317b /lib
parent66fd3a3b0f5be39ba30a2d6aa617604c8d221230 (diff)
downloaddpdk-77b7485af7f63f7d528f614ce27a5ce014cfd2c7.zip
dpdk-77b7485af7f63f7d528f614ce27a5ce014cfd2c7.tar.gz
dpdk-77b7485af7f63f7d528f614ce27a5ce014cfd2c7.tar.xz
latency: fix timestamp marking and latency calculation
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/librte_latencystats/rte_latencystats.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/librte_latencystats/rte_latencystats.c b/lib/librte_latencystats/rte_latencystats.c
index 1fdec68..5715549 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;
}