]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: Move elision implementations into libc
authorFlorian Weimer <fweimer@redhat.com>
Tue, 23 Feb 2021 13:59:34 +0000 (14:59 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 23 Feb 2021 13:59:34 +0000 (14:59 +0100)
The elision interfaces are closely aligned between the targets that
implement them, so declare them in the generic <lowlevellock.h>
file.

Empty .c stubs are provided, so that fewer makefile updates
under sysdeps are needed.  Also simplify initialization via
__libc_early_init.

The symbols __lll_clocklock_elision, __lll_lock_elision,
__lll_trylock_elision, __lll_unlock_elision, __pthread_force_elision
move into libc.  For the time being, non-hidden references are used
from libpthread to access them, but once that part of libpthread
is moved into libc, hidden symbols will be used again.  (Hidden
references seem desirable to reduce the likelihood of transactions
aborts.)

46 files changed:
elf/libc_early_init.c
nptl/Makefile
nptl/Versions
nptl/elision-conf.c [moved from sysdeps/unix/sysv/linux/s390/pthread_mutex_lock.c with 79% similarity]
nptl/elision-lock.c [moved from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_lock.c with 79% similarity]
nptl/elision-timed.c [moved from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_trylock.c with 78% similarity]
nptl/elision-trylock.c [moved from sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c with 79% similarity]
nptl/elision-unlock.c [new file with mode: 0644]
nptl/lowlevellock.c
nptl/pthread_mutex_lock.c
nptl/pthread_mutex_timedlock.c
nptl/pthread_mutex_trylock.c
nptl/pthread_mutex_unlock.c
sysdeps/nptl/lowlevellock.h
sysdeps/pthread/elision-conf.h [moved from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_timedlock.c with 63% similarity]
sysdeps/unix/sysv/linux/powerpc/Makefile
sysdeps/unix/sysv/linux/powerpc/elision-conf.c
sysdeps/unix/sysv/linux/powerpc/elision-conf.h
sysdeps/unix/sysv/linux/powerpc/elision-lock.c
sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
sysdeps/unix/sysv/linux/powerpc/force-elision.h [deleted file]
sysdeps/unix/sysv/linux/powerpc/lowlevellock.h [deleted file]
sysdeps/unix/sysv/linux/powerpc/pthread_mutex_cond_lock.c [deleted file]
sysdeps/unix/sysv/linux/s390/Makefile
sysdeps/unix/sysv/linux/s390/elision-conf.c
sysdeps/unix/sysv/linux/s390/elision-conf.h
sysdeps/unix/sysv/linux/s390/elision-lock.c
sysdeps/unix/sysv/linux/s390/elision-trylock.c
sysdeps/unix/sysv/linux/s390/elision-unlock.c
sysdeps/unix/sysv/linux/s390/force-elision.h [deleted file]
sysdeps/unix/sysv/linux/s390/lowlevellock.h [deleted file]
sysdeps/unix/sysv/linux/s390/pthread_mutex_cond_lock.c [deleted file]
sysdeps/unix/sysv/linux/s390/pthread_mutex_timedlock.c [deleted file]
sysdeps/unix/sysv/linux/s390/pthread_mutex_trylock.c [deleted file]
sysdeps/unix/sysv/linux/x86/Makefile
sysdeps/unix/sysv/linux/x86/elision-conf.c
sysdeps/unix/sysv/linux/x86/elision-conf.h
sysdeps/unix/sysv/linux/x86/elision-lock.c
sysdeps/unix/sysv/linux/x86/elision-trylock.c
sysdeps/unix/sysv/linux/x86/elision-unlock.c
sysdeps/unix/sysv/linux/x86/force-elision.h [deleted file]
sysdeps/unix/sysv/linux/x86/lowlevellock.h
sysdeps/unix/sysv/linux/x86/pthread_mutex_cond_lock.c [deleted file]
sysdeps/unix/sysv/linux/x86/pthread_mutex_timedlock.c [deleted file]
sysdeps/unix/sysv/linux/x86/pthread_mutex_trylock.c [deleted file]

index 4755554f12db83345db46bbcefe73bfb78a0c415..9b1901a706040fcf28c34e4ab957d8f712c68fcb 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #include <ctype.h>
+#include <elision-conf.h>
 #include <libc-early-init.h>
 #include <libc-internal.h>
+#include <lowlevellock.h>
 #include <sys/single_threaded.h>
 
 #ifdef SHARED
@@ -37,4 +39,8 @@ __libc_early_init (_Bool initial)
 #ifdef SHARED
   __libc_initial = initial;
 #endif
+
+#if ENABLE_ELISION_SUPPORT
+  __lll_elision_init ();
+#endif
 }
index 4dd9c6a6a81a4a96ab9730074c893520a050f699..5f85dd7854e33982eb76c1088a62d11bb235a7af 100644 (file)
@@ -30,6 +30,11 @@ extra-libs-others := $(extra-libs)
 
 routines = \
   alloca_cutoff \
+  elision-conf \
+  elision-lock \
+  elision-timed \
+  elision-trylock \
+  elision-unlock \
   forward \
   futex-internal \
   libc-cancellation \
index 6cca579a0ab46257367f166b01a3c27df5c3133a..186befebfd5b89e836f692e4693ed920065c00a3 100644 (file)
@@ -79,8 +79,12 @@ libc {
     __libc_current_sigrtmin_private;
     __libc_dl_error_tsd;
     __libc_pthread_init;
+    __lll_clocklock_elision;
+    __lll_lock_elision;
     __lll_lock_wait;
     __lll_lock_wait_private;
+    __lll_trylock_elision;
+    __lll_unlock_elision;
     __pthread_attr_copy;
     __pthread_attr_destroy;
     __pthread_attr_init;
@@ -88,6 +92,7 @@ libc {
     __pthread_attr_setsigmask_internal;
     __pthread_cond_destroy; # Used by the C11 threads.
     __pthread_cond_init; # Used by the C11 threads.
+    __pthread_force_elision;
     __pthread_getattr_default_np;
   }
 }
