unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
To: "Carlos O'Donell" <carlos@redhat.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] x86: Install <bits/platform/x86.h> [BZ #27958]
Date: Sat, 10 Jul 2021 10:21:21 -0700	[thread overview]
Message-ID: <CAMe9rOpPbX4qrrpWgsq0djFvVhAK4U=kEjGuwwvmgNO=9WSTJw@mail.gmail.com> (raw)
In-Reply-To: <83077104-ea01-0afc-5636-87e1039d463a@redhat.com>

On Fri, Jul 9, 2021 at 1:01 PM Carlos O'Donell <carlos@redhat.com> wrote:
>
> On 6/5/21 9:59 AM, H.J. Lu via Libc-alpha wrote:
> > Install <bits/platform/x86.h> for <sys/platform/x86.h> which includes
> > <bits/platform/x86.h>.
> >
> > Fixes BZ #27958.
>
> The constants in bits/platform/x86.h are largely ABI given the behaviour
> of the cpuid instruction. Likewise we do a consistent mapping between
> the cpuid_array <-> usable_array without exposing internal details.
>
> The API in sys/platform/x86.h has already been reviewed, discussed, and
> exposes HAS_CPU_FEATURE(name) and CPU_FEATURE_USABLE(name).
>
> Given that we get one more chance at review let me ask a few final questions.
>
> (1) API prefixes in macros help developers remember names.
>
>   Consistent prefix for APIs help developers remember.
>
>   We use HAS_* but also CPU_* which requires the programmer remember
>   two distinct naming strategies.
>
>   Suggestion: CPU_FEATURE_PRESENT(), CPU_FEATURE_USABLE()?

I will rename them to CPU_FEATURE_PRESENT and CPU_FEATURE_POSSIBLE.
Given the current AMX support discussion, additional information may be needed
from the Linux kernel to determine if a feature can be used.

>   Note: We do this in the underlying name e.g. x86_cpu_*
>         has_feature (could be is_present) vs. is_usable.

I will change them to x86_cpu_present and x86_cpu_possible.   I will also
rename the "usable" field to "possible".

> (2) ABI testing?
>
>   - How are we making sure we don't accidentally break ABI?
>
>     - Do we need any further testing?

We only export

struct cpuid_feature
{
  unsigned int cpuid_array[4];
  unsigned int possible_array[4];
};

extern const struct cpuid_feature *__x86_get_cpuid_feature_leaf (unsigned int)
     __attribute__ ((pure));

const struct cpuid_feature *
__x86_get_cpuid_feature_leaf (unsigned int leaf)
{
  static const struct cpuid_feature feature = {};
  if (leaf < CPUID_INDEX_MAX)
    return ((const struct cpuid_feature *)
      &GLRO(dl_x86_cpu_features).features[leaf]);
  else
    return &feature;
}

As long as all new features are appended to the end, there should be
no ABI issues.

>   - Do we have a decoupled test to ensure a refactor doesn't break
>     things?

This shouldn't be a problem.

>     - We have tst-cpu-features-cpuinfo.c, which should cover
>       comparison to the decoupled cpuinfo.
>
> Notes:
>
> - We will not be able to avoid in-place-update failures, in that rpm
>   will do an atomic rename that unlinks the old libc.so.6 with the
>   new libc.so.6 and if ld.so is not yet updated or updated first then
>   a process that starts will crash. This makes it error prone to update
>   the ABI in downstream minor updates.
>
> > ---
> >  sysdeps/x86/Makefile | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
> > index 346ec491b3..567ea54243 100644
> > --- a/sysdeps/x86/Makefile
> > +++ b/sysdeps/x86/Makefile
> > @@ -5,7 +5,7 @@ endif
> >  ifeq ($(subdir),elf)
> >  sysdep_routines += get-cpuid-feature-leaf
> >  sysdep-dl-routines += dl-get-cpu-features
> > -sysdep_headers += sys/platform/x86.h
> > +sysdep_headers += sys/platform/x86.h bits/platform/x86.h
> >
> >  CFLAGS-get-cpuid-feature-leaf.o += $(no-stack-protector)
>
>
>
> --
> Cheers,
> Carlos.
>

Thanks.

-- 
H.J.

  reply	other threads:[~2021-07-10 17:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-05 13:59 [PATCH] x86: Install <bits/platform/x86.h> [BZ #27958] H.J. Lu via Libc-alpha
2021-07-09 20:01 ` Carlos O'Donell via Libc-alpha
2021-07-10 17:21   ` H.J. Lu via Libc-alpha [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-07-10 17:21 H.J. Lu via Libc-alpha
2021-07-19  2:13 ` Carlos O'Donell via Libc-alpha
2021-07-19 15:20   ` H.J. Lu via Libc-alpha

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to='CAMe9rOpPbX4qrrpWgsq0djFvVhAK4U=kEjGuwwvmgNO=9WSTJw@mail.gmail.com' \
    --to=libc-alpha@sourceware.org \
    --cc=carlos@redhat.com \
    --cc=hjl.tools@gmail.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).