File: local-revert-aarch64-check-kernel-version-for-sve-ifuncs.diff

package info (click to toggle)
glibc 2.36-9%2Bdeb12u13
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates
  • size: 300,148 kB
  • sloc: ansic: 1,055,755; asm: 324,942; makefile: 15,198; python: 12,603; sh: 10,884; cpp: 5,685; awk: 1,883; perl: 518; yacc: 292; pascal: 182; sed: 39
file content (140 lines) | stat: -rw-r--r-- 4,765 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
From 8191e8bdb07fd35d25bc3a50353f188e88fb11ac Mon Sep 17 00:00:00 2001
From: Aurelien Jarno <aurelien@aurel32.net>
Date: Sat, 26 Oct 2024 22:41:09 +0200
Subject: [PATCH] Revert "AArch64: Check kernel version for SVE ifuncs"

This reverts commit 24de733967029fd902c34073d2ab25b900887352.
---
 sysdeps/aarch64/multiarch/init-arch.h         |  2 -
 sysdeps/aarch64/multiarch/memcpy.c            |  2 +-
 sysdeps/aarch64/multiarch/memmove.c           |  2 +-
 .../unix/sysv/linux/aarch64/cpu-features.c    | 48 -------------------
 .../unix/sysv/linux/aarch64/cpu-features.h    |  1 -
 5 files changed, 2 insertions(+), 53 deletions(-)

diff --git a/sysdeps/aarch64/multiarch/init-arch.h b/sysdeps/aarch64/multiarch/init-arch.h
index 5b2cf5cb12..5da1656954 100644
--- a/sysdeps/aarch64/multiarch/init-arch.h
+++ b/sysdeps/aarch64/multiarch/init-arch.h
@@ -36,7 +36,5 @@
     MTE_ENABLED ();							      \
   bool __attribute__((unused)) sve =					      \
     GLRO(dl_aarch64_cpu_features).sve;					      \
-  bool __attribute__((unused)) prefer_sve_ifuncs =			      \
-    GLRO(dl_aarch64_cpu_features).prefer_sve_ifuncs;			      \
   bool __attribute__((unused)) mops =					      \
     GLRO(dl_aarch64_cpu_features).mops;
diff --git a/sysdeps/aarch64/multiarch/memcpy.c b/sysdeps/aarch64/multiarch/memcpy.c
index 3de66c14d4..d1cf5bec16 100644
--- a/sysdeps/aarch64/multiarch/memcpy.c
+++ b/sysdeps/aarch64/multiarch/memcpy.c
@@ -47,7 +47,7 @@ select_memcpy_ifunc (void)
     {
       if (IS_A64FX (midr))
 	return __memcpy_a64fx;
-      return prefer_sve_ifuncs ? __memcpy_sve : __memcpy_generic;
+      return __memcpy_sve;
     }
 
   if (IS_THUNDERX (midr))
diff --git a/sysdeps/aarch64/multiarch/memmove.c b/sysdeps/aarch64/multiarch/memmove.c
index fdcf418820..90729e0275 100644
--- a/sysdeps/aarch64/multiarch/memmove.c
+++ b/sysdeps/aarch64/multiarch/memmove.c
@@ -47,7 +47,7 @@ select_memmove_ifunc (void)
     {
       if (IS_A64FX (midr))
 	return __memmove_a64fx;
-      return prefer_sve_ifuncs ? __memmove_sve : __memmove_generic;
+      return __memmove_sve;
     }
 
   if (IS_THUNDERX (midr))
diff --git a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c
index 2543128352..6ee1cb4bc2 100644
--- a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c
+++ b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c
@@ -20,7 +20,6 @@
 #include <sys/auxv.h>
 #include <elf/dl-hwcaps.h>
 #include <sys/prctl.h>
-#include <sys/utsname.h>
 
 #define DCZID_DZP_MASK (1 << 4)
 #define DCZID_BS_MASK (0xf)
@@ -60,46 +59,6 @@ get_midr_from_mcpu (const char *mcpu)
 }
 #endif
 
-#if __LINUX_KERNEL_VERSION < 0x060200
-
-/* Return true if we prefer using SVE in string ifuncs.  Old kernels disable
-   SVE after every system call which results in unnecessary traps if memcpy
-   uses SVE.  This is true for kernels between 4.15.0 and before 6.2.0, except
-   for 5.14.0 which was patched.  For these versions return false to avoid using
-   SVE ifuncs.
-   Parse the kernel version into a 24-bit kernel.major.minor value without
-   calling any library functions.  If uname() is not supported or if the version
-   format is not recognized, assume the kernel is modern and return true.  */
-
-static inline bool
-prefer_sve_ifuncs (void)
-{
-  struct utsname buf;
-  const char *p = &buf.release[0];
-  int kernel = 0;
-  int val;
-
-  if (__uname (&buf) < 0)
-    return true;
-
-  for (int shift = 16; shift >= 0; shift -= 8)
-    {
-      for (val = 0; *p >= '0' && *p <= '9'; p++)
-	val = val * 10 + *p - '0';
-      kernel |= (val & 255) << shift;
-      if (*p++ != '.')
-	break;
-    }
-
-  if (kernel >= 0x060200 || kernel == 0x050e00)
-    return true;
-  if (kernel >= 0x040f00)
-    return false;
-  return true;
-}
-
-#endif
-
 static inline void
 init_cpu_features (struct cpu_features *cpu_features)
 {
@@ -166,13 +125,6 @@ init_cpu_features (struct cpu_features *cpu_features)
   /* Check if SVE is supported.  */
   cpu_features->sve = GLRO (dl_hwcap) & HWCAP_SVE;
 
-  cpu_features->prefer_sve_ifuncs = cpu_features->sve;
-
-#if __LINUX_KERNEL_VERSION < 0x060200
-  if (cpu_features->sve)
-    cpu_features->prefer_sve_ifuncs = prefer_sve_ifuncs ();
-#endif
-
   /* Check if MOPS is supported.  */
   cpu_features->mops = GLRO (dl_hwcap2) & HWCAP2_MOPS;
 }
diff --git a/sysdeps/unix/sysv/linux/aarch64/cpu-features.h b/sysdeps/unix/sysv/linux/aarch64/cpu-features.h
index d51597b923..b4bd43a228 100644
--- a/sysdeps/unix/sysv/linux/aarch64/cpu-features.h
+++ b/sysdeps/unix/sysv/linux/aarch64/cpu-features.h
@@ -71,7 +71,6 @@ struct cpu_features
   /* Currently, the GLIBC memory tagging tunable only defines 8 bits.  */
   uint8_t mte_state;
   bool sve;
-  bool prefer_sve_ifuncs;
   bool mops;
 };
 
-- 
2.45.2