agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow retrieving x86 TSC frequency/flags from CPUID
Date: Tue, 07 Apr 2026 17:59:42 +0000
Message-ID: <E1wAAiD-003Qwj-0r@gemulon.postgresql.org> (raw)

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 <lukas@fittl.com>
Author: David Geier <geidav.pg@gmail.com>
Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: David Geier <geidav.pg@gmail.com>
Reviewed-by: John Naylor <john.naylor@postgresql.org>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com> (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(-)



Message-ID: <E1wAAiD-003Qwj-0r@gemulon.postgresql.org>
Permalink:  ../E1wAAiD-003Qwj-0r@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wAAiD-003Qwj-0r@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Allow retrieving x86 TSC frequency/flags from CPUID
  In-Reply-To: <E1wAAiD-003Qwj-0r@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox