public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Remove some i386 system call optimizations
@ 2022-01-11 10:05 Florian Weimer
  2022-01-11 10:06 ` [PATCH 1/2] i386: Always treat %ebx as an allocatable register Florian Weimer
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Florian Weimer @ 2022-01-11 10:05 UTC (permalink / raw)
  To: libc-alpha; +Cc: Jakub Jelinek, H.J. Lu

The configure check for CAN_USE_REGISTER_ASM_EBP is unreliable.  And we
used it to switch away from using %ebx in assembler constraints, but
this appears to be no longer necessary.

Tested on i686-linux-gnu.  Built with build-many-glibcs.py.

Thanks,
Florian

Florian Weimer (2):
  i386: Always treat %ebx as an allocatable register
  i386: Always use __libc_do_syscall for 6-argument syscalls (bug 27997)

 config.h.in                               |   4 -
 sysdeps/unix/sysv/linux/i386/configure    |  39 ----
 sysdeps/unix/sysv/linux/i386/configure.ac |  17 --
 sysdeps/unix/sysv/linux/i386/sysdep.h     | 222 +++-------------------
 4 files changed, 27 insertions(+), 255 deletions(-)


base-commit: e72ef23ee88187284b4b1ca9b2e314e618429d35
-- 
2.34.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/2] i386: Always treat %ebx as an allocatable register
  2022-01-11 10:05 [PATCH 0/2] Remove some i386 system call optimizations Florian Weimer
@ 2022-01-11 10:06 ` Florian Weimer
  2022-01-11 10:06 ` [PATCH 2/2] i386: Always use __libc_do_syscall for 6-argument syscalls (bug 27997) Florian Weimer
  2022-01-11 14:00 ` [PATCH 0/2] Remove some i386 system call optimizations H.J. Lu
  2 siblings, 0 replies; 14+ messages in thread
From: Florian Weimer @ 2022-01-11 10:06 UTC (permalink / raw)
  To: libc-alpha; +Cc: Jakub Jelinek, H.J. Lu

!CAN_USE_REGISTER_ASM_EBP also disables the direct use of %ebx
in system calls, but that is not actually needed anymore.
---
 sysdeps/unix/sysv/linux/i386/sysdep.h | 192 ++++----------------------
 1 file changed, 25 insertions(+), 167 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 66c2833a49..fcd78e3157 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -239,35 +239,6 @@ extern int __syscall_error (int)
   attribute_hidden __attribute__ ((__regparm__ (1)));
 
 #ifndef OPTIMIZE_FOR_GCC_5
-/* We need some help from the assembler to generate optimal code.  We
-   define some macros here which later will be used.  */
-asm (".L__X'%ebx = 1\n\t"
-     ".L__X'%ecx = 2\n\t"
-     ".L__X'%edx = 2\n\t"
-     ".L__X'%eax = 3\n\t"
-     ".L__X'%esi = 3\n\t"
-     ".L__X'%edi = 3\n\t"
-     ".L__X'%ebp = 3\n\t"
-     ".L__X'%esp = 3\n\t"
-     ".macro bpushl name reg\n\t"
-     ".if 1 - \\name\n\t"
-     ".if 2 - \\name\n\t"
-     "error\n\t"
-     ".else\n\t"
-     "xchgl \\reg, %ebx\n\t"
-     ".endif\n\t"
-     ".endif\n\t"
-     ".endm\n\t"
-     ".macro bpopl name reg\n\t"
-     ".if 1 - \\name\n\t"
-     ".if 2 - \\name\n\t"
-     "error\n\t"
-     ".else\n\t"
-     "xchgl \\reg, %ebx\n\t"
-     ".endif\n\t"
-     ".endif\n\t"
-     ".endm\n\t");
-
 /* Six-argument syscalls use an out-of-line helper, because an inline
    asm using all registers apart from %esp cannot work reliably and
    the assembler does not support describing an asm that saves and
@@ -379,187 +350,74 @@ struct libc_do_syscall_args
     (int) resultvar; })
 
 #if I386_USE_SYSENTER
-# ifdef OPTIMIZE_FOR_GCC_5
-#  ifdef PIC
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
+# ifdef PIC
+#  define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "call *%%gs:%P2"							\
     : "=a" (resultvar)							\
     : "a" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo))		\
       ASMARGS_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
+#  define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "call *%%gs:%P2"							\
     : "=a" (resultvar)							\
     : "a" (name), "i" (offsetof (tcbhead_t, sysinfo))			\
       ASMARGS_##nr(args) : "memory", "cc")
-#  else
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
+# else /* I386_USE_SYSENTER && !PIC */
+#  define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "call *_dl_sysinfo"							\
     : "=a" (resultvar)							\
     : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
+#  define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "call *_dl_sysinfo"							\
     : "=a" (resultvar)							\
     : "a" (name) ASMARGS_##nr(args) : "memory", "cc")
-#  endif
-# else /* GCC 5  */
-#  ifdef PIC
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "movl %1, %%eax\n\t"						      \
-    "call *%%gs:%P2\n\t"						      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "i" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo))		      \
-      ASMFMT_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "call *%%gs:%P2\n\t"						      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "0" (name), "i" (offsetof (tcbhead_t, sysinfo))			      \
-      ASMFMT_##nr(args) : "memory", "cc")
-#  else
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "movl %1, %%eax\n\t"						      \
-    "call *_dl_sysinfo\n\t"						      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "call *_dl_sysinfo\n\t"						      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "0" (name) ASMFMT_##nr(args) : "memory", "cc")
-#  endif
-# endif /* GCC 5  */
-#else
-# ifdef OPTIMIZE_FOR_GCC_5
-#  define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
+# endif /* I386_USE_SYSENTER && !PIC */
+#else /* !I386_USE_SYSENTER */
+# define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "int $0x80"								\
     : "=a" (resultvar)							\
     : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
-#  define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
+# define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "int $0x80"								\
     : "=a" (resultvar)							\
     : "a" (name) ASMARGS_##nr(args) : "memory", "cc")
-# else /* GCC 5  */
-#  define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "movl %1, %%eax\n\t"						      \
-    "int $0x80\n\t"							      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
-#  define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "int $0x80\n\t"							      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "0" (name) ASMFMT_##nr(args) : "memory", "cc")
-# endif /* GCC 5  */
-#endif
+#endif /* !I386_USE_SYSENTER */
 
-#define LOADARGS_0
-#ifdef __PIC__
-# if I386_USE_SYSENTER && defined PIC
-#  define LOADARGS_1 \
-    "bpushl .L__X'%k3, %k3\n\t"
-#  define LOADARGS_5 \
-    "movl %%ebx, %4\n\t"						      \
-    "movl %3, %%ebx\n\t"
-# else
-#  define LOADARGS_1 \
-    "bpushl .L__X'%k2, %k2\n\t"
-#  define LOADARGS_5 \
-    "movl %%ebx, %3\n\t"						      \
-    "movl %2, %%ebx\n\t"
-# endif
-# define LOADARGS_2	LOADARGS_1
-# define LOADARGS_3 \
-    "xchgl %%ebx, %%edi\n\t"
-# define LOADARGS_4	LOADARGS_3
-#else
-# define LOADARGS_1
-# define LOADARGS_2
-# define LOADARGS_3
-# define LOADARGS_4
-# define LOADARGS_5
-#endif
-
-#define RESTOREARGS_0
-#ifdef __PIC__
-# if I386_USE_SYSENTER && defined PIC
-#  define RESTOREARGS_1 \
-    "bpopl .L__X'%k3, %k3\n\t"
-#  define RESTOREARGS_5 \
-    "movl %4, %%ebx"
-# else
-#  define RESTOREARGS_1 \
-    "bpopl .L__X'%k2, %k2\n\t"
-#  define RESTOREARGS_5 \
-    "movl %3, %%ebx"
-# endif
-# define RESTOREARGS_2	RESTOREARGS_1
-# define RESTOREARGS_3 \
-    "xchgl %%edi, %%ebx\n\t"
-# define RESTOREARGS_4	RESTOREARGS_3
-#else
-# define RESTOREARGS_1
-# define RESTOREARGS_2
-# define RESTOREARGS_3
-# define RESTOREARGS_4
-# define RESTOREARGS_5
-#endif
-
-#ifdef OPTIMIZE_FOR_GCC_5
-# define LOADREGS_0()
-# define ASMARGS_0()
-# define LOADREGS_1(arg1) \
+#define LOADREGS_0()
+#define ASMARGS_0()
+#define LOADREGS_1(arg1) \
 	LOADREGS_0 ()
-# define ASMARGS_1(arg1) \
+#define ASMARGS_1(arg1) \
 	ASMARGS_0 (), "b" ((unsigned int) (arg1))
-# define LOADREGS_2(arg1, arg2) \
+#define LOADREGS_2(arg1, arg2) \
 	LOADREGS_1 (arg1)
-# define ASMARGS_2(arg1, arg2) \
+#define ASMARGS_2(arg1, arg2) \
 	ASMARGS_1 (arg1), "c" ((unsigned int) (arg2))
-# define LOADREGS_3(arg1, arg2, arg3) \
+#define LOADREGS_3(arg1, arg2, arg3) \
 	LOADREGS_2 (arg1, arg2)
-# define ASMARGS_3(arg1, arg2, arg3) \
+#define ASMARGS_3(arg1, arg2, arg3) \
 	ASMARGS_2 (arg1, arg2), "d" ((unsigned int) (arg3))
-# define LOADREGS_4(arg1, arg2, arg3, arg4) \
+#define LOADREGS_4(arg1, arg2, arg3, arg4) \
 	LOADREGS_3 (arg1, arg2, arg3)
-# define ASMARGS_4(arg1, arg2, arg3, arg4) \
+#define ASMARGS_4(arg1, arg2, arg3, arg4) \
 	ASMARGS_3 (arg1, arg2, arg3), "S" ((unsigned int) (arg4))
-# define LOADREGS_5(arg1, arg2, arg3, arg4, arg5) \
+#define LOADREGS_5(arg1, arg2, arg3, arg4, arg5) \
 	LOADREGS_4 (arg1, arg2, arg3, arg4)
-# define ASMARGS_5(arg1, arg2, arg3, arg4, arg5) \
+#define ASMARGS_5(arg1, arg2, arg3, arg4, arg5) \
 	ASMARGS_4 (arg1, arg2, arg3, arg4), "D" ((unsigned int) (arg5))
+
+#ifdef OPTIMIZE_FOR_GCC_5
 # define LOADREGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
 	register unsigned int _a6 asm ("ebp") = (unsigned int) (arg6); \
 	LOADREGS_5 (arg1, arg2, arg3, arg4, arg5)
