From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Subject: [PATCH 2/2] x86: Add CPU-specific diagnostics to ld.so --list-diagnostics
Date: Wed, 24 Feb 2021 14:43:17 +0100 [thread overview]
Message-ID: <87y2fdr37u.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <875z2hshtn.fsf@oldenburg.str.redhat.com>
---
sysdeps/x86/dl-diagnostics.h | 154 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 154 insertions(+)
diff --git a/sysdeps/x86/dl-diagnostics.h b/sysdeps/x86/dl-diagnostics.h
new file mode 100644
index 0000000000..92c3b9541e
--- /dev/null
+++ b/sysdeps/x86/dl-diagnostics.h
@@ -0,0 +1,154 @@
+/* Print diagnostics data in ld.so. x86 version.
+ Copyright (C) 2021 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/>. */
+
+#ifndef _DL_DIAGNOSTICS_H
+#define _DL_DIAGNOSTICS_H
+
+static void
+print_cpu_features_value (const char *label, uint64_t value)
+{
+ _dl_printf ("x86.cpu_features.");
+ _dl_diagnostics_print_labeled_value (label, value);
+}
+
+static void
+print_cpu_feature_internal (unsigned int index, const char *kind,
+ unsigned int reg, uint32_t value)
+{
+ _dl_printf ("x86.cpu_features.features[0x%x].%s[0x%x]=0x%x\n",
+ index, kind, reg, value);
+}
+
+static void
+print_cpu_feature_preferred (const char *label, unsigned int flag)
+{
+ _dl_printf("x86.cpu_features.preferred.%s=0x%x\n", label, flag);
+}
+
+static inline void
+_dl_diagnostics_sysdeps (void)
+{
+ const struct cpu_features *cpu_features = __get_cpu_features ();
+
+ print_cpu_features_value ("basic.kind", cpu_features->basic.kind);
+ print_cpu_features_value ("basic.max_cpuid", cpu_features->basic.max_cpuid);
+ print_cpu_features_value ("basic.family", cpu_features->basic.family);
+ print_cpu_features_value ("basic.model", cpu_features->basic.model);
+ print_cpu_features_value ("basic.stepping", cpu_features->basic.stepping);
+
+ for (unsigned int index = 0; index < CPUID_INDEX_MAX; ++index)
+ {
+ /* The index values are part of the ABI via
+ <sys/platform/x86.h>, so translating them to strings is not
+ necessary. */
+ for (unsigned int reg = 0; reg < 4; ++reg)
+ print_cpu_feature_internal
+ (index, "cpuid", reg,
+ cpu_features->features[index].cpuid_array[reg]);
+ for (unsigned int reg = 0; reg < 4; ++reg)
+ print_cpu_feature_internal
+ (index, "usable", reg,
+ cpu_features->features[index].usable_array[reg]);
+ }
+
+ /* The preferred indicators are not part of the ABI and need to be
+ translated. */
+ print_cpu_feature_preferred
+ ("i586", CPU_FEATURE_PREFERRED_P (cpu_features, I586));
+ print_cpu_feature_preferred
+ ("i686", CPU_FEATURE_PREFERRED_P (cpu_features, I686));
+ print_cpu_feature_preferred
+ ("fast_rep_string",
+ CPU_FEATURE_PREFERRED_P (cpu_features, Fast_Rep_String));
+ print_cpu_feature_preferred
+ ("fast_copy_backward",
+ CPU_FEATURE_PREFERRED_P (cpu_features, Fast_Copy_Backward));
+ print_cpu_feature_preferred
+ ("fast_unaligned_load",
+ CPU_FEATURE_PREFERRED_P (cpu_features, Fast_Unaligned_Load));
+ print_cpu_feature_preferred
+ ("fast_unaligned_copy",
+ CPU_FEATURE_PREFERRED_P (cpu_features, Fast_Unaligned_Copy));
+ print_cpu_feature_preferred
+ ("slow_bsf", CPU_FEATURE_PREFERRED_P (cpu_features, Slow_BSF));
+ print_cpu_feature_preferred
+ ("slow_sse4_2", CPU_FEATURE_PREFERRED_P (cpu_features, Slow_SSE4_2));
+ print_cpu_feature_preferred
+ ("avx_fast_unaligned_load",
+ CPU_FEATURE_PREFERRED_P (cpu_features, AVX_Fast_Unaligned_Load));
+ print_cpu_feature_preferred
+ ("prefer_map_32bit_exec",
+ CPU_FEATURE_PREFERRED_P (cpu_features, Prefer_MAP_32BIT_EXEC));
+ print_cpu_feature_preferred
+ ("prefer_pminub_for_stringop",
+ CPU_FEATURE_PREFERRED_P (cpu_features, Prefer_PMINUB_for_stringop));
+ print_cpu_feature_preferred
+ ("prefer_no_vzeroupper",
+ CPU_FEATURE_PREFERRED_P (cpu_features, Prefer_No_VZEROUPPER));
+ print_cpu_feature_preferred
+ ("prefer_erms", CPU_FEATURE_PREFERRED_P (cpu_features, Prefer_ERMS));
+ print_cpu_feature_preferred
+ ("prefer_fsrm", CPU_FEATURE_PREFERRED_P (cpu_features, Prefer_FSRM));
+ print_cpu_feature_preferred
+ ("prefer_no_avx512",
+ CPU_FEATURE_PREFERRED_P (cpu_features, Prefer_No_AVX512));
+ print_cpu_feature_preferred
+ ("mathvec_prefer_no_avx512",
+ CPU_FEATURE_PREFERRED_P (cpu_features, MathVec_Prefer_No_AVX512));
+
+ print_cpu_features_value ("isa_1", cpu_features->isa_1);
+ print_cpu_features_value ("xsave_state_size",
+ cpu_features->xsave_state_size);
+ print_cpu_features_value ("xsave_state_full_size",
+ cpu_features->xsave_state_full_size);
+ print_cpu_features_value ("data_cache_size", cpu_features->data_cache_size);
+ print_cpu_features_value ("shared_cache_size",
+ cpu_features->shared_cache_size);
+ print_cpu_features_value ("non_temporal_threshold",
+ cpu_features->non_temporal_threshold);
+ print_cpu_features_value ("rep_movsb_threshold",
+ cpu_features->rep_movsb_threshold);
+ print_cpu_features_value ("rep_movsb_stop_threshold",
+ cpu_features->rep_movsb_stop_threshold);
+ print_cpu_features_value ("rep_stosb_threshold",
+ cpu_features->rep_stosb_threshold);
+ print_cpu_features_value ("level1_icache_size",
+ cpu_features->level1_icache_size);
+ print_cpu_features_value ("level1_dcache_size",
+ cpu_features->level1_dcache_size);
+ print_cpu_features_value ("level1_dcache_assoc",
+ cpu_features->level1_dcache_assoc);
+ print_cpu_features_value ("level1_dcache_linesize",
+ cpu_features->level1_dcache_linesize);
+ print_cpu_features_value ("level2_cache_size",
+ cpu_features->level2_cache_size);
+ print_cpu_features_value ("level2_cache_assoc",
+ cpu_features->level2_cache_assoc);
+ print_cpu_features_value ("level2_cache_linesize",
+ cpu_features->level2_cache_linesize);
+ print_cpu_features_value ("level3_cache_size",
+ cpu_features->level3_cache_size);
+ print_cpu_features_value ("level3_cache_assoc",
+ cpu_features->level3_cache_assoc);
+ print_cpu_features_value ("level3_cache_linesize",
+ cpu_features->level3_cache_linesize);
+ print_cpu_features_value ("level4_cache_size",
+ cpu_features->level4_cache_size);
+}
+
+#endif /* _DL_DIAGNOSTICS_H */
next prev parent reply other threads:[~2021-02-24 14:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-24 13:42 [PATCH 1/2] ld.so: Implement the --list-diagnostics option Florian Weimer
2021-02-24 13:43 ` Florian Weimer [this message]
2021-03-01 23:20 ` [PATCH 2/2] x86: Add CPU-specific diagnostics to ld.so --list-diagnostics H.J. Lu
2021-03-02 6:32 ` Florian Weimer
2021-03-01 9:12 ` [PATCH 1/2] ld.so: Implement the --list-diagnostics option Florian Weimer
2021-03-01 23:13 ` H.J. Lu
2021-03-02 6:00 ` Florian Weimer
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=87y2fdr37u.fsf@oldenburg.str.redhat.com \
--to=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).