This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] nptl: Remove __ASSUME_PRIVATE_FUTEX


On Wed, May 16, 2018 at 9:45 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 05/16/2018 06:36 PM, H.J. Lu wrote:
>>
>> Good idea.  How about this patch to remove __ASSUME_PRIVATE_FUTEX
>> checks first?
>
>
> I would prefer if you removed the whole thing, including its definition.
>

Here is the patch to remove __ASSUME_PRIVATE_FUTEX.  OK
for trunk?


-- 
H.J.
From 5e5e2840e38ebac37ab08042512e9515d0e247e0 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 16 May 2018 09:30:14 -0700
Subject: [PATCH] nptl: Remove __ASSUME_PRIVATE_FUTEX

Since __ASSUME_PRIVATE_FUTEX is always defined, this patch removes the
!__ASSUME_PRIVATE_FUTEX paths.

Tested with build-many-glibcs.py.

	* nptl/allocatestack.c (allocate_stack): Remove the
	!__ASSUME_PRIVATE_FUTEX paths.
	* nptl/descr.h (header): Remove the !__ASSUME_PRIVATE_FUTEX path.
	* nptl/nptl-init.c (__pthread_initialize_minimal_internal):
	Likewise.
	* sysdeps/i386/nptl/tcb-offsets.sym (PRIVATE_FUTEX): Removed.
	* sysdeps/powerpc/nptl/tcb-offsets.sym (PRIVATE_FUTEX): Likewise.
	* sysdeps/sh/nptl/tcb-offsets.sym (PRIVATE_FUTEX): Likewise.
	* sysdeps/x86_64/nptl/tcb-offsets.sym (PRIVATE_FUTEX): Likewise.
	* sysdeps/i386/nptl/tls.h: (tcbhead_t): Remve the
	!__ASSUME_PRIVATE_FUTEX path.
	* sysdeps/s390/nptl/tls.h (tcbhead_t): Likewise.
	* sysdeps/sparc/nptl/tls.h (tcbhead_t): Likewise.
	* sysdeps/x86_64/nptl/tls.h (tcbhead_t): Likewise.
	* sysdeps/unix/sysv/linux/i386/lowlevellock.S: Remove the
	!__ASSUME_PRIVATE_FUTEX macros.
	* sysdeps/unix/sysv/linux/lowlevellock-futex.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/cancellation.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_PRIVATE_FUTEX): Removed.
---
 nptl/allocatestack.c                          | 12 ------
 nptl/descr.h                                  |  3 --
 nptl/nptl-init.c                              | 18 --------
 sysdeps/i386/nptl/tcb-offsets.sym             |  3 --
 sysdeps/i386/nptl/tls.h                       |  4 --
 sysdeps/powerpc/nptl/tcb-offsets.sym          |  3 --
 sysdeps/s390/nptl/tls.h                       |  4 --
 sysdeps/sh/nptl/tcb-offsets.sym               |  3 --
 sysdeps/sparc/nptl/tls.h                      |  3 --
 sysdeps/unix/sysv/linux/i386/lowlevellock.S   | 42 +++----------------
 sysdeps/unix/sysv/linux/kernel-features.h     |  3 --
 sysdeps/unix/sysv/linux/lowlevellock-futex.h  | 19 +--------
 sysdeps/unix/sysv/linux/x86_64/cancellation.S | 13 +-----
 sysdeps/unix/sysv/linux/x86_64/lowlevellock.S | 42 +++----------------
 sysdeps/x86_64/nptl/tcb-offsets.sym           |  3 --
 sysdeps/x86_64/nptl/tls.h                     |  4 --
 16 files changed, 13 insertions(+), 166 deletions(-)

diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index b374f4794d..9c10b993fd 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -486,12 +486,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
       __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
 #endif
 
-#ifndef __ASSUME_PRIVATE_FUTEX
-      /* The thread must know when private futexes are supported.  */
-      pd->header.private_futex = THREAD_GETMEM (THREAD_SELF,
-						header.private_futex);
-#endif
-
 #ifdef NEED_DL_SYSINFO
       SETUP_THREAD_SYSINFO (pd);
 #endif
@@ -610,12 +604,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
 	  __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
 #endif
 