similarity index 79%
rename from sysdeps/unix/sysv/linux/s390/pthread_mutex_lock.c
rename to nptl/elision-conf.c
index b193b5b2b0f252bffbdb6489faa79607fde05fe9..d71c30a01b620da0b2cf8f9cfba335c7887e2a78 100644 (file)
@@ -1,5 +1,5 @@
-/* Elided version of pthread_mutex_lock.
-   Copyright (C) 2014-2021 Free Software Foundation, Inc.
+/* elision-conf.c: Lock elision tunable parameters.  Stub version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -15,8 +15,3 @@
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
-
-#include <elision-conf.h>
-#include <force-elision.h>
-
-#include <nptl/pthread_mutex_lock.c>
similarity index 79%
rename from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_lock.c
rename to nptl/elision-lock.c
index 110a6bf47bad5750b32caf98b8251c1858de6f04..a8235cbbeabf66c57f44377e6ff599599c9d2d5f 100644 (file)
@@ -1,5 +1,5 @@
-/* Elided version of pthread_mutex_lock.
-   Copyright (C) 2015-2021 Free Software Foundation, Inc.
+/* elision-lock.c: Lock elision locking.  Stub version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -15,8 +15,3 @@
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
-
-#include <elision-conf.h>
-#include <force-elision.h>
-
-#include <nptl/pthread_mutex_lock.c>
similarity index 78%
rename from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_trylock.c
rename to nptl/elision-timed.c
index ee9fe1d18628b2d6354685d5ca465599daa38d26..472319736342c7cc3bf48f7626ab367f91d380f6 100644 (file)
@@ -1,5 +1,5 @@
-/* Elided version of pthread_mutex_trylock.
-   Copyright (C) 2015-2021 Free Software Foundation, Inc.
+/* elision-lock.c: Lock elision timed locking.  Stub version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -15,8 +15,3 @@
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
-
-#include <elision-conf.h>
-#include <force-elision.h>
-
-#include <nptl/pthread_mutex_trylock.c>
similarity index 79%
rename from sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c
rename to nptl/elision-trylock.c
index 6e5f1f996419a059024f46e84a825ce255a4a8f4..286a7417fab84386c3e9622ba60d6399b4807e43 100644 (file)
@@ -1,5 +1,5 @@
-/* Elided version of pthread_mutex_lock.
-   Copyright (C) 2011-2021 Free Software Foundation, Inc.
+/* elision-lock.c: Lock elision locking attempts.  Stub version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -15,8 +15,3 @@
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
-
-#include <elision-conf.h>
-#include "force-elision.h"
-
-#include "nptl/pthread_mutex_lock.c"
diff --git a/nptl/elision-unlock.c b/nptl/elision-unlock.c
new file mode 100644 (file)
index 0000000..552a90a
--- /dev/null
@@ -0,0 +1,17 @@
+/* elision-lock.c: Lock elision unlocking support.  Stub version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
index 7976c6d8f50ad9b04995af2f2478b35225184a05..2d077d86941bad64277b7691b6ead1eada8975cb 100644 (file)
@@ -51,3 +51,8 @@ __lll_lock_wait (int *futex, int private)
     }
 }
 libc_hidden_def (__lll_lock_wait)
+
+#if ENABLE_ELISION_SUPPORT
+int __pthread_force_elision __attribute__ ((nocommon));
+libc_hidden_data_def (__pthread_force_elision)
+#endif
index 319658adc4e682ff7f2e5e9466a21b8f0dd1ceb8..f0de7b7fd67785d33224b71b5e582791b9b22b73 100644 (file)
 #include <futex-internal.h>
 #include <stap-probe.h>
 
-#ifndef lll_lock_elision
-#define lll_lock_elision(lock, try_lock, private)      ({ \
-      lll_lock (lock, private); 0; })
-#endif
-
-#ifndef lll_trylock_elision
-#define lll_trylock_elision(a,t) lll_trylock(a)
-#endif
-
 /* Some of the following definitions differ when pthread_mutex_cond_lock.c
    includes this file.  */
 #ifndef LLL_MUTEX_LOCK
                   PTHREAD_MUTEX_PSHARED (mutex))
 #endif
 
-#ifndef FORCE_ELISION
-#define FORCE_ELISION(m, s)
-#endif
-
 static int __pthread_mutex_lock_full (pthread_mutex_t *mutex)
      __attribute_noinline__;
 
@@ -80,7 +67,7 @@ __pthread_mutex_lock (pthread_mutex_t *mutex)
       LLL_MUTEX_LOCK (mutex);
       assert (mutex->__data.__owner == 0);
     }
