git: 84eaf2ccc6aa - x86: stop punishing VMs with low priority for TSC timecounter

Konstantin Belousov kostikbel at gmail.com
Wed Dec 23 17:21:42 UTC 2020


On Wed, Dec 23, 2020 at 08:59:54AM -0800, Maxim Sobolev wrote:
> Thanks! The slowdown in my experience mostly comes from the fact that only
> TSC has userspace-mapped implementation for the clock_gettime(2) and
> friends. Combined of course with the fact that syscall is still
HPET has userspace implementation, but of course HPET page access is
slower by several orders than RDTSC, if hypervisor is not involved.

That said, it really depends on hypervisor. It is possible to trap
RDTSC* and some hypervisors do that.  Some use feature available on most
Intel machines, where tsc can be adjusted by some fixed amount, which
avoids VMX exit.

Other clocks, like typically used ACPI-fast or i8254 if TSC is
disabled, always require VMX exit in addition to syscall, that makes
gettimeofday() prohibitely slow.

> horrendously expensive on VM. So if you have say 10 threads calling
> clock_gettime() 100 times per second (not uncommon for RTP/RTC apps) that
> causes 1,000 context switches just to do that. Let alone any useful
> workload the  app might be doing.
> 
> Unless the MFC is planned it might also be a good idea to document that for
> 12.x/11.x, the issue can easily be worked around by forcing TSC via loader
> tunable / sysctl.

I plan to do MFC, but plan to give a long time for this change in HEAD
to see complains.  Although in practicy I rarely get good feedback before
such kind of changes are merged to stable.


More information about the dev-commits-src-all mailing list