public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Peter Bergner <bergner@linux.ibm.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	bmahi496@linux.ibm.com, libc-alpha@sourceware.org
Cc: rajis@linux.ibm.com, Mahesh Bodapati <mahesh.bodapati@ibm.com>
Subject: Re: [PATCH v3] PowerPC: Influence cpu/arch hwcap features via GLIBC_TUNABLES.
Date: Thu, 6 Jul 2023 15:38:21 -0500	[thread overview]
Message-ID: <6deeb5cf-3b57-21a2-0d5f-56b48f8d147b@linux.ibm.com> (raw)
In-Reply-To: <d7ddf02b-69fc-a3ed-4ff6-7b60b7bbe95c@linaro.org>

On 7/6/23 8:16 AM, Adhemerval Zanella Netto wrote:
> On 06/07/23 09:25, bmahi496--- via Libc-alpha wrote:
>>  struct cpu_features
>>  {
>>    bool use_cached_memopt;
>> +  unsigned long int hwcap;
>> +  unsigned long int hwcap2;
>> +};
>> +
>> +static const struct
>> +{
>> +  const char *name;
>> +  int mask;
>> +  bool id;
>> +} hwcap_tunables[] = {
>> +   /* AT_HWCAP tunable masks.  */
>> +   { "4xxmac",           PPC_FEATURE_HAS_4xxMAC,                 0 },
> 
> This creates one extra dynamic relocation per entry:
> 
> powerpc64le-linux-gnu-base$ powerpc64le-linux-gnu-readelf -a elf/ld.so
> [...]
> Relocation section '.relr.dyn' at offset 0xc68 contains 3 entries:
>   10 offsets
> [...]
> 
> powerpc64le-linux-gnu-patch$ powerpc64le-linux-gnu-readelf -a elf/ld.so
> [...]
> Relocation section '.relr.dyn' at offset 0xc68 contains 5 entries:
>   53 offsets
> [...]

Good catch!  Especially since the plan is to add space for hwcap3 and hwcap4
(possibly more) in the near future.  We don't need the extra hwcaps yet, but
we want to reserve the space in the TCB for them now, where __builtin_cpu_supports()
uses them, so that when we need them in the future, the space is already
there to use in distro glibcs.




> Which I think we should avoid since is a small slow down on every program
> invocation.  You can either define the name with a predefine size that
> fits for every name (say 32), but this will waste a some of space.  Or
> you can specify the hwcap_tunables struct as pointing to an offset:
> 
>   static const char hwcap_names[] = 
>     "4xxmac\0"
>     "altivec\0"
>    [...]
> 
>   static const struct
>   {
>     unsigned short off;
>     int mask;
>     bool id;
>   } hwcap_tunables[] = {
>     { 0,    PPC_FEATURE_HAS_4xxMAC,                 0 },
>     { 7,    PPC_FEATURE_HAS_ALTIVEC,                0 },
>     [...]
>   }
> And then you check the name as:
> 
>   for (i = 0; array_length (hwcap_tunables); ++i)
>     {
>       const char *hwcap_name = hwcap_names + hwcap_tunables[i].off;
>       [...]
>     }
> 
> The drowback is to get the offsets right it would require some preprocessor
> phase (something like we do for the signal and errno list).

I don't think we need the offset in the struct, since Mahesh's loop is
already calculating the strlen of hwcap_names[].name, so we can just
update the pointer as we go.  Ala...

  const char *hwcap_name = &hwcap_names[0];
  for (i = 0; array_length (hwcap_tunables); ++i)
    {
      size_t tunable_len = STRLEN_DEFAULT (hwcap_name);

      /* Check the tunable name on the supported list.  */
      if (tunable_len == feature_len
          && MEMCMP_DEFAULT (feature, hwcap_name, feature_len) == 0)
        {
           ...
        }
      hwcap_name += tunable_len + 1;
    }


Peter


  reply	other threads:[~2023-07-06 20:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 12:25 bmahi496
2023-07-06 13:16 ` Adhemerval Zanella Netto
2023-07-06 20:38   ` Peter Bergner [this message]
2023-07-07 10:44   ` MAHESH BODAPATI
2023-07-06 21:05 ` Peter Bergner
2023-07-07 10:52   ` MAHESH BODAPATI
2023-07-07 16:40     ` Peter Bergner
2023-07-07 14:25   ` Adhemerval Zanella Netto
2023-07-07 16:07     ` Peter Bergner

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=6deeb5cf-3b57-21a2-0d5f-56b48f8d147b@linux.ibm.com \
    --to=bergner@linux.ibm.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=bmahi496@linux.ibm.com \
    --cc=libc-alpha@sourceware.org \
    --cc=mahesh.bodapati@ibm.com \
    --cc=rajis@linux.ibm.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).