-- 
2.34.1



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 2/2] i386: Always use __libc_do_syscall for 6-argument syscalls (bug 27997)
  2022-01-11 10:05 [PATCH 0/2] Remove some i386 system call optimizations Florian Weimer
  2022-01-11 10:06 ` [PATCH 1/2] i386: Always treat %ebx as an allocatable register Florian Weimer
@ 2022-01-11 10:06 ` Florian Weimer
  2022-01-11 14:00 ` [PATCH 0/2] Remove some i386 system call optimizations H.J. Lu
  2 siblings, 0 replies; 14+ messages in thread
From: Florian Weimer @ 2022-01-11 10:06 UTC (permalink / raw)
  To: libc-alpha; +Cc: Jakub Jelinek, H.J. Lu

The CAN_USE_REGISTER_ASM_EBP optimization was unreliable because
the configure-time check did not match how %ebp was used during
the build.  With GCC 12, autovectorization at -O2, and the need
for -mstackrealign for compatibility with legacy binaries, the check
is increasingly problematic: CAN_USE_REGISTER_ASM_EBP is set to 1,
but glibc cannot be built with this optimization.
---
 config.h.in                               |  4 ---
 sysdeps/unix/sysv/linux/i386/configure    | 39 -----------------------
 sysdeps/unix/sysv/linux/i386/configure.ac | 17 ----------
 sysdeps/unix/sysv/linux/i386/sysdep.h     | 34 +++-----------------
 4 files changed, 4 insertions(+), 90 deletions(-)

diff --git a/config.h.in b/config.h.in
index 82ade1cec4..ff8597413d 100644
--- a/config.h.in
+++ b/config.h.in
@@ -277,10 +277,6 @@
 /* Define if static PIE is enabled.  */
 #define ENABLE_STATIC_PIE 0
 
-/* Some compiler options may now allow to use ebp in __asm__ (used mainly
-   in i386 6 argument syscall issue).  */
-#define CAN_USE_REGISTER_ASM_EBP 0
-
 /* The default value of x86 CET control.  */
 #define DEFAULT_DL_X86_CET_CONTROL cet_elf_property
 
diff --git a/sysdeps/unix/sysv/linux/i386/configure b/sysdeps/unix/sysv/linux/i386/configure
index 0327590486..f119e62fc3 100644
--- a/sysdeps/unix/sysv/linux/i386/configure
+++ b/sysdeps/unix/sysv/linux/i386/configure
@@ -1,44 +1,5 @@
 # This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
  # Local configure fragment for sysdeps/unix/sysv/linux/i386.
 
-# Check if CFLAGS allows compiler to use ebp register in inline assembly.
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler flags allows ebp in inline assembly" >&5
-$as_echo_n "checking if compiler flags allows ebp in inline assembly... " >&6; }
-if ${libc_cv_can_use_register_asm_ebp+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-    void foo (int i)
-    {
-      register int reg asm ("ebp") = i;
-      asm ("# %0" : : "r" (reg));
-    }
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  libc_cv_can_use_register_asm_ebp=yes
-else
-  libc_cv_can_use_register_asm_ebp=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_can_use_register_asm_ebp" >&5
-$as_echo "$libc_cv_can_use_register_asm_ebp" >&6; }
-if test $libc_cv_can_use_register_asm_ebp = yes; then
-  $as_echo "#define CAN_USE_REGISTER_ASM_EBP 1" >>confdefs.h
-
-fi
-
 libc_cv_gcc_unwind_find_fde=yes
 ldd_rewrite_script=sysdeps/unix/sysv/linux/ldd-rewrite.sed
diff --git a/sysdeps/unix/sysv/linux/i386/configure.ac b/sysdeps/unix/sysv/linux/i386/configure.ac
index 9e980784bb..64ab2cc2c8 100644
--- a/sysdeps/unix/sysv/linux/i386/configure.ac
+++ b/sysdeps/unix/sysv/linux/i386/configure.ac
@@ -1,22 +1,5 @@
 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 # Local configure fragment for sysdeps/unix/sysv/linux/i386.
 
-# Check if CFLAGS allows compiler to use ebp register in inline assembly.
-AC_CACHE_CHECK([if compiler flags allows ebp in inline assembly],
-                libc_cv_can_use_register_asm_ebp, [
-AC_COMPILE_IFELSE(
-  [AC_LANG_PROGRAM([
-    void foo (int i)
-    {
-      register int reg asm ("ebp") = i;
-      asm ("# %0" : : "r" (reg));
-    }])],
-  [libc_cv_can_use_register_asm_ebp=yes],
-  [libc_cv_can_use_register_asm_ebp=no])
-])
-if test $libc_cv_can_use_register_asm_ebp = yes; then
-  AC_DEFINE(CAN_USE_REGISTER_ASM_EBP)
-fi
-
 libc_cv_gcc_unwind_find_fde=yes
 ldd_rewrite_script=sysdeps/unix/sysv/linux/ldd-rewrite.sed
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index fcd78e3157..4558ab66cb 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -42,15 +42,6 @@
 # endif
 #endif
 
-/* Since GCC 5 and above can properly spill %ebx with PIC when needed,
-   we can inline syscalls with 6 arguments if GCC 5 or above is used
-   to compile glibc.  Disable GCC 5 optimization when compiling for
-   profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
-   can't be used to put the 6th argument in %ebp for syscall.  */
-#if !defined PROF && CAN_USE_REGISTER_ASM_EBP
-# define OPTIMIZE_FOR_GCC_5
-#endif
-
 #ifdef __ASSEMBLER__
 
 /* Linux uses a negative return value to indicate syscall errors,
@@ -238,7 +229,6 @@
 extern int __syscall_error (int)
   attribute_hidden __attribute__ ((__regparm__ (1)));
 
-#ifndef OPTIMIZE_FOR_GCC_5
 /* Six-argument syscalls use an out-of-line helper, because an inline
    asm using all registers apart from %esp cannot work reliably and
    the assembler does not support describing an asm that saves and
@@ -249,7 +239,6 @@ struct libc_do_syscall_args
 {
   int ebx, edi, ebp;
 };
-#endif
 
 # define VDSO_NAME  "LINUX_2.6"
 # define VDSO_HASH  61765110
@@ -302,14 +291,8 @@ struct libc_do_syscall_args
 
 /* Each object using 6-argument inline syscalls must include a
    definition of __libc_do_syscall.  */
-#ifdef OPTIMIZE_FOR_GCC_5
-# define INTERNAL_SYSCALL_MAIN_6(name, args...) \
-    INTERNAL_SYSCALL_MAIN_INLINE(name, 6, args)
-# define INTERNAL_SYSCALL_MAIN_NCS_6(name, args...) \
-    INTERNAL_SYSCALL_MAIN_NCS(name, 6, args)
-#else /* GCC 5  */
-# define INTERNAL_SYSCALL_MAIN_6(name, arg1, arg2, arg3,		\
-				 arg4, arg5, arg6)			\
+#define INTERNAL_SYSCALL_MAIN_6(name, arg1, arg2, arg3,			\
+				arg4, arg5, arg6)			\
   struct libc_do_syscall_args _xv =					\
     {									\
       (int) (arg1),							\
@@ -322,8 +305,8 @@ struct libc_do_syscall_args
     : "=a" (resultvar)							\
     : "i" (__NR_##name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \
     : "memory", "cc")
-# define INTERNAL_SYSCALL_MAIN_NCS_6(name, arg1, arg2, arg3,		\
-				     arg4, arg5, arg6)			\
+#define INTERNAL_SYSCALL_MAIN_NCS_6(name, arg1, arg2, arg3,		\
+				    arg4, arg5, arg6)			\
   struct libc_do_syscall_args _xv =					\
     {									\
       (int) (arg1),							\
@@ -336,7 +319,6 @@ struct libc_do_syscall_args
     : "=a" (resultvar)							\
     : "a" (name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv)	\
     : "memory", "cc")
-#endif /* GCC 5  */
 
 #define INTERNAL_SYSCALL(name, nr, args...) \
   ({									      \
@@ -417,14 +399,6 @@ struct libc_do_syscall_args
 #define ASMARGS_5(arg1, arg2, arg3, arg4, arg5) \
 	ASMARGS_4 (arg1, arg2, arg3, arg4), "D" ((unsigned int) (arg5))
 
-#ifdef OPTIMIZE_FOR_GCC_5
-# define LOADREGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
-	register unsigned int _a6 asm ("ebp") = (unsigned int) (arg6); \
-	LOADREGS_5 (arg1, arg2, arg3, arg4, arg5)
-# define ASMARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
-	ASMARGS_5 (arg1, arg2, arg3, arg4, arg5), "r" (_a6)
-#endif /* GCC 5  */
-
 #define ASMFMT_0()
 #ifdef __PIC__
 # define ASMFMT_1(arg1) \
-- 
2.34.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] Remove some i386 system call optimizations
  2022-01-11 10:05 [PATCH 0/2] Remove some i386 system call optimizations Florian Weimer
  2022-01-11 10:06 ` [PATCH 1/2] i386: Always treat %ebx as an allocatable register Florian Weimer
  2022-01-11 10:06 ` [PATCH 2/2] i386: Always use __libc_do_syscall for 6-argument syscalls (bug 27997) Florian Weimer
@ 2022-01-11 14:00 ` H.J. Lu
  2022-01-11 20:30   ` H.J. Lu
  2 siblings, 1 reply; 14+ messages in thread
From: H.J. Lu @ 2022-01-11 14:00 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library, Jakub Jelinek

On Tue, Jan 11, 2022 at 2:05 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> The configure check for CAN_USE_REGISTER_ASM_EBP is unreliable.  And we
> used it to switch away from using %ebx in assembler constraints, but
> this appears to be no longer necessary.

This GCC bug has been fixed in GCC 5 as seen in

commit 021478683cc091de9902d297a7b161f8343ffb6a
Author: Uros Bizjak <uros@gcc.gnu.org>
Date:   Fri Oct 17 08:00:58 2014 +0200

    cpuid.h (__cpuid): Remove definitions that handle %ebx register in
a special way.

            * config/i386/cpuid.h (__cpuid): Remove definitions that handle %ebx
            register in a special way.
            (__cpuid_count): Ditto.
            * config/i386/driver-i386.h: Protect with
            "#if defined(__GNUC__) && (__GNUC__ >= 5 || !defined(__PIC__))".
            (host_detect_local_cpu): Mention that GCC with non-fixed %ebx
            is required to compile the function.

    From-SVN: r216362

Since GCC 6.2 or above is required to build glibc, please
remove the !OPTIMIZE_FOR_GCC_5 path and this issue
will be resolved automatically.

> Tested on i686-linux-gnu.  Built with build-many-glibcs.py.
>
> Thanks,
> Florian
>
> Florian Weimer (2):
>   i386: Always treat %ebx as an allocatable register
>   i386: Always use __libc_do_syscall for 6-argument syscalls (bug 27997)
>
>  config.h.in                               |   4 -
>  sysdeps/unix/sysv/linux/i386/configure    |  39 ----
>  sysdeps/unix/sysv/linux/i386/configure.ac |  17 --
>  sysdeps/unix/sysv/linux/i386/sysdep.h     | 222 +++-------------------
>  4 files changed, 27 insertions(+), 255 deletions(-)
>
>
> base-commit: e72ef23ee88187284b4b1ca9b2e314e618429d35
> --
> 2.34.1
>


--
H.J.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] Remove some i386 system call optimizations
  2022-01-11 14:00 ` [PATCH 0/2] Remove some i386 system call optimizations H.J. Lu
