[PATCH] eal/x86: fix TSC frequency query

Thomas Monjalon thomas at monjalon.net
Fri Jan 30 18:10:26 CET 2026


After getting TSC information from cpuid instruction,
some values must be multiplied and divided.
We must multiply first to get the most accurate value.

Example:
	before: 1000000000 * (23 / 10) = 2 GHz
	after:  1000000000 * 23 / 10 = 2.3 GHz

Bugzilla ID: 1869
Fixes: ad3516bb4ae1 ("eal/x86: implement arch-specific TSC freq query")
Cc: stable at dpdk.org

Reported-by: Luigi Rizzo <rizzo.unipi at gmail.com>
Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
---
 lib/eal/x86/rte_cycles.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/eal/x86/rte_cycles.c b/lib/eal/x86/rte_cycles.c
index f147a5231d..e8e805e710 100644
--- a/lib/eal/x86/rte_cycles.c
+++ b/lib/eal/x86/rte_cycles.c
@@ -145,7 +145,7 @@ get_tsc_freq_arch(void)
 
 		/* EBX : TSC/Crystal ratio, ECX : Crystal Hz */
 		if (b && c)
-			return c * (b / a);
+			return (uint64_t)c * b / a;
 	}
 
 #ifdef RTE_TOOLCHAIN_MSVC
-- 
2.52.0



More information about the stable mailing list