latency: clear mbuf timestamp after latency calculation

Message ID 1537345551-70316-1-git-send-email-longtb5@viettel.com.vn (mailing list archive)
State Superseded, archived
Headers
Series latency: clear mbuf timestamp after latency calculation |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

longtb5@viettel.com.vn Sept. 19, 2018, 8:18 a.m. UTC
  The timestamp of a mbuf should be cleared after that mbuf was used for
latency calculation, otherwise future packets which reuse the same mbuf
would inherit that previous timestamp. The latencystats library looks
for mbuf with non-zero timestamp, thus incorrectly inherited value would
result in incorrect latency measurement.

Cc: stable@dpdk.org

Signed-off-by: Bao-Long Tran <longtb5@viettel.com.vn>
---
 lib/librte_latencystats/rte_latencystats.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Patch

diff --git a/lib/librte_latencystats/rte_latencystats.c b/lib/librte_latencystats/rte_latencystats.c
index 1fdec68..2d5384e 100644
--- a/lib/librte_latencystats/rte_latencystats.c
+++ b/lib/librte_latencystats/rte_latencystats.c
@@ -156,8 +156,10 @@  calc_latency(uint16_t pid __rte_unused,
 
 	now = rte_rdtsc();
 	for (i = 0; i < nb_pkts; i++) {
-		if (pkts[i]->timestamp)
+		if (pkts[i]->timestamp) {
 			latency[cnt++] = now - pkts[i]->timestamp;
+			pkts[i]->timestamp = 0;
+		}
 	}
 
 	for (i = 0; i < cnt; i++) {