V2 [PATCH] x86: Update CPU feature detection

H.J. Lu hjl.tools@gmail.com
Thu Jun 18 15:09:43 GMT 2020


On Thu, Jun 18, 2020 at 1:09 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu via Libc-alpha:
>
> > 1. Add COMMON_CPUID_INDEX_7_ECX_1 for AVX512_BF16.
>
> Do you expect similar changes in the future?  This changes the layout of
> struct cpu_features.
>
> If __x86_get_cpu_features is exported, such a change will require a new
> symbol version for __x86_get_cpu_features and can therefore only be made
> at a release boundary.  Even then, statically linked libraries will
> silently use the old layout of struct cpu_features, silently giving
> incorrect results if linked against a newer glibc version.
>

Here is the updated patch with:

1. Divide architecture features into the usable features and the preferred
features.  The usable features are for correctness and can be exported in
a stable ABI.  The preferred features are for performance and only for
glibc internal use.
2. Change struct cpu_features to

struct cpu_features
{
  struct cpu_features_basic basic;
  unsigned int usable[USABLE_FEATURE_INDEX_MAX];
  struct cpuid_registers cpuid[COMMON_CPUID_INDEX_MAX];
  unsigned int preferred[PREFERRED_FEATURE_INDEX_MAX];
  ...
};

so that

struct cpu_features
{
  struct cpu_features_basic basic;
  unsigned int usable[USABLE_FEATURE_INDEX_MAX];
  struct cpuid_registers cpuid[COMMON_CPUID_INDEX_MAX];
};

can be exported via a stable ABI.  Currently there are 70 unused bits in
the usable array.  They should be sufficient for future use.  The cpuid
array can be expanded with backward binary compatibility for both .o and
.so files.


-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-x86-Update-CPU-feature-detection.patch
Type: text/x-patch
Size: 45077 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20200618/f6fdf74e/attachment-0001.bin>


More information about the Libc-alpha mailing list