diff mbox series

[3/6] powerpc: Move cache geometry information to ld diagnostics

Message ID 20250226190308.2163908-4-adhemerval.zanella@linaro.org
State New
Headers show
Series Remove dl-procinfo.h | expand

Commit Message

Adhemerval Zanella Feb. 26, 2025, 7 p.m. UTC
From LD_SHOW_AUXV output.

Checked on powerpc64le-linux-gnu.
---
 sysdeps/powerpc/dl-diagnostics-cpu.c | 49 ++++++++++++++++++++
 sysdeps/powerpc/dl-procinfo.h        | 67 +---------------------------
 2 files changed, 50 insertions(+), 66 deletions(-)
diff mbox series

Patch

diff --git a/sysdeps/powerpc/dl-diagnostics-cpu.c b/sysdeps/powerpc/dl-diagnostics-cpu.c
index db8d19c7ec..6e7a5302fd 100644
--- a/sysdeps/powerpc/dl-diagnostics-cpu.c
+++ b/sysdeps/powerpc/dl-diagnostics-cpu.c
@@ -38,6 +38,38 @@  print_hwcap_value (const char *label, int hwcap, unsigned long int value)
   _dl_printf ("\"\n");
 }
 
+static void
+print_cache_geometry_value (const char *label, unsigned long int geometry)
+{
+  unsigned long int assocty, line;
+
+  _dl_printf ("powerpc.cpu_features.%s=\"", label);
+
+  line = geometry & 0xffff;
+  assocty = (geometry >> 16) & 0xffff;
+
+  if (line == 0)
+    _dl_printf ("Unknown line size, ");
+  else
+    _dl_printf ("%luB line size, ", line);
+
+  switch (assocty)
+    {
+    case 0:
+      _dl_printf ("Unknown associativity");
+      break;
+    case 1:
+      _dl_printf ("Directly mapped");
+      break;
+    case 0xffff:
+      _dl_printf ("Fully associative");
+      break;
+    default:
+      _dl_printf ("%lu-way set associative", assocty);
+    }
+  _dl_printf ("\"\n");
+}
+
 void
 _dl_diagnostics_cpu (void)
 {
@@ -45,4 +77,21 @@  _dl_diagnostics_cpu (void)
   print_hwcap_value ("hwcap2", AT_HWCAP2, GLRO(dl_hwcap2));
   print_hwcap_value ("hwcap3", AT_HWCAP3, GLRO(dl_hwcap3));
   print_hwcap_value ("hwcap4", AT_HWCAP4, GLRO(dl_hwcap4));
+
+  for (ElfW(auxv_t) *av = GLRO(dl_auxv); av->a_type != AT_NULL; ++av)
+    switch (av->a_type)
+      {
+      case AT_L1I_CACHEGEOMETRY:
+        print_cache_geometry_value ("l1i_cachegeometry", av->a_un.a_val);
+        break;
+      case AT_L1D_CACHEGEOMETRY:
+        print_cache_geometry_value ("l1d_cachegeometry", av->a_un.a_val);
+        break;
+      case AT_L2_CACHEGEOMETRY:
+        print_cache_geometry_value ("l2_cachegeometry", av->a_un.a_val);
+        break;
+      case AT_L3_CACHEGEOMETRY:
+        print_cache_geometry_value ("l3_cachegeometry", av->a_un.a_val);
+        break;
+      }
 }
diff --git a/sysdeps/powerpc/dl-procinfo.h b/sysdeps/powerpc/dl-procinfo.h
index 04bbe7ba1c..adb1c6994e 100644
--- a/sysdeps/powerpc/dl-procinfo.h
+++ b/sysdeps/powerpc/dl-procinfo.h
@@ -124,71 +124,6 @@  _dl_string_platform (const char *str)
   return -1;
 }
 
-#if IS_IN (rtld)
-static inline void
-cache_geometry (const char * name, unsigned long int geometry)
-{
-  unsigned long int assocty, line;
-
-  _dl_printf ("%s", name);
-
-  line = geometry & 0xffff;
-  assocty = (geometry >> 16) & 0xffff;
-
-  if (line == 0)
-    _dl_printf ("Unknown line size, ");
-  else
-    _dl_printf ("%luB line size, ", line);
-
-  switch (assocty)
-    {
-    case 0:
-      _dl_printf ("Unknown associativity");
-      break;
-    case 1:
-      _dl_printf ("Directly mapped");
-      break;
-    case 0xffff:
-      _dl_printf ("Fully associative");
-      break;
-    default:
-      _dl_printf ("%lu-way set associative", assocty);
-    }
-}
-
-static inline int
-__attribute__ ((unused))
-_dl_procinfo (unsigned int type, unsigned long int word)
-{
-  switch(type)
-    {
-    case AT_L1I_CACHEGEOMETRY:
-      {
-	cache_geometry ("AT_L1I_CACHEGEOMETRY: ", word);
-	break;
-      }
-    case AT_L1D_CACHEGEOMETRY:
-      {
-	cache_geometry ("AT_L1D_CACHEGEOMETRY: ", word);
-	break;
-      }
-    case AT_L2_CACHEGEOMETRY:
-      {
-	cache_geometry ("AT_L2_CACHEGEOMETRY:  ", word);
-	break;
-      }
-    case AT_L3_CACHEGEOMETRY:
-      {
-	cache_geometry ("AT_L3_CACHEGEOMETRY:  ", word);
-	break;
-      }
-    default:
-      /* Fallback to generic output mechanism.  */
-      return -1;
-    }
-   _dl_printf ("\n");
-  return 0;
-}
-#endif
+#define _dl_procinfo(type, word) -1
 
 #endif /* dl-procinfo.h */