Page MenuHomeFreeBSD

libc: Fall back to rdtsc when using pvclock and rdtscp is not available
ClosedPublic

Authored by markj on Feb 1 2023, 5:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 13, 5:01 AM
Unknown Object (File)
Mon, Nov 10, 10:27 AM
Unknown Object (File)
Sat, Nov 1, 1:40 PM
Unknown Object (File)
Tue, Oct 28, 9:51 AM
Unknown Object (File)
Oct 19 2025, 7:26 AM
Unknown Object (File)
Oct 13 2025, 9:38 PM
Unknown Object (File)
Oct 13 2025, 9:38 PM
Unknown Object (File)
Oct 13 2025, 9:38 PM
Subscribers

Details

Summary

Now that kvmclock can optionally export timekeeping info to userspace
even on systems without rdtscp, we should fall back to using rdtsc when
necessary. This mimics pvclock_read_time_info() in the kernel.

Tested by: Shrikanth R Kamath <kshrikanth@juniper.net>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Feb 1 2023, 5:17 PM

I am curious, what is the hw/sw configuration where RDTSCP is not available? I believe the instruction itself was added at least with Nehalem (2009).

This revision is now accepted and ready to land.Feb 1 2023, 8:30 PM
In D38341#871021, @kib wrote:

I am curious, what is the hw/sw configuration where RDTSCP is not available? I believe the instruction itself was added at least with Nehalem (2009).

By default, the machine emulated by qemu-system-x86_64 is missing many "newer" capabilities. I did not ask for the exact configuration, but in my testing, the default -machine and -cpu parameters give you a system without AMDID_RDTSCP. So, this diff is mostly useful in cases where one does not control the (poorly chosen) hypervisor configuration.