Skip to contentSkip to conversation

incorrect get_tsc_freq_arch() due to integer truncation

DPDK/core Bug 1869 [email protected] 1 participant 2 messages Jan 22 – Feb 17

lore
Share & tools
lore
#0 lore raw

http://bugs.dpdk.org/show_bug.cgi?id=1869

Bug ID: 1869
Summary: incorrect get_tsc_freq_arch() due to integer
truncation
Product: DPDK
Version: unspecified
Hardware: x86
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: core
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---

There is a bug in
https://github.com/DPDK/dpdk/blob/main/lib/eal/x86/rte_cycles.c#L148

143 __cpuid(0x15, a, b, c, d);
...
146 /* EBX : TSC/Crystal ratio, ECX : Crystal Hz */
147 if (b && c)
148 return c * (b / a);

On one machine, line 143 returns a 10 b 23 c 1000000000 d 0, the division (b / a) returns 2 hence leading to
an incorrect value (2 GHz instead of 2.3 GHz)

The trivial fix is to replace line 148 with

    return (uint64_t)c * b / a;
Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.
#1 lore raw

http://bugs.dpdk.org/show_bug.cgi?id=1869

Thomas Monjalon ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------

         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from Thomas Monjalon ([email protected]) --- Resolved in http://git.dpdk.org/dpdk/commit/?id=a17499cf33

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.