@ 2022-01-11 20:30   ` H.J. Lu
  2022-01-11 20:37     ` Florian Weimer
  0 siblings, 1 reply; 14+ messages in thread
From: H.J. Lu @ 2022-01-11 20:30 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library, Jakub Jelinek

On Tue, Jan 11, 2022 at 6:00 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Tue, Jan 11, 2022 at 2:05 AM Florian Weimer <fweimer@redhat.com> wrote:
> >
> > The configure check for CAN_USE_REGISTER_ASM_EBP is unreliable.  And we
> > used it to switch away from using %ebx in assembler constraints, but
> > this appears to be no longer necessary.
>
> This GCC bug has been fixed in GCC 5 as seen in
>
> commit 021478683cc091de9902d297a7b161f8343ffb6a
> Author: Uros Bizjak <uros@gcc.gnu.org>
> Date:   Fri Oct 17 08:00:58 2014 +0200
>
>     cpuid.h (__cpuid): Remove definitions that handle %ebx register in
> a special way.
>
>             * config/i386/cpuid.h (__cpuid): Remove definitions that handle %ebx
>             register in a special way.
>             (__cpuid_count): Ditto.
>             * config/i386/driver-i386.h: Protect with
>             "#if defined(__GNUC__) && (__GNUC__ >= 5 || !defined(__PIC__))".
>             (host_detect_local_cpu): Mention that GCC with non-fixed %ebx
>             is required to compile the function.
>
>     From-SVN: r216362
>
> Since GCC 6.2 or above is required to build glibc, please
> remove the !OPTIMIZE_FOR_GCC_5 path and this issue
> will be resolved automatically.

