unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH v3 3/3] aarch64: Enhanced CPU diagnostics for ld.so
Date: Fri, 5 Apr 2024 15:49:51 +0100	[thread overview]
Message-ID: <ZhAPjwQRW8s49QWD@arm.com> (raw)
In-Reply-To: <ddf8aad3798c861d5b8916c309135a90bf655ff3.1712312063.git.fweimer@redhat.com>

The 04/05/2024 12:16, Florian Weimer wrote:
> This prints some information from struct cpu_features, and the midr_el1
> and dczid_el0 system register contents on every CPU.

thanks.

i think we already rely on zva size to be the same across all cores
(in memset) and i don't think linux allows different dczid_el0 per
core (even if somebody built such a system).

so i don't think that is needed.

...
> +++ b/sysdeps/aarch64/dl-diagnostics-cpu.c
> @@ -0,0 +1,84 @@
> +/* Print CPU diagnostics data in ld.so.  AArch64 version.
> +   Copyright (C) 2021-2024 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <dl-diagnostics.h>
> +
> +#include <cpu-features.h>
> +#include <dl-iterate_cpu.h>
> +#include <ldsodefs.h>
> +#include <sys/auxv.h>
> +
> +static void
> +print_cpu_features_value (const char *label, uint64_t value)
> +{
> +  _dl_printf ("aarch64.cpu_features.");
> +  _dl_diagnostics_print_labeled_value (label, value);
> +}
> +
> +static void
> +print_per_cpu_value (const struct dl_iterate_cpu *dic,
> +                     const char *label, uint64_t value)
> +{
> +  _dl_printf ("aarch64.processor[0x%x].", dic->processor_index);
> +  _dl_diagnostics_print_labeled_value (label, value);
> +}
> +
> +void
> +_dl_diagnostics_cpu (void)
> +{
> +  print_cpu_features_value ("bti", GLRO (dl_aarch64_cpu_features).bti);
> +  print_cpu_features_value ("midr_el1",
> +                            GLRO (dl_aarch64_cpu_features).midr_el1);
> +  print_cpu_features_value ("mops", GLRO (dl_aarch64_cpu_features).mops);
> +  print_cpu_features_value ("mte_state",
> +                            GLRO (dl_aarch64_cpu_features).mte_state);
> +  print_cpu_features_value ("prefer_sve_ifuncs",
> +                            GLRO (dl_aarch64_cpu_features).prefer_sve_ifuncs);
> +  print_cpu_features_value ("sve", GLRO (dl_aarch64_cpu_features).sve);
> +  print_cpu_features_value ("zva_size",
> +                            GLRO (dl_aarch64_cpu_features).zva_size);

i would use something like

  const struct cpu_features *p = &GLRO (dl_aarch64_cpu_features);
  ... p->bti ...

or even

#define P(x) print_cpu_features_value (#x, GLRO (dl_aarch64_cpu_features).x)

to make this list more compact.

i wonder if we should place a comment in init-arch.h to update
_dl_diagnostics_cpu in case ifunc rules change as this seems
easy to forget

> +
> +  struct dl_iterate_cpu dic;
> +  _dl_iterate_cpu_init (&dic);
> +
> +  while (_dl_iterate_cpu_next (&dic))
> +    {
> +      if (dic.requested_cpu >= 0)
> +        _dl_printf ("aarch64.processor[0x%x].requested=0x%x\n",
> +                    dic.processor_index, dic.requested_cpu);
> +      if (dic.actual_cpu >= 0)
> +        _dl_printf ("aarch64.processor[0x%x].observed=0x%x\n",
> +                    dic.processor_index, dic.actual_cpu);
> +      if (dic.actual_node >= 0)
> +        _dl_printf ("aarch64.processor[0x%x].observed_node=0x%x\n",
> +                    dic.processor_index, dic.actual_node);
> +
> +      if (GLRO (dl_hwcap) & HWCAP_CPUID)
> +        {
> +          uint64_t midr_el1;
> +          asm ("mrs %0, midr_el1" : "=r" (midr_el1));
> +          print_per_cpu_value (&dic, "midr_el1", midr_el1);
> +        }
> +
> +      {
> +        uint64_t dczid_el0;
> +        asm ("mrs %0, dczid_el0" : "=r" (dczid_el0));
> +        print_per_cpu_value (&dic, "dczid_el0", dczid_el0);
> +      }
> +    }
> +}
> -- 
> 2.44.0
> 

  parent reply	other threads:[~2024-04-05 14:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05 10:16 [PATCH v3 0/3] Enhanced CPU diagnostics for ld.so Florian Weimer
2024-04-05 10:16 ` [PATCH v3 1/3] elf: Add CPU iteration support for future use in ld.so diagnostics Florian Weimer
2024-04-05 12:57   ` H.J. Lu
2024-04-05 10:16 ` [PATCH v3 2/3] x86: Add generic CPUID data dumper to ld.so --list-diagnostics Florian Weimer
2024-04-05 12:57   ` H.J. Lu
2024-04-05 10:16 ` [PATCH v3 3/3] aarch64: Enhanced CPU diagnostics for ld.so Florian Weimer
2024-04-05 13:42   ` Adhemerval Zanella Netto
2024-04-08  8:38     ` Florian Weimer
2024-04-05 14:49   ` Szabolcs Nagy [this message]
2024-04-05 14:54     ` Florian Weimer
2024-04-08  7:36       ` Szabolcs Nagy

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=ZhAPjwQRW8s49QWD@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).