-#ifdef HAVE_ELISION
+#if ENABLE_ELISION_SUPPORT
   else if (__glibc_likely (type == PTHREAD_MUTEX_TIMED_ELISION_NP))
     {
   elision: __attribute__((unused))
index 8428ebca0f59b604a3653fa42b660d332eb29285..5e52a4d856d0e08383c77a57be56f130e33856b5 100644 (file)
 
 #include <stap-probe.h>
 
-#ifndef lll_clocklock_elision
-#define lll_clocklock_elision(futex, adapt_count, clockid, abstime, private) \
-  __futex_clocklock64 (&(futex), clockid, abstime, private)
-#endif
-
-#ifndef lll_trylock_elision
-#define lll_trylock_elision(a,t) lll_trylock(a)
-#endif
-
-#ifndef FORCE_ELISION
-#define FORCE_ELISION(m, s)
-#endif
-
 int
 __pthread_mutex_clocklock_common (pthread_mutex_t *mutex,
                                  clockid_t clockid,
index 519727580d1ae19b8991f9ce94023b6b938fd3f4..e52dddafbd8af2f8ad33410d94fb2fab35c2eaf6 100644 (file)
 #include <lowlevellock.h>
 #include <futex-internal.h>
 
-#ifndef lll_trylock_elision
-#define lll_trylock_elision(a,t) lll_trylock(a)
-#endif
-
-#ifndef FORCE_ELISION
-#define FORCE_ELISION(m, s)
-#endif
-
 int
 __pthread_mutex_trylock (pthread_mutex_t *mutex)
 {
index e29bb7fa533264068f5dc280d2f1bf0257f88cce..3b5ccdacf910093440832b1dff812c5daedc0b12 100644 (file)
 #include <stap-probe.h>
 #include <futex-internal.h>
 
-#ifndef lll_unlock_elision
-#define lll_unlock_elision(a,b,c) ({ lll_unlock (a,c); 0; })
-#endif
-
 static int
 __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
      __attribute_noinline__;
index 176ba96251066bc149dc477ec8ba4b4530be31f3..be60c9ac28b103a573458b64d4dbaed5442564d3 100644 (file)
@@ -20,6 +20,7 @@
 #define _LOWLEVELLOCK_H        1
 
 #include <atomic.h>
+#include <elision-conf.h>
 #include <lowlevellock-futex.h>
 #include <time.h>
 
@@ -160,4 +161,105 @@ libc_hidden_proto (__lll_lock_wait)
 #define LLL_LOCK_INITIALIZER           (0)
 #define LLL_LOCK_INITIALIZER_LOCKED    (1)
 
+/* Elision support.  */
+
+#if ENABLE_ELISION_SUPPORT
+/* Force elision for all new locks.  This is used to decide whether
+   existing DEFAULT locks should be automatically upgraded to elision
+   in pthread_mutex_lock.  Disabled for suid programs.  Only used when
+   elision is available.  */
+extern int __pthread_force_elision;
+libc_hidden_proto (__pthread_force_elision)
+
+extern void __lll_elision_init (void) attribute_hidden;
+extern int __lll_clocklock_elision (int *futex, short *adapt_count,
+                                    clockid_t clockid,
+                                   const struct __timespec64 *timeout,
+                                   int private);
+libc_hidden_proto (__lll_clocklock_elision)
+
+extern int __lll_lock_elision (int *futex, short *adapt_count, int private);
+libc_hidden_proto (__lll_lock_elision)
+
+# if ELISION_UNLOCK_NEEDS_ADAPT_COUNT
+extern int __lll_unlock_elision (int *lock, short *adapt_count, int private);
+# else
+extern int __lll_unlock_elision (int *lock, int private);
+# endif
+libc_hidden_proto (__lll_unlock_elision)
+
+extern int __lll_trylock_elision (int *lock, short *adapt_count);
+libc_hidden_proto (__lll_trylock_elision)
+
+# define lll_clocklock_elision(futex, adapt_count, clockid, timeout, private) \
+  __lll_clocklock_elision (&(futex), &(adapt_count), clockid, timeout, private)
+# define lll_lock_elision(futex, adapt_count, private)         \
+  __lll_lock_elision (&(futex), &(adapt_count), private)
+# define lll_trylock_elision(futex, adapt_count)       \
+  __lll_trylock_elision (&(futex), &(adapt_count))
+# if ELISION_UNLOCK_NEEDS_ADAPT_COUNT
+#  define lll_unlock_elision(futex, adapt_count, private)      \
+  __lll_unlock_elision (&(futex), &(adapt_count), private)
+# else
+#  define lll_unlock_elision(futex, adapt_count, private)      \
+  __lll_unlock_elision (&(futex), private)
+# endif
+
+/* Automatically enable elision for existing user lock kinds.  */
+# define FORCE_ELISION(m, s)                                            \
+  if (__pthread_force_elision)                                          \
+    {                                                                   \
+      /* See concurrency notes regarding __kind in                      \
+         struct __pthread_mutex_s in                                    \
+         sysdeps/nptl/bits/thread-shared-types.h.                       \
+                                                                        \
+         There are the following cases for the kind of a mutex          \
+         (The mask PTHREAD_MUTEX_ELISION_FLAGS_NP covers the flags      \
+         PTHREAD_MUTEX_ELISION_NP and PTHREAD_MUTEX_NO_ELISION_NP where \
+         only one of both flags can be set):                            \
+         - both flags are not set:                                      \
+         This is the first lock operation for this mutex.  Enable       \
+         elision as it is not enabled so far.                           \
+         Note: It can happen that multiple threads are calling e.g.     \
+         pthread_mutex_lock at the same time as the first lock          \
+         operation for this mutex.  Then elision is enabled for this    \
+         mutex by multiple threads.  Storing with relaxed MO is enough  \
+         as all threads will store the same new value for the kind of   \
+         the mutex.  But we have to ensure that we always use the       \
+         elision path regardless if this thread has enabled elision or  \
+         another one.                                                   \
+                                                                        \
+         - PTHREAD_MUTEX_ELISION_NP flag is set:                        \
+         Elision was already enabled for this mutex by a previous lock  \
+         operation.  See case above.  Just use the elision path.        \
+                                                                        \
+         - PTHREAD_MUTEX_NO_ELISION_NP flag is set:                     \
+         Elision was explicitly disabled by pthread_mutexattr_settype.  \
+         Do not use the elision path.                                   \
+         Note: The flag PTHREAD_MUTEX_NO_ELISION_NP will never be       \
+         changed after mutex initialization.  */                        \
+      int mutex_kind = atomic_load_relaxed (&((m)->__data.__kind));     \
+      if ((mutex_kind & PTHREAD_MUTEX_ELISION_FLAGS_NP) == 0)           \
+        {                                                               \
+          mutex_kind |= PTHREAD_MUTEX_ELISION_NP;                       \
+          atomic_store_relaxed (&((m)->__data.__kind), mutex_kind);     \
+        }                                                               \
+      if ((mutex_kind & PTHREAD_MUTEX_ELISION_NP) != 0)                 \
+        {                                                               \
+          s;                                                            \
+        }                                                               \
+    }
+
+#else /* !ENABLE_ELISION_SUPPORT */
+
+# define lll_clocklock_elision(futex, adapt_count, clockid, abstime, private) \
+  __futex_clocklock64 (&(futex), clockid, abstime, private)
+# define lll_lock_elision(lock, try_lock, private)     \
+  ({ lll_lock (lock, private); 0; })
+# define lll_trylock_elision(a,t) lll_trylock(a)
+# define lll_unlock_elision(a,b,c) ({ lll_unlock (a,c); 0; })
+# define FORCE_ELISION(m, s)
+
+#endif /* !ENABLE_ELISION_SUPPORT */
+
 #endif /* lowlevellock.h */
similarity index 63%
rename from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_timedlock.c
rename to sysdeps/pthread/elision-conf.h
index 6f8b06d459f43289fe370ae39b1d131c2d324873..946f2c43b11a4f18980564795c8adb3b11ecffb9 100644 (file)
@@ -1,5 +1,5 @@
-/* Elided version of pthread_mutex_timedlock.
-   Copyright (C) 2015-2021 Free Software Foundation, Inc.
+/* elision-conf.h: Lock elision  configuration.  Stub version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <elision-conf.h>
-#include <force-elision.h>
+#ifndef _ELISION_CONF_H
+#define _ELISION_CONF_H 1
 
-#include <nptl/pthread_mutex_timedlock.c>
+/* No elision support by default.  */
+#define ENABLE_ELISION_SUPPORT 0
+
+/* Whether __lll_unlock_elision expects a pointer argument to the
+   adaptive counter.  Here, an unused arbitrary value.  */
+#define ELISION_UNLOCK_NEEDS_ADAPT_COUNT 0
+
+#endif
index cc2f804d86b37f97c7e2a7de1e93a08cff57cd4b..a093cda68b1dbaa3e13b46ff6edf6fd8a6f2dd64 100644 (file)
@@ -32,7 +32,5 @@ endif
 
 ifeq ($(subdir),nptl)
 libpthread-routines += sysdep
-libpthread-sysdep_routines += elision-lock elision-unlock elision-timed \
-                             elision-trylock
 libpthread-shared-only-routines += sysdep
 endif
index 003bc82343723c2414d60e93abae1f5f7e6384cf..1ecc2a7b8fac6122ea1641aef7842d7cb312ef57 100644 (file)
@@ -51,12 +51,6 @@ struct elision_config __elision_aconf =
     .skip_trylock_internal_abort = 3,
   };
 
-/* Force elision for all new locks.  This is used to decide whether existing
-   DEFAULT locks should be automatically use elision in pthread_mutex_lock().
-   Disabled for suid programs.  Only used when elision is available.  */
-
-int __pthread_force_elision attribute_hidden = 0;
-
 #if HAVE_TUNABLES
 static inline void
 __always_inline
@@ -104,10 +98,8 @@ TUNABLE_CALLBACK_FNDECL (skip_trylock_internal_abort, int32_t);
 
 /* Initialize elision.  */
 
-static void
-elision_init (int argc __attribute__ ((unused)),
-             char **argv  __attribute__ ((unused)),
-             char **environ)
+void
+__lll_elision_init (void)
 {
 #if HAVE_TUNABLES
   /* Elision depends on tunables and must be explicitly turned on by setting
@@ -150,17 +142,3 @@ elision_init (int argc __attribute__ ((unused)),
   if (!__pthread_force_elision)
     __elision_aconf.try_tbegin = 0; /* Disable elision on rwlocks.  */
 }
-
-#ifdef SHARED
-# define INIT_SECTION ".init_array"
-# define MAYBE_CONST
-#else
-# define INIT_SECTION ".preinit_array"
-# define MAYBE_CONST const
-#endif
-
-void (*MAYBE_CONST __pthread_init_array []) (int, char **, char **)
-  __attribute__ ((section (INIT_SECTION), aligned (sizeof (void *)))) =
-{
-  &elision_init
-};
index 8c444d8695e58ccfd1573f972738d6497ffe6f6e..86c677fb7aee51dfaa578ba8124500a89b1fff49 100644 (file)
@@ -22,6 +22,9 @@
 #include <pthread.h>
 #include <time.h>
 
+#define ENABLE_ELISION_SUPPORT 1
+#define ELISION_UNLOCK_NEEDS_ADAPT_COUNT 1
+
 /* Should make sure there is no false sharing on this.  */
 struct elision_config
 {
@@ -34,9 +37,4 @@ struct elision_config
 
 extern struct elision_config __elision_aconf attribute_hidden;
 
-extern int __pthread_force_elision attribute_hidden;
-
-/* Tell the test suite to test elision for this architecture.  */
-#define HAVE_ELISION 1
-
 #endif
index 767d439f884ccfced57cd2742ea78c4b7f5fb01e..f5fb46df2523ad0f633157793e59f0a7eaa5b577 100644 (file)
 #include <elision-conf.h>
 #include "htm.h"
 
-#if !defined(LLL_LOCK) && !defined(EXTRAARG)
-/* Make sure the configuration code is always linked in for static
-   libraries.  */
-#include "elision-conf.c"
-#endif
-
 #ifndef EXTRAARG
 # define EXTRAARG
 #endif
@@ -84,3 +78,4 @@ __lll_lock_elision (int *lock, short *adapt_count, EXTRAARG int pshared)
 use_lock:
   return LLL_LOCK ((*lock), pshared);
 }
+libc_hidden_def (__lll_lock_elision)
index ab92f4d72fcfce3b28f2888c9244caaa261d34c8..5ebbced4271c14c3dfea9ee65a04fc261d2dd0c7 100644 (file)
@@ -67,3 +67,4 @@ __lll_trylock_elision (int *futex, short *adapt_count)
 use_lock:
   return lll_trylock (*futex);
 }
+libc_hidden_def (__lll_trylock_elision)
index 35044af40bb7190d828d2f7d0490616664a42fc1..5aa87521c55fa977fc9593c00dcd1e76d5b0b3a5 100644 (file)
@@ -41,3 +41,4 @@ __lll_unlock_elision (int *lock, short *adapt_count, int pshared)
     }
   return 0;
 }
