Allow retrieving x86 TSC frequency/flags from CPUID

This adds additional x86 specific CPUID checks for flags needed for
determining whether the Time-Stamp Counter (TSC) is usable on a given system,
as well as a helper function to retrieve the TSC frequency from CPUID.

This is intended for a future patch that will utilize the TSC to lower the
overhead of timing instrumentation.

In passing, always make pg_cpuid_subleaf reset the variables used for its
result, to avoid accidentally using stale results if __get_cpuid_count errors
out and the caller doesn't check for it.

Author: Lukas Fittl <[email protected]>
Author: David Geier <[email protected]>
Author: Andres Freund <[email protected]>
Reviewed-by: Andres Freund <[email protected]>
Reviewed-by: David Geier <[email protected]>
Reviewed-by: John Naylor <[email protected]>
Reviewed-by: Jakub Wartak <[email protected]> (in an earlier 
version)
Discussion: 
https://www.postgresql.org/message-id/flat/20200612232810.f46nbqkdhbutzqdg%40alap3.anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/bcb2cf41f964e9ed4d27abe4dee8daa249f659bb

Modified Files
--------------
src/include/port/pg_cpu.h |  12 +++-
src/port/pg_cpu_x86.c     | 138 ++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 145 insertions(+), 5 deletions(-)

Reply via email to