There are

/* Since GCC 5 and above can properly spill %ebx with PIC when needed,
   we can inline syscalls with 6 arguments if GCC 5 or above is used
   to compile glibc.  Disable GCC 5 optimization when compiling for
   profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
   can't be used to put the 6th argument in %ebp for syscall.  */
#if !defined PROF && CAN_USE_REGISTER_ASM_EBP
# define OPTIMIZE_FOR_GCC_5
#endif

If we want to support profiling or -fno-omit-frame-pointer,
we need to keep these codes.

> > Tested on i686-linux-gnu.  Built with build-many-glibcs.py.
> >
> > Thanks,
> > Florian
> >
> > Florian Weimer (2):
> >   i386: Always treat %ebx as an allocatable register
> >   i386: Always use __libc_do_syscall for 6-argument syscalls (bug 27997)
> >
> >  config.h.in                               |   4 -
> >  sysdeps/unix/sysv/linux/i386/configure    |  39 ----
> >  sysdeps/unix/sysv/linux/i386/configure.ac |  17 --
> >  sysdeps/unix/sysv/linux/i386/sysdep.h     | 222 +++-------------------
> >  4 files changed, 27 insertions(+), 255 deletions(-)
> >
> >
> > base-commit: e72ef23ee88187284b4b1ca9b2e314e618429d35
> > --
> > 2.34.1
> >
>
>
> --
> H.J.



-- 
H.J.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] Remove some i386 system call optimizations
  2022-01-11 20:30   ` H.J. Lu
@ 2022-01-11 20:37     ` Florian Weimer
  2022-01-11 22:20       ` H.J. Lu
  0 siblings, 1 reply; 14+ messages in thread
From: Florian Weimer @ 2022-01-11 20:37 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library, Jakub Jelinek

* H. J. Lu:

> On Tue, Jan 11, 2022 at 6:00 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> On Tue, Jan 11, 2022 at 2:05 AM Florian Weimer <fweimer@redhat.com> wrote:
>> >
>> > The configure check for CAN_USE_REGISTER_ASM_EBP is unreliable.  And we
>> > used it to switch away from using %ebx in assembler constraints, but
>> > this appears to be no longer necessary.
>>
>> This GCC bug has been fixed in GCC 5 as seen in
>>
>> commit 021478683cc091de9902d297a7b161f8343ffb6a
>> Author: Uros Bizjak <uros@gcc.gnu.org>
>> Date:   Fri Oct 17 08:00:58 2014 +0200
>>
>>     cpuid.h (__cpuid): Remove definitions that handle %ebx register in
>> a special way.
>>
>>             * config/i386/cpuid.h (__cpuid): Remove definitions that handle %ebx
>>             register in a special way.
>>             (__cpuid_count): Ditto.
>>             * config/i386/driver-i386.h: Protect with
>>             "#if defined(__GNUC__) && (__GNUC__ >= 5 || !defined(__PIC__))".
>>             (host_detect_local_cpu): Mention that GCC with non-fixed %ebx
>>             is required to compile the function.
>>
>>     From-SVN: r216362
>>
>> Since GCC 6.2 or above is required to build glibc, please
>> remove the !OPTIMIZE_FOR_GCC_5 path and this issue
>> will be resolved automatically.
>
> There are
>
> /* Since GCC 5 and above can properly spill %ebx with PIC when needed,
>    we can inline syscalls with 6 arguments if GCC 5 or above is used
>    to compile glibc.  Disable GCC 5 optimization when compiling for
>    profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
>    can't be used to put the 6th argument in %ebp for syscall.  */
> #if !defined PROF && CAN_USE_REGISTER_ASM_EBP
> # define OPTIMIZE_FOR_GCC_5
> #endif
>
> If we want to support profiling or -fno-omit-frame-pointer,
> we need to keep these codes.

This is strictly for %ebp, I think, as indicated by the comment.  %ebx
does not need to be special-cased for profiling.

I assume that building glibc (with profiling) is proof enough that this
works?

Thanks,
Florian


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] Remove some i386 system call optimizations
  2022-01-11 20:37     ` Florian Weimer
@ 2022-01-11 22:20       ` H.J. Lu
  2022-01-11 22:52         ` Florian Weimer
  0 siblings, 1 reply; 14+ messages in thread