+libc_hidden_def (__lll_unlock_elision)
diff --git a/sysdeps/unix/sysv/linux/powerpc/force-elision.h b/sysdeps/unix/sysv/linux/powerpc/force-elision.h
deleted file mode 100644 (file)
index d1fa611..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* force-elision.h: Automatic enabling of elision for mutexes
-   Copyright (C) 2015-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-/* Automatically enable elision for existing user lock kinds.  */
-#define FORCE_ELISION(m, s)                                            \
-  if (__pthread_force_elision)                                         \
-    {                                                                  \
-      /* See concurrency notes regarding __kind in                     \
-        struct __pthread_mutex_s in                                    \
-        sysdeps/nptl/bits/thread-shared-types.h.                       \
-                                                                       \
-        There are the following cases for the kind of a mutex          \
-        (The mask PTHREAD_MUTEX_ELISION_FLAGS_NP covers the flags      \
-        PTHREAD_MUTEX_ELISION_NP and PTHREAD_MUTEX_NO_ELISION_NP where \
-        only one of both flags can be set):                            \
-        - both flags are not set:                                      \
-        This is the first lock operation for this mutex.  Enable       \
-        elision as it is not enabled so far.                           \
-        Note: It can happen that multiple threads are calling e.g.     \
-        pthread_mutex_lock at the same time as the first lock          \
-        operation for this mutex.  Then elision is enabled for this    \
-        mutex by multiple threads.  Storing with relaxed MO is enough  \
-        as all threads will store the same new value for the kind of   \
-        the mutex.  But we have to ensure that we always use the       \
-        elision path regardless if this thread has enabled elision or  \
-        another one.                                                   \
-                                                                       \
-        - PTHREAD_MUTEX_ELISION_NP flag is set:                        \
-        Elision was already enabled for this mutex by a previous lock  \
-        operation.  See case above.  Just use the elision path.        \
-                                                                       \
-        - PTHREAD_MUTEX_NO_ELISION_NP flag is set:                     \
-        Elision was explicitly disabled by pthread_mutexattr_settype.  \
-        Do not use the elision path.                                   \
-        Note: The flag PTHREAD_MUTEX_NO_ELISION_NP will never be       \
-        changed after mutex initialization.  */                        \
-      int mutex_kind = atomic_load_relaxed (&((m)->__data.__kind));    \
-      if ((mutex_kind & PTHREAD_MUTEX_ELISION_FLAGS_NP) == 0)          \
-       {                                                               \
-         mutex_kind |= PTHREAD_MUTEX_ELISION_NP;                       \
-         atomic_store_relaxed (&((m)->__data.__kind), mutex_kind);     \
-       }                                                               \
-      if ((mutex_kind & PTHREAD_MUTEX_ELISION_NP) != 0)                        \
-       {                                                               \
-         s;                                                            \
-       }                                                               \
-    }
diff --git a/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
deleted file mode 100644 (file)
index 6596202..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* PowerPC specific lock definitions.
-   Copyright (C) 2015-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef _POWERPC_LOWLEVELLOCK_H
-#define _POWERPC_LOWLEVELLOCK_H 1
-
-#include <sysdeps/nptl/lowlevellock.h>
-
-/* Transactional lock elision definitions.  */
-extern int __lll_clocklock_elision
-  (int *futex, short *adapt_count,
-   clockid_t clockid, const struct __timespec64 *timeout, int private)
-  attribute_hidden;
-
-#define lll_clocklock_elision(futex, adapt_count, clockid, timeout, private) \
-  __lll_clocklock_elision (&(futex), &(adapt_count), clockid, timeout, private)
-
-extern int __lll_lock_elision (int *futex, short *adapt_count, int private)
-  attribute_hidden;
-
-extern int __lll_unlock_elision (int *lock, short *adapt_count, int private)
-  attribute_hidden;
-
-extern int __lll_trylock_elision(int *lock, short *adapt_count)
-  attribute_hidden;
-
-#define lll_lock_elision(futex, adapt_count, private) \
-  __lll_lock_elision (&(futex), &(adapt_count), private)
-#define lll_unlock_elision(futex, adapt_count, private) \
-  __lll_unlock_elision (&(futex), &(adapt_count), private)
-#define lll_trylock_elision(futex, adapt_count) \
-  __lll_trylock_elision (&(futex), &(adapt_count))
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_cond_lock.c b/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_cond_lock.c
deleted file mode 100644 (file)
index f33bac7..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (C) 2015-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-/* The cond lock is not actually elided yet, but we still need to handle
-   already elided locks.  */
-#include <elision-conf.h>
-
-#include <nptl/pthread_mutex_cond_lock.c>
index d9db1b54227be7fd8e6daac669220a97ab3bcf5a..3de9579e236600e2ef81a43ea0b4fe34845bb8aa 100644 (file)
@@ -12,9 +12,6 @@ gen-as-const-headers += ucontext_i.sym
 endif
 
 ifeq ($(subdir),nptl)
