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
F131790058: D38341.id116426.diff
Sat, Oct 11, 4:39 AM
F131767688: D38341.diff
Sat, Oct 11, 12:26 AM
Unknown Object (File)
Wed, Oct 8, 1:54 AM
Unknown Object (File)
Tue, Oct 7, 5:56 AM
Unknown Object (File)
Mon, Sep 29, 8:24 AM
Unknown Object (File)
Fri, Sep 26, 4:36 AM
Unknown Object (File)
Fri, Sep 26, 2:42 AM
Unknown Object (File)
Fri, Sep 26, 12:52 AM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 49416
Build 46306: arc lint + arc unit

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.