-#ifndef __ASSUME_PRIVATE_FUTEX
-	  /* The thread must know when private futexes are supported.  */
-	  pd->header.private_futex = THREAD_GETMEM (THREAD_SELF,
-						    header.private_futex);
-#endif
-
 #ifdef NEED_DL_SYSINFO
 	  SETUP_THREAD_SYSINFO (pd);
 #endif
diff --git a/nptl/descr.h b/nptl/descr.h
index 64ba29e1cb..0a0abb4d5a 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -145,9 +145,6 @@ struct pthread
 	 looks to cancel itself and is hence going to end anyway.  */
       int multiple_threads;
       int gscope_flag;
-# ifndef __ASSUME_PRIVATE_FUTEX
-      int private_futex;
-# endif
     } header;
 #endif
 
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index 5a4b52419f..1d3790f500 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -313,24 +313,6 @@ __pthread_initialize_minimal_internal (void)
   }
 
 #ifdef __NR_futex
-# ifndef __ASSUME_PRIVATE_FUTEX
-  /* Private futexes are always used (at least internally) so that
-     doing the test once this early is beneficial.  */
-  {
-    int word = 0;
-    INTERNAL_SYSCALL_DECL (err);
-    word = INTERNAL_SYSCALL (futex, err, 3, &word,
-			    FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1);
-    if (!INTERNAL_SYSCALL_ERROR_P (word, err))
-      THREAD_SETMEM (pd, header.private_futex, FUTEX_PRIVATE_FLAG);
-  }
-
-  /* Private futexes have been introduced earlier than the
-     FUTEX_CLOCK_REALTIME flag.  We don't have to run the test if we
-     know the former are not supported.  This also means we know the
-     kernel will return ENOSYS for unknown operations.  */
-  if (THREAD_GETMEM (pd, header.private_futex) != 0)
-# endif
 # ifndef __ASSUME_FUTEX_CLOCK_REALTIME
     {
       int word = 0;
diff --git a/sysdeps/i386/nptl/tcb-offsets.sym b/sysdeps/i386/nptl/tcb-offsets.sym
index 695a810386..7d7fe5e71c 100644
--- a/sysdeps/i386/nptl/tcb-offsets.sym
+++ b/sysdeps/i386/nptl/tcb-offsets.sym
@@ -12,6 +12,3 @@ CLEANUP			offsetof (struct pthread, cleanup)
 CLEANUP_PREV		offsetof (struct _pthread_cleanup_buffer, __prev)
 MUTEX_FUTEX		offsetof (pthread_mutex_t, __data.__lock)
 POINTER_GUARD		offsetof (tcbhead_t, pointer_guard)
-#ifndef __ASSUME_PRIVATE_FUTEX
-PRIVATE_FUTEX		offsetof (tcbhead_t, private_futex)
-#endif
diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
index 8ca0924692..6c36e58e9c 100644
--- a/sysdeps/i386/nptl/tls.h
+++ b/sysdeps/i386/nptl/tls.h
@@ -41,11 +41,7 @@ typedef struct
   uintptr_t stack_guard;
   uintptr_t pointer_guard;
   int gscope_flag;
-#ifndef __ASSUME_PRIVATE_FUTEX
-  int private_futex;
-#else
   int __glibc_reserved1;
-#endif
   /* Reservation of some values for the TM ABI.  */
   void *__private_tm[4];
   /* GCC split stack support.  */
diff --git a/sysdeps/powerpc/nptl/tcb-offsets.sym b/sysdeps/powerpc/nptl/tcb-offsets.sym
index 7c9fd33562..e5bb2b376d 100644
--- a/sysdeps/powerpc/nptl/tcb-offsets.sym
+++ b/sysdeps/powerpc/nptl/tcb-offsets.sym
@@ -27,6 +27,3 @@ TCB_AT_PLATFORM			(offsetof (tcbhead_t, at_platform) - TLS_TCB_OFFSET - sizeof(t
 PADDING				(offsetof (tcbhead_t, padding) - TLS_TCB_OFFSET - sizeof(tcbhead_t))
 #endif
 TCB_HWCAP			(offsetof (tcbhead_t, hwcap) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
-#ifndef __ASSUME_PRIVATE_FUTEX
-PRIVATE_FUTEX_OFFSET		thread_offsetof (header.private_futex)
-#endif
diff --git a/sysdeps/s390/nptl/tls.h b/sysdeps/s390/nptl/tls.h
index 37692e96ed..220bdfffb3 100644
--- a/sysdeps/s390/nptl/tls.h
+++ b/sysdeps/s390/nptl/tls.h
@@ -39,11 +39,7 @@ typedef struct
   uintptr_t sysinfo;
   uintptr_t stack_guard;
   int gscope_flag;
-#ifndef __ASSUME_PRIVATE_FUTEX
-  int private_futex;
-#else
   int __glibc_reserved1;
-#endif
   /* GCC split stack support.  */
   void *__private_ss;
 } tcbhead_t;
diff --git a/sysdeps/sh/nptl/tcb-offsets.sym b/sysdeps/sh/nptl/tcb-offsets.sym
index 4963e1506f..234207779d 100644
--- a/sysdeps/sh/nptl/tcb-offsets.sym
+++ b/sysdeps/sh/nptl/tcb-offsets.sym
@@ -10,6 +10,3 @@ MULTIPLE_THREADS_OFFSET	offsetof (struct pthread, header.multiple_threads)
 TLS_PRE_TCB_SIZE	sizeof (struct pthread)
 MUTEX_FUTEX		offsetof (pthread_mutex_t, __data.__lock)
 POINTER_GUARD		offsetof (tcbhead_t, pointer_guard)
-#ifndef __ASSUME_PRIVATE_FUTEX
-PRIVATE_FUTEX		offsetof (struct pthread, header.private_futex)
-#endif
diff --git a/sysdeps/sparc/nptl/tls.h b/sysdeps/sparc/nptl/tls.h
index 8a547f138e..2a79868ee2 100644
--- a/sysdeps/sparc/nptl/tls.h
+++ b/sysdeps/sparc/nptl/tls.h
@@ -45,9 +45,6 @@ typedef struct
 #if __WORDSIZE != 64
   int gscope_flag;
 #endif
-#ifndef __ASSUME_PRIVATE_FUTEX
-  int private_futex;
-#endif
 } tcbhead_t;
 
 #else /* __ASSEMBLER__ */
diff --git a/sysdeps/unix/sysv/linux/i386/lowlevellock.S b/sysdeps/unix/sysv/linux/i386/lowlevellock.S
index 416b484170..feda390eeb 100644
--- a/sysdeps/unix/sysv/linux/i386/lowlevellock.S
+++ b/sysdeps/unix/sysv/linux/i386/lowlevellock.S
@@ -25,48 +25,16 @@
 
 	.text
 
-#ifdef __ASSUME_PRIVATE_FUTEX
-# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+#define LOAD_PRIVATE_FUTEX_WAIT(reg) \
 	movl	$(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
-# define LOAD_PRIVATE_FUTEX_WAKE(reg) \
+#define LOAD_PRIVATE_FUTEX_WAKE(reg) \
 	movl	$(FUTEX_WAKE | FUTEX_PRIVATE_FLAG), reg
-# define LOAD_FUTEX_WAIT(reg) \
+#define LOAD_FUTEX_WAIT(reg) \
 	xorl	$(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
-# define LOAD_FUTEX_WAIT_ABS(reg) \
+#define LOAD_FUTEX_WAIT_ABS(reg) \
 	xorl	$(FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME), reg
-# define LOAD_FUTEX_WAKE(reg) \
+#define LOAD_FUTEX_WAKE(reg) \
 	xorl	$(FUTEX_WAKE | FUTEX_PRIVATE_FLAG), reg
-#else
-# if FUTEX_WAIT == 0
-#  define LOAD_PRIVATE_FUTEX_WAIT(reg) \
-	movl	%gs:PRIVATE_FUTEX, reg
-# else
-#  define LOAD_PRIVATE_FUTEX_WAIT(reg) \
-	movl	%gs:PRIVATE_FUTEX, reg ; \
-	orl	$FUTEX_WAIT, reg
-# endif
-# define LOAD_PRIVATE_FUTEX_WAKE(reg) \
-	movl	%gs:PRIVATE_FUTEX, reg ; \
-	orl	$FUTEX_WAKE, reg
-# if FUTEX_WAIT == 0
-#  define LOAD_FUTEX_WAIT(reg) \
-	xorl	$FUTEX_PRIVATE_FLAG, reg ; \
-	andl	%gs:PRIVATE_FUTEX, reg
-# else
-#  define LOAD_FUTEX_WAIT(reg) \
-	xorl	$FUTEX_PRIVATE_FLAG, reg ; \
-	andl	%gs:PRIVATE_FUTEX, reg ; \
-	orl	$FUTEX_WAIT, reg
-# endif
-# define LOAD_FUTEX_WAIT_ABS(reg) \
-	xorl	$FUTEX_PRIVATE_FLAG, reg ; \
-	andl	%gs:PRIVATE_FUTEX, reg ; \
-	orl	$FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME, reg
-# define LOAD_FUTEX_WAKE(reg) \
-	xorl	$FUTEX_PRIVATE_FLAG, reg ; \
-	andl	%gs:PRIVATE_FUTEX, reg ; \
-	orl	$FUTEX_WAKE, reg
-#endif
 
 	.globl	__lll_lock_wait_private
 	.type	__lll_lock_wait_private,@function
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index 2ef2916a52..b90ea30195 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -61,9 +61,6 @@
    configurations).  */
 #define __ASSUME_SET_ROBUST_LIST	1
 
-/* Support for private futexes was added in 2.6.22.  */
-#define __ASSUME_PRIVATE_FUTEX	1
-
 /* Support for various CLOEXEC and NONBLOCK flags was added in
    2.6.27.  */
 #define __ASSUME_IN_NONBLOCK	1
diff --git a/sysdeps/unix/sysv/linux/lowlevellock-futex.h b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
index 4eddadb052..fc834ed16e 100644
--- a/sysdeps/unix/sysv/linux/lowlevellock-futex.h
+++ b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
@@ -53,31 +53,16 @@
 
 #if IS_IN (libc) || IS_IN (rtld)
 /* In libc.so or ld.so all futexes are private.  */
-# ifdef __ASSUME_PRIVATE_FUTEX
-#  define __lll_private_flag(fl, private)			\
+# define __lll_private_flag(fl, private)			\
   ({								\
     /* Prevent warnings in callers of this macro.  */		\
     int __lll_private_flag_priv __attribute__ ((unused));	\
     __lll_private_flag_priv = (private);			\
     ((fl) | FUTEX_PRIVATE_FLAG);				\
   })
-# else
-#  define __lll_private_flag(fl, private) \
-  ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
-# endif
 #else
-# ifdef __ASSUME_PRIVATE_FUTEX
-#  define __lll_private_flag(fl, private) \
+# define __lll_private_flag(fl, private) \
   (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
-# else
-#  define __lll_private_flag(fl, private) \
-  (__builtin_constant_p (private)					      \
-   ? ((private) == 0							      \
-      ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))	      \
-      : (fl))								      \
-   : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG)				      \
-	      & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
-# endif
 #endif
 
 #define lll_futex_syscall(nargs, futexp, op, ...)                       \
diff --git a/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/sysdeps/unix/sysv/linux/x86_64/cancellation.S
index f3fb19dec2..53dbabd6d2 100644
--- a/sysdeps/unix/sysv/linux/x86_64/cancellation.S
+++ b/sysdeps/unix/sysv/linux/x86_64/cancellation.S
@@ -34,19 +34,8 @@
 #endif
 
 
-#ifdef __ASSUME_PRIVATE_FUTEX
-# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+#define LOAD_PRIVATE_FUTEX_WAIT(reg) \
 	movl	$(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
-#else
-# if FUTEX_WAIT == 0
-#  define LOAD_PRIVATE_FUTEX_WAIT(reg) \
-	movl	%fs:PRIVATE_FUTEX, reg
-# else
-#  define LOAD_PRIVATE_FUTEX_WAIT(reg) \
-	movl	%fs:PRIVATE_FUTEX, reg ; \
-	orl	$FUTEX_WAIT, reg
-# endif
-#endif
 
 /* It is crucial that the functions in this file don't modify registers
    other than %rax and %r11.  The syscall wrapper code depends on this
diff --git a/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
index 92561e1da0..71dd740202 100644
--- a/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+++ b/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
@@ -25,48 +25,16 @@
 
 	.text
 
-#ifdef __ASSUME_PRIVATE_FUTEX
-# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+#define LOAD_PRIVATE_FUTEX_WAIT(reg) \
 	movl	$(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
-# define LOAD_PRIVATE_FUTEX_WAKE(reg) \
+#define LOAD_PRIVATE_FUTEX_WAKE(reg) \
 	movl	$(FUTEX_WAKE | FUTEX_PRIVATE_FLAG), reg
-# define LOAD_FUTEX_WAIT(reg) \
+#define LOAD_FUTEX_WAIT(reg) \
 	xorl	$(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
-# define LOAD_FUTEX_WAIT_ABS(reg) \
+#define LOAD_FUTEX_WAIT_ABS(reg) \
 	xorl	$(FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME), reg
-# define LOAD_FUTEX_WAKE(reg) \
+#define LOAD_FUTEX_WAKE(reg) \
 	xorl	$(FUTEX_WAKE | FUTEX_PRIVATE_FLAG), reg
-#else
-# if FUTEX_WAIT == 0
-#  define LOAD_PRIVATE_FUTEX_WAIT(reg) \
-	movl    %fs:PRIVATE_FUTEX, reg
-# else
-#  define LOAD_PRIVATE_FUTEX_WAIT(reg) \
-	movl	%fs:PRIVATE_FUTEX, reg ; \
-	orl	$FUTEX_WAIT, reg
-# endif
-# define LOAD_PRIVATE_FUTEX_WAKE(reg) \
-	movl    %fs:PRIVATE_FUTEX, reg ; \
-	orl     $FUTEX_WAKE, reg
-# if FUTEX_WAIT == 0
-#  define LOAD_FUTEX_WAIT(reg) \
-	xorl	$FUTEX_PRIVATE_FLAG, reg ; \
-	andl	%fs:PRIVATE_FUTEX, reg
-# else
-#  define LOAD_FUTEX_WAIT(reg) \
-	xorl	$FUTEX_PRIVATE_FLAG, reg ; \
-	andl	%fs:PRIVATE_FUTEX, reg ; \
-	orl	$FUTEX_WAIT, reg
-# endif
-# define LOAD_FUTEX_WAIT_ABS(reg) \
-	xorl	$FUTEX_PRIVATE_FLAG, reg ; \
-	andl	%fs:PRIVATE_FUTEX, reg ; \
-	orl	$FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME, reg
-# define LOAD_FUTEX_WAKE(reg) \
-	xorl	$FUTEX_PRIVATE_FLAG, reg ; \
-	andl	%fs:PRIVATE_FUTEX, reg ; \
-	orl	$FUTEX_WAKE, reg
-#endif
 
 
 	.globl	__lll_lock_wait_private
diff --git a/sysdeps/x86_64/nptl/tcb-offsets.sym b/sysdeps/x86_64/nptl/tcb-offsets.sym
index 8a25c482cb..be63404a16 100644
--- a/sysdeps/x86_64/nptl/tcb-offsets.sym
+++ b/sysdeps/x86_64/nptl/tcb-offsets.sym
@@ -12,9 +12,6 @@ MUTEX_FUTEX		offsetof (pthread_mutex_t, __data.__lock)
 MULTIPLE_THREADS_OFFSET	offsetof (tcbhead_t, multiple_threads)
 POINTER_GUARD		offsetof (tcbhead_t, pointer_guard)
 VGETCPU_CACHE_OFFSET	offsetof (tcbhead_t, vgetcpu_cache)
-#ifndef __ASSUME_PRIVATE_FUTEX
-PRIVATE_FUTEX		offsetof (tcbhead_t, private_futex)
-#endif
 
 -- Not strictly offsets, but these values are also used in the TCB.
 TCB_CANCELSTATE_BITMASK	 CANCELSTATE_BITMASK
diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
index 059f9675a0..6da1c04a98 100644
--- a/sysdeps/x86_64/nptl/tls.h
+++ b/sysdeps/x86_64/nptl/tls.h
@@ -51,11 +51,7 @@ typedef struct
   uintptr_t stack_guard;
   uintptr_t pointer_guard;
   unsigned long int vgetcpu_cache[2];
-# ifndef __ASSUME_PRIVATE_FUTEX
-  int private_futex;
-# else
   int __glibc_reserved1;
-# endif
   int __glibc_unused1;
   /* Reservation of some values for the TM ABI.  */
   void *__private_tm[4];
-- 
2.17.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]