I'm really trying to understand why our guest VMs aren't using the kvm-clock driver "like they're supposed to". They're running RHEL 7.2, glibc-2.17, kern 3.10.0. Programs such as
perl -e 'print time' get the current time, but do so without making a system call. This is confirmed with strace and ltrace and further confirmed by using gdb and tracing through assembly which bypassed the
syscall and instead executed some instruction called
Is this an attempt at optimization by the glibc authors? Is there any way to disable this and force glibc calls to make the systemcall (short of LD_PRELOAD hacks)?
After reviewing the latest POSIX draft, part of the answer is clear: there is a way to request the clock from the CPU, but GNU glibc has wrongly forced this implementation on its users. The work-around is to invoke the system call directly. (Booooh)
If _POSIX_CPUTIME is defined, implementations shall support clock ID values obtained by invoking clock_getcpuclockid(), which represent the CPU-time clock of a given process. Implementations shall also support the special clockid_t value CLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_() or timer_() functions.
Given that the user can Is there any real argument against the notion that if
clock_id is set to
CLOCK_REALTIME, the system call should be used?