From: H.J. Lu @ 2022-01-11 22:20 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library, Jakub Jelinek

On Tue, Jan 11, 2022 at 12:37 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Tue, Jan 11, 2022 at 6:00 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >>
> >> On Tue, Jan 11, 2022 at 2:05 AM Florian Weimer <fweimer@redhat.com> wrote:
> >> >
> >> > The configure check for CAN_USE_REGISTER_ASM_EBP is unreliable.  And we
> >> > used it to switch away from using %ebx in assembler constraints, but
> >> > this appears to be no longer necessary.
> >>
> >> This GCC bug has been fixed in GCC 5 as seen in
> >>
> >> commit 021478683cc091de9902d297a7b161f8343ffb6a
> >> Author: Uros Bizjak <uros@gcc.gnu.org>
> >> Date:   Fri Oct 17 08:00:58 2014 +0200
> >>
> >>     cpuid.h (__cpuid): Remove definitions that handle %ebx register in
> >> a special way.
> >>
> >>             * config/i386/cpuid.h (__cpuid): Remove definitions that handle %ebx
> >>             register in a special way.
> >>             (__cpuid_count): Ditto.
> >>             * config/i386/driver-i386.h: Protect with
> >>             "#if defined(__GNUC__) && (__GNUC__ >= 5 || !defined(__PIC__))".
> >>             (host_detect_local_cpu): Mention that GCC with non-fixed %ebx
> >>             is required to compile the function.
> >>
> >>     From-SVN: r216362
> >>
> >> Since GCC 6.2 or above is required to build glibc, please
> >> remove the !OPTIMIZE_FOR_GCC_5 path and this issue
> >> will be resolved automatically.
> >
> > There are
> >
> > /* Since GCC 5 and above can properly spill %ebx with PIC when needed,
> >    we can inline syscalls with 6 arguments if GCC 5 or above is used
> >    to compile glibc.  Disable GCC 5 optimization when compiling for
> >    profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
> >    can't be used to put the 6th argument in %ebp for syscall.  */
> > #if !defined PROF && CAN_USE_REGISTER_ASM_EBP
> > # define OPTIMIZE_FOR_GCC_5
> > #endif
> >
> > If we want to support profiling or -fno-omit-frame-pointer,
> > we need to keep these codes.
>
> This is strictly for %ebp, I think, as indicated by the comment.  %ebx
> does not need to be special-cased for profiling.
>
> I assume that building glibc (with profiling) is proof enough that this
> works?

You need to test glibc build with -fno-omit-frame-pointer.

-- 
H.J.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] Remove some i386 system call optimizations
  2022-01-11 22:20       ` H.J. Lu
@ 2022-01-11 22:52         ` Florian Weimer
  2022-01-12 18:49           ` H.J. Lu
  0 siblings, 1 reply; 14+ messages in thread
From: Florian Weimer @ 2022-01-11 22:52 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library, Jakub Jelinek

* H. J. Lu:

>> > There are
>> >
>> > /* Since GCC 5 and above can properly spill %ebx with PIC when needed,
>> >    we can inline syscalls with 6 arguments if GCC 5 or above is used
>> >    to compile glibc.  Disable GCC 5 optimization when compiling for
>> >    profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
>> >    can't be used to put the 6th argument in %ebp for syscall.  */
>> > #if !defined PROF && CAN_USE_REGISTER_ASM_EBP
>> > # define OPTIMIZE_FOR_GCC_5
>> > #endif
>> >
>> > If we want to support profiling or -fno-omit-frame-pointer,
>> > we need to keep these codes.
>>
>> This is strictly for %ebp, I think, as indicated by the comment.  %ebx
>> does not need to be special-cased for profiling.
>>
>> I assume that building glibc (with profiling) is proof enough that this
>> works?
>
> You need to test glibc build with -fno-omit-frame-pointer.

I tried it, it works (with both patches applied).
-fno-omit-frame-pointer is about %ebp, not %ebx.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] Remove some i386 system call optimizations
  2022-01-11 22:52         ` Florian Weimer
@ 2022-01-12 18:49           ` H.J. Lu
  2022-01-12 19:37             ` Florian Weimer
  0 siblings, 1 reply; 14+ messages in thread
From: H.J. Lu @ 2022-01-12 18:49 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library, Jakub Jelinek

On Tue, Jan 11, 2022 at 2:52 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> >> > There are
> >> >
> >> > /* Since GCC 5 and above can properly spill %ebx with PIC when needed,
> >> >    we can inline syscalls with 6 arguments if GCC 5 or above is used
> >> >    to compile glibc.  Disable GCC 5 optimization when compiling for
> >> >    profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
> >> >    can't be used to put the 6th argument in %ebp for syscall.  */
> >> > #if !defined PROF && CAN_USE_REGISTER_ASM_EBP
> >> > # define OPTIMIZE_FOR_GCC_5
> >> > #endif
> >> >
> >> > If we want to support profiling or -fno-omit-frame-pointer,
> >> > we need to keep these codes.
> >>
> >> This is strictly for %ebp, I think, as indicated by the comment.  %ebx
> >> does not need to be special-cased for profiling.
> >>
> >> I assume that building glibc (with profiling) is proof enough that this
> >> works?
> >
> > You need to test glibc build with -fno-omit-frame-pointer.
>
> I tried it, it works (with both patches applied).
> -fno-omit-frame-pointer is about %ebp, not %ebx.
>
> Thanks,
> Florian
>

