Accuracy of rte_get_tsc_hz() compared to linux
Isaac Boukris
iboukris at gmail.com
Thu Sep 19 11:37:43 CEST 2024
On Thu, Sep 19, 2024 at 2:27 AM Stephen Hemminger
<stephen at networkplumber.org> wrote:
>
> On Thu, 19 Sep 2024 01:04:40 +0300
> Isaac Boukris <iboukris at gmail.com> wrote:
>
> > I've run the helloworld application on an isolated cpu:
> > taskset -c 10 ./dpdk-helloworld --log-level=lib.eal:debug --no-huge
> >
> > The results are:
> > EAL: TSC frequency arch ~2100000 KHz
> > EAL: TSC frequency linux ~2095082 KHz
> > EAL: TSC frequency estimate ~2095346 KHz
> >
> > The arch one is picked, which seems rather wrong, any way to override that?
> > Should we lower the estimation rounding to 1MHz or even 1KHz in the linux one?
> >
> > Thoughts? Thanks!
> >
> > Kernel: 4.18.0-513.9.1.el8_9.x86_64
>
> Note: 4.18 kernel was end of life 12 August 2018, I assume
> this is RHEL8 which does their own backports and never changes kernel version.
Indeed RHEL 8.9
> What is the kernel dmesg, why is it deciding on that value?
It comes from kernel's determine_cpu_tsc_frequencies() afaict (which
didn't change that much).
As a matter of fact, I got a similar behavior on my vmware VM on my
laptop (although smaller diff).
kernel: 4.18.0-553.8.1.el8_10.x86_64
lscpu:
Model name: 12th Gen Intel(R) Core(TM) i7-1260P
Stepping: 3
CPU MHz: 2495.994
BogoMIPS: 4991.98
Hypervisor vendor: VMware
dmesg | grep -i tsc
[ 0.000000] vmware: TSC freq read from hypervisor : 2495.994 MHz
[ 0.000000] tsc: Detected 2495.994 MHz processor
[ 0.000000] TSC deadline timer available
[ 0.010000] clocksource: tsc-early: mask: 0xffffffffffffffff
max_cycles: 0x23fa717cb36, max_idle_ns: 440795237972 ns
[ 0.905000] clocksource: Switched to clocksource tsc-early
[ 3.104381] tsc: Refined TSC clocksource calibration: 2495.990 MHz
[ 3.105473] clocksource: tsc: mask: 0xffffffffffffffff max_cycles:
0x23fa6db1dfc, max_idle_ns: 440795265852 ns
[ 3.264297] clocksource: Switched to clocksource tsc
cat /sys/devices/system/cpu/cpu0/tsc_freq_khz
2495990
sudo bpftrace -e 'BEGIN { printf("%u\n", *kaddr("tsc_khz")); exit(); }'
Attaching 1 probe...
2495990
My modified dpdk code above gives:
EAL: TSC frequency arch ~0 KHz
EAL: TSC frequency linux ~2495982 KHz
EAL: TSC frequency estimate ~2497263 KHz
Note that with the unmodified dpdk code which rounds to 10MHz both the
linux and the common estimation would give 2500000 KHz.
More information about the users
mailing list