-libpthread-sysdep_routines += elision-lock elision-unlock elision-timed \
-                             elision-trylock
-
 elision-CFLAGS = -mhtm -msoft-float
 CFLAGS-elision-lock.c = $(elision-CFLAGS)
 CFLAGS-elision-timed.c = $(elision-CFLAGS)
index c05c046e567e51a4312cbd706a511a0bc15325a4..a7a90e73ebb15b1d02d4ae9fc05e46b1ed4b5bd4 100644 (file)
@@ -51,13 +51,6 @@ struct elision_config __elision_aconf =
     .skip_trylock_internal_abort = 3,
   };
 
-/* Force elision for all new locks.  This is used to decide whether existing
-   DEFAULT locks should be automatically upgraded to elision in
-   pthread_mutex_lock().  Disabled for suid programs.  Only used when elision
-   is available.  */
-
-int __pthread_force_elision attribute_hidden = 0;
-
 #if HAVE_TUNABLES
 static inline void
 __always_inline
@@ -104,10 +97,8 @@ TUNABLE_CALLBACK_FNDECL (skip_trylock_internal_abort, int32_t);
 
 /* Initialize elison.  */
 
-static void
-elision_init (int argc __attribute__ ((unused)),
-             char **argv  __attribute__ ((unused)),
-             char **environ)
+void
+__lll_elision_init (void)
 {
 #if HAVE_TUNABLES
   /* Elision depends on tunables and must be explicitly turned on by setting
@@ -130,17 +121,3 @@ elision_init (int argc __attribute__ ((unused)),
   if (!__pthread_force_elision)
     __elision_aconf.try_tbegin = 0; /* Disable elision on rwlocks.  */
 }