Do they have to be in glibc 2.35?  If not, I prefer to do it after
2.35 is branched.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] Remove some i386 system call optimizations
  2022-01-12 18:49           ` H.J. Lu
@ 2022-01-12 19:37             ` Florian Weimer
  2022-01-12 19:56               ` H.J. Lu
  0 siblings, 1 reply; 14+ messages in thread
From: Florian Weimer @ 2022-01-12 19:37 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library, Jakub Jelinek

* H. J. Lu:

> On Tue, Jan 11, 2022 at 2:52 PM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> >> > There are
>> >> >
>> >> > /* Since GCC 5 and above can properly spill %ebx with PIC when needed,
>> >> >    we can inline syscalls with 6 arguments if GCC 5 or above is used
>> >> >    to compile glibc.  Disable GCC 5 optimization when compiling for
>> >> >    profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
>> >> >    can't be used to put the 6th argument in %ebp for syscall.  */
>> >> > #if !defined PROF && CAN_USE_REGISTER_ASM_EBP
>> >> > # define OPTIMIZE_FOR_GCC_5
>> >> > #endif
>> >> >
>> >> > If we want to support profiling or -fno-omit-frame-pointer,
>> >> > we need to keep these codes.
>> >>
>> >> This is strictly for %ebp, I think, as indicated by the comment.  %ebx
>> >> does not need to be special-cased for profiling.
>> >>
>> >> I assume that building glibc (with profiling) is proof enough that this
>> >> works?
>> >
>> > You need to test glibc build with -fno-omit-frame-pointer.
>>
>> I tried it, it works (with both patches applied).
>> -fno-omit-frame-pointer is about %ebp, not %ebx.
>>
>> Thanks,
>> Florian
>>
>
> Do they have to be in glibc 2.35?  If not, I prefer to do it after
> 2.35 is branched.

We can't build glibc 2.35 with GCC 12 in Fedora without these changes.

The %ebp avoidance I can activate with a configure argument, but the
macros for optimized %ebx usage are incompatible with .altmacro, as used
by the current Systemtap probes.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] Remove some i386 system call optimizations
  2022-01-12 19:37             ` Florian Weimer
@ 2022-01-12 19:56               ` H.J. Lu
  2022-01-12 20:12                 ` Florian Weimer
  0 siblings, 1 reply; 14+ messages in thread
From: H.J. Lu @ 2022-01-12 19:56 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library, Jakub Jelinek

On Wed, Jan 12, 2022 at 11:37 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Tue, Jan 11, 2022 at 2:52 PM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu:
> >>
> >> >> > There are
> >> >> >
> >> >> > /* Since GCC 5 and above can properly spill %ebx with PIC when needed,
> >> >> >    we can inline syscalls with 6 arguments if GCC 5 or above is used
> >> >> >    to compile glibc.  Disable GCC 5 optimization when compiling for
> >> >> >    profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
> >> >> >    can't be used to put the 6th argument in %ebp for syscall.  */
> >> >> > #if !defined PROF && CAN_USE_REGISTER_ASM_EBP
> >> >> > # define OPTIMIZE_FOR_GCC_5
> >> >> > #endif
> >> >> >
> >> >> > If we want to support profiling or -fno-omit-frame-pointer,
> >> >> > we need to keep these codes.
> >> >>
> >> >> This is strictly for %ebp, I think, as indicated by the comment.  %ebx
> >> >> does not need to be special-cased for profiling.
> >> >>
> >> >> I assume that building glibc (with profiling) is proof enough that this
> >> >> works?
> >> >
> >> > You need to test glibc build with -fno-omit-frame-pointer.
> >>
> >> I tried it, it works (with both patches applied).
> >> -fno-omit-frame-pointer is about %ebp, not %ebx.
> >>
> >> Thanks,
> >> Florian
> >>
> >
> > Do they have to be in glibc 2.35?  If not, I prefer to do it after
> > 2.35 is branched.
>
> We can't build glibc 2.35 with GCC 12 in Fedora without these changes.
>
> The %ebp avoidance I can activate with a configure argument, but the
> macros for optimized %ebx usage are incompatible with .altmacro, as used
> by the current Systemtap probes.

Please open a glibc bug with a reproducer and CC me.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] Remove some i386 system call optimizations
  2022-01-12 19:56               ` H.J. Lu
@ 2022-01-12 20:12                 ` Florian Weimer
  2022-01-12 21:59                   ` H.J. Lu
  0 siblings, 1 reply; 14+ messages in thread
From: Florian Weimer @ 2022-01-12 20:12 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library, Jakub Jelinek

* H. J. Lu:

> On Wed, Jan 12, 2022 at 11:37 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> > On Tue, Jan 11, 2022 at 2:52 PM Florian Weimer <fweimer@redhat.com> wrote:
>> >>
>> >> * H. J. Lu:
>> >>
>> >> >> > There are
>> >> >> >
>> >> >> > /* Since GCC 5 and above can properly spill %ebx with PIC when needed,
>> >> >> >    we can inline syscalls with 6 arguments if GCC 5 or above is used
>> >> >> >    to compile glibc.  Disable GCC 5 optimization when compiling for
>> >> >> >    profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
>> >> >> >    can't be used to put the 6th argument in %ebp for syscall.  */
>> >> >> > #if !defined PROF && CAN_USE_REGISTER_ASM_EBP
>> >> >> > # define OPTIMIZE_FOR_GCC_5
>> >> >> > #endif
>> >> >> >
>> >> >> > If we want to support profiling or -fno-omit-frame-pointer,
>> >> >> > we need to keep these codes.
>> >> >>
>> >> >> This is strictly for %ebp, I think, as indicated by the comment.  %ebx
>> >> >> does not need to be special-cased for profiling.
>> >> >>
>> >> >> I assume that building glibc (with profiling) is proof enough that this
>> >> >> works?
>> >> >
>> >> > You need to test glibc build with -fno-omit-frame-pointer.
>> >>
>> >> I tried it, it works (with both patches applied).
>> >> -fno-omit-frame-pointer is about %ebp, not %ebx.
>> >>
>> >> Thanks,
>> >> Florian
>> >>
>> >
>> > Do they have to be in glibc 2.35?  If not, I prefer to do it after
>> > 2.35 is branched.
>>
>> We can't build glibc 2.35 with GCC 12 in Fedora without these changes.
>>
>> The %ebp avoidance I can activate with a configure argument, but the
>> macros for optimized %ebx usage are incompatible with .altmacro, as used
>> by the current Systemtap probes.
>
> Please open a glibc bug with a reproducer and CC me.

Done: <https://sourceware.org/bugzilla/show_bug.cgi?id=28771>

Thanks,
Florian


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] Remove some i386 system call optimizations
  2022-01-12 20:12                 ` Florian Weimer
