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, Jan 30, 10:19 AM
Unknown Object (File)
Fri, Jan 24, 11:02 AM
Unknown Object (File)
Mon, Jan 6, 3:53 PM
Unknown Object (File)
Oct 21 2024, 1:20 PM
Unknown Object (File)
Oct 21 2024, 1:19 PM
Unknown Object (File)
Oct 21 2024, 1:19 PM
Unknown Object (File)
Oct 21 2024, 1:05 PM
Unknown Object (File)
Sep 18 2024, 8:20 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.