linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org, linux-api@vger.kernel.org,
	x86@kernel.org, linux-arch@vger.kernel.org,
	"H.J. Lu" <hjl.tools@gmail.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>
Subject: Re: x86 CPU features detection for applications (and AMX)
Date: Thu, 8 Jul 2021 18:56:55 +0100	[thread overview]
Message-ID: <20210708175655.GA33786@sirena.org.uk> (raw)
In-Reply-To: <87tulo39ms.fsf@oldenburg.str.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1662 bytes --]

On Wed, Jun 23, 2021 at 05:04:27PM +0200, Florian Weimer wrote:

Copying in Catalin & Will.

> We have an interface in glibc to query CPU features:

>   X86-specific Facilities
>   <https://www.gnu.org/software/libc/manual/html_node/X86.html>

> CPU_FEATURE_USABLE all preconditions for a feature are met,
> HAS_CPU_FEATURE means it's in silicon but possibly dormant.
> CPU_FEATURE_USABLE is supposed to look at XCR0, AT_HWCAP2 etc. before
> enabling the relevant bit (so it cannot pass through any unknown bits).

...

> When we designed this glibc interface, we assumed that bits would be
> static during the life-time of the process, initialized at process
> start.  That follows the model of previous x86 CPU feature enablement.

...

> This still wouldn't cover the enable/disable side, but at least it would
> work for CPU features which are modal and come and go.  The fact that we
> tell GCC to cache the returned pointer from that internal function, but
> not that the data is immutable works to our advantage here.

> On the other hand, maybe there is a way to give users a better
> interface.  Obviously we want to avoid a syscall for a simple CPU
> feature check.  And we also need something to enable/disable CPU
> features.

This enabling and disabling of CPU features sounds like something that
might also become relevant for arm64, for example I can see a use case
for having something that allows some of the more expensive features
to be masked from some userspace processes for resource management
purposes.  This sounds like a bit of a different use case to x86 AIUI
but I think there's overlap in the actual operations that would be
needed.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      parent reply	other threads:[~2021-07-08 17:57 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23 15:04 x86 CPU features detection for applications (and AMX) Florian Weimer
2021-06-23 15:32 ` Dave Hansen
2021-07-08  6:05   ` Florian Weimer
2021-07-08 14:19     ` Dave Hansen
2021-07-08 14:31       ` Florian Weimer
2021-07-08 14:36         ` Dave Hansen
2021-07-08 14:41           ` Florian Weimer
2021-06-25 23:31 ` Thiago Macieira
2021-06-28 12:40   ` Enrico Weigelt, metux IT consult
2021-06-28 13:20     ` Peter Zijlstra
2021-06-30 12:50       ` Enrico Weigelt, metux IT consult
2021-06-30 15:36         ` Thiago Macieira
2021-07-01  7:35           ` Enrico Weigelt, metux IT consult
2021-06-28 15:08     ` Thiago Macieira
2021-06-28 15:27       ` Peter Zijlstra
2021-06-28 16:13         ` Thiago Macieira
2021-06-28 17:11           ` Peter Zijlstra
2021-06-28 17:23             ` Thiago Macieira
2021-06-28 19:08               ` Peter Zijlstra
2021-06-28 19:26                 ` Thiago Macieira
2021-06-28 17:43           ` Peter Zijlstra
2021-06-28 19:05             ` Thiago Macieira
2021-06-30 14:32       ` Enrico Weigelt, metux IT consult
2021-06-30 14:34         ` Florian Weimer
2021-06-30 15:16           ` Enrico Weigelt, metux IT consult
2021-06-30 15:38             ` Florian Weimer
2021-07-01  8:08               ` Enrico Weigelt, metux IT consult
2021-07-01  8:21                 ` Florian Weimer
2021-07-01 11:59                   ` Enrico Weigelt, metux IT consult
2021-07-06 12:57                     ` Florian Weimer
2021-06-30 15:29         ` Thiago Macieira
2021-07-01 11:57           ` Enrico Weigelt, metux IT consult
2021-07-08  7:08   ` Florian Weimer
2021-07-08 15:13     ` Thiago Macieira
2021-07-08 17:56 ` Mark Brown [this message]

Reply instructions:

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

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

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210708175655.GA33786@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).