latencystats: fix timestamp marking and latency calculation
PATCH 1/1 latencystats: 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.
--- lib/librte_latencystats/rte_latencystats.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
lib/librte_latencystats/rte_latencystats.c +6 -2
@@ -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,8 @@ 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 ) && + pkts[i]->timestamp) latency[cnt++] = now - pkts[i]->timestamp; }
Signature · 1 line
2.14.4
Hi Reshma,
Quoted 6 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, September 21, 2018 11:02 PM
To: [email protected]; [email protected]; [email protected]
Cc: Reshma Pattan <[email protected]>
Subject: [PATCH] latencystats: fix timestamp marking and latency
calculation
Quoted 4 lines
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
Quoted 9 lines
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
Quoted 2 lines
is valid.
This solution as suggested by Konstantin is great. Not only does it solve the problem but also now the usage of mbuf->timestamp is not exclusive to latencystats anymore. The application can make use of timestamp at the same as latencystats simply by toggling PKT_RX_TIMESTAMP. I think we should update the doc to include this information.
Quoted 30 lines
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 <[email protected]>Signed-off-by Reshma Pattan <[email protected]>--- lib/librte_latencystats/rte_latencystats.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)lib/librte_latencystats/rte_latencystats.c +4
-1@@ -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;
lib/librte_latencystats/rte_latencystats.c calc_latency(uint16_t pid __rte_unused, · line 163
Quoted 6 lines
lib/librte_latencystats/rte_latencystats.c +2
-1@@ -156,7 +159,8 @@ 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 ) && + pkts[i]->timestamp)
Just a nit, but I think we don't have to check for pkts[i]->timestamp here.
Quoted 5 lines
lib/librte_latencystats/rte_latencystats.c +0
-1latency[cnt++] = now - pkts[i]->timestamp; } --2.14.4
Best regards,
BL
Hi,
Quoted 34 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Saturday, September 22, 2018 3:58 AM
To: Pattan, Reshma <[email protected]>; Ananyev, Konstantin <[email protected]>; [email protected]
Subject: RE: [PATCH] latencystats: fix timestamp marking and latency calculationHi Reshma,
Quoted 4 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, September 21, 2018 11:02 PM
To: [email protected]; [email protected];Quoted 2 lines
Cc: Reshma Pattan <[email protected]>
Subject: [PATCH] latencystats: fix timestamp marking and latencycalculation
Quoted 5 lines
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
Quoted 9 lines
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
Quoted 9 lines
Quoted 2 lines
is valid.
This solution as suggested by Konstantin is great. Not only does it solve the problem but also now the usage of
mbuf->timestampis not exclusive to latencystats anymore. The application can make use of timestamp at the same as latencystats simply by togglingPKT_RX_TIMESTAMP. I think we should update the doc to include this information.
Do you mean latency stats document? Or Mbuf doc.
Thanks,
Reshma
Hi Reshma,
I mean in the latencystats document. A few lines about what is taken away by the library (the mbuf timestamp when PKT_RX_TIMESTAMP is set) would be very helpful.
Best regards,
BL
----- Original Message -----
From: "reshma pattan" <[email protected]>
To: [email protected]
Cc: "Konstantin Ananyev" <[email protected]>, [email protected]
Sent: Monday, September 24, 2018 8:07:18 PM
Subject: RE: [PATCH] latencystats: fix timestamp marking and latency calculation
Hi,
Quoted 34 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Saturday, September 22, 2018 3:58 AM
To: Pattan, Reshma <[email protected]>; Ananyev, Konstantin <[email protected]>; [email protected]
Subject: RE: [PATCH] latencystats: fix timestamp marking and latency calculationHi Reshma,
Quoted 4 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, September 21, 2018 11:02 PM
To: [email protected]; [email protected];Quoted 2 lines
Cc: Reshma Pattan <[email protected]>
Subject: [PATCH] latencystats: fix timestamp marking and latencycalculation
Quoted 5 lines
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
Quoted 9 lines
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
Quoted 9 lines
Quoted 2 lines
is valid.
This solution as suggested by Konstantin is great. Not only does it solve the problem but also now the usage of
mbuf->timestampis not exclusive to latencystats anymore. The application can make use of timestamp at the same as latencystats simply by togglingPKT_RX_TIMESTAMP. I think we should update the doc to include this information.
Do you mean latency stats document? Or Mbuf doc.
Thanks,
Reshma
Quoted 6 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, September 21, 2018 11:02 PM
To: [email protected]; [email protected]; [email protected]
Cc: Reshma Pattan <[email protected]>
Subject: [PATCH] latencystats: fix timestamp marking and latency
calculation
Quoted 4 lines
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
Quoted 9 lines
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
Quoted 9 lines
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 <[email protected]>Signed-off-by Reshma Pattan <[email protected]>
PATCH v2 1/1 latencystats: fix timestamp marking and latency calculation
In reply to Reshma PattanLatency 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.
---
v2: remove check for mbuf->timestamp
--- lib/librte_latencystats/rte_latencystats.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
lib/librte_latencystats/rte_latencystats.c +5 -2
@@ -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; }
Signature · 1 line
2.14.4
Hi Reshma,
Quoted 38 lines
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 <[email protected]>Signed-off-by Reshma Pattan <[email protected]>Tested-by Bao-Long Tran <[email protected]>---
v2: remove check formbuf->timestamp--- lib/librte_latencystats/rte_latencystats.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)lib/librte_latencystats/rte_latencystats.c +0
-0
lib/librte_latencystats/rte_latencystats.c add_time_stamps(uint16_t pid __rte_unused, · line 130
Quoted 7 lines
lib/librte_latencystats/rte_latencystats.c +3
-1@@ -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)) {
As a nit - I think you need extra tab here, to follow dpdk codying style. Apart from that:
Quoted 16 lines
lib/librte_latencystats/rte_latencystats.c +2
-2pkts[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.14.4
PATCH v3 1/1 latencystats: fix timestamp marking and latency calculation
In reply to Reshma PattanLatency 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.
---
v3: style related fix
v2: remove check for mbuf->timestamp
--- lib/librte_latencystats/rte_latencystats.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
lib/librte_latencystats/rte_latencystats.c +5 -2
@@ -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; }
Signature · 1 line
2.17.1
Thomas Monjalon
Applied25/09/2018 16:51, Reshma Pattan:
Quoted 28 lines
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 <[email protected]>Signed-off-by Reshma Pattan <[email protected]>Tested-by Bao-Long Tran <[email protected]>
Quoted 4 lines
---
v3: style related fix
v2: remove check formbuf->timestamp
---
Applied, thanks