-
-#ifdef SHARED
-# define INIT_SECTION ".init_array"
-# define MAYBE_CONST
-#else
-# define INIT_SECTION ".preinit_array"
-# define MAYBE_CONST const
-#endif
-
-void (*MAYBE_CONST __pthread_init_array []) (int, char **, char **)
-  __attribute__ ((section (INIT_SECTION), aligned (sizeof (void *)))) =
-{
-  &elision_init
-};
index 846c5ff297e092c82bb96e72d7dc448560e9a93b..cb8a784ad07235141de69454c2df19851206c95e 100644 (file)
@@ -21,6 +21,9 @@
 #include <pthread.h>
 #include <time.h>
 
+#define ENABLE_ELISION_SUPPORT 1
+#define ELISION_UNLOCK_NEEDS_ADAPT_COUNT 1
+
 /* Should make sure there is no false sharing on this.  */
 
 struct elision_config
@@ -34,9 +37,4 @@ struct elision_config
 
 extern struct elision_config __elision_aconf attribute_hidden;
 
-extern int __pthread_force_elision attribute_hidden;
-
-/* Tell the test suite to test elision for this architecture.  */
-#define HAVE_ELISION 1
-
 #endif
index 26474c6398106712b35ed00a032e7e34e15c6526..d5dd6023a049868a66f9d89180467ee18d6662ae 100644 (file)
 #include <elision-conf.h>
 #include <stdint.h>
 
-#if !defined(LLL_LOCK) && !defined(EXTRAARG)
-/* Make sure the configuration code is always linked in for static
-   libraries.  */
-#include "elision-conf.c"
-#endif
-
 #ifndef EXTRAARG
 #define EXTRAARG
 #endif
@@ -123,3 +117,4 @@ __lll_lock_elision (int *futex, short *adapt_count, EXTRAARG int private)
      succeed.  */
   return LLL_LOCK ((*futex), private);
 }
+libc_hidden_def (__lll_lock_elision)
index 484c3cc913002ba9de84c8accd8e3147d337f67e..2470955c891846d0536e42f1c09caa20db8765f0 100644 (file)
@@ -95,3 +95,4 @@ __lll_trylock_elision (int *futex, short *adapt_count)
      succeed.  */
   return lll_trylock (*futex);
 }
+libc_hidden_def (__lll_trylock_elision)
index 5ac6758df2f9b6baae626afdecb8077d9bbfa9bf..87a5bd7cbf34b9ba3e005a80e039b180fe44998a 100644 (file)
@@ -59,3 +59,4 @@ __lll_unlock_elision(int *futex, short *adapt_count, int private)
     }
   return 0;
 }
+libc_hidden_def (__lll_unlock_elision)
diff --git a/sysdeps/unix/sysv/linux/s390/force-elision.h b/sysdeps/unix/sysv/linux/s390/force-elision.h
deleted file mode 100644 (file)
index 154740d..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Automatic enabling of elision for mutexes
-   Copyright (C) 2014-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-/* Automatically enable elision for existing user lock kinds.  */
-#define FORCE_ELISION(m, s)                                            \
-  if (__pthread_force_elision)                                         \
-    {                                                                  \
-      /* See concurrency notes regarding __kind in                     \
-        struct __pthread_mutex_s in                                    \
-        sysdeps/nptl/bits/thread-shared-types.h.                       \
-                                                                       \
-        There are the following cases for the kind of a mutex          \
-        (The mask PTHREAD_MUTEX_ELISION_FLAGS_NP covers the flags      \
-        PTHREAD_MUTEX_ELISION_NP and PTHREAD_MUTEX_NO_ELISION_NP where \
-        only one of both flags can be set):                            \
-        - both flags are not set:                                      \
-        This is the first lock operation for this mutex.  Enable       \
-        elision as it is not enabled so far.                           \
-        Note: It can happen that multiple threads are calling e.g.     \
-        pthread_mutex_lock at the same time as the first lock          \
-        operation for this mutex.  Then elision is enabled for this    \
-        mutex by multiple threads.  Storing with relaxed MO is enough  \
-        as all threads will store the same new value for the kind of   \
-        the mutex.  But we have to ensure that we always use the       \
-        elision path regardless if this thread has enabled elision or  \
-        another one.                                                   \
-                                                                       \
-        - PTHREAD_MUTEX_ELISION_NP flag is set:                        \
-        Elision was already enabled for this mutex by a previous lock  \
-        operation.  See case above.  Just use the elision path.        \
-                                                                       \
-        - PTHREAD_MUTEX_NO_ELISION_NP flag is set:                     \
-        Elision was explicitly disabled by pthread_mutexattr_settype.  \
-        Do not use the elision path.                                   \
-        Note: The flag PTHREAD_MUTEX_NO_ELISION_NP will never be       \
-        changed after mutex initialization.  */                        \
-      int mutex_kind = atomic_load_relaxed (&((m)->__data.__kind));    \
-      if ((mutex_kind & PTHREAD_MUTEX_ELISION_FLAGS_NP) == 0)          \
-       {                                                               \
-         mutex_kind |= PTHREAD_MUTEX_ELISION_NP;                       \
-         atomic_store_relaxed (&((m)->__data.__kind), mutex_kind);     \
-       }                                                               \
-      if ((mutex_kind & PTHREAD_MUTEX_ELISION_NP) != 0)                        \
-       {                                                               \
-         s;                                                            \
-       }                                                               \
-    }
diff --git a/sysdeps/unix/sysv/linux/s390/lowlevellock.h b/sysdeps/unix/sysv/linux/s390/lowlevellock.h
deleted file mode 100644 (file)
index 98d78f5..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright (C) 2003-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef _S390_LOWLEVELLOCK_H
-#define _S390_LOWLEVELLOCK_H   1
-
-#include <sysdeps/nptl/lowlevellock.h>
-
-/* Transactional lock elision definitions.  */
-extern int __lll_clocklock_elision
-  (int *futex, short *adapt_count,
-   clockid_t clockid, const struct __timespec64 *timeout, int private)
-  attribute_hidden;
-
-#  define lll_clocklock_elision(futex, adapt_count, clockid, timeout, private) \
-  __lll_clocklock_elision (&(futex), &(adapt_count), clockid, timeout, private)
-
-extern int __lll_lock_elision (int *futex, short *adapt_count, int private)
-  attribute_hidden;
-
-extern int __lll_unlock_elision(int *futex, short *adapt_count, int private)
-  attribute_hidden;
-
-extern int __lll_trylock_elision(int *futex, short *adapt_count)
-  attribute_hidden;
-
-#  define lll_lock_elision(futex, adapt_count, private) \
-  __lll_lock_elision (&(futex), &(adapt_count), private)
-#  define lll_unlock_elision(futex, adapt_count, private) \
-  __lll_unlock_elision (&(futex), &(adapt_count), private)
-#  define lll_trylock_elision(futex, adapt_count) \
-  __lll_trylock_elision(&(futex), &(adapt_count))
-
-#endif /* lowlevellock.h */
diff --git a/sysdeps/unix/sysv/linux/s390/pthread_mutex_cond_lock.c b/sysdeps/unix/sysv/linux/s390/pthread_mutex_cond_lock.c
deleted file mode 100644 (file)
index 8398ff6..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (C) 2014-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-/* The cond lock is not actually elided yet, but we still need to handle
-   already elided locks.  */
-#include <elision-conf.h>
-
-#include <nptl/pthread_mutex_cond_lock.c>
diff --git a/sysdeps/unix/sysv/linux/s390/pthread_mutex_timedlock.c b/sysdeps/unix/sysv/linux/s390/pthread_mutex_timedlock.c
deleted file mode 100644 (file)
index 8538f15..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Elided version of pthread_mutex_timedlock.
-   Copyright (C) 2014-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <elision-conf.h>
-#include <force-elision.h>
-
-#include <nptl/pthread_mutex_timedlock.c>
diff --git a/sysdeps/unix/sysv/linux/s390/pthread_mutex_trylock.c b/sysdeps/unix/sysv/linux/s390/pthread_mutex_trylock.c
deleted file mode 100644 (file)
index c4de136..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Elided version of pthread_mutex_trylock.
-   Copyright (C) 2014-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <elision-conf.h>
-#include <force-elision.h>
-
-#include <nptl/pthread_mutex_trylock.c>
index 6bfd6bec4925f17020d9c74fd5bc613caa9eaa98..9dfdd689a909c7209fc5f018f0acb02cf2c673c9 100644 (file)
@@ -12,8 +12,6 @@ sysdep_headers += sys/elf.h sys/perm.h sys/reg.h sys/vm86.h sys/debugreg.h sys/i
 endif
 
 ifeq ($(subdir),nptl)
