aboutsummaryrefslogtreecommitdiff
path: root/test/performance
diff options
context:
space:
mode:
authorIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>2015-11-05 17:33:45 +0200
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-11-25 16:11:07 +0300
commit9ba0ff81a33077472eea84670b45e85a8457ea23 (patch)
tree3a550c4124faf33849bf42874ff8ea4ee8b93ff4 /test/performance
parenta7eacf3e43ea0b127fc7ee2327ad1f7d598d4d38 (diff)
performance: odp_pktio_perf: fix potential overflow in wait loop
There cannot be used direct comparison of timestamps of counter that can overflow, better to compare ranges. Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'test/performance')
-rw-r--r--test/performance/odp_pktio_perf.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index efd26dc73..ae5b4c0b2 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -591,9 +591,13 @@ static int setup_txrx_masks(odp_cpumask_t *thd_mask_tx,
*/
static void busy_loop_ns(uint64_t wait_ns)
{
- uint64_t end = odp_time_cycles() + odp_time_ns_to_cycles(wait_ns);
- while (odp_time_cycles() < end)
- ;
+ uint64_t diff;
+ uint64_t start_time = odp_time_cycles();
+ uint64_t wait = odp_time_ns_to_cycles(wait_ns);
+
+ do {
+ diff = odp_time_diff_cycles(start_time, odp_time_cycles());
+ } while (diff < wait);
}
/*