diff mbox

[API-NEXT,2/2] linux-generic: cpu: fix cycle lost while cycle counter overflow

Message ID 1444049893-28349-3-git-send-email-ivan.khoronzhuk@linaro.org
State Accepted
Commit 88984e1ea814764ffa3697ed0a4d51bca817854b
Headers show

Commit Message

Ivan Khoronzhuk Oct. 5, 2015, 12:58 p.m. UTC
When counter reaches it's counter value, the next clock cycle will
cause it to roll over to zero. As result the counter spends 1
additional cycle to switch from UINT64_MAX to 0, it should be
taken into account with diff function.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 platform/linux-generic/include/odp_cpu_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_cpu_internal.h b/platform/linux-generic/include/odp_cpu_internal.h
index 28a0a84..5eeabef 100644
--- a/platform/linux-generic/include/odp_cpu_internal.h
+++ b/platform/linux-generic/include/odp_cpu_internal.h
@@ -19,7 +19,7 @@  uint64_t _odp_cpu_cycles_diff(uint64_t c1, uint64_t c2)
 	if (odp_likely(c2 >= c1))
 		return c2 - c1;
 
-	return c2 + (odp_cpu_cycles_max() - c1);
+	return c2 + (odp_cpu_cycles_max() - c1) + 1;
 }
 
 #ifdef __cplusplus