How to confirm whether __GI___clock_gettime() implemented as fast system call or not on x86_64 platform with Linux 4.19.84?

Florian Weimer fw@deneb.enyo.de
Tue Jul 21 17:02:44 GMT 2020


* Hal Murray:

> fw@deneb.enyo.de said:
>> You can run the program under strace, to see if the clock_gettime function
>> performs any system calls.  If the fast path is used, no system call shows
>> up. 
>
> Is there a way for a program to test at runtime if the fast path or syscall 
> will happen?

glibc doesn't know this.  It's possible that we call into the kernel
vDSO (where the syscall-less fast path lives), but the code there
still makes the system call after all because some precondition for
the fast path isn't met.

The kernel doesn't expose any explicit interface for this either, as
far as I know.

You'll have to use something with fork and ptrace, to see if a
clock_gettime call makes a system call or not (but in general, that
may even change over time).


More information about the Libc-help mailing list