V2 [PATCH] x86: Update CPU feature detection

H.J. Lu hjl.tools@gmail.com
Sat Jun 20 17:21:03 GMT 2020


On Thu, Jun 18, 2020 at 8:09 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> 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.
>

I will check it in on Monday if there are no further comments:

https://sourceware.org/pipermail/libc-alpha/2020-June/115171.html

Thanks.

-- 
H.J.


More information about the Libc-alpha mailing list