From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 221BF322C for ; Fri, 30 Nov 2018 00:14:36 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from yskoh@mellanox.com) with ESMTPS (AES256-SHA encrypted); 30 Nov 2018 01:20:26 +0200 Received: from scfae-sc-2.mti.labs.mlnx (scfae-sc-2.mti.labs.mlnx [10.101.0.96]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id wATNCW8A032075; Fri, 30 Nov 2018 01:14:31 +0200 From: Yongseok Koh To: Reshma Pattan Cc: Bao-Long Tran , Konstantin Ananyev , dpdk stable Date: Thu, 29 Nov 2018 15:11:04 -0800 Message-Id: <20181129231202.30436-70-yskoh@mellanox.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181129231202.30436-1-yskoh@mellanox.com> References: <20181129231202.30436-1-yskoh@mellanox.com> Subject: [dpdk-stable] patch 'latency: fix timestamp marking and latency calculation' has been queued to LTS release 17.11.5 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Nov 2018 23:14:36 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.5 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/01/18. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. If the code is different (ie: not only metadata diffs), due for example to a change in context or macro names, please double check it. Thanks. Yongseok --- >>From fb7cbbab947656038723156c7994cbc6c22dbbda Mon Sep 17 00:00:00 2001 From: Reshma Pattan Date: Tue, 25 Sep 2018 15:51:26 +0100 Subject: [PATCH] latency: fix timestamp marking and latency calculation [ upstream commit 77b7485af7f63f7d528f614ce27a5ce014cfd2c7 ] 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") Reported-by: Bao-Long Tran Signed-off-by: Reshma Pattan Tested-by: Bao-Long Tran Acked-by: Konstantin Ananyev --- 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 d6ad13c4e..b038c8154 100644 --- a/lib/librte_latencystats/rte_latencystats.c +++ b/lib/librte_latencystats/rte_latencystats.c @@ -153,8 +153,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; @@ -184,7 +187,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.11.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2018-11-29 15:01:48.306344626 -0800 +++ 0070-latency-fix-timestamp-marking-and-latency-calculatio.patch 2018-11-29 15:01:45.177962000 -0800 @@ -1,8 +1,10 @@ -From 77b7485af7f63f7d528f614ce27a5ce014cfd2c7 Mon Sep 17 00:00:00 2001 +From fb7cbbab947656038723156c7994cbc6c22dbbda Mon Sep 17 00:00:00 2001 From: Reshma Pattan Date: Tue, 25 Sep 2018 15:51:26 +0100 Subject: [PATCH] latency: fix timestamp marking and latency calculation +[ upstream commit 77b7485af7f63f7d528f614ce27a5ce014cfd2c7 ] + 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 @@ -23,7 +25,6 @@ have been used. Fixes: 5cd3cac9ed ("latency: added new library for latency stats") -Cc: stable@dpdk.org Reported-by: Bao-Long Tran Signed-off-by: Reshma Pattan @@ -34,10 +35,10 @@ 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 +index d6ad13c4e..b038c8154 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, +@@ -153,8 +153,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; @@ -50,7 +51,7 @@ timer_tsc = 0; } prev_tsc = now; -@@ -156,7 +159,7 @@ calc_latency(uint16_t pid __rte_unused, +@@ -184,7 +187,7 @@ calc_latency(uint16_t pid __rte_unused, now = rte_rdtsc(); for (i = 0; i < nb_pkts; i++) {