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;

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to