diff mbox

[2/2] performance: odp_pktio_perf: fix potential overflow for burst_gap

Message ID 1438870038-25155-3-git-send-email-ivan.khoronzhuk@linaro.org
State New
Headers show

Commit Message

Ivan Khoronzhuk Aug. 6, 2015, 2:07 p.m. UTC
The direct comparing of "cur_cycles" and "next_tx_cycles" is not
valid, as "next_tx_cycles" can be overflowed and comparison will
give wrong result. So use odp_time_diff_cycles() for that, as it
takes in account ticks overflow.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 test/performance/odp_pktio_perf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index 8f1daeb..4a537ec 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -338,7 +338,8 @@  static void *run_thread_tx(void *arg)
 	while (odp_time_diff_cycles(cur_cycles, end_cycles) < send_duration) {
 		unsigned alloc_cnt = 0, tx_cnt;
 
-		if (cur_cycles < next_tx_cycles) {
+		if (odp_time_diff_cycles(cur_cycles, next_tx_cycles)
+							< burst_gap_cycles) {
 			cur_cycles = odp_time_cycles();
 			if (idle_start == 0)
 				idle_start = cur_cycles;