@ 2022-01-12 21:59                   ` H.J. Lu
  2022-01-12 22:33                     ` Florian Weimer
  0 siblings, 1 reply; 14+ messages in thread
From: H.J. Lu @ 2022-01-12 21:59 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library, Jakub Jelinek

On Wed, Jan 12, 2022 at 12:12 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Wed, Jan 12, 2022 at 11:37 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu:
> >>
> >> > On Tue, Jan 11, 2022 at 2:52 PM Florian Weimer <fweimer@redhat.com> wrote:
> >> >>
> >> >> * H. J. Lu:
> >> >>
> >> >> >> > There are
> >> >> >> >
> >> >> >> > /* Since GCC 5 and above can properly spill %ebx with PIC when needed,
> >> >> >> >    we can inline syscalls with 6 arguments if GCC 5 or above is used
> >> >> >> >    to compile glibc.  Disable GCC 5 optimization when compiling for
> >> >> >> >    profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
> >> >> >> >    can't be used to put the 6th argument in %ebp for syscall.  */
> >> >> >> > #if !defined PROF && CAN_USE_REGISTER_ASM_EBP
> >> >> >> > # define OPTIMIZE_FOR_GCC_5
> >> >> >> > #endif
> >> >> >> >
> >> >> >> > If we want to support profiling or -fno-omit-frame-pointer,
> >> >> >> > we need to keep these codes.
> >> >> >>
> >> >> >> This is strictly for %ebp, I think, as indicated by the comment.  %ebx
> >> >> >> does not need to be special-cased for profiling.
> >> >> >>
> >> >> >> I assume that building glibc (with profiling) is proof enough that this
> >> >> >> works?
> >> >> >
> >> >> > You need to test glibc build with -fno-omit-frame-pointer.
> >> >>
> >> >> I tried it, it works (with both patches applied).
> >> >> -fno-omit-frame-pointer is about %ebp, not %ebx.
> >> >>
> >> >> Thanks,
> >> >> Florian
> >> >>
> >> >
> >> > Do they have to be in glibc 2.35?  If not, I prefer to do it after
> >> > 2.35 is branched.
> >>
> >> We can't build glibc 2.35 with GCC 12 in Fedora without these changes.
> >>
> >> The %ebp avoidance I can activate with a configure argument, but the
> >> macros for optimized %ebx usage are incompatible with .altmacro, as used
> >> by the current Systemtap probes.
> >
> > Please open a glibc bug with a reproducer and CC me.
>
> Done: <https://sourceware.org/bugzilla/show_bug.cgi?id=28771>
>

OPTIMIZE_FOR_GCC_5 enables 2 things: one is let GCC handle
-fPIC and the other is use

register int reg asm ("ebp")

which is unreliable.   You want to let GCC handle -fPIC and
remove CAN_USE_REGISTER_ASM_EBP.  If this is correct,
please combine 2 patches into one and reference BZ #28771
in the commit log.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] Remove some i386 system call optimizations
  2022-01-12 21:59                   ` H.J. Lu
@ 2022-01-12 22:33                     ` Florian Weimer
  0 siblings, 0 replies; 14+ messages in thread
From: Florian Weimer @ 2022-01-12 22:33 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library, Jakub Jelinek

* H. J. Lu:

> OPTIMIZE_FOR_GCC_5 enables 2 things: one is let GCC handle
> -fPIC and the other is use
>
> register int reg asm ("ebp")
>
> which is unreliable.   You want to let GCC handle -fPIC and
> remove CAN_USE_REGISTER_ASM_EBP.  If this is correct,
> please combine 2 patches into one and reference BZ #28771
> in the commit log.

Yes, that is an accurate summary.  I will send a patch according to your
suggestions tomorrow.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-01-12 22:38 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 10:05 [PATCH 0/2] Remove some i386 system call optimizations Florian Weimer
2022-01-11 10:06 ` [PATCH 1/2] i386: Always treat %ebx as an allocatable register Florian Weimer
2022-01-11 10:06 ` [PATCH 2/2] i386: Always use __libc_do_syscall for 6-argument syscalls (bug 27997) Florian Weimer
2022-01-11 14:00 ` [PATCH 0/2] Remove some i386 system call optimizations H.J. Lu
2022-01-11 20:30   ` H.J. Lu
2022-01-11 20:37     ` Florian Weimer
2022-01-11 22:20       ` H.J. Lu
2022-01-11 22:52         ` Florian Weimer
2022-01-12 18:49           ` H.J. Lu
2022-01-12 19:37             ` Florian Weimer
2022-01-12 19:56               ` H.J. Lu
2022-01-12 20:12                 ` Florian Weimer
2022-01-12 21:59                   ` H.J. Lu
2022-01-12 22:33                     ` Florian Weimer

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).