-libpthread-sysdep_routines += elision-lock elision-unlock elision-timed \
-                             elision-trylock
 CFLAGS-elision-lock.c += -mrtm
 CFLAGS-elision-unlock.c += -mrtm
 CFLAGS-elision-timed.c += -mrtm
index e8ffe022f02ceb342a9890604aca1a008fd7d6fd..a5a4043d1508889a3b72f255b90e348952d6047c 100644 (file)
@@ -48,13 +48,6 @@ struct elision_config __elision_aconf =
     .skip_trylock_internal_abort = 3,
   };
 
-/* Force elision for all new locks.  This is used to decide whether existing
-   DEFAULT locks should be automatically upgraded to elision in
-   pthread_mutex_lock().  Disabled for suid programs.  Only used when elision
-   is available.  */
-
-int __pthread_force_elision attribute_hidden = 0;
-
 #if HAVE_TUNABLES
 static __always_inline void
 do_set_elision_enable (int32_t elision_enable)
@@ -98,10 +91,8 @@ TUNABLE_CALLBACK_FNDECL (skip_trylock_internal_abort, int32_t);
 
 /* Initialize elision.  */
 
-static void
-elision_init (int argc __attribute__ ((unused)),
-             char **argv  __attribute__ ((unused)),
-             char **environ)
+void
+__lll_elision_init (void)
 {
 #if HAVE_TUNABLES
   /* Elision depends on tunables and must be explicitly turned on by setting
@@ -122,15 +113,3 @@ elision_init (int argc __attribute__ ((unused)),
   if (!__pthread_force_elision)
     __elision_aconf.retry_try_xbegin = 0; /* Disable elision on rwlocks.  */
 }
-
-#ifdef SHARED
-# define INIT_SECTION ".init_array"
-#else
-# define INIT_SECTION ".preinit_array"
-#endif
-
-void (*const __pthread_init_array []) (int, char **, char **)
-  __attribute__ ((section (INIT_SECTION), aligned (sizeof (void *)))) =
-{
-  &elision_init
-};
index bc5e73bd10602e5ffd859a18995c0b263c36c2a9..6016820312e0c65c89d97f8bce818656db5715fd 100644 (file)
@@ -21,6 +21,9 @@
 #include <pthread.h>
 #include <time.h>
 
+#define ENABLE_ELISION_SUPPORT 1
+#define ELISION_UNLOCK_NEEDS_ADAPT_COUNT 0
+
 /* Should make sure there is no false sharing on this.  */
 
 struct elision_config
@@ -33,9 +36,4 @@ struct elision_config
 
 extern struct elision_config __elision_aconf attribute_hidden;
 
-extern int __pthread_force_elision attribute_hidden;
-
-/* Tell the test suite to test elision for this architecture.  */
-#define HAVE_ELISION 1
-
 #endif
index 16d4f6e4f1211d2f3b1cdd414e6893ec61f2dca8..ea5f373c6786be2892adb347623336f88d1104fe 100644 (file)
 #include "hle.h"
 #include <elision-conf.h>
 
-#if !defined(LLL_LOCK) && !defined(EXTRAARG)
-/* Make sure the configuration code is always linked in for static
-   libraries.  */
-#include "elision-conf.c"
-#endif
-
 #ifndef EXTRAARG
 #define EXTRAARG
 #endif
@@ -105,3 +99,4 @@ __lll_lock_elision (int *futex, short *adapt_count, EXTRAARG int private)
   /* Use a normal lock here.  */
   return LLL_LOCK ((*futex), private);
 }
+libc_hidden_def (__lll_lock_elision)
index ef9aa238198d67f87ee00559b0106d3bfc6a0749..5e689f577f4a483b5ef9ef3761bb49fc3b54a0af 100644 (file)
@@ -73,3 +73,4 @@ __lll_trylock_elision (int *futex, short *adapt_count)
 
   return lll_trylock (*futex);
 }
+libc_hidden_def (__lll_trylock_elision)
index edd8b1fd08ec03ed698fc8f7bd42afa8cbb8d9b5..eb877bc18c4228be20f3a26f26274a220c72f711 100644 (file)
@@ -31,3 +31,4 @@ __lll_unlock_elision(int *lock, int private)
     lll_unlock ((*lock), private);
   return 0;
 }
+libc_hidden_def (__lll_unlock_elision)
diff --git a/sysdeps/unix/sysv/linux/x86/force-elision.h b/sysdeps/unix/sysv/linux/x86/force-elision.h
deleted file mode 100644 (file)
index 3c0a0e0..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* force-elision.h: Automatic enabling of elision for mutexes
-   Copyright (C) 2013-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-/* Automatically enable elision for existing user lock kinds.  */
-#define FORCE_ELISION(m, s)                                            \
-  if (__pthread_force_elision)                                         \
-    {                                                                  \
-      /* See concurrency notes regarding __kind in                     \
-        struct __pthread_mutex_s in                                    \
-        sysdeps/nptl/bits/thread-shared-types.h.                       \
-                                                                       \
-        There are the following cases for the kind of a mutex          \
-        (The mask PTHREAD_MUTEX_ELISION_FLAGS_NP covers the flags      \
-        PTHREAD_MUTEX_ELISION_NP and PTHREAD_MUTEX_NO_ELISION_NP where \
-        only one of both flags can be set):                            \
-        - both flags are not set:                                      \
-        This is the first lock operation for this mutex.  Enable       \
-        elision as it is not enabled so far.                           \
-        Note: It can happen that multiple threads are calling e.g.     \
-        pthread_mutex_lock at the same time as the first lock          \
-        operation for this mutex.  Then elision is enabled for this    \
-        mutex by multiple threads.  Storing with relaxed MO is enough  \
-        as all threads will store the same new value for the kind of   \
-        the mutex.  But we have to ensure that we always use the       \
-        elision path regardless if this thread has enabled elision or  \
-        another one.                                                   \
-                                                                       \
-        - PTHREAD_MUTEX_ELISION_NP flag is set:                        \
-        Elision was already enabled for this mutex by a previous lock  \
-        operation.  See case above.  Just use the elision path.        \
-                                                                       \
-        - PTHREAD_MUTEX_NO_ELISION_NP flag is set:                     \
-        Elision was explicitly disabled by pthread_mutexattr_settype.  \
-        Do not use the elision path.                                   \
-        Note: The flag PTHREAD_MUTEX_NO_ELISION_NP will never be       \
-        changed after mutex initialization.  */                        \
-      int mutex_kind = atomic_load_relaxed (&((m)->__data.__kind));    \
-      if ((mutex_kind & PTHREAD_MUTEX_ELISION_FLAGS_NP) == 0)          \
-       {                                                               \
-         mutex_kind |= PTHREAD_MUTEX_ELISION_NP;                       \
-         atomic_store_relaxed (&((m)->__data.__kind), mutex_kind);     \
-       }                                                               \
-      if ((mutex_kind & PTHREAD_MUTEX_ELISION_NP) != 0)                        \
-       {                                                               \
-         s;                                                            \
-       }                                                               \
-    }
index 435a190ec9e4c9ab6e4fab249548625ece76a244..7205bcadfdfef1ea57b83c7f5e231265092b1d3c 100644 (file)
@@ -82,30 +82,6 @@ __lll_cas_lock (int *futex)
        __lll_unlock (&(lock), private);                                             \
    }))
 
-extern int __lll_clocklock_elision (int *futex, short *adapt_count,
-                                    clockid_t clockid,
-                                   const struct __timespec64 *timeout,
-                                   int private) attribute_hidden;
-
-#define lll_clocklock_elision(futex, adapt_count, clockid, timeout, private) \
-  __lll_clocklock_elision (&(futex), &(adapt_count), clockid, timeout, private)
-
-extern int __lll_lock_elision (int *futex, short *adapt_count, int private)
-  attribute_hidden;
-
-extern int __lll_unlock_elision (int *lock, int private)
-  attribute_hidden;
-
-extern int __lll_trylock_elision (int *lock, short *adapt_count)
-  attribute_hidden;
-
-#define lll_lock_elision(futex, adapt_count, private) \
-  __lll_lock_elision (&(futex), &(adapt_count), private)
-#define lll_unlock_elision(futex, adapt_count, private) \
-  __lll_unlock_elision (&(futex), private)
-#define lll_trylock_elision(futex, adapt_count) \
-  __lll_trylock_elision (&(futex), &(adapt_count))
-
 #endif  /* !__ASSEMBLER__ */
 
 #endif /* lowlevellock.h */
diff --git a/sysdeps/unix/sysv/linux/x86/pthread_mutex_cond_lock.c b/sysdeps/unix/sysv/linux/x86/pthread_mutex_cond_lock.c
deleted file mode 100644 (file)
index 7604f87..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (C) 2013-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-/* The cond lock is not actually elided yet, but we still need to handle
-   already elided locks.  */
-#include <elision-conf.h>
-
-#include <nptl/pthread_mutex_cond_lock.c>
diff --git a/sysdeps/unix/sysv/linux/x86/pthread_mutex_timedlock.c b/sysdeps/unix/sysv/linux/x86/pthread_mutex_timedlock.c
deleted file mode 100644 (file)
index 3fbfe02..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Elided version of pthread_mutex_timedlock.
-   Copyright (C) 2011-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <elision-conf.h>
-#include "force-elision.h"
-
-#include "nptl/pthread_mutex_timedlock.c"
diff --git a/sysdeps/unix/sysv/linux/x86/pthread_mutex_trylock.c b/sysdeps/unix/sysv/linux/x86/pthread_mutex_trylock.c
deleted file mode 100644 (file)
index c7abb5a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Elided version of pthread_mutex_trylock.
-   Copyright (C) 2011-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <elision-conf.h>
-#include "force-elision.h"
-
-#include "nptl/pthread_mutex_trylock.c"