diff mbox series

[10/11] s390: Use dl-symbol-redir-ifunc.h on cpu-tunables

Message ID 20231010180111.561793-11-adhemerval.zanella@linaro.org
State Superseded
Headers show
Series Improve tunable handling | expand

Commit Message

Adhemerval Zanella Netto Oct. 10, 2023, 6:01 p.m. UTC
Using the memcmp symbol directly allows the compile to inline the
memcmp calls (especially because _dl_tunable_set_hwcaps uses constants
values), generating better code.

Checked with tst-tunables on s390x-linux-gnu (qemu system).
---
 sysdeps/s390/cpu-features.c                   | 30 +++++++++----------
 .../s390/multiarch/dl-symbol-redir-ifunc.h    |  2 ++
 2 files changed, 17 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/sysdeps/s390/cpu-features.c b/sysdeps/s390/cpu-features.c
index 39f8c23a60..55449ba07f 100644
--- a/sysdeps/s390/cpu-features.c
+++ b/sysdeps/s390/cpu-features.c
@@ -21,7 +21,7 @@ 
 #include <elf/dl-tunables.h>
 #include <ifunc-memcmp.h>
 #include <string.h>
-extern __typeof (memcmp) MEMCMP_DEFAULT;
+#include <dl-symbol-redir-ifunc.h>
 
 #define S390_COPY_CPU_FEATURES(SRC_PTR, DEST_PTR)	\
   (DEST_PTR)->hwcap = (SRC_PTR)->hwcap;			\
@@ -89,9 +89,9 @@  TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
       if ((*feature == 'z' || *feature == 'a'))
 	{
 	  if ((feature_len == 5 && *feature == 'z'
-	       && MEMCMP_DEFAULT (feature, "zEC12", 5) == 0)
+	       && memcmp (feature, "zEC12", 5) == 0)
 	      || (feature_len == 6 && *feature == 'a'
-		  && MEMCMP_DEFAULT (feature, "arch10", 6) == 0))
+		  && memcmp (feature, "arch10", 6) == 0))
 	    {
 	      reset_features = true;
 	      disable = true;
@@ -100,9 +100,9 @@  TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
 	      stfle_bits0_mask = S390_STFLE_MASK_ARCH13_MIE3;
 	    }
 	  else if ((feature_len == 3 && *feature == 'z'
-		    && MEMCMP_DEFAULT (feature, "z13", 3) == 0)
+		    && memcmp (feature, "z13", 3) == 0)
 		   || (feature_len == 6 && *feature == 'a'
-		       && MEMCMP_DEFAULT (feature, "arch11", 6) == 0))
+		       && memcmp (feature, "arch11", 6) == 0))
 	    {
 	      reset_features = true;
 	      disable = true;
@@ -110,9 +110,9 @@  TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
 	      stfle_bits0_mask = S390_STFLE_MASK_ARCH13_MIE3;
 	    }
 	  else if ((feature_len == 3 && *feature == 'z'
-		    && MEMCMP_DEFAULT (feature, "z14", 3) == 0)
+		    && memcmp (feature, "z14", 3) == 0)
 		   || (feature_len == 6 && *feature == 'a'
-		       && MEMCMP_DEFAULT (feature, "arch12", 6) == 0))
+		       && memcmp (feature, "arch12", 6) == 0))
 	    {
 	      reset_features = true;
 	      disable = true;
@@ -120,11 +120,11 @@  TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
 	      stfle_bits0_mask = S390_STFLE_MASK_ARCH13_MIE3;
 	    }
 	  else if ((feature_len == 3 && *feature == 'z'
-		    && (MEMCMP_DEFAULT (feature, "z15", 3) == 0
-			|| MEMCMP_DEFAULT (feature, "z16", 3) == 0))
+		    && (memcmp (feature, "z15", 3) == 0
+			|| memcmp (feature, "z16", 3) == 0))
 		   || (feature_len == 6
-		       && (MEMCMP_DEFAULT (feature, "arch13", 6) == 0
-			   || MEMCMP_DEFAULT (feature, "arch14", 6) == 0)))
+		       && (memcmp (feature, "arch13", 6) == 0
+			   || memcmp (feature, "arch14", 6) == 0)))
 	    {
 	      /* For z15 or newer we don't have to disable something,
 		 but we have to reset to the original values.  */
@@ -134,14 +134,14 @@  TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
       else if (*feature == 'H')
 	{
 	  if (feature_len == 15
-	      && MEMCMP_DEFAULT (feature, "HWCAP_S390_VXRS", 15) == 0)
+	      && memcmp (feature, "HWCAP_S390_VXRS", 15) == 0)
 	    {
 	      hwcap_mask = HWCAP_S390_VXRS;
 	      if (disable)
 		hwcap_mask |= HWCAP_S390_VXRS_EXT | HWCAP_S390_VXRS_EXT2;
 	    }
 	  else if (feature_len == 19
-		   && MEMCMP_DEFAULT (feature, "HWCAP_S390_VXRS_EXT", 19) == 0)
+		   && memcmp (feature, "HWCAP_S390_VXRS_EXT", 19) == 0)
 	    {
 	      hwcap_mask = HWCAP_S390_VXRS_EXT;
 	      if (disable)
@@ -150,7 +150,7 @@  TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
 		hwcap_mask |= HWCAP_S390_VXRS;
 	    }
 	  else if (feature_len == 20
-		   && MEMCMP_DEFAULT (feature, "HWCAP_S390_VXRS_EXT2", 20) == 0)
+		   && memcmp (feature, "HWCAP_S390_VXRS_EXT2", 20) == 0)
 	    {
 	      hwcap_mask = HWCAP_S390_VXRS_EXT2;
 	      if (!disable)
@@ -160,7 +160,7 @@  TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
       else if (*feature == 'S')
 	{
 	  if (feature_len == 10
-	      && MEMCMP_DEFAULT (feature, "STFLE_MIE3", 10) == 0)
+	      && memcmp (feature, "STFLE_MIE3", 10) == 0)
 	    {
 	      stfle_bits0_mask = S390_STFLE_MASK_ARCH13_MIE3;
 	    }
diff --git a/sysdeps/s390/multiarch/dl-symbol-redir-ifunc.h b/sysdeps/s390/multiarch/dl-symbol-redir-ifunc.h
index aa084fdcde..0f58897c48 100644
--- a/sysdeps/s390/multiarch/dl-symbol-redir-ifunc.h
+++ b/sysdeps/s390/multiarch/dl-symbol-redir-ifunc.h
@@ -20,10 +20,12 @@ 
 #define _DL_IFUNC_GENERIC_H
 
 #include <ifunc-memset.h>
+#include <ifunc-memcmp.h>
 
 #define IFUNC_SYMBOL_STR1(s)	#s
 #define IFUNC_SYMBOL_STR(s)	IFUNC_SYMBOL_STR1(s)
 
 asm ("memset = " IFUNC_SYMBOL_STR(MEMSET_DEFAULT));
+asm ("memcmp = " IFUNC_SYMBOL_STR(MEMCMP_DEFAULT));
 
 #endif