public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/6] More libpthread removal preparations
@ 2021-02-17 17:21 Florian Weimer
  2021-02-17 17:21 ` [PATCH 1/6] nptl: Split libpthread-routines into one routine per line Florian Weimer
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Florian Weimer @ 2021-02-17 17:21 UTC (permalink / raw)
  To: libc-alpha

These commits clean up some things and move low-level libpthread
infrastructure into libc.

The final patch consolidates the elision infrastructure, except the
actual elision implementation routines.  It looks like a reasonable
cleanup to me.

Thanks,
Florian

Florian Weimer (6):
  nptl: Split libpthread-routines into one routine per line
  nptl: Reformat Versions
  nptl: Move futex-internal.c into main nptl directory
  nptl: Move lowlevellock into libc
  nptl: Move futex-internal into libc
  nptl: Move elision implementations into libc

 elf/libc_early_init.c                         |   6 +
 nptl/Makefile                                 | 247 +++++----
 nptl/Versions                                 | 474 +++++++++++-------
 .../elision-conf.c                            |   9 +-
 .../elision-lock.c                            |   9 +-
 .../elision-timed.c                           |   9 +-
 .../elision-trylock.c                         |   9 +-
 nptl/elision-unlock.c                         |  17 +
 {sysdeps/nptl => nptl}/futex-internal.c       |   4 +-
 nptl/libc-lowlevellock.c                      |  20 -
 nptl/lowlevellock.c                           |   9 +-
 nptl/pthread_mutex_lock.c                     |  13 -
 nptl/pthread_mutex_timedlock.c                |  13 -
 nptl/pthread_mutex_trylock.c                  |   8 -
 nptl/pthread_mutex_unlock.c                   |   4 -
 sysdeps/nptl/Makefile                         |   3 +-
 sysdeps/nptl/futex-internal.h                 |   4 +-
 sysdeps/nptl/lowlevellock.h                   | 108 +++-
 .../elision-conf.h}                           |  17 +-
 sysdeps/riscv/nptl/libc-lowlevellock.c        |   8 -
 sysdeps/unix/sysv/linux/powerpc/Makefile      |   2 -
 .../unix/sysv/linux/powerpc/elision-conf.c    |  26 +-
 .../unix/sysv/linux/powerpc/elision-conf.h    |   8 +-
 .../unix/sysv/linux/powerpc/elision-lock.c    |   7 +-
 .../unix/sysv/linux/powerpc/elision-trylock.c |   1 +
 .../unix/sysv/linux/powerpc/elision-unlock.c  |   1 +
 .../unix/sysv/linux/powerpc/force-elision.h   |  62 ---
 .../unix/sysv/linux/powerpc/lowlevellock.h    |  49 --
 .../linux/powerpc/pthread_mutex_cond_lock.c   |  22 -
 .../linux/powerpc/pthread_mutex_timedlock.c   |  22 -
 sysdeps/unix/sysv/linux/s390/Makefile         |   3 -
 sysdeps/unix/sysv/linux/s390/elision-conf.c   |  27 +-
 sysdeps/unix/sysv/linux/s390/elision-conf.h   |   8 +-
 sysdeps/unix/sysv/linux/s390/elision-lock.c   |   7 +-
 .../unix/sysv/linux/s390/elision-trylock.c    |   1 +
 sysdeps/unix/sysv/linux/s390/elision-unlock.c |   1 +
 sysdeps/unix/sysv/linux/s390/force-elision.h  |  62 ---
 sysdeps/unix/sysv/linux/s390/lowlevellock.h   |  49 --
 .../sysv/linux/s390/pthread_mutex_cond_lock.c |  22 -
 .../sysv/linux/s390/pthread_mutex_timedlock.c |  22 -
 sysdeps/unix/sysv/linux/x86/Makefile          |   2 -
 sysdeps/unix/sysv/linux/x86/elision-conf.c    |  25 +-
 sysdeps/unix/sysv/linux/x86/elision-conf.h    |   8 +-
 sysdeps/unix/sysv/linux/x86/elision-lock.c    |   7 +-
 sysdeps/unix/sysv/linux/x86/elision-trylock.c |   1 +
 sysdeps/unix/sysv/linux/x86/elision-unlock.c  |   1 +
 sysdeps/unix/sysv/linux/x86/force-elision.h   |  62 ---
 sysdeps/unix/sysv/linux/x86/lowlevellock.h    |  24 -
 .../sysv/linux/x86/pthread_mutex_cond_lock.c  |  22 -
 .../sysv/linux/x86/pthread_mutex_timedlock.c  |  22 -
 .../sysv/linux/x86/pthread_mutex_trylock.c    |  22 -
 51 files changed, 630 insertions(+), 959 deletions(-)
 rename sysdeps/unix/sysv/linux/s390/pthread_mutex_lock.c => nptl/elision-conf.c (79%)
 rename sysdeps/unix/sysv/linux/powerpc/pthread_mutex_lock.c => nptl/elision-lock.c (79%)
 rename sysdeps/unix/sysv/linux/s390/pthread_mutex_trylock.c => nptl/elision-timed.c (78%)
 rename sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c => nptl/elision-trylock.c (79%)
 create mode 100644 nptl/elision-unlock.c
 rename {sysdeps/nptl => nptl}/futex-internal.c (97%)
 delete mode 100644 nptl/libc-lowlevellock.c
 rename sysdeps/{unix/sysv/linux/powerpc/pthread_mutex_trylock.c => pthread/elision-conf.h} (64%)
 delete mode 100644 sysdeps/riscv/nptl/libc-lowlevellock.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/force-elision.h
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/pthread_mutex_cond_lock.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/pthread_mutex_timedlock.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/force-elision.h
 delete mode 100644 sysdeps/unix/sysv/linux/s390/lowlevellock.h
 delete mode 100644 sysdeps/unix/sysv/linux/s390/pthread_mutex_cond_lock.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/pthread_mutex_timedlock.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/force-elision.h
 delete mode 100644 sysdeps/unix/sysv/linux/x86/pthread_mutex_cond_lock.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/pthread_mutex_timedlock.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/pthread_mutex_trylock.c

-- 
2.29.2


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

* [PATCH 1/6] nptl: Split libpthread-routines into one routine per line
  2021-02-17 17:21 [PATCH 0/6] More libpthread removal preparations Florian Weimer
@ 2021-02-17 17:21 ` Florian Weimer
  2021-02-22 14:23   ` Adhemerval Zanella
  2021-02-17 17:21 ` [PATCH 2/6] nptl: Reformat Versions Florian Weimer
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-02-17 17:21 UTC (permalink / raw)
  To: libc-alpha

And sort the lines lexicographically.  This will make it easier to review
patches which move symbols from libpthread to libc.
---
 nptl/Makefile | 238 ++++++++++++++++++++++++++++++++------------------
 1 file changed, 152 insertions(+), 86 deletions(-)

diff --git a/nptl/Makefile b/nptl/Makefile
index 8fb7fee6db..94c3873623 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -85,92 +85,158 @@ pthread-compat-wrappers = \
 		      sigwait sigsuspend \
 		      recvmsg sendmsg
 
-libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \
-		      pthread_create pthread_exit pthread_detach \
-		      pthread_join pthread_tryjoin pthread_timedjoin \
-		      pthread_clockjoin pthread_join_common pthread_yield \
-		      pthread_getconcurrency pthread_setconcurrency \
-		      pthread_setschedprio \
-		      pthread_attr_getguardsize pthread_attr_setguardsize \
-		      pthread_attr_getstackaddr pthread_attr_setstackaddr \
-		      pthread_attr_getstacksize pthread_attr_setstacksize \
-		      pthread_attr_getstack pthread_attr_setstack \
-		      pthread_mutex_init pthread_mutex_destroy \
-		      pthread_mutex_lock pthread_mutex_trylock \
-		      pthread_mutex_timedlock pthread_mutex_unlock \
-		      pthread_mutex_cond_lock \
-		      pthread_mutexattr_init pthread_mutexattr_destroy \
-		      pthread_mutexattr_getpshared \
-		      pthread_mutexattr_setpshared \
-		      pthread_mutexattr_gettype pthread_mutexattr_settype \
-		      pthread_rwlock_init pthread_rwlock_destroy \
-		      pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
-		      pthread_rwlock_clockrdlock \
-		      pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
-		      pthread_rwlock_clockwrlock \
-		      pthread_rwlock_tryrdlock pthread_rwlock_trywrlock \
-		      pthread_rwlock_unlock \
-		      pthread_rwlockattr_init pthread_rwlockattr_destroy \
-		      pthread_rwlockattr_getpshared \
-		      pthread_rwlockattr_setpshared \
-		      pthread_rwlockattr_getkind_np \
-		      pthread_rwlockattr_setkind_np \
-		      pthread_cond_wait \
-		      pthread_cond_signal pthread_cond_broadcast \
-		      old_pthread_cond_wait old_pthread_cond_timedwait \
-		      old_pthread_cond_signal old_pthread_cond_broadcast \
-		      pthread_condattr_getpshared pthread_condattr_setpshared \
-		      pthread_condattr_getclock pthread_condattr_setclock \
-		      pthread_spin_init pthread_spin_destroy \
-		      pthread_spin_lock pthread_spin_trylock \
-		      pthread_spin_unlock \
-		      pthread_barrier_init pthread_barrier_destroy \
-		      pthread_barrier_wait \
-		      pthread_barrierattr_init pthread_barrierattr_destroy \
-		      pthread_barrierattr_getpshared \
-		      pthread_barrierattr_setpshared \
-		      pthread_key_create pthread_key_delete \
-		      pthread_getspecific pthread_setspecific \
-		      pthread_kill pthread_sigqueue \
-		      pthread_cancel pthread_testcancel \
-		      pthread_setcancelstate pthread_setcanceltype \
-		      pthread_once \
-		      old_pthread_atfork \
-		      pthread_getcpuclockid \
-		      sem_init sem_destroy sem_routines \
-		      sem_open sem_close sem_unlink \
-		      sem_getvalue \
-		      sem_wait sem_timedwait sem_clockwait sem_post \
-		      cleanup cleanup_defer cleanup_compat \
-		      cleanup_defer_compat unwind \
-		      pt-longjmp pt-cleanup\
-		      cancellation \
-		      lowlevellock \
-		      pt-fork pt-fcntl \
-		      $(pthread-compat-wrappers) \
-		      pt-raise pt-system \
-		      flockfile ftrylockfile funlockfile \
-		      sigaction \
-		      herrno res pt-allocrtsig \
-		      pthread_kill_other_threads \
-		      pthread_setaffinity \
-		      pthread_attr_getaffinity \
-		      pthread_mutexattr_getrobust pthread_mutexattr_setrobust \
-		      pthread_mutex_consistent \
-		      cleanup_routine unwind-forcedunwind \
-		      pthread_mutexattr_getprotocol \
-		      pthread_mutexattr_setprotocol \
-		      pthread_mutexattr_getprioceiling \
-		      pthread_mutexattr_setprioceiling tpp \
-		      pthread_mutex_getprioceiling \
-		      pthread_mutex_setprioceiling \
-		      pthread_setname pthread_getname \
-		      pthread_setattr_default_np pthread_getattr_default_np \
-		      pthread_mutex_conf \
-		      libpthread-compat
-
-libpthread-shared-only-routines = version pt-interp pt-allocrtsig \
-				  unwind-forcedunwind
+libpthread-routines = \
+  $(pthread-compat-wrappers) \
+  cancellation \
+  cleanup \
+  cleanup_compat \
+  cleanup_defer \
+  cleanup_defer_compat \
+  cleanup_routine \
+  events \
+  flockfile \
+  ftrylockfile \
+  funlockfile \
+  herrno \
+  libpthread-compat \
+  lowlevellock \
+  nptl-init \
+  nptlfreeres \
+  old_pthread_atfork \
+  old_pthread_cond_broadcast \
+  old_pthread_cond_signal \
+  old_pthread_cond_timedwait \
+  old_pthread_cond_wait \
+  pt-allocrtsig \
+  pt-cleanup \
+  pt-fcntl \
+  pt-fork \
+  pt-interp \
+  pt-longjmp \
+  pt-raise \
+  pt-system \
+  pthread_attr_getaffinity \
+  pthread_attr_getguardsize \
+  pthread_attr_getstack \
+  pthread_attr_getstackaddr \
+  pthread_attr_getstacksize \
+  pthread_attr_setguardsize \
+  pthread_attr_setstack \
+  pthread_attr_setstackaddr \
+  pthread_attr_setstacksize \
+  pthread_barrier_destroy \
+  pthread_barrier_init \
+  pthread_barrier_wait \
+  pthread_barrierattr_destroy \
+  pthread_barrierattr_getpshared \
+  pthread_barrierattr_init \
+  pthread_barrierattr_setpshared \
+  pthread_cancel \
+  pthread_clockjoin \
+  pthread_cond_broadcast \
+  pthread_cond_signal \
+  pthread_cond_wait \
+  pthread_condattr_getclock \
+  pthread_condattr_getpshared \
+  pthread_condattr_setclock \
+  pthread_condattr_setpshared \
+  pthread_create \
+  pthread_detach \
+  pthread_exit \
+  pthread_getattr_default_np \
+  pthread_getconcurrency \
+  pthread_getcpuclockid \
+  pthread_getname \
+  pthread_getspecific \
+  pthread_join \
+  pthread_join_common \
+  pthread_key_create \
+  pthread_key_delete \
+  pthread_kill \
+  pthread_kill_other_threads \
+  pthread_mutex_cond_lock \
+  pthread_mutex_conf \
+  pthread_mutex_consistent \
+  pthread_mutex_destroy \
+  pthread_mutex_getprioceiling \
+  pthread_mutex_init \
+  pthread_mutex_lock \
+  pthread_mutex_setprioceiling \
+  pthread_mutex_timedlock \
+  pthread_mutex_trylock \
+  pthread_mutex_unlock \
+  pthread_mutexattr_destroy \
+  pthread_mutexattr_getprioceiling \
+  pthread_mutexattr_getprotocol \
+  pthread_mutexattr_getpshared \
+  pthread_mutexattr_getrobust \
+  pthread_mutexattr_gettype \
+  pthread_mutexattr_init \
+  pthread_mutexattr_setprioceiling \
+  pthread_mutexattr_setprotocol \
+  pthread_mutexattr_setpshared \
+  pthread_mutexattr_setrobust \
+  pthread_mutexattr_settype \
+  pthread_once \
+  pthread_rwlock_clockrdlock \
+  pthread_rwlock_clockwrlock \
+  pthread_rwlock_destroy \
+  pthread_rwlock_init \
+  pthread_rwlock_rdlock \
+  pthread_rwlock_timedrdlock \
+  pthread_rwlock_timedwrlock \
+  pthread_rwlock_tryrdlock \
+  pthread_rwlock_trywrlock \
+  pthread_rwlock_unlock \
+  pthread_rwlock_wrlock \
+  pthread_rwlockattr_destroy \
+  pthread_rwlockattr_getkind_np \
+  pthread_rwlockattr_getpshared \
+  pthread_rwlockattr_init \
+  pthread_rwlockattr_setkind_np \
+  pthread_rwlockattr_setpshared \
+  pthread_setaffinity \
+  pthread_setattr_default_np \
+  pthread_setcancelstate \
+  pthread_setcanceltype \
+  pthread_setconcurrency \
+  pthread_setname \
+  pthread_setschedprio \
+  pthread_setspecific \
+  pthread_sigqueue \
+  pthread_spin_destroy \
+  pthread_spin_init \
+  pthread_spin_lock \
+  pthread_spin_trylock \
+  pthread_spin_unlock \
+  pthread_testcancel \
+  pthread_timedjoin \
+  pthread_tryjoin \
+  pthread_yield \
+  res \
+  sem_clockwait \
+  sem_close \
+  sem_destroy \
+  sem_getvalue \
+  sem_init \
+  sem_open \
+  sem_post \
+  sem_routines \
+  sem_timedwait \
+  sem_unlink \
+  sem_wait \
+  sigaction \
+  tpp \
+  unwind \
+  unwind-forcedunwind \
+  vars \
+  version \
+
+libpthread-shared-only-routines = \
+  pt-allocrtsig \
+  pt-interp \
+  unwind-forcedunwind \
+  version \
 
 # Since cancellation handling is in large parts handled using exceptions
 # we have to compile some files with exception handling enabled, some
-- 
2.29.2



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

* [PATCH 2/6] nptl: Reformat Versions
  2021-02-17 17:21 [PATCH 0/6] More libpthread removal preparations Florian Weimer
  2021-02-17 17:21 ` [PATCH 1/6] nptl: Split libpthread-routines into one routine per line Florian Weimer
@ 2021-02-17 17:21 ` Florian Weimer
  2021-02-22 16:31   ` Adhemerval Zanella
  2021-02-17 17:21 ` [PATCH 3/6] nptl: Move futex-internal.c into main nptl directory Florian Weimer
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-02-17 17:21 UTC (permalink / raw)
  To: libc-alpha

One symbol per line, lexicographically ordered.
---
 nptl/Versions | 467 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 279 insertions(+), 188 deletions(-)

diff --git a/nptl/Versions b/nptl/Versions
index 5db713d1ae..7254ca4750 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -1,21 +1,36 @@
 libc {
   GLIBC_2.0 {
-    pthread_attr_destroy; pthread_attr_init;
-    pthread_attr_getdetachstate; pthread_attr_setdetachstate;
-    pthread_attr_getinheritsched; pthread_attr_setinheritsched;
-    pthread_attr_getschedparam; pthread_attr_setschedparam;
-    pthread_attr_getschedpolicy;  pthread_attr_setschedpolicy;
-    pthread_attr_getscope; pthread_attr_setscope;
-    pthread_condattr_destroy; pthread_condattr_init;
-    pthread_cond_broadcast; pthread_cond_destroy;
-    pthread_cond_init; pthread_cond_signal; pthread_cond_wait;
+    pthread_attr_destroy;
+    pthread_attr_getdetachstate;
+    pthread_attr_getinheritsched;
+    pthread_attr_getschedparam;
+    pthread_attr_getschedpolicy;
+    pthread_attr_getscope;
+    pthread_attr_init;
+    pthread_attr_setdetachstate;
+    pthread_attr_setinheritsched;
+    pthread_attr_setschedparam;
+    pthread_attr_setschedpolicy;
+    pthread_attr_setscope;
+    pthread_cond_broadcast;
+    pthread_cond_destroy;
+    pthread_cond_init;
+    pthread_cond_signal;
     pthread_cond_timedwait;
-    pthread_equal; pthread_exit;
-    pthread_getschedparam; pthread_setschedparam;
-    pthread_mutex_destroy; pthread_mutex_init;
-    pthread_mutex_lock; pthread_mutex_unlock;
+    pthread_cond_wait;
+    pthread_condattr_destroy;
+    pthread_condattr_init;
+    pthread_equal;
+    pthread_exit;
+    pthread_getschedparam;
+    pthread_mutex_destroy;
+    pthread_mutex_init;
+    pthread_mutex_lock;
+    pthread_mutex_unlock;
     pthread_self;
-    pthread_setcancelstate; pthread_setcanceltype;
+    pthread_setcancelstate;
+    pthread_setcanceltype;
+    pthread_setschedparam;
     pthread_sigmask;
   }
   GLIBC_2.1 {
@@ -26,11 +41,12 @@ libc {
   }
   GLIBC_2.3.2 {
     __register_atfork;
-
-    # Changed pthread_cond_t.
-    pthread_cond_init; pthread_cond_destroy;
-    pthread_cond_wait; pthread_cond_signal;
-    pthread_cond_broadcast; pthread_cond_timedwait;
+    pthread_cond_broadcast;
+    pthread_cond_destroy;
+    pthread_cond_init;
+    pthread_cond_signal;
+    pthread_cond_timedwait;
+    pthread_cond_wait;
   }
   GLIBC_2.3.3 {
     pthread_attr_setaffinity_np;
@@ -41,7 +57,10 @@ libc {
   }
   # C11 thread symbols.
   GLIBC_2.28 {
-    thrd_current; thrd_equal; thrd_sleep; thrd_yield;
+    thrd_current;
+    thrd_equal;
+    thrd_sleep;
+    thrd_yield;
   }
   GLIBC_2.32 {
     pthread_attr_getsigmask_np;
@@ -53,114 +72,164 @@ libc {
   }
   GLIBC_PRIVATE {
     __libc_alloca_cutoff;
-    # Internal libc interface to libpthread
+    __libc_allocate_rtsig_private;
+    __libc_current_sigrtmax_private;
+    __libc_current_sigrtmin_private;
     __libc_dl_error_tsd;
     __libc_pthread_init;
-    __libc_current_sigrtmin_private; __libc_current_sigrtmax_private;
-    __libc_allocate_rtsig_private;
-    # Used by the C11 threads implementation.
-    __pthread_cond_destroy; __pthread_cond_init;
-    __pthread_attr_setaffinity_np;
-    __pthread_attr_init; __pthread_attr_destroy;
     __pthread_attr_copy;
-    __pthread_getattr_default_np;
+    __pthread_attr_destroy;
+    __pthread_attr_init;
+    __pthread_attr_setaffinity_np;
     __pthread_attr_setsigmask_internal;
+    __pthread_cond_destroy; # Used by the C11 threads.
+    __pthread_cond_init; # Used by the C11 threads.
+    __pthread_getattr_default_np;
   }
 }
 
 libpthread {
   GLIBC_2.0 {
-    pthread_create; pthread_join;
-    pthread_exit; pthread_detach;
-
-    pthread_mutex_init; pthread_mutex_destroy;
-    pthread_mutex_lock; pthread_mutex_trylock; pthread_mutex_unlock;
-
-    pthread_mutexattr_init; pthread_mutexattr_destroy;
-
-    pthread_cond_wait; pthread_cond_timedwait;
-    pthread_cond_signal; pthread_cond_broadcast;
-
-    pthread_cancel; pthread_testcancel;
-    pthread_setcancelstate; pthread_setcanceltype;
-
-    pthread_sigmask; pthread_kill;
-
-    pthread_key_create; pthread_key_delete;
-    pthread_getspecific; pthread_setspecific;
-
-    pthread_once;
-
-    pthread_atfork;
-
-    flockfile; funlockfile; ftrylockfile;
-
-    # Non-standard POSIX1.x functions.
-    pthread_mutexattr_getkind_np; pthread_mutexattr_setkind_np;
-
-    # Protected names for functions used in other shared objects.
-    __pthread_mutex_init; __pthread_mutex_destroy;
-    __pthread_mutex_lock; __pthread_mutex_trylock; __pthread_mutex_unlock;
-    __pthread_mutexattr_init; __pthread_mutexattr_destroy;
+    _Exit;
+    _IO_flockfile;
+    _IO_ftrylockfile;
+    _IO_funlockfile;
+    __close;
+    __connect;
+    __errno_location;
+    __fcntl;
+    __fork;
+    __h_errno_location;
+    __lseek;
+    __open;
+    __pthread_atfork;
+    __pthread_getspecific;
+    __pthread_key_create;
+    __pthread_mutex_destroy;
+    __pthread_mutex_init;
+    __pthread_mutex_lock;
+    __pthread_mutex_trylock;
+    __pthread_mutex_unlock;
+    __pthread_mutexattr_destroy;
+    __pthread_mutexattr_init;
     __pthread_mutexattr_settype;
-    __pthread_key_create; __pthread_getspecific; __pthread_setspecific;
-    __pthread_once; __pthread_atfork;
-    _IO_flockfile; _IO_ftrylockfile; _IO_funlockfile;
-
-    # Semaphores.
-    sem_destroy; sem_getvalue; sem_init; sem_post; sem_trywait; sem_wait;
-
-    # Special fork handling.
-    fork; __fork;
-
-    # Cancellation points.
-    close; __close; fcntl; __fcntl; read; __read; write; __write; accept;
-    connect; __connect; recv; recvfrom; recvmsg; send; __send; sendmsg; sendto;
-    fsync; lseek; __lseek; msync; open; __open; pause; tcdrain;
-    system;
-
-    # Hidden entry point (through macros).
-    _pthread_cleanup_push; _pthread_cleanup_pop;
-    _pthread_cleanup_push_defer; _pthread_cleanup_pop_restore;
-
+    __pthread_once;
+    __pthread_setspecific;
+    __read;
+    __send;
+    __sigaction;
+    __write;
+    _exit;
+    _pthread_cleanup_pop;
+    _pthread_cleanup_pop_restore;
+    _pthread_cleanup_push;
+    _pthread_cleanup_push_defer;
+    accept;
+    close;
+    connect;
+    fcntl;
+    flockfile;
+    fork;
+    fsync;
+    ftrylockfile;
+    funlockfile;
+    longjmp;
+    lseek;
+    msync;
+    open;
+    pause;
+    pthread_atfork;
+    pthread_cancel;
+    pthread_cond_broadcast;
+    pthread_cond_signal;
+    pthread_cond_timedwait;
+    pthread_cond_wait;
+    pthread_create;
+    pthread_detach;
+    pthread_exit;
+    pthread_getspecific;
+    pthread_join;
+    pthread_key_create;
+    pthread_key_delete;
+    pthread_kill;
     pthread_kill_other_threads_np;
-
-    # The error functions.
-    __errno_location; __h_errno_location;
-
-    # Functions which previously have been overwritten.
-    sigwait; sigaction; __sigaction; _exit; _Exit; longjmp; siglongjmp;
+    pthread_mutex_destroy;
+    pthread_mutex_init;
+    pthread_mutex_lock;
+    pthread_mutex_trylock;
+    pthread_mutex_unlock;
+    pthread_mutexattr_destroy;
+    pthread_mutexattr_getkind_np;
+    pthread_mutexattr_init;
+    pthread_mutexattr_setkind_np;
+    pthread_once;
+    pthread_setcancelstate;
+    pthread_setcanceltype;
+    pthread_setspecific;
+    pthread_sigmask;
+    pthread_testcancel;
     raise;
+    read;
+    recv;
+    recvfrom;
+    recvmsg;
+    sem_destroy;
+    sem_getvalue;
+    sem_init;
+    sem_post;
+    sem_trywait;
+    sem_wait;
+    send;
+    sendmsg;
+    sendto;
+    sigaction;
+    siglongjmp;
+    sigwait;
+    system;
+    tcdrain;
+    write;
   }
 
   GLIBC_2.1 {
-    pthread_create;
-
-    pthread_attr_getguardsize; pthread_attr_setguardsize;
-    pthread_attr_getstackaddr; pthread_attr_setstackaddr;
-    pthread_attr_getstacksize; pthread_attr_setstacksize;
-
-    pthread_mutexattr_gettype; pthread_mutexattr_settype;
-
-    pthread_rwlock_init; pthread_rwlock_destroy;
-    pthread_rwlock_rdlock; pthread_rwlock_wrlock; pthread_rwlock_unlock;
-    pthread_rwlock_tryrdlock; pthread_rwlock_trywrlock;
-
-    pthread_rwlockattr_init; pthread_rwlockattr_destroy;
-    pthread_rwlockattr_getpshared; pthread_rwlockattr_setpshared;
-    pthread_rwlockattr_getkind_np; pthread_rwlockattr_setkind_np;
-
-    pthread_getconcurrency; pthread_setconcurrency;
-
-    # Semaphores.
-    sem_destroy; sem_getvalue; sem_init; sem_post; sem_trywait; sem_wait;
-
-    __libc_current_sigrtmin; __libc_current_sigrtmax;
     __libc_allocate_rtsig;
+    __libc_current_sigrtmax;
+    __libc_current_sigrtmin;
+    pthread_attr_getguardsize;
+    pthread_attr_getstackaddr;
+    pthread_attr_getstacksize;
+    pthread_attr_setguardsize;
+    pthread_attr_setstackaddr;
+    pthread_attr_setstacksize;
+    pthread_create;
+    pthread_getconcurrency;
+    pthread_mutexattr_gettype;
+    pthread_mutexattr_settype;
+    pthread_rwlock_destroy;
+    pthread_rwlock_init;
+    pthread_rwlock_rdlock;
+    pthread_rwlock_tryrdlock;
+    pthread_rwlock_trywrlock;
+    pthread_rwlock_unlock;
+    pthread_rwlock_wrlock;
+    pthread_rwlockattr_destroy;
+    pthread_rwlockattr_getkind_np;
+    pthread_rwlockattr_getpshared;
+    pthread_rwlockattr_init;
+    pthread_rwlockattr_setkind_np;
+    pthread_rwlockattr_setpshared;
+    pthread_setconcurrency;
+    sem_destroy;
+    sem_getvalue;
+    sem_init;
+    sem_post;
+    sem_trywait;
+    sem_wait;
   }
 
   GLIBC_2.1.1 {
-    sem_close; sem_open; sem_unlink;
+    sem_close;
+    sem_open;
+    sem_unlink;
   }
 
   GLIBC_2.1.2 {
@@ -168,41 +237,46 @@ libpthread {
   }
 
   GLIBC_2.2 {
-    pthread_mutexattr_getpshared; pthread_mutexattr_setpshared;
-
-    pthread_condattr_getpshared; pthread_condattr_setpshared;
-
-    # New functions from IEEE Std. 1003.1-2001.
-    pthread_mutex_timedlock;
-
-    pthread_rwlock_timedrdlock; pthread_rwlock_timedwrlock;
-
-    pthread_attr_getstack; pthread_attr_setstack;
-
-    pthread_spin_destroy; pthread_spin_init; pthread_spin_lock;
-    pthread_spin_trylock; pthread_spin_unlock;
-
-    pthread_barrier_init; pthread_barrier_destroy; pthread_barrier_wait;
-    pthread_barrierattr_destroy; pthread_barrierattr_init;
-    pthread_barrierattr_setpshared;
-
-    sem_timedwait;
-
-    pthread_yield;
-
-    pthread_getcpuclockid;
-
-    # Cancellation points.
-    lseek64; open64; __open64; pread; pread64; __pread64; pwrite; pwrite64;
-    __pwrite64;
-
-    # Names used internally.
-    __pthread_rwlock_init; __pthread_rwlock_destroy;
-    __pthread_rwlock_rdlock; __pthread_rwlock_tryrdlock;
-    __pthread_rwlock_wrlock; __pthread_rwlock_trywrlock;
+    __open64;
+    __pread64;
+    __pthread_rwlock_destroy;
+    __pthread_rwlock_init;
+    __pthread_rwlock_rdlock;
+    __pthread_rwlock_tryrdlock;
+    __pthread_rwlock_trywrlock;
     __pthread_rwlock_unlock;
-
+    __pthread_rwlock_wrlock;
+    __pwrite64;
     __res_state;
+    lseek64;
+    open64;
+    pread64;
+    pread;
+    pthread_attr_getstack;
+    pthread_attr_setstack;
+    pthread_barrier_destroy;
+    pthread_barrier_init;
+    pthread_barrier_wait;
+    pthread_barrierattr_destroy;
+    pthread_barrierattr_init;
+    pthread_barrierattr_setpshared;
+    pthread_condattr_getpshared;
+    pthread_condattr_setpshared;
+    pthread_getcpuclockid;
+    pthread_mutex_timedlock;
+    pthread_mutexattr_getpshared;
+    pthread_mutexattr_setpshared;
+    pthread_rwlock_timedrdlock;
+    pthread_rwlock_timedwrlock;
+    pthread_spin_destroy;
+    pthread_spin_init;
+    pthread_spin_lock;
+    pthread_spin_trylock;
+    pthread_spin_unlock;
+    pthread_yield;
+    pwrite64;
+    pwrite;
+    sem_timedwait;
   }
 
   GLIBC_2.2.3 {
@@ -214,47 +288,46 @@ libpthread {
   }
 
   GLIBC_2.3.2 {
-    # Changed pthread_cond_t.
+    pthread_cond_broadcast;
     pthread_cond_init;
-    pthread_cond_wait; pthread_cond_timedwait;
-    pthread_cond_signal; pthread_cond_broadcast;
+    pthread_cond_signal;
+    pthread_cond_timedwait;
+    pthread_cond_wait;
   }
 
   GLIBC_2.3.3 {
-    # 1003.1-2001 function accidentally left out in 2.2.
-    pthread_barrierattr_getpshared;
-
-    # Unix CS option.
-    pthread_condattr_getclock; pthread_condattr_setclock;
-
-    # Proposed API extensions.
-    pthread_tryjoin_np; pthread_timedjoin_np;
-
-    # New cancellation cleanup handling.
-    __pthread_register_cancel; __pthread_unregister_cancel;
-    __pthread_register_cancel_defer; __pthread_unregister_cancel_restore;
-    __pthread_unwind_next;
     __pthread_cleanup_routine;
-
-    # affinity interfaces without size parameter
-    pthread_setaffinity_np;
+    __pthread_register_cancel;
+    __pthread_register_cancel_defer;
+    __pthread_unregister_cancel;
+    __pthread_unregister_cancel_restore;
+    __pthread_unwind_next;
     pthread_attr_getaffinity_np;
+    pthread_barrierattr_getpshared;
+    pthread_condattr_getclock;
+    pthread_condattr_setclock;
+    pthread_setaffinity_np;
+    pthread_timedjoin_np;
+    pthread_tryjoin_np;
   }
 
   GLIBC_2.3.4 {
-    # New affinity interfaces.
-    pthread_getaffinity_np; pthread_setaffinity_np;
     pthread_attr_getaffinity_np;
-
+    pthread_getaffinity_np;
+    pthread_setaffinity_np;
     pthread_setschedprio;
   }
 
   GLIBC_2.4 {
-    pthread_mutexattr_getrobust_np; pthread_mutexattr_setrobust_np;
     pthread_mutex_consistent_np;
-    pthread_mutexattr_getprotocol; pthread_mutexattr_setprotocol;
-    pthread_mutexattr_getprioceiling; pthread_mutexattr_setprioceiling;
-    pthread_mutex_getprioceiling; pthread_mutex_setprioceiling;
+    pthread_mutex_getprioceiling;
+    pthread_mutex_setprioceiling;
+    pthread_mutexattr_getprioceiling;
+    pthread_mutexattr_getprotocol;
+    pthread_mutexattr_getrobust_np;
+    pthread_mutexattr_setprioceiling;
+    pthread_mutexattr_setprotocol;
+    pthread_mutexattr_setrobust_np;
   };
 
   GLIBC_2.11 {
@@ -262,10 +335,11 @@ libpthread {
   };
 
   GLIBC_2.12 {
-    pthread_mutex_consistent; pthread_mutexattr_getrobust;
+    pthread_getname_np;
+    pthread_mutex_consistent;
+    pthread_mutexattr_getrobust;
     pthread_mutexattr_setrobust;
-
-    pthread_setname_np; pthread_getname_np;
+    pthread_setname_np;
   };
 
   GLIBC_2.18 {
@@ -273,24 +347,37 @@ libpthread {
     pthread_setattr_default_np;
   }
 
-  GLIBC_2.20 {
-  }
-
-  GLIBC_2.22 {
-  }
-
   # C11 thread symbols.
   GLIBC_2.28 {
-    thrd_create; thrd_detach; thrd_exit; thrd_join;
-    mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; mtx_unlock; mtx_destroy;
-    call_once; cnd_broadcast; cnd_destroy; cnd_init; cnd_signal;
-    cnd_timedwait; cnd_wait; tss_create; tss_delete; tss_get; tss_set;
+    call_once;
+    cnd_broadcast;
+    cnd_destroy;
+    cnd_init;
+    cnd_signal;
+    cnd_timedwait;
+    cnd_wait;
+    mtx_destroy;
+    mtx_init;
+    mtx_lock;
+    mtx_timedlock;
+    mtx_trylock;
+    mtx_unlock;
+    thrd_create;
+    thrd_detach;
+    thrd_exit;
+    thrd_join;
+    tss_create;
+    tss_delete;
+    tss_get;
+    tss_set;
   }
 
   GLIBC_2.30 {
-    sem_clockwait; pthread_cond_clockwait;
-    pthread_rwlock_clockrdlock; pthread_rwlock_clockwrlock;
+    pthread_cond_clockwait;
     pthread_mutex_clocklock;
+    pthread_rwlock_clockrdlock;
+    pthread_rwlock_clockwrlock;
+    sem_clockwait;
   }
 
   GLIBC_2.31 {
@@ -298,11 +385,15 @@ libpthread {
   }
 
   GLIBC_PRIVATE {
-    __pthread_initialize_minimal;
-    __pthread_clock_gettime; __pthread_clock_settime;
-    __pthread_unwind; __pthread_get_minstack;
-    __pthread_barrier_init; __pthread_barrier_wait;
-    __futex_abstimed_wait64; __futex_abstimed_wait_cancelable64;
+    __futex_abstimed_wait64;
+    __futex_abstimed_wait_cancelable64;
     __libpthread_freeres;
+    __pthread_barrier_init;
+    __pthread_barrier_wait;
+    __pthread_clock_gettime;
+    __pthread_clock_settime;
+    __pthread_get_minstack;
+    __pthread_initialize_minimal;
+    __pthread_unwind;
   }
 }
-- 
2.29.2



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

* [PATCH 3/6] nptl: Move futex-internal.c into main nptl directory
  2021-02-17 17:21 [PATCH 0/6] More libpthread removal preparations Florian Weimer
  2021-02-17 17:21 ` [PATCH 1/6] nptl: Split libpthread-routines into one routine per line Florian Weimer
  2021-02-17 17:21 ` [PATCH 2/6] nptl: Reformat Versions Florian Weimer
@ 2021-02-17 17:21 ` Florian Weimer
  2021-02-22 16:34   ` Adhemerval Zanella
  2021-02-17 17:21 ` [PATCH 4/6] nptl: Move lowlevellock into libc Florian Weimer
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-02-17 17:21 UTC (permalink / raw)
  To: libc-alpha

---
 nptl/Makefile                           | 3 +++
 {sysdeps/nptl => nptl}/futex-internal.c | 0
 sysdeps/nptl/Makefile                   | 3 +--
 3 files changed, 4 insertions(+), 2 deletions(-)
 rename {sysdeps/nptl => nptl}/futex-internal.c (100%)

diff --git a/nptl/Makefile b/nptl/Makefile
index 94c3873623..5a7558d943 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -97,6 +97,7 @@ libpthread-routines = \
   flockfile \
   ftrylockfile \
   funlockfile \
+  futex-internal \
   herrno \
   libpthread-compat \
   lowlevellock \
@@ -314,6 +315,8 @@ CFLAGS-fsync.c += -fexceptions -fasynchronous-unwind-tables
 
 CFLAGS-pt-system.c += -fexceptions
 
+CFLAGS-futex-internal.c += -fexceptions -fasynchronous-unwind-tables
+
 LDLIBS-tst-once5 = -lstdc++
 CFLAGS-tst-thread_local1.o = -std=gnu++11
 LDLIBS-tst-thread_local1 = -lstdc++
diff --git a/sysdeps/nptl/futex-internal.c b/nptl/futex-internal.c
similarity index 100%
rename from sysdeps/nptl/futex-internal.c
rename to nptl/futex-internal.c
diff --git a/sysdeps/nptl/Makefile b/sysdeps/nptl/Makefile
index bdba75d85f..adcced422b 100644
--- a/sysdeps/nptl/Makefile
+++ b/sysdeps/nptl/Makefile
@@ -17,8 +17,7 @@
 # <https://www.gnu.org/licenses/>.
 
 ifeq ($(subdir),nptl)
-libpthread-sysdep_routines += errno-loc futex-internal
-CFLAGS-futex-internal.c += -fexceptions -fasynchronous-unwind-tables
+libpthread-sysdep_routines += errno-loc
 endif
 
 ifeq ($(subdir),rt)
-- 
2.29.2



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

* [PATCH 4/6] nptl: Move lowlevellock into libc
  2021-02-17 17:21 [PATCH 0/6] More libpthread removal preparations Florian Weimer
                   ` (2 preceding siblings ...)
  2021-02-17 17:21 ` [PATCH 3/6] nptl: Move futex-internal.c into main nptl directory Florian Weimer
@ 2021-02-17 17:21 ` Florian Weimer
  2021-02-22 16:38   ` Adhemerval Zanella
  2021-02-17 17:21 ` [PATCH 5/6] nptl: Move futex-internal " Florian Weimer
  2021-02-17 17:22 ` [PATCH 6/6] nptl: Move elision implementations " Florian Weimer
  5 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-02-17 17:21 UTC (permalink / raw)
  To: libc-alpha

And export __lll_lock_wait and __lll_lock_wait_private as
GLIBC_PRIVATE.  This should eliminate the need for the previous
riscv kludge.
---
 nptl/Makefile                          |  3 +--
 nptl/Versions                          |  2 ++
 nptl/libc-lowlevellock.c               | 20 --------------------
 nptl/lowlevellock.c                    |  6 ++----
 sysdeps/nptl/lowlevellock.h            |  6 ++++--
 sysdeps/riscv/nptl/libc-lowlevellock.c |  8 --------
 6 files changed, 9 insertions(+), 36 deletions(-)
 delete mode 100644 nptl/libc-lowlevellock.c
 delete mode 100644 sysdeps/riscv/nptl/libc-lowlevellock.c

diff --git a/nptl/Makefile b/nptl/Makefile
index 5a7558d943..62f368af1e 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -33,9 +33,9 @@ routines = \
   forward \
   libc-cancellation \
   libc-cleanup \
-  libc-lowlevellock \
   libc_multiple_threads \
   libc_pthread_init \
+  lowlevellock \
   old_pthread_cond_destroy \
   old_pthread_cond_init \
   pthread_atfork \
@@ -100,7 +100,6 @@ libpthread-routines = \
   futex-internal \
   herrno \
   libpthread-compat \
-  lowlevellock \
   nptl-init \
   nptlfreeres \
   old_pthread_atfork \
diff --git a/nptl/Versions b/nptl/Versions
index 7254ca4750..694747bb44 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -77,6 +77,8 @@ libc {
     __libc_current_sigrtmin_private;
     __libc_dl_error_tsd;
     __libc_pthread_init;
+    __lll_lock_wait;
+    __lll_lock_wait_private;
     __pthread_attr_copy;
     __pthread_attr_destroy;
     __pthread_attr_init;
diff --git a/nptl/libc-lowlevellock.c b/nptl/libc-lowlevellock.c
deleted file mode 100644
index e840399c41..0000000000
--- a/nptl/libc-lowlevellock.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2003-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Paul Mackerras <paulus@au.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/>.  */
-
-/* No difference to lowlevellock.c, except we lose a couple of functions.  */
-#include <lowlevellock.c>
diff --git a/nptl/lowlevellock.c b/nptl/lowlevellock.c
index 1ea397d5cb..7976c6d8f5 100644
--- a/nptl/lowlevellock.c
+++ b/nptl/lowlevellock.c
@@ -35,10 +35,8 @@ __lll_lock_wait_private (int *futex)
       futex_wait ((unsigned int *) futex, 2, LLL_PRIVATE); /* Wait if *futex == 2.  */
     }
 }
+libc_hidden_def (__lll_lock_wait_private)
 
-
-/* This function doesn't get included in libc.  */
-#if IS_IN (libpthread)
 void
 __lll_lock_wait (int *futex, int private)
 {
@@ -52,4 +50,4 @@ __lll_lock_wait (int *futex, int private)
       futex_wait ((unsigned int *) futex, 2, private); /* Wait if *futex == 2.  */
     }
 }
-#endif
+libc_hidden_def (__lll_lock_wait)
diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h
index 0a2b413f86..176ba96251 100644
--- a/sysdeps/nptl/lowlevellock.h
+++ b/sysdeps/nptl/lowlevellock.h
@@ -75,8 +75,10 @@
 #define lll_cond_trylock(lock)	\
   __glibc_unlikely (atomic_compare_and_exchange_bool_acq (&(lock), 2, 0))
 
-extern void __lll_lock_wait_private (int *futex) attribute_hidden;
-extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
+extern void __lll_lock_wait_private (int *futex);
+libc_hidden_proto (__lll_lock_wait_private)
+extern void __lll_lock_wait (int *futex, int private);
+libc_hidden_proto (__lll_lock_wait)
 
 /* This is an expression rather than a statement even though its value is
    void, so that it can be used in a comma expression or as an expression
diff --git a/sysdeps/riscv/nptl/libc-lowlevellock.c b/sysdeps/riscv/nptl/libc-lowlevellock.c
deleted file mode 100644
index 9523fb46a5..0000000000
--- a/sysdeps/riscv/nptl/libc-lowlevellock.c
+++ /dev/null
@@ -1,8 +0,0 @@
-/* This kludge works around a libpthread static linking problem:
-   https://sourceware.org/bugzilla/show_bug.cgi?id=15648.  */
-
-#ifndef SHARED
-# define __lll_lock_wait_private weak_function __lll_lock_wait_private
-#endif
-
-#include <lowlevellock.c>
-- 
2.29.2



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

* [PATCH 5/6] nptl: Move futex-internal into libc
  2021-02-17 17:21 [PATCH 0/6] More libpthread removal preparations Florian Weimer
                   ` (3 preceding siblings ...)
  2021-02-17 17:21 ` [PATCH 4/6] nptl: Move lowlevellock into libc Florian Weimer
@ 2021-02-17 17:21 ` Florian Weimer
  2021-02-22 16:39   ` Adhemerval Zanella
  2021-02-17 17:22 ` [PATCH 6/6] nptl: Move elision implementations " Florian Weimer
  5 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-02-17 17:21 UTC (permalink / raw)
  To: libc-alpha

This moves  __futex_abstimed_wait64 and
__futex_abstimed_wait_cancelable64 and exports these functions as
GLIBC_PRIVATE.
---
 nptl/Makefile                 | 2 +-
 nptl/Versions                 | 4 ++--
 nptl/futex-internal.c         | 4 ++--
 sysdeps/nptl/futex-internal.h | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/nptl/Makefile b/nptl/Makefile
index 62f368af1e..4dd9c6a6a8 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -31,6 +31,7 @@ extra-libs-others := $(extra-libs)
 routines = \
   alloca_cutoff \
   forward \
+  futex-internal \
   libc-cancellation \
   libc-cleanup \
   libc_multiple_threads \
@@ -97,7 +98,6 @@ libpthread-routines = \
   flockfile \
   ftrylockfile \
   funlockfile \
-  futex-internal \
   herrno \
   libpthread-compat \
   nptl-init \
diff --git a/nptl/Versions b/nptl/Versions
index 694747bb44..6cca579a0a 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -71,6 +71,8 @@ libc {
     pthread_sigmask;
   }
   GLIBC_PRIVATE {
+    __futex_abstimed_wait64;
+    __futex_abstimed_wait_cancelable64;
     __libc_alloca_cutoff;
     __libc_allocate_rtsig_private;
     __libc_current_sigrtmax_private;
@@ -387,8 +389,6 @@ libpthread {
   }
 
   GLIBC_PRIVATE {
-    __futex_abstimed_wait64;
-    __futex_abstimed_wait_cancelable64;
     __libpthread_freeres;
     __pthread_barrier_init;
     __pthread_barrier_wait;
diff --git a/nptl/futex-internal.c b/nptl/futex-internal.c
index 89b4ba76e9..850bf4fd83 100644
--- a/nptl/futex-internal.c
+++ b/nptl/futex-internal.c
@@ -112,7 +112,7 @@ __futex_abstimed_wait64 (unsigned int* futex_word, unsigned int expected,
   return __futex_abstimed_wait_common64 (futex_word, expected, clockid,
                                          abstime, private, false);
 }
-libpthread_hidden_def (__futex_abstimed_wait64)
+libc_hidden_def (__futex_abstimed_wait64)
 
 int
 __futex_abstimed_wait_cancelable64 (unsigned int* futex_word,
@@ -123,4 +123,4 @@ __futex_abstimed_wait_cancelable64 (unsigned int* futex_word,
   return __futex_abstimed_wait_common64 (futex_word, expected, clockid,
                                          abstime, private, true);
 }
-libpthread_hidden_def (__futex_abstimed_wait_cancelable64)
+libc_hidden_def (__futex_abstimed_wait_cancelable64)
diff --git a/sysdeps/nptl/futex-internal.h b/sysdeps/nptl/futex-internal.h
index 4c192c99e3..969ab2bf4b 100644
--- a/sysdeps/nptl/futex-internal.h
+++ b/sysdeps/nptl/futex-internal.h
@@ -345,14 +345,14 @@ __futex_abstimed_wait_cancelable64 (unsigned int* futex_word,
                                     unsigned int expected, clockid_t clockid,
                                     const struct __timespec64* abstime,
                                     int private);
-libpthread_hidden_proto (__futex_abstimed_wait_cancelable64);
+libc_hidden_proto (__futex_abstimed_wait_cancelable64);
 
 int
 __futex_abstimed_wait64 (unsigned int* futex_word, unsigned int expected,
                          clockid_t clockid,
                          const struct __timespec64* abstime,
                          int private);
-libpthread_hidden_proto (__futex_abstimed_wait64);
+libc_hidden_proto (__futex_abstimed_wait64);
 
 
 static __always_inline int
-- 
2.29.2



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

* [PATCH 6/6] nptl: Move elision implementations into libc
  2021-02-17 17:21 [PATCH 0/6] More libpthread removal preparations Florian Weimer
                   ` (4 preceding siblings ...)
  2021-02-17 17:21 ` [PATCH 5/6] nptl: Move futex-internal " Florian Weimer
@ 2021-02-17 17:22 ` Florian Weimer
  2021-02-22 16:53   ` Adhemerval Zanella
  5 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-02-17 17:22 UTC (permalink / raw)
  To: libc-alpha

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.)
---
 elf/libc_early_init.c                         |   6 ++
 nptl/Makefile                                 |   5 +
 nptl/Versions                                 |   5 +
 .../elision-conf.c                            |   9 +-
 .../elision-lock.c                            |   9 +-
 .../elision-timed.c                           |   9 +-
 .../elision-trylock.c                         |   9 +-
 nptl/elision-unlock.c                         |  17 +++
 nptl/lowlevellock.c                           |   5 +
 nptl/pthread_mutex_lock.c                     |  13 ---
 nptl/pthread_mutex_timedlock.c                |  13 ---
 nptl/pthread_mutex_trylock.c                  |   8 --
 nptl/pthread_mutex_unlock.c                   |   4 -
 sysdeps/nptl/lowlevellock.h                   | 102 ++++++++++++++++++
 .../elision-conf.h}                           |  17 ++-
 sysdeps/unix/sysv/linux/powerpc/Makefile      |   2 -
 .../unix/sysv/linux/powerpc/elision-conf.c    |  26 +----
 .../unix/sysv/linux/powerpc/elision-conf.h    |   8 +-
 .../unix/sysv/linux/powerpc/elision-lock.c    |   7 +-
 .../unix/sysv/linux/powerpc/elision-trylock.c |   1 +
 .../unix/sysv/linux/powerpc/elision-unlock.c  |   1 +
 .../unix/sysv/linux/powerpc/force-elision.h   |  62 -----------
 .../unix/sysv/linux/powerpc/lowlevellock.h    |  49 ---------
 .../linux/powerpc/pthread_mutex_cond_lock.c   |  22 ----
 sysdeps/unix/sysv/linux/s390/Makefile         |   3 -
 sysdeps/unix/sysv/linux/s390/elision-conf.c   |  27 +----
 sysdeps/unix/sysv/linux/s390/elision-conf.h   |   8 +-
 sysdeps/unix/sysv/linux/s390/elision-lock.c   |   7 +-
 .../unix/sysv/linux/s390/elision-trylock.c    |   1 +
 sysdeps/unix/sysv/linux/s390/elision-unlock.c |   1 +
 sysdeps/unix/sysv/linux/s390/force-elision.h  |  62 -----------
 sysdeps/unix/sysv/linux/s390/lowlevellock.h   |  49 ---------
 .../sysv/linux/s390/pthread_mutex_cond_lock.c |  22 ----
 .../sysv/linux/s390/pthread_mutex_timedlock.c |  22 ----
 .../sysv/linux/s390/pthread_mutex_trylock.c   |  22 ----
 sysdeps/unix/sysv/linux/x86/Makefile          |   2 -
 sysdeps/unix/sysv/linux/x86/elision-conf.c    |  25 +----
 sysdeps/unix/sysv/linux/x86/elision-conf.h    |   8 +-
 sysdeps/unix/sysv/linux/x86/elision-lock.c    |   7 +-
 sysdeps/unix/sysv/linux/x86/elision-trylock.c |   1 +
 sysdeps/unix/sysv/linux/x86/elision-unlock.c  |   1 +
 sysdeps/unix/sysv/linux/x86/force-elision.h   |  62 -----------
 sysdeps/unix/sysv/linux/x86/lowlevellock.h    |  24 -----
 .../sysv/linux/x86/pthread_mutex_cond_lock.c  |  22 ----
 .../sysv/linux/x86/pthread_mutex_timedlock.c  |  22 ----
 .../sysv/linux/x86/pthread_mutex_trylock.c    |  22 ----
 46 files changed, 184 insertions(+), 645 deletions(-)
 rename sysdeps/unix/sysv/linux/s390/pthread_mutex_lock.c => nptl/elision-conf.c (79%)
 rename sysdeps/unix/sysv/linux/powerpc/pthread_mutex_lock.c => nptl/elision-lock.c (79%)
 rename sysdeps/unix/sysv/linux/powerpc/pthread_mutex_trylock.c => nptl/elision-timed.c (78%)
 rename sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c => nptl/elision-trylock.c (79%)
 create mode 100644 nptl/elision-unlock.c
 rename sysdeps/{unix/sysv/linux/powerpc/pthread_mutex_timedlock.c => pthread/elision-conf.h} (64%)
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/force-elision.h
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/pthread_mutex_cond_lock.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/force-elision.h
 delete mode 100644 sysdeps/unix/sysv/linux/s390/lowlevellock.h
 delete mode 100644 sysdeps/unix/sysv/linux/s390/pthread_mutex_cond_lock.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/pthread_mutex_timedlock.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/pthread_mutex_trylock.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/force-elision.h
 delete mode 100644 sysdeps/unix/sysv/linux/x86/pthread_mutex_cond_lock.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/pthread_mutex_timedlock.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/pthread_mutex_trylock.c

diff --git a/elf/libc_early_init.c b/elf/libc_early_init.c
index 4755554f12..ce23393d90 100644
--- a/elf/libc_early_init.c
+++ b/elf/libc_early_init.c
@@ -17,8 +17,10 @@
    <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 HAVE_ELISION
+  __lll_elision_init ();
+#endif
 }
diff --git a/nptl/Makefile b/nptl/Makefile
index 4dd9c6a6a8..5f85dd7854 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -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 \
diff --git a/nptl/Versions b/nptl/Versions
index 6cca579a0a..186befebfd 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -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;
   }
 }
diff --git a/sysdeps/unix/sysv/linux/s390/pthread_mutex_lock.c b/nptl/elision-conf.c
similarity index 79%
rename from sysdeps/unix/sysv/linux/s390/pthread_mutex_lock.c
rename to nptl/elision-conf.c
index b193b5b2b0..d71c30a01b 100644
--- a/sysdeps/unix/sysv/linux/s390/pthread_mutex_lock.c
+++ b/nptl/elision-conf.c
@@ -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>
diff --git a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_lock.c b/nptl/elision-lock.c
similarity index 79%
rename from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_lock.c
rename to nptl/elision-lock.c
index 110a6bf47b..a8235cbbea 100644
--- a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_lock.c
+++ b/nptl/elision-lock.c
@@ -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>
diff --git a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_trylock.c b/nptl/elision-timed.c
similarity index 78%
rename from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_trylock.c
rename to nptl/elision-timed.c
index ee9fe1d186..4723197363 100644
--- a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_trylock.c
+++ b/nptl/elision-timed.c
@@ -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>
diff --git a/sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c b/nptl/elision-trylock.c
similarity index 79%
rename from sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c
rename to nptl/elision-trylock.c
index 6e5f1f9964..286a7417fa 100644
--- a/sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c
+++ b/nptl/elision-trylock.c
@@ -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
index 0000000000..552a90ade2
--- /dev/null
+++ b/nptl/elision-unlock.c
@@ -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/>.  */
diff --git a/nptl/lowlevellock.c b/nptl/lowlevellock.c
index 7976c6d8f5..0c0dd0ee00 100644
--- a/nptl/lowlevellock.c
+++ b/nptl/lowlevellock.c
@@ -51,3 +51,8 @@ __lll_lock_wait (int *futex, int private)
     }
 }
 libc_hidden_def (__lll_lock_wait)
+
+#if HAVE_ELISION
+int __pthread_force_elision __attribute__ ((nocommon));
+libc_hidden_data_def (__pthread_force_elision)
+#endif
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index 319658adc4..0e24ae09d7 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -27,15 +27,6 @@
 #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
@@ -52,10 +43,6 @@
 		   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__;
 
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
index 8428ebca0f..5e52a4d856 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -29,19 +29,6 @@
 
 #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,
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index 519727580d..e52dddafbd 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -23,14 +23,6 @@
 #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)
 {
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
index e29bb7fa53..3b5ccdacf9 100644
--- a/nptl/pthread_mutex_unlock.c
+++ b/nptl/pthread_mutex_unlock.c
@@ -24,10 +24,6 @@
 #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__;
diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h
index 176ba96251..c4b32756f9 100644
--- a/sysdeps/nptl/lowlevellock.h
+++ b/sysdeps/nptl/lowlevellock.h
@@ -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.  */
+
+/* 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)
+
+#if HAVE_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 /* !HAVE_ELISION */
+
+#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 /* !HAVE_ELISION */
+
 #endif	/* lowlevellock.h */
diff --git a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_timedlock.c b/sysdeps/pthread/elision-conf.h
similarity index 64%
rename from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_timedlock.c
rename to sysdeps/pthread/elision-conf.h
index 6f8b06d459..6635a7c56f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_timedlock.c
+++ b/sysdeps/pthread/elision-conf.h
@@ -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
@@ -16,7 +16,14 @@
    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 HAVE_ELISION 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
diff --git a/sysdeps/unix/sysv/linux/powerpc/Makefile b/sysdeps/unix/sysv/linux/powerpc/Makefile
index cc2f804d86..a093cda68b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/Makefile
+++ b/sysdeps/unix/sysv/linux/powerpc/Makefile
@@ -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
diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-conf.c b/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
index 003bc82343..1ecc2a7b8f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
+++ b/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
@@ -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
-};
diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-conf.h b/sysdeps/unix/sysv/linux/powerpc/elision-conf.h
index 8c444d8695..1a1bd644ea 100644
--- a/sysdeps/unix/sysv/linux/powerpc/elision-conf.h
+++ b/sysdeps/unix/sysv/linux/powerpc/elision-conf.h
@@ -22,6 +22,9 @@
 #include <pthread.h>
 #include <time.h>
 
+#define HAVE_ELISION 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
diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
index 767d439f88..f5fb46df25 100644
--- a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
+++ b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
@@ -23,12 +23,6 @@
 #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)
diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c b/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
index ab92f4d72f..5ebbced427 100644
--- a/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
+++ b/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
@@ -67,3 +67,4 @@ __lll_trylock_elision (int *futex, short *adapt_count)
 use_lock:
   return lll_trylock (*futex);
 }
+libc_hidden_def (__lll_trylock_elision)
diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c b/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
index 35044af40b..5aa87521c5 100644
--- a/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
+++ b/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
@@ -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
index d1fa611c52..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/force-elision.h
+++ /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
index 65962020c6..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
+++ /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
index f33bac7ca1..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_cond_lock.c
+++ /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>
diff --git a/sysdeps/unix/sysv/linux/s390/Makefile b/sysdeps/unix/sysv/linux/s390/Makefile
index d9db1b5422..3de9579e23 100644
--- a/sysdeps/unix/sysv/linux/s390/Makefile
+++ b/sysdeps/unix/sysv/linux/s390/Makefile
@@ -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)
diff --git a/sysdeps/unix/sysv/linux/s390/elision-conf.c b/sysdeps/unix/sysv/linux/s390/elision-conf.c
index c05c046e56..a7a90e73eb 100644
--- a/sysdeps/unix/sysv/linux/s390/elision-conf.c
+++ b/sysdeps/unix/sysv/linux/s390/elision-conf.c
@@ -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
-};
diff --git a/sysdeps/unix/sysv/linux/s390/elision-conf.h b/sysdeps/unix/sysv/linux/s390/elision-conf.h
index 846c5ff297..3789817c56 100644
--- a/sysdeps/unix/sysv/linux/s390/elision-conf.h
+++ b/sysdeps/unix/sysv/linux/s390/elision-conf.h
@@ -21,6 +21,9 @@
 #include <pthread.h>
 #include <time.h>
 
+#define HAVE_ELISION 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
diff --git a/sysdeps/unix/sysv/linux/s390/elision-lock.c b/sysdeps/unix/sysv/linux/s390/elision-lock.c
index 26474c6398..d5dd6023a0 100644
--- a/sysdeps/unix/sysv/linux/s390/elision-lock.c
+++ b/sysdeps/unix/sysv/linux/s390/elision-lock.c
@@ -23,12 +23,6 @@
 #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)
diff --git a/sysdeps/unix/sysv/linux/s390/elision-trylock.c b/sysdeps/unix/sysv/linux/s390/elision-trylock.c
index 484c3cc913..2470955c89 100644
--- a/sysdeps/unix/sysv/linux/s390/elision-trylock.c
+++ b/sysdeps/unix/sysv/linux/s390/elision-trylock.c
@@ -95,3 +95,4 @@ __lll_trylock_elision (int *futex, short *adapt_count)
      succeed.  */
   return lll_trylock (*futex);
 }
+libc_hidden_def (__lll_trylock_elision)
diff --git a/sysdeps/unix/sysv/linux/s390/elision-unlock.c b/sysdeps/unix/sysv/linux/s390/elision-unlock.c
index 5ac6758df2..87a5bd7cbf 100644
--- a/sysdeps/unix/sysv/linux/s390/elision-unlock.c
+++ b/sysdeps/unix/sysv/linux/s390/elision-unlock.c
@@ -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
index 154740d37f..0000000000
--- a/sysdeps/unix/sysv/linux/s390/force-elision.h
+++ /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
index 98d78f5270..0000000000
--- a/sysdeps/unix/sysv/linux/s390/lowlevellock.h
+++ /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
index 8398ff6425..0000000000
--- a/sysdeps/unix/sysv/linux/s390/pthread_mutex_cond_lock.c
+++ /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
index 8538f157a0..0000000000
--- a/sysdeps/unix/sysv/linux/s390/pthread_mutex_timedlock.c
+++ /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
index c4de1363cb..0000000000
--- a/sysdeps/unix/sysv/linux/s390/pthread_mutex_trylock.c
+++ /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>
diff --git a/sysdeps/unix/sysv/linux/x86/Makefile b/sysdeps/unix/sysv/linux/x86/Makefile
index 6bfd6bec49..9dfdd689a9 100644
--- a/sysdeps/unix/sysv/linux/x86/Makefile
+++ b/sysdeps/unix/sysv/linux/x86/Makefile
@@ -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
diff --git a/sysdeps/unix/sysv/linux/x86/elision-conf.c b/sysdeps/unix/sysv/linux/x86/elision-conf.c
index e8ffe022f0..a5a4043d15 100644
--- a/sysdeps/unix/sysv/linux/x86/elision-conf.c
+++ b/sysdeps/unix/sysv/linux/x86/elision-conf.c
@@ -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
-};
diff --git a/sysdeps/unix/sysv/linux/x86/elision-conf.h b/sysdeps/unix/sysv/linux/x86/elision-conf.h
index bc5e73bd10..78f06ae602 100644
--- a/sysdeps/unix/sysv/linux/x86/elision-conf.h
+++ b/sysdeps/unix/sysv/linux/x86/elision-conf.h
@@ -21,6 +21,9 @@
 #include <pthread.h>
 #include <time.h>
 
+#define HAVE_ELISION 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
diff --git a/sysdeps/unix/sysv/linux/x86/elision-lock.c b/sysdeps/unix/sysv/linux/x86/elision-lock.c
index 16d4f6e4f1..ea5f373c67 100644
--- a/sysdeps/unix/sysv/linux/x86/elision-lock.c
+++ b/sysdeps/unix/sysv/linux/x86/elision-lock.c
@@ -22,12 +22,6 @@
 #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)
diff --git a/sysdeps/unix/sysv/linux/x86/elision-trylock.c b/sysdeps/unix/sysv/linux/x86/elision-trylock.c
index ef9aa23819..5e689f577f 100644
--- a/sysdeps/unix/sysv/linux/x86/elision-trylock.c
+++ b/sysdeps/unix/sysv/linux/x86/elision-trylock.c
@@ -73,3 +73,4 @@ __lll_trylock_elision (int *futex, short *adapt_count)
 
   return lll_trylock (*futex);
 }
+libc_hidden_def (__lll_trylock_elision)
diff --git a/sysdeps/unix/sysv/linux/x86/elision-unlock.c b/sysdeps/unix/sysv/linux/x86/elision-unlock.c
index edd8b1fd08..eb877bc18c 100644
--- a/sysdeps/unix/sysv/linux/x86/elision-unlock.c
+++ b/sysdeps/unix/sysv/linux/x86/elision-unlock.c
@@ -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
index 3c0a0e0ac5..0000000000
--- a/sysdeps/unix/sysv/linux/x86/force-elision.h
+++ /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;								\
-	}								\
-    }
diff --git a/sysdeps/unix/sysv/linux/x86/lowlevellock.h b/sysdeps/unix/sysv/linux/x86/lowlevellock.h
index 435a190ec9..7205bcadfd 100644
--- a/sysdeps/unix/sysv/linux/x86/lowlevellock.h
+++ b/sysdeps/unix/sysv/linux/x86/lowlevellock.h
@@ -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
index 7604f8706f..0000000000
--- a/sysdeps/unix/sysv/linux/x86/pthread_mutex_cond_lock.c
+++ /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
index 3fbfe02690..0000000000
--- a/sysdeps/unix/sysv/linux/x86/pthread_mutex_timedlock.c
+++ /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
index c7abb5ad4f..0000000000
--- a/sysdeps/unix/sysv/linux/x86/pthread_mutex_trylock.c
+++ /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"
-- 
2.29.2


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

* Re: [PATCH 1/6] nptl: Split libpthread-routines into one routine per line
  2021-02-17 17:21 ` [PATCH 1/6] nptl: Split libpthread-routines into one routine per line Florian Weimer
@ 2021-02-22 14:23   ` Adhemerval Zanella
  0 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-02-22 14:23 UTC (permalink / raw)
  To: libc-alpha, Florian Weimer



On 17/02/2021 14:21, Florian Weimer via Libc-alpha wrote:
> And sort the lines lexicographically.  This will make it easier to review
> patches which move symbols from libpthread to libc.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  nptl/Makefile | 238 ++++++++++++++++++++++++++++++++------------------
>  1 file changed, 152 insertions(+), 86 deletions(-)
> 
> diff --git a/nptl/Makefile b/nptl/Makefile
> index 8fb7fee6db..94c3873623 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -85,92 +85,158 @@ pthread-compat-wrappers = \
>  		      sigwait sigsuspend \
>  		      recvmsg sendmsg
>  
> -libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \
> -		      pthread_create pthread_exit pthread_detach \
> -		      pthread_join pthread_tryjoin pthread_timedjoin \
> -		      pthread_clockjoin pthread_join_common pthread_yield \
> -		      pthread_getconcurrency pthread_setconcurrency \
> -		      pthread_setschedprio \
> -		      pthread_attr_getguardsize pthread_attr_setguardsize \
> -		      pthread_attr_getstackaddr pthread_attr_setstackaddr \
> -		      pthread_attr_getstacksize pthread_attr_setstacksize \
> -		      pthread_attr_getstack pthread_attr_setstack \
> -		      pthread_mutex_init pthread_mutex_destroy \
> -		      pthread_mutex_lock pthread_mutex_trylock \
> -		      pthread_mutex_timedlock pthread_mutex_unlock \
> -		      pthread_mutex_cond_lock \
> -		      pthread_mutexattr_init pthread_mutexattr_destroy \
> -		      pthread_mutexattr_getpshared \
> -		      pthread_mutexattr_setpshared \
> -		      pthread_mutexattr_gettype pthread_mutexattr_settype \
> -		      pthread_rwlock_init pthread_rwlock_destroy \
> -		      pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
> -		      pthread_rwlock_clockrdlock \
> -		      pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
> -		      pthread_rwlock_clockwrlock \
> -		      pthread_rwlock_tryrdlock pthread_rwlock_trywrlock \
> -		      pthread_rwlock_unlock \
> -		      pthread_rwlockattr_init pthread_rwlockattr_destroy \
> -		      pthread_rwlockattr_getpshared \
> -		      pthread_rwlockattr_setpshared \
> -		      pthread_rwlockattr_getkind_np \
> -		      pthread_rwlockattr_setkind_np \
> -		      pthread_cond_wait \
> -		      pthread_cond_signal pthread_cond_broadcast \
> -		      old_pthread_cond_wait old_pthread_cond_timedwait \
> -		      old_pthread_cond_signal old_pthread_cond_broadcast \
> -		      pthread_condattr_getpshared pthread_condattr_setpshared \
> -		      pthread_condattr_getclock pthread_condattr_setclock \
> -		      pthread_spin_init pthread_spin_destroy \
> -		      pthread_spin_lock pthread_spin_trylock \
> -		      pthread_spin_unlock \
> -		      pthread_barrier_init pthread_barrier_destroy \
> -		      pthread_barrier_wait \
> -		      pthread_barrierattr_init pthread_barrierattr_destroy \
> -		      pthread_barrierattr_getpshared \
> -		      pthread_barrierattr_setpshared \
> -		      pthread_key_create pthread_key_delete \
> -		      pthread_getspecific pthread_setspecific \
> -		      pthread_kill pthread_sigqueue \
> -		      pthread_cancel pthread_testcancel \
> -		      pthread_setcancelstate pthread_setcanceltype \
> -		      pthread_once \
> -		      old_pthread_atfork \
> -		      pthread_getcpuclockid \
> -		      sem_init sem_destroy sem_routines \
> -		      sem_open sem_close sem_unlink \
> -		      sem_getvalue \
> -		      sem_wait sem_timedwait sem_clockwait sem_post \
> -		      cleanup cleanup_defer cleanup_compat \
> -		      cleanup_defer_compat unwind \
> -		      pt-longjmp pt-cleanup\
> -		      cancellation \
> -		      lowlevellock \
> -		      pt-fork pt-fcntl \
> -		      $(pthread-compat-wrappers) \
> -		      pt-raise pt-system \
> -		      flockfile ftrylockfile funlockfile \
> -		      sigaction \
> -		      herrno res pt-allocrtsig \
> -		      pthread_kill_other_threads \
> -		      pthread_setaffinity \
> -		      pthread_attr_getaffinity \
> -		      pthread_mutexattr_getrobust pthread_mutexattr_setrobust \
> -		      pthread_mutex_consistent \
> -		      cleanup_routine unwind-forcedunwind \
> -		      pthread_mutexattr_getprotocol \
> -		      pthread_mutexattr_setprotocol \
> -		      pthread_mutexattr_getprioceiling \
> -		      pthread_mutexattr_setprioceiling tpp \
> -		      pthread_mutex_getprioceiling \
> -		      pthread_mutex_setprioceiling \
> -		      pthread_setname pthread_getname \
> -		      pthread_setattr_default_np pthread_getattr_default_np \
> -		      pthread_mutex_conf \
> -		      libpthread-compat
> -
> -libpthread-shared-only-routines = version pt-interp pt-allocrtsig \
> -				  unwind-forcedunwind
> +libpthread-routines = \
> +  $(pthread-compat-wrappers) \
> +  cancellation \
> +  cleanup \
> +  cleanup_compat \
> +  cleanup_defer \
> +  cleanup_defer_compat \
> +  cleanup_routine \
> +  events \
> +  flockfile \
> +  ftrylockfile \
> +  funlockfile \
> +  herrno \
> +  libpthread-compat \
> +  lowlevellock \
> +  nptl-init \
> +  nptlfreeres \
> +  old_pthread_atfork \
> +  old_pthread_cond_broadcast \
> +  old_pthread_cond_signal \
> +  old_pthread_cond_timedwait \
> +  old_pthread_cond_wait \
> +  pt-allocrtsig \
> +  pt-cleanup \
> +  pt-fcntl \
> +  pt-fork \
> +  pt-interp \
> +  pt-longjmp \
> +  pt-raise \
> +  pt-system \
> +  pthread_attr_getaffinity \
> +  pthread_attr_getguardsize \
> +  pthread_attr_getstack \
> +  pthread_attr_getstackaddr \
> +  pthread_attr_getstacksize \
> +  pthread_attr_setguardsize \
> +  pthread_attr_setstack \
> +  pthread_attr_setstackaddr \
> +  pthread_attr_setstacksize \
> +  pthread_barrier_destroy \
> +  pthread_barrier_init \
> +  pthread_barrier_wait \
> +  pthread_barrierattr_destroy \
> +  pthread_barrierattr_getpshared \
> +  pthread_barrierattr_init \
> +  pthread_barrierattr_setpshared \
> +  pthread_cancel \
> +  pthread_clockjoin \
> +  pthread_cond_broadcast \
> +  pthread_cond_signal \
> +  pthread_cond_wait \
> +  pthread_condattr_getclock \
> +  pthread_condattr_getpshared \
> +  pthread_condattr_setclock \
> +  pthread_condattr_setpshared \
> +  pthread_create \
> +  pthread_detach \
> +  pthread_exit \
> +  pthread_getattr_default_np \
> +  pthread_getconcurrency \
> +  pthread_getcpuclockid \
> +  pthread_getname \
> +  pthread_getspecific \
> +  pthread_join \
> +  pthread_join_common \
> +  pthread_key_create \
> +  pthread_key_delete \
> +  pthread_kill \
> +  pthread_kill_other_threads \
> +  pthread_mutex_cond_lock \
> +  pthread_mutex_conf \
> +  pthread_mutex_consistent \
> +  pthread_mutex_destroy \
> +  pthread_mutex_getprioceiling \
> +  pthread_mutex_init \
> +  pthread_mutex_lock \
> +  pthread_mutex_setprioceiling \
> +  pthread_mutex_timedlock \
> +  pthread_mutex_trylock \
> +  pthread_mutex_unlock \
> +  pthread_mutexattr_destroy \
> +  pthread_mutexattr_getprioceiling \
> +  pthread_mutexattr_getprotocol \
> +  pthread_mutexattr_getpshared \
> +  pthread_mutexattr_getrobust \
> +  pthread_mutexattr_gettype \
> +  pthread_mutexattr_init \
> +  pthread_mutexattr_setprioceiling \
> +  pthread_mutexattr_setprotocol \
> +  pthread_mutexattr_setpshared \
> +  pthread_mutexattr_setrobust \
> +  pthread_mutexattr_settype \
> +  pthread_once \
> +  pthread_rwlock_clockrdlock \
> +  pthread_rwlock_clockwrlock \
> +  pthread_rwlock_destroy \
> +  pthread_rwlock_init \
> +  pthread_rwlock_rdlock \
> +  pthread_rwlock_timedrdlock \
> +  pthread_rwlock_timedwrlock \
> +  pthread_rwlock_tryrdlock \
> +  pthread_rwlock_trywrlock \
> +  pthread_rwlock_unlock \
> +  pthread_rwlock_wrlock \
> +  pthread_rwlockattr_destroy \
> +  pthread_rwlockattr_getkind_np \
> +  pthread_rwlockattr_getpshared \
> +  pthread_rwlockattr_init \
> +  pthread_rwlockattr_setkind_np \
> +  pthread_rwlockattr_setpshared \
> +  pthread_setaffinity \
> +  pthread_setattr_default_np \
> +  pthread_setcancelstate \
> +  pthread_setcanceltype \
> +  pthread_setconcurrency \
> +  pthread_setname \
> +  pthread_setschedprio \
> +  pthread_setspecific \
> +  pthread_sigqueue \
> +  pthread_spin_destroy \
> +  pthread_spin_init \
> +  pthread_spin_lock \
> +  pthread_spin_trylock \
> +  pthread_spin_unlock \
> +  pthread_testcancel \
> +  pthread_timedjoin \
> +  pthread_tryjoin \
> +  pthread_yield \
> +  res \
> +  sem_clockwait \
> +  sem_close \
> +  sem_destroy \
> +  sem_getvalue \
> +  sem_init \
> +  sem_open \
> +  sem_post \
> +  sem_routines \
> +  sem_timedwait \
> +  sem_unlink \
> +  sem_wait \
> +  sigaction \
> +  tpp \
> +  unwind \
> +  unwind-forcedunwind \
> +  vars \
> +  version \
> +
> +libpthread-shared-only-routines = \
> +  pt-allocrtsig \
> +  pt-interp \
> +  unwind-forcedunwind \
> +  version \
>  
>  # Since cancellation handling is in large parts handled using exceptions
>  # we have to compile some files with exception handling enabled, some
> 

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

* Re: [PATCH 2/6] nptl: Reformat Versions
  2021-02-17 17:21 ` [PATCH 2/6] nptl: Reformat Versions Florian Weimer
@ 2021-02-22 16:31   ` Adhemerval Zanella
  0 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-02-22 16:31 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 17/02/2021 14:21, Florian Weimer via Libc-alpha wrote:
> One symbol per line, lexicographically ordered.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  nptl/Versions | 467 ++++++++++++++++++++++++++++++--------------------
>  1 file changed, 279 insertions(+), 188 deletions(-)
> 
> diff --git a/nptl/Versions b/nptl/Versions
> index 5db713d1ae..7254ca4750 100644
> --- a/nptl/Versions
> +++ b/nptl/Versions
> @@ -1,21 +1,36 @@
>  libc {
>    GLIBC_2.0 {
> -    pthread_attr_destroy; pthread_attr_init;
> -    pthread_attr_getdetachstate; pthread_attr_setdetachstate;
> -    pthread_attr_getinheritsched; pthread_attr_setinheritsched;
> -    pthread_attr_getschedparam; pthread_attr_setschedparam;
> -    pthread_attr_getschedpolicy;  pthread_attr_setschedpolicy;
> -    pthread_attr_getscope; pthread_attr_setscope;
> -    pthread_condattr_destroy; pthread_condattr_init;
> -    pthread_cond_broadcast; pthread_cond_destroy;
> -    pthread_cond_init; pthread_cond_signal; pthread_cond_wait;
> +    pthread_attr_destroy;
> +    pthread_attr_getdetachstate;
> +    pthread_attr_getinheritsched;
> +    pthread_attr_getschedparam;
> +    pthread_attr_getschedpolicy;
> +    pthread_attr_getscope;
> +    pthread_attr_init;
> +    pthread_attr_setdetachstate;
> +    pthread_attr_setinheritsched;
> +    pthread_attr_setschedparam;
> +    pthread_attr_setschedpolicy;
> +    pthread_attr_setscope;
> +    pthread_cond_broadcast;
> +    pthread_cond_destroy;
> +    pthread_cond_init;
> +    pthread_cond_signal;
>      pthread_cond_timedwait;
> -    pthread_equal; pthread_exit;
> -    pthread_getschedparam; pthread_setschedparam;
> -    pthread_mutex_destroy; pthread_mutex_init;
> -    pthread_mutex_lock; pthread_mutex_unlock;
> +    pthread_cond_wait;
> +    pthread_condattr_destroy;
> +    pthread_condattr_init;
> +    pthread_equal;
> +    pthread_exit;
> +    pthread_getschedparam;
> +    pthread_mutex_destroy;
> +    pthread_mutex_init;
> +    pthread_mutex_lock;
> +    pthread_mutex_unlock;
>      pthread_self;
> -    pthread_setcancelstate; pthread_setcanceltype;
> +    pthread_setcancelstate;
> +    pthread_setcanceltype;
> +    pthread_setschedparam;
>      pthread_sigmask;
>    }
>    GLIBC_2.1 {
> @@ -26,11 +41,12 @@ libc {
>    }
>    GLIBC_2.3.2 {
>      __register_atfork;
> -
> -    # Changed pthread_cond_t.
> -    pthread_cond_init; pthread_cond_destroy;
> -    pthread_cond_wait; pthread_cond_signal;
> -    pthread_cond_broadcast; pthread_cond_timedwait;
> +    pthread_cond_broadcast;
> +    pthread_cond_destroy;
> +    pthread_cond_init;
> +    pthread_cond_signal;
> +    pthread_cond_timedwait;
> +    pthread_cond_wait;
>    }
>    GLIBC_2.3.3 {
>      pthread_attr_setaffinity_np;
> @@ -41,7 +57,10 @@ libc {
>    }
>    # C11 thread symbols.
>    GLIBC_2.28 {
> -    thrd_current; thrd_equal; thrd_sleep; thrd_yield;
> +    thrd_current;
> +    thrd_equal;
> +    thrd_sleep;
> +    thrd_yield;
>    }
>    GLIBC_2.32 {
>      pthread_attr_getsigmask_np;
> @@ -53,114 +72,164 @@ libc {
>    }
>    GLIBC_PRIVATE {
>      __libc_alloca_cutoff;
> -    # Internal libc interface to libpthread
> +    __libc_allocate_rtsig_private;
> +    __libc_current_sigrtmax_private;
> +    __libc_current_sigrtmin_private;
>      __libc_dl_error_tsd;
>      __libc_pthread_init;
> -    __libc_current_sigrtmin_private; __libc_current_sigrtmax_private;
> -    __libc_allocate_rtsig_private;
> -    # Used by the C11 threads implementation.
> -    __pthread_cond_destroy; __pthread_cond_init;
> -    __pthread_attr_setaffinity_np;
> -    __pthread_attr_init; __pthread_attr_destroy;
>      __pthread_attr_copy;
> -    __pthread_getattr_default_np;
> +    __pthread_attr_destroy;
> +    __pthread_attr_init;
> +    __pthread_attr_setaffinity_np;
>      __pthread_attr_setsigmask_internal;
> +    __pthread_cond_destroy; # Used by the C11 threads.
> +    __pthread_cond_init; # Used by the C11 threads.
> +    __pthread_getattr_default_np;
>    }
>  }
>  
>  libpthread {
>    GLIBC_2.0 {
> -    pthread_create; pthread_join;
> -    pthread_exit; pthread_detach;
> -
> -    pthread_mutex_init; pthread_mutex_destroy;
> -    pthread_mutex_lock; pthread_mutex_trylock; pthread_mutex_unlock;
> -
> -    pthread_mutexattr_init; pthread_mutexattr_destroy;
> -
> -    pthread_cond_wait; pthread_cond_timedwait;
> -    pthread_cond_signal; pthread_cond_broadcast;
> -
> -    pthread_cancel; pthread_testcancel;
> -    pthread_setcancelstate; pthread_setcanceltype;
> -
> -    pthread_sigmask; pthread_kill;
> -
> -    pthread_key_create; pthread_key_delete;
> -    pthread_getspecific; pthread_setspecific;
> -
> -    pthread_once;
> -
> -    pthread_atfork;
> -
> -    flockfile; funlockfile; ftrylockfile;
> -
> -    # Non-standard POSIX1.x functions.
> -    pthread_mutexattr_getkind_np; pthread_mutexattr_setkind_np;
> -
> -    # Protected names for functions used in other shared objects.
> -    __pthread_mutex_init; __pthread_mutex_destroy;
> -    __pthread_mutex_lock; __pthread_mutex_trylock; __pthread_mutex_unlock;
> -    __pthread_mutexattr_init; __pthread_mutexattr_destroy;
> +    _Exit;
> +    _IO_flockfile;
> +    _IO_ftrylockfile;
> +    _IO_funlockfile;
> +    __close;
> +    __connect;
> +    __errno_location;
> +    __fcntl;
> +    __fork;
> +    __h_errno_location;
> +    __lseek;
> +    __open;
> +    __pthread_atfork;
> +    __pthread_getspecific;
> +    __pthread_key_create;
> +    __pthread_mutex_destroy;
> +    __pthread_mutex_init;
> +    __pthread_mutex_lock;
> +    __pthread_mutex_trylock;
> +    __pthread_mutex_unlock;
> +    __pthread_mutexattr_destroy;
> +    __pthread_mutexattr_init;
>      __pthread_mutexattr_settype;
> -    __pthread_key_create; __pthread_getspecific; __pthread_setspecific;
> -    __pthread_once; __pthread_atfork;
> -    _IO_flockfile; _IO_ftrylockfile; _IO_funlockfile;
> -
> -    # Semaphores.
> -    sem_destroy; sem_getvalue; sem_init; sem_post; sem_trywait; sem_wait;
> -
> -    # Special fork handling.
> -    fork; __fork;
> -
> -    # Cancellation points.
> -    close; __close; fcntl; __fcntl; read; __read; write; __write; accept;
> -    connect; __connect; recv; recvfrom; recvmsg; send; __send; sendmsg; sendto;
> -    fsync; lseek; __lseek; msync; open; __open; pause; tcdrain;
> -    system;
> -
> -    # Hidden entry point (through macros).
> -    _pthread_cleanup_push; _pthread_cleanup_pop;
> -    _pthread_cleanup_push_defer; _pthread_cleanup_pop_restore;
> -
> +    __pthread_once;
> +    __pthread_setspecific;
> +    __read;
> +    __send;
> +    __sigaction;
> +    __write;
> +    _exit;
> +    _pthread_cleanup_pop;
> +    _pthread_cleanup_pop_restore;
> +    _pthread_cleanup_push;
> +    _pthread_cleanup_push_defer;
> +    accept;
> +    close;
> +    connect;
> +    fcntl;
> +    flockfile;
> +    fork;
> +    fsync;
> +    ftrylockfile;
> +    funlockfile;
> +    longjmp;
> +    lseek;
> +    msync;
> +    open;
> +    pause;
> +    pthread_atfork;
> +    pthread_cancel;
> +    pthread_cond_broadcast;
> +    pthread_cond_signal;
> +    pthread_cond_timedwait;
> +    pthread_cond_wait;
> +    pthread_create;
> +    pthread_detach;
> +    pthread_exit;
> +    pthread_getspecific;
> +    pthread_join;
> +    pthread_key_create;
> +    pthread_key_delete;
> +    pthread_kill;
>      pthread_kill_other_threads_np;
> -
> -    # The error functions.
> -    __errno_location; __h_errno_location;
> -
> -    # Functions which previously have been overwritten.
> -    sigwait; sigaction; __sigaction; _exit; _Exit; longjmp; siglongjmp;
> +    pthread_mutex_destroy;
> +    pthread_mutex_init;
> +    pthread_mutex_lock;
> +    pthread_mutex_trylock;
> +    pthread_mutex_unlock;
> +    pthread_mutexattr_destroy;
> +    pthread_mutexattr_getkind_np;
> +    pthread_mutexattr_init;
> +    pthread_mutexattr_setkind_np;
> +    pthread_once;
> +    pthread_setcancelstate;
> +    pthread_setcanceltype;
> +    pthread_setspecific;
> +    pthread_sigmask;
> +    pthread_testcancel;
>      raise;
> +    read;
> +    recv;
> +    recvfrom;
> +    recvmsg;
> +    sem_destroy;
> +    sem_getvalue;
> +    sem_init;
> +    sem_post;
> +    sem_trywait;
> +    sem_wait;
> +    send;
> +    sendmsg;
> +    sendto;
> +    sigaction;
> +    siglongjmp;
> +    sigwait;
> +    system;
> +    tcdrain;
> +    write;
>    }
>  
>    GLIBC_2.1 {
> -    pthread_create;
> -
> -    pthread_attr_getguardsize; pthread_attr_setguardsize;
> -    pthread_attr_getstackaddr; pthread_attr_setstackaddr;
> -    pthread_attr_getstacksize; pthread_attr_setstacksize;
> -
> -    pthread_mutexattr_gettype; pthread_mutexattr_settype;
> -
> -    pthread_rwlock_init; pthread_rwlock_destroy;
> -    pthread_rwlock_rdlock; pthread_rwlock_wrlock; pthread_rwlock_unlock;
> -    pthread_rwlock_tryrdlock; pthread_rwlock_trywrlock;
> -
> -    pthread_rwlockattr_init; pthread_rwlockattr_destroy;
> -    pthread_rwlockattr_getpshared; pthread_rwlockattr_setpshared;
> -    pthread_rwlockattr_getkind_np; pthread_rwlockattr_setkind_np;
> -
> -    pthread_getconcurrency; pthread_setconcurrency;
> -
> -    # Semaphores.
> -    sem_destroy; sem_getvalue; sem_init; sem_post; sem_trywait; sem_wait;
> -
> -    __libc_current_sigrtmin; __libc_current_sigrtmax;
>      __libc_allocate_rtsig;
> +    __libc_current_sigrtmax;
> +    __libc_current_sigrtmin;
> +    pthread_attr_getguardsize;
> +    pthread_attr_getstackaddr;
> +    pthread_attr_getstacksize;
> +    pthread_attr_setguardsize;
> +    pthread_attr_setstackaddr;
> +    pthread_attr_setstacksize;
> +    pthread_create;
> +    pthread_getconcurrency;
> +    pthread_mutexattr_gettype;
> +    pthread_mutexattr_settype;
> +    pthread_rwlock_destroy;
> +    pthread_rwlock_init;
> +    pthread_rwlock_rdlock;
> +    pthread_rwlock_tryrdlock;
> +    pthread_rwlock_trywrlock;
> +    pthread_rwlock_unlock;
> +    pthread_rwlock_wrlock;
> +    pthread_rwlockattr_destroy;
> +    pthread_rwlockattr_getkind_np;
> +    pthread_rwlockattr_getpshared;
> +    pthread_rwlockattr_init;
> +    pthread_rwlockattr_setkind_np;
> +    pthread_rwlockattr_setpshared;
> +    pthread_setconcurrency;
> +    sem_destroy;
> +    sem_getvalue;
> +    sem_init;
> +    sem_post;
> +    sem_trywait;
> +    sem_wait;
>    }
>  
>    GLIBC_2.1.1 {
> -    sem_close; sem_open; sem_unlink;
> +    sem_close;
> +    sem_open;
> +    sem_unlink;
>    }
>  
>    GLIBC_2.1.2 {
> @@ -168,41 +237,46 @@ libpthread {
>    }
>  
>    GLIBC_2.2 {
> -    pthread_mutexattr_getpshared; pthread_mutexattr_setpshared;
> -
> -    pthread_condattr_getpshared; pthread_condattr_setpshared;
> -
> -    # New functions from IEEE Std. 1003.1-2001.
> -    pthread_mutex_timedlock;
> -
> -    pthread_rwlock_timedrdlock; pthread_rwlock_timedwrlock;
> -
> -    pthread_attr_getstack; pthread_attr_setstack;
> -
> -    pthread_spin_destroy; pthread_spin_init; pthread_spin_lock;
> -    pthread_spin_trylock; pthread_spin_unlock;
> -
> -    pthread_barrier_init; pthread_barrier_destroy; pthread_barrier_wait;
> -    pthread_barrierattr_destroy; pthread_barrierattr_init;
> -    pthread_barrierattr_setpshared;
> -
> -    sem_timedwait;
> -
> -    pthread_yield;
> -
> -    pthread_getcpuclockid;
> -
> -    # Cancellation points.
> -    lseek64; open64; __open64; pread; pread64; __pread64; pwrite; pwrite64;
> -    __pwrite64;
> -
> -    # Names used internally.
> -    __pthread_rwlock_init; __pthread_rwlock_destroy;
> -    __pthread_rwlock_rdlock; __pthread_rwlock_tryrdlock;
> -    __pthread_rwlock_wrlock; __pthread_rwlock_trywrlock;
> +    __open64;
> +    __pread64;
> +    __pthread_rwlock_destroy;
> +    __pthread_rwlock_init;
> +    __pthread_rwlock_rdlock;
> +    __pthread_rwlock_tryrdlock;
> +    __pthread_rwlock_trywrlock;
>      __pthread_rwlock_unlock;
> -
> +    __pthread_rwlock_wrlock;
> +    __pwrite64;
>      __res_state;
> +    lseek64;
> +    open64;
> +    pread64;
> +    pread;
> +    pthread_attr_getstack;
> +    pthread_attr_setstack;
> +    pthread_barrier_destroy;
> +    pthread_barrier_init;
> +    pthread_barrier_wait;
> +    pthread_barrierattr_destroy;
> +    pthread_barrierattr_init;
> +    pthread_barrierattr_setpshared;
> +    pthread_condattr_getpshared;
> +    pthread_condattr_setpshared;
> +    pthread_getcpuclockid;
> +    pthread_mutex_timedlock;
> +    pthread_mutexattr_getpshared;
> +    pthread_mutexattr_setpshared;
> +    pthread_rwlock_timedrdlock;
> +    pthread_rwlock_timedwrlock;
> +    pthread_spin_destroy;
> +    pthread_spin_init;
> +    pthread_spin_lock;
> +    pthread_spin_trylock;
> +    pthread_spin_unlock;
> +    pthread_yield;
> +    pwrite64;
> +    pwrite;
> +    sem_timedwait;
>    }
>  
>    GLIBC_2.2.3 {
> @@ -214,47 +288,46 @@ libpthread {
>    }
>  
>    GLIBC_2.3.2 {
> -    # Changed pthread_cond_t.
> +    pthread_cond_broadcast;
>      pthread_cond_init;
> -    pthread_cond_wait; pthread_cond_timedwait;
> -    pthread_cond_signal; pthread_cond_broadcast;
> +    pthread_cond_signal;
> +    pthread_cond_timedwait;
> +    pthread_cond_wait;
>    }
>  
>    GLIBC_2.3.3 {
> -    # 1003.1-2001 function accidentally left out in 2.2.
> -    pthread_barrierattr_getpshared;
> -
> -    # Unix CS option.
> -    pthread_condattr_getclock; pthread_condattr_setclock;
> -
> -    # Proposed API extensions.
> -    pthread_tryjoin_np; pthread_timedjoin_np;
> -
> -    # New cancellation cleanup handling.
> -    __pthread_register_cancel; __pthread_unregister_cancel;
> -    __pthread_register_cancel_defer; __pthread_unregister_cancel_restore;
> -    __pthread_unwind_next;
>      __pthread_cleanup_routine;
> -
> -    # affinity interfaces without size parameter
> -    pthread_setaffinity_np;
> +    __pthread_register_cancel;
> +    __pthread_register_cancel_defer;
> +    __pthread_unregister_cancel;
> +    __pthread_unregister_cancel_restore;
> +    __pthread_unwind_next;
>      pthread_attr_getaffinity_np;
> +    pthread_barrierattr_getpshared;
> +    pthread_condattr_getclock;
> +    pthread_condattr_setclock;
> +    pthread_setaffinity_np;
> +    pthread_timedjoin_np;
> +    pthread_tryjoin_np;
>    }
>  
>    GLIBC_2.3.4 {
> -    # New affinity interfaces.
> -    pthread_getaffinity_np; pthread_setaffinity_np;
>      pthread_attr_getaffinity_np;
> -
> +    pthread_getaffinity_np;
> +    pthread_setaffinity_np;
>      pthread_setschedprio;
>    }
>  
>    GLIBC_2.4 {
> -    pthread_mutexattr_getrobust_np; pthread_mutexattr_setrobust_np;
>      pthread_mutex_consistent_np;
> -    pthread_mutexattr_getprotocol; pthread_mutexattr_setprotocol;
> -    pthread_mutexattr_getprioceiling; pthread_mutexattr_setprioceiling;
> -    pthread_mutex_getprioceiling; pthread_mutex_setprioceiling;
> +    pthread_mutex_getprioceiling;
> +    pthread_mutex_setprioceiling;
> +    pthread_mutexattr_getprioceiling;
> +    pthread_mutexattr_getprotocol;
> +    pthread_mutexattr_getrobust_np;
> +    pthread_mutexattr_setprioceiling;
> +    pthread_mutexattr_setprotocol;
> +    pthread_mutexattr_setrobust_np;
>    };
>  
>    GLIBC_2.11 {
> @@ -262,10 +335,11 @@ libpthread {
>    };
>  
>    GLIBC_2.12 {
> -    pthread_mutex_consistent; pthread_mutexattr_getrobust;
> +    pthread_getname_np;
> +    pthread_mutex_consistent;
> +    pthread_mutexattr_getrobust;
>      pthread_mutexattr_setrobust;
> -
> -    pthread_setname_np; pthread_getname_np;
> +    pthread_setname_np;
>    };
>  
>    GLIBC_2.18 {
> @@ -273,24 +347,37 @@ libpthread {
>      pthread_setattr_default_np;
>    }
>  
> -  GLIBC_2.20 {
> -  }
> -
> -  GLIBC_2.22 {
> -  }
> -
>    # C11 thread symbols.
>    GLIBC_2.28 {
> -    thrd_create; thrd_detach; thrd_exit; thrd_join;
> -    mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; mtx_unlock; mtx_destroy;
> -    call_once; cnd_broadcast; cnd_destroy; cnd_init; cnd_signal;
> -    cnd_timedwait; cnd_wait; tss_create; tss_delete; tss_get; tss_set;
> +    call_once;
> +    cnd_broadcast;
> +    cnd_destroy;
> +    cnd_init;
> +    cnd_signal;
> +    cnd_timedwait;
> +    cnd_wait;
> +    mtx_destroy;
> +    mtx_init;
> +    mtx_lock;
> +    mtx_timedlock;
> +    mtx_trylock;
> +    mtx_unlock;
> +    thrd_create;
> +    thrd_detach;
> +    thrd_exit;
> +    thrd_join;
> +    tss_create;
> +    tss_delete;
> +    tss_get;
> +    tss_set;
>    }
>  
>    GLIBC_2.30 {
> -    sem_clockwait; pthread_cond_clockwait;
> -    pthread_rwlock_clockrdlock; pthread_rwlock_clockwrlock;
> +    pthread_cond_clockwait;
>      pthread_mutex_clocklock;
> +    pthread_rwlock_clockrdlock;
> +    pthread_rwlock_clockwrlock;
> +    sem_clockwait;
>    }
>  
>    GLIBC_2.31 {
> @@ -298,11 +385,15 @@ libpthread {
>    }
>  
>    GLIBC_PRIVATE {
> -    __pthread_initialize_minimal;
> -    __pthread_clock_gettime; __pthread_clock_settime;
> -    __pthread_unwind; __pthread_get_minstack;
> -    __pthread_barrier_init; __pthread_barrier_wait;
> -    __futex_abstimed_wait64; __futex_abstimed_wait_cancelable64;
> +    __futex_abstimed_wait64;
> +    __futex_abstimed_wait_cancelable64;
>      __libpthread_freeres;
> +    __pthread_barrier_init;
> +    __pthread_barrier_wait;
> +    __pthread_clock_gettime;
> +    __pthread_clock_settime;
> +    __pthread_get_minstack;
> +    __pthread_initialize_minimal;
> +    __pthread_unwind;
>    }
>  }
> 

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

* Re: [PATCH 3/6] nptl: Move futex-internal.c into main nptl directory
  2021-02-17 17:21 ` [PATCH 3/6] nptl: Move futex-internal.c into main nptl directory Florian Weimer
@ 2021-02-22 16:34   ` Adhemerval Zanella
  0 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-02-22 16:34 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

On 17/02/2021 14:21, Florian Weimer via Libc-alpha wrote:
> ---
>  nptl/Makefile                           | 3 +++
>  {sysdeps/nptl => nptl}/futex-internal.c | 0
>  sysdeps/nptl/Makefile                   | 3 +--
>  3 files changed, 4 insertions(+), 2 deletions(-)
>  rename {sysdeps/nptl => nptl}/futex-internal.c (100%)
> 
> diff --git a/nptl/Makefile b/nptl/Makefile
> index 94c3873623..5a7558d943 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -97,6 +97,7 @@ libpthread-routines = \
>    flockfile \
>    ftrylockfile \
>    funlockfile \
> +  futex-internal \
>    herrno \
>    libpthread-compat \
>    lowlevellock \
> @@ -314,6 +315,8 @@ CFLAGS-fsync.c += -fexceptions -fasynchronous-unwind-tables
>  
>  CFLAGS-pt-system.c += -fexceptions
>  
> +CFLAGS-futex-internal.c += -fexceptions -fasynchronous-unwind-tables
> +
>  LDLIBS-tst-once5 = -lstdc++
>  CFLAGS-tst-thread_local1.o = -std=gnu++11
>  LDLIBS-tst-thread_local1 = -lstdc++

Ok.

> diff --git a/sysdeps/nptl/futex-internal.c b/nptl/futex-internal.c
> similarity index 100%
> rename from sysdeps/nptl/futex-internal.c
> rename to nptl/futex-internal.c

Ok.

> diff --git a/sysdeps/nptl/Makefile b/sysdeps/nptl/Makefile
> index bdba75d85f..adcced422b 100644
> --- a/sysdeps/nptl/Makefile
> +++ b/sysdeps/nptl/Makefile
> @@ -17,8 +17,7 @@
>  # <https://www.gnu.org/licenses/>.
>  
>  ifeq ($(subdir),nptl)
> -libpthread-sysdep_routines += errno-loc futex-internal
> -CFLAGS-futex-internal.c += -fexceptions -fasynchronous-unwind-tables
> +libpthread-sysdep_routines += errno-loc
>  endif
>  
>  ifeq ($(subdir),rt)
> 

Ok

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

* Re: [PATCH 4/6] nptl: Move lowlevellock into libc
  2021-02-17 17:21 ` [PATCH 4/6] nptl: Move lowlevellock into libc Florian Weimer
@ 2021-02-22 16:38   ` Adhemerval Zanella
  2021-02-22 16:46     ` Florian Weimer
  0 siblings, 1 reply; 15+ messages in thread
From: Adhemerval Zanella @ 2021-02-22 16:38 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 17/02/2021 14:21, Florian Weimer via Libc-alpha wrote:
> And export __lll_lock_wait and __lll_lock_wait_private as
> GLIBC_PRIVATE.  This should eliminate the need for the previous
> riscv kludge.

Should it mark BZ#15648 as fixed (Carlos has opened BZ#15658 to track
the LTO issue)?

LGTM, thanks

> ---
>  nptl/Makefile                          |  3 +--
>  nptl/Versions                          |  2 ++
>  nptl/libc-lowlevellock.c               | 20 --------------------
>  nptl/lowlevellock.c                    |  6 ++----
>  sysdeps/nptl/lowlevellock.h            |  6 ++++--
>  sysdeps/riscv/nptl/libc-lowlevellock.c |  8 --------
>  6 files changed, 9 insertions(+), 36 deletions(-)
>  delete mode 100644 nptl/libc-lowlevellock.c
>  delete mode 100644 sysdeps/riscv/nptl/libc-lowlevellock.c
> 
> diff --git a/nptl/Makefile b/nptl/Makefile
> index 5a7558d943..62f368af1e 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -33,9 +33,9 @@ routines = \
>    forward \
>    libc-cancellation \
>    libc-cleanup \
> -  libc-lowlevellock \
>    libc_multiple_threads \
>    libc_pthread_init \
> +  lowlevellock \
>    old_pthread_cond_destroy \
>    old_pthread_cond_init \
>    pthread_atfork \

Ok.

> @@ -100,7 +100,6 @@ libpthread-routines = \
>    futex-internal \
>    herrno \
>    libpthread-compat \
> -  lowlevellock \
>    nptl-init \
>    nptlfreeres \
>    old_pthread_atfork \

Ok.

> diff --git a/nptl/Versions b/nptl/Versions
> index 7254ca4750..694747bb44 100644
> --- a/nptl/Versions
> +++ b/nptl/Versions
> @@ -77,6 +77,8 @@ libc {
>      __libc_current_sigrtmin_private;
>      __libc_dl_error_tsd;
>      __libc_pthread_init;
> +    __lll_lock_wait;
> +    __lll_lock_wait_private;
>      __pthread_attr_copy;
>      __pthread_attr_destroy;
>      __pthread_attr_init;

Ok.

> diff --git a/nptl/libc-lowlevellock.c b/nptl/libc-lowlevellock.c
> deleted file mode 100644
> index e840399c41..0000000000
> --- a/nptl/libc-lowlevellock.c
> +++ /dev/null
> @@ -1,20 +0,0 @@
> -/* Copyright (C) 2003-2021 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -   Contributed by Paul Mackerras <paulus@au.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/>.  */
> -
> -/* No difference to lowlevellock.c, except we lose a couple of functions.  */
> -#include <lowlevellock.c>

Ok.

> diff --git a/nptl/lowlevellock.c b/nptl/lowlevellock.c
> index 1ea397d5cb..7976c6d8f5 100644
> --- a/nptl/lowlevellock.c
> +++ b/nptl/lowlevellock.c
> @@ -35,10 +35,8 @@ __lll_lock_wait_private (int *futex)
>        futex_wait ((unsigned int *) futex, 2, LLL_PRIVATE); /* Wait if *futex == 2.  */
>      }
>  }
> +libc_hidden_def (__lll_lock_wait_private)
>  
> -
> -/* This function doesn't get included in libc.  */
> -#if IS_IN (libpthread)
>  void
>  __lll_lock_wait (int *futex, int private)
>  {
> @@ -52,4 +50,4 @@ __lll_lock_wait (int *futex, int private)
>        futex_wait ((unsigned int *) futex, 2, private); /* Wait if *futex == 2.  */
>      }
>  }
> -#endif
> +libc_hidden_def (__lll_lock_wait)

Ok.

> diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h
> index 0a2b413f86..176ba96251 100644
> --- a/sysdeps/nptl/lowlevellock.h
> +++ b/sysdeps/nptl/lowlevellock.h
> @@ -75,8 +75,10 @@
>  #define lll_cond_trylock(lock)	\
>    __glibc_unlikely (atomic_compare_and_exchange_bool_acq (&(lock), 2, 0))
>  
> -extern void __lll_lock_wait_private (int *futex) attribute_hidden;
> -extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
> +extern void __lll_lock_wait_private (int *futex);
> +libc_hidden_proto (__lll_lock_wait_private)
> +extern void __lll_lock_wait (int *futex, int private);
> +libc_hidden_proto (__lll_lock_wait)
>  
>  /* This is an expression rather than a statement even though its value is
>     void, so that it can be used in a comma expression or as an expression

Ok.

> diff --git a/sysdeps/riscv/nptl/libc-lowlevellock.c b/sysdeps/riscv/nptl/libc-lowlevellock.c
> deleted file mode 100644
> index 9523fb46a5..0000000000
> --- a/sysdeps/riscv/nptl/libc-lowlevellock.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -/* This kludge works around a libpthread static linking problem:
> -   https://sourceware.org/bugzilla/show_bug.cgi?id=15648.  */
> -
> -#ifndef SHARED
> -# define __lll_lock_wait_private weak_function __lll_lock_wait_private
> -#endif
> -
> -#include <lowlevellock.c>
> 

Ok.

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

* Re: [PATCH 5/6] nptl: Move futex-internal into libc
  2021-02-17 17:21 ` [PATCH 5/6] nptl: Move futex-internal " Florian Weimer
@ 2021-02-22 16:39   ` Adhemerval Zanella
  0 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-02-22 16:39 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 17/02/2021 14:21, Florian Weimer via Libc-alpha wrote:
> This moves  __futex_abstimed_wait64 and
> __futex_abstimed_wait_cancelable64 and exports these functions as
> GLIBC_PRIVATE.


LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  nptl/Makefile                 | 2 +-
>  nptl/Versions                 | 4 ++--
>  nptl/futex-internal.c         | 4 ++--
>  sysdeps/nptl/futex-internal.h | 4 ++--
>  4 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/nptl/Makefile b/nptl/Makefile
> index 62f368af1e..4dd9c6a6a8 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -31,6 +31,7 @@ extra-libs-others := $(extra-libs)
>  routines = \
>    alloca_cutoff \
>    forward \
> +  futex-internal \
>    libc-cancellation \
>    libc-cleanup \
>    libc_multiple_threads \
> @@ -97,7 +98,6 @@ libpthread-routines = \
>    flockfile \
>    ftrylockfile \
>    funlockfile \
> -  futex-internal \
>    herrno \
>    libpthread-compat \
>    nptl-init \

Ok.

> diff --git a/nptl/Versions b/nptl/Versions
> index 694747bb44..6cca579a0a 100644
> --- a/nptl/Versions
> +++ b/nptl/Versions
> @@ -71,6 +71,8 @@ libc {
>      pthread_sigmask;
>    }
>    GLIBC_PRIVATE {
> +    __futex_abstimed_wait64;
> +    __futex_abstimed_wait_cancelable64;
>      __libc_alloca_cutoff;
>      __libc_allocate_rtsig_private;
>      __libc_current_sigrtmax_private;

Ok.

> @@ -387,8 +389,6 @@ libpthread {
>    }
>  
>    GLIBC_PRIVATE {
> -    __futex_abstimed_wait64;
> -    __futex_abstimed_wait_cancelable64;
>      __libpthread_freeres;
>      __pthread_barrier_init;
>      __pthread_barrier_wait;

Ok.

> diff --git a/nptl/futex-internal.c b/nptl/futex-internal.c
> index 89b4ba76e9..850bf4fd83 100644
> --- a/nptl/futex-internal.c
> +++ b/nptl/futex-internal.c
> @@ -112,7 +112,7 @@ __futex_abstimed_wait64 (unsigned int* futex_word, unsigned int expected,
>    return __futex_abstimed_wait_common64 (futex_word, expected, clockid,
>                                           abstime, private, false);
>  }
> -libpthread_hidden_def (__futex_abstimed_wait64)
> +libc_hidden_def (__futex_abstimed_wait64)
>  
>  int
>  __futex_abstimed_wait_cancelable64 (unsigned int* futex_word,
> @@ -123,4 +123,4 @@ __futex_abstimed_wait_cancelable64 (unsigned int* futex_word,
>    return __futex_abstimed_wait_common64 (futex_word, expected, clockid,
>                                           abstime, private, true);
>  }
> -libpthread_hidden_def (__futex_abstimed_wait_cancelable64)
> +libc_hidden_def (__futex_abstimed_wait_cancelable64)

Ok.

> diff --git a/sysdeps/nptl/futex-internal.h b/sysdeps/nptl/futex-internal.h
> index 4c192c99e3..969ab2bf4b 100644
> --- a/sysdeps/nptl/futex-internal.h
> +++ b/sysdeps/nptl/futex-internal.h
> @@ -345,14 +345,14 @@ __futex_abstimed_wait_cancelable64 (unsigned int* futex_word,
>                                      unsigned int expected, clockid_t clockid,
>                                      const struct __timespec64* abstime,
>                                      int private);
> -libpthread_hidden_proto (__futex_abstimed_wait_cancelable64);
> +libc_hidden_proto (__futex_abstimed_wait_cancelable64);
>  
>  int
>  __futex_abstimed_wait64 (unsigned int* futex_word, unsigned int expected,
>                           clockid_t clockid,
>                           const struct __timespec64* abstime,
>                           int private);
> -libpthread_hidden_proto (__futex_abstimed_wait64);
> +libc_hidden_proto (__futex_abstimed_wait64);
>  
>  
>  static __always_inline int
> 

Ok.

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

* Re: [PATCH 4/6] nptl: Move lowlevellock into libc
  2021-02-22 16:38   ` Adhemerval Zanella
@ 2021-02-22 16:46     ` Florian Weimer
  0 siblings, 0 replies; 15+ messages in thread
From: Florian Weimer @ 2021-02-22 16:46 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> On 17/02/2021 14:21, Florian Weimer via Libc-alpha wrote:
>> And export __lll_lock_wait and __lll_lock_wait_private as
>> GLIBC_PRIVATE.  This should eliminate the need for the previous
>> riscv kludge.
>
> Should it mark BZ#15648 as fixed (Carlos has opened BZ#15658 to track
> the LTO issue)?

Makes sense, I've added the [BZ #15648] reference.  The multiple
definition issue will definitely be gone after this change.

Thanks,
Florian


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

* Re: [PATCH 6/6] nptl: Move elision implementations into libc
  2021-02-17 17:22 ` [PATCH 6/6] nptl: Move elision implementations " Florian Weimer
@ 2021-02-22 16:53   ` Adhemerval Zanella
  2021-02-22 17:02     ` Florian Weimer
  0 siblings, 1 reply; 15+ messages in thread
From: Adhemerval Zanella @ 2021-02-22 16:53 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 17/02/2021 14:22, Florian Weimer via Libc-alpha wrote:
> 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.)

LGTM, some comments below.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  elf/libc_early_init.c                         |   6 ++
>  nptl/Makefile                                 |   5 +
>  nptl/Versions                                 |   5 +
>  .../elision-conf.c                            |   9 +-
>  .../elision-lock.c                            |   9 +-
>  .../elision-timed.c                           |   9 +-
>  .../elision-trylock.c                         |   9 +-
>  nptl/elision-unlock.c                         |  17 +++
>  nptl/lowlevellock.c                           |   5 +
>  nptl/pthread_mutex_lock.c                     |  13 ---
>  nptl/pthread_mutex_timedlock.c                |  13 ---
>  nptl/pthread_mutex_trylock.c                  |   8 --
>  nptl/pthread_mutex_unlock.c                   |   4 -
>  sysdeps/nptl/lowlevellock.h                   | 102 ++++++++++++++++++
>  .../elision-conf.h}                           |  17 ++-
>  sysdeps/unix/sysv/linux/powerpc/Makefile      |   2 -
>  .../unix/sysv/linux/powerpc/elision-conf.c    |  26 +----
>  .../unix/sysv/linux/powerpc/elision-conf.h    |   8 +-
>  .../unix/sysv/linux/powerpc/elision-lock.c    |   7 +-
>  .../unix/sysv/linux/powerpc/elision-trylock.c |   1 +
>  .../unix/sysv/linux/powerpc/elision-unlock.c  |   1 +
>  .../unix/sysv/linux/powerpc/force-elision.h   |  62 -----------
>  .../unix/sysv/linux/powerpc/lowlevellock.h    |  49 ---------
>  .../linux/powerpc/pthread_mutex_cond_lock.c   |  22 ----
>  sysdeps/unix/sysv/linux/s390/Makefile         |   3 -
>  sysdeps/unix/sysv/linux/s390/elision-conf.c   |  27 +----
>  sysdeps/unix/sysv/linux/s390/elision-conf.h   |   8 +-
>  sysdeps/unix/sysv/linux/s390/elision-lock.c   |   7 +-
>  .../unix/sysv/linux/s390/elision-trylock.c    |   1 +
>  sysdeps/unix/sysv/linux/s390/elision-unlock.c |   1 +
>  sysdeps/unix/sysv/linux/s390/force-elision.h  |  62 -----------
>  sysdeps/unix/sysv/linux/s390/lowlevellock.h   |  49 ---------
>  .../sysv/linux/s390/pthread_mutex_cond_lock.c |  22 ----
>  .../sysv/linux/s390/pthread_mutex_timedlock.c |  22 ----
>  .../sysv/linux/s390/pthread_mutex_trylock.c   |  22 ----
>  sysdeps/unix/sysv/linux/x86/Makefile          |   2 -
>  sysdeps/unix/sysv/linux/x86/elision-conf.c    |  25 +----
>  sysdeps/unix/sysv/linux/x86/elision-conf.h    |   8 +-
>  sysdeps/unix/sysv/linux/x86/elision-lock.c    |   7 +-
>  sysdeps/unix/sysv/linux/x86/elision-trylock.c |   1 +
>  sysdeps/unix/sysv/linux/x86/elision-unlock.c  |   1 +
>  sysdeps/unix/sysv/linux/x86/force-elision.h   |  62 -----------
>  sysdeps/unix/sysv/linux/x86/lowlevellock.h    |  24 -----
>  .../sysv/linux/x86/pthread_mutex_cond_lock.c  |  22 ----
>  .../sysv/linux/x86/pthread_mutex_timedlock.c  |  22 ----
>  .../sysv/linux/x86/pthread_mutex_trylock.c    |  22 ----
>  46 files changed, 184 insertions(+), 645 deletions(-)
>  rename sysdeps/unix/sysv/linux/s390/pthread_mutex_lock.c => nptl/elision-conf.c (79%)
>  rename sysdeps/unix/sysv/linux/powerpc/pthread_mutex_lock.c => nptl/elision-lock.c (79%)
>  rename sysdeps/unix/sysv/linux/powerpc/pthread_mutex_trylock.c => nptl/elision-timed.c (78%)
>  rename sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c => nptl/elision-trylock.c (79%)
>  create mode 100644 nptl/elision-unlock.c
>  rename sysdeps/{unix/sysv/linux/powerpc/pthread_mutex_timedlock.c => pthread/elision-conf.h} (64%)
>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/force-elision.h
>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/pthread_mutex_cond_lock.c
>  delete mode 100644 sysdeps/unix/sysv/linux/s390/force-elision.h
>  delete mode 100644 sysdeps/unix/sysv/linux/s390/lowlevellock.h
>  delete mode 100644 sysdeps/unix/sysv/linux/s390/pthread_mutex_cond_lock.c
>  delete mode 100644 sysdeps/unix/sysv/linux/s390/pthread_mutex_timedlock.c
>  delete mode 100644 sysdeps/unix/sysv/linux/s390/pthread_mutex_trylock.c
>  delete mode 100644 sysdeps/unix/sysv/linux/x86/force-elision.h
>  delete mode 100644 sysdeps/unix/sysv/linux/x86/pthread_mutex_cond_lock.c
>  delete mode 100644 sysdeps/unix/sysv/linux/x86/pthread_mutex_timedlock.c
>  delete mode 100644 sysdeps/unix/sysv/linux/x86/pthread_mutex_trylock.c
> 
> diff --git a/elf/libc_early_init.c b/elf/libc_early_init.c
> index 4755554f12..ce23393d90 100644
> --- a/elf/libc_early_init.c
> +++ b/elf/libc_early_init.c
> @@ -17,8 +17,10 @@
>     <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 HAVE_ELISION
> +  __lll_elision_init ();
> +#endif
>  }

Ok.

> diff --git a/nptl/Makefile b/nptl/Makefile
> index 4dd9c6a6a8..5f85dd7854 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -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 \

Ok.

> diff --git a/nptl/Versions b/nptl/Versions
> index 6cca579a0a..186befebfd 100644
> --- a/nptl/Versions
> +++ b/nptl/Versions
> @@ -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;
>    }
>  }

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/pthread_mutex_lock.c b/nptl/elision-conf.c
> similarity index 79%
> rename from sysdeps/unix/sysv/linux/s390/pthread_mutex_lock.c
> rename to nptl/elision-conf.c

Ok.

> index b193b5b2b0..d71c30a01b 100644
> --- a/sysdeps/unix/sysv/linux/s390/pthread_mutex_lock.c
> +++ b/nptl/elision-conf.c
> @@ -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>

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_lock.c b/nptl/elision-lock.c
> similarity index 79%
> rename from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_lock.c
> rename to nptl/elision-lock.c
> index 110a6bf47b..a8235cbbea 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_lock.c
> +++ b/nptl/elision-lock.c
> @@ -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>

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_trylock.c b/nptl/elision-timed.c
> similarity index 78%
> rename from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_trylock.c
> rename to nptl/elision-timed.c
> index ee9fe1d186..4723197363 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_trylock.c
> +++ b/nptl/elision-timed.c
> @@ -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>

Ok.

> diff --git a/sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c b/nptl/elision-trylock.c
> similarity index 79%
> rename from sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c
> rename to nptl/elision-trylock.c
> index 6e5f1f9964..286a7417fa 100644
> --- a/sysdeps/unix/sysv/linux/x86/pthread_mutex_lock.c
> +++ b/nptl/elision-trylock.c
> @@ -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"

Ok.

> diff --git a/nptl/elision-unlock.c b/nptl/elision-unlock.c
> new file mode 100644
> index 0000000000..552a90ade2
> --- /dev/null
> +++ b/nptl/elision-unlock.c
> @@ -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/>.  */

Ok.

> diff --git a/nptl/lowlevellock.c b/nptl/lowlevellock.c
> index 7976c6d8f5..0c0dd0ee00 100644
> --- a/nptl/lowlevellock.c
> +++ b/nptl/lowlevellock.c
> @@ -51,3 +51,8 @@ __lll_lock_wait (int *futex, int private)
>      }
>  }
>  libc_hidden_def (__lll_lock_wait)
> +
> +#if HAVE_ELISION
> +int __pthread_force_elision __attribute__ ((nocommon));
> +libc_hidden_data_def (__pthread_force_elision)
> +#endif

Ok, attribute nocommon now that it exported from libc.

> diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
> index 319658adc4..0e24ae09d7 100644
> --- a/nptl/pthread_mutex_lock.c
> +++ b/nptl/pthread_mutex_lock.c
> @@ -27,15 +27,6 @@
>  #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

Ok.

> @@ -52,10 +43,6 @@
>  		   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__;
>  

Ok.

> diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
> index 8428ebca0f..5e52a4d856 100644
> --- a/nptl/pthread_mutex_timedlock.c
> +++ b/nptl/pthread_mutex_timedlock.c
> @@ -29,19 +29,6 @@
>  
>  #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,

Ok.

> diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
> index 519727580d..e52dddafbd 100644
> --- a/nptl/pthread_mutex_trylock.c
> +++ b/nptl/pthread_mutex_trylock.c
> @@ -23,14 +23,6 @@
>  #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)
>  {

Ok.

> diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
> index e29bb7fa53..3b5ccdacf9 100644
> --- a/nptl/pthread_mutex_unlock.c
> +++ b/nptl/pthread_mutex_unlock.c
> @@ -24,10 +24,6 @@
>  #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__;

Ok.

> diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h
> index 176ba96251..c4b32756f9 100644
> --- a/sysdeps/nptl/lowlevellock.h
> +++ b/sysdeps/nptl/lowlevellock.h
> @@ -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.  */
> +
> +/* 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)

Ok.

> +
> +#if HAVE_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;                                                            \
> +        }                                                               \
> +    }

Maybe since you are refactoring it, to use a static inline instead of macro
here?

> +
> +#else /* !HAVE_ELISION */
> +
> +#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 /* !HAVE_ELISION */
> +
>  #endif	/* lowlevellock.h */

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_timedlock.c b/sysdeps/pthread/elision-conf.h
> similarity index 64%
> rename from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_timedlock.c
> rename to sysdeps/pthread/elision-conf.h
> index 6f8b06d459..6635a7c56f 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_timedlock.c
> +++ b/sysdeps/pthread/elision-conf.h
> @@ -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
> @@ -16,7 +16,14 @@
>     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 HAVE_ELISION 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

Maybe prepend the define with a string related to code it relates to,
like 'ELISION_CONF_'? This links the define more directly to the
implementation, since HAVE_* is usually defined by config.h.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/Makefile b/sysdeps/unix/sysv/linux/powerpc/Makefile
> index cc2f804d86..a093cda68b 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/Makefile
> +++ b/sysdeps/unix/sysv/linux/powerpc/Makefile
> @@ -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

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-conf.c b/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
> index 003bc82343..1ecc2a7b8f 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
> @@ -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
> -};

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-conf.h b/sysdeps/unix/sysv/linux/powerpc/elision-conf.h
> index 8c444d8695..1a1bd644ea 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/elision-conf.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/elision-conf.h
> @@ -22,6 +22,9 @@
>  #include <pthread.h>
>  #include <time.h>
>  
> +#define HAVE_ELISION 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

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
> index 767d439f88..f5fb46df25 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
> @@ -23,12 +23,6 @@
>  #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)

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c b/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
> index ab92f4d72f..5ebbced427 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
> @@ -67,3 +67,4 @@ __lll_trylock_elision (int *futex, short *adapt_count)
>  use_lock:
>    return lll_trylock (*futex);
>  }
> +libc_hidden_def (__lll_trylock_elision)

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c b/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
> index 35044af40b..5aa87521c5 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
> @@ -41,3 +41,4 @@ __lll_unlock_elision (int *lock, short *adapt_count, int pshared)
>      }
>    return 0;
>  }
> +libc_hidden_def (__lll_unlock_elision)

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/force-elision.h b/sysdeps/unix/sysv/linux/powerpc/force-elision.h
> deleted file mode 100644
> index d1fa611c52..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/force-elision.h
> +++ /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;								\
> -	}								\
> -    }

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
> deleted file mode 100644
> index 65962020c6..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
> +++ /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

Ok.

> 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
> index f33bac7ca1..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_cond_lock.c
> +++ /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>

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/Makefile b/sysdeps/unix/sysv/linux/s390/Makefile
> index d9db1b5422..3de9579e23 100644
> --- a/sysdeps/unix/sysv/linux/s390/Makefile
> +++ b/sysdeps/unix/sysv/linux/s390/Makefile
> @@ -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)

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/elision-conf.c b/sysdeps/unix/sysv/linux/s390/elision-conf.c
> index c05c046e56..a7a90e73eb 100644
> --- a/sysdeps/unix/sysv/linux/s390/elision-conf.c
> +++ b/sysdeps/unix/sysv/linux/s390/elision-conf.c
> @@ -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
> -};

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/elision-conf.h b/sysdeps/unix/sysv/linux/s390/elision-conf.h
> index 846c5ff297..3789817c56 100644
> --- a/sysdeps/unix/sysv/linux/s390/elision-conf.h
> +++ b/sysdeps/unix/sysv/linux/s390/elision-conf.h
> @@ -21,6 +21,9 @@
>  #include <pthread.h>
>  #include <time.h>
>  
> +#define HAVE_ELISION 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

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/elision-lock.c b/sysdeps/unix/sysv/linux/s390/elision-lock.c
> index 26474c6398..d5dd6023a0 100644
> --- a/sysdeps/unix/sysv/linux/s390/elision-lock.c
> +++ b/sysdeps/unix/sysv/linux/s390/elision-lock.c
> @@ -23,12 +23,6 @@
>  #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)

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/elision-trylock.c b/sysdeps/unix/sysv/linux/s390/elision-trylock.c
> index 484c3cc913..2470955c89 100644
> --- a/sysdeps/unix/sysv/linux/s390/elision-trylock.c
> +++ b/sysdeps/unix/sysv/linux/s390/elision-trylock.c
> @@ -95,3 +95,4 @@ __lll_trylock_elision (int *futex, short *adapt_count)
>       succeed.  */
>    return lll_trylock (*futex);
>  }
> +libc_hidden_def (__lll_trylock_elision)

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/elision-unlock.c b/sysdeps/unix/sysv/linux/s390/elision-unlock.c
> index 5ac6758df2..87a5bd7cbf 100644
> --- a/sysdeps/unix/sysv/linux/s390/elision-unlock.c
> +++ b/sysdeps/unix/sysv/linux/s390/elision-unlock.c
> @@ -59,3 +59,4 @@ __lll_unlock_elision(int *futex, short *adapt_count, int private)
>      }
>    return 0;
>  }
> +libc_hidden_def (__lll_unlock_elision)

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/force-elision.h b/sysdeps/unix/sysv/linux/s390/force-elision.h
> deleted file mode 100644
> index 154740d37f..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/force-elision.h
> +++ /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;								\
> -	}								\
> -    }

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/lowlevellock.h b/sysdeps/unix/sysv/linux/s390/lowlevellock.h
> deleted file mode 100644
> index 98d78f5270..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/lowlevellock.h
> +++ /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 */

Ok.

> 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
> index 8398ff6425..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/pthread_mutex_cond_lock.c
> +++ /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>

Ok.


> 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
> index 8538f157a0..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/pthread_mutex_timedlock.c
> +++ /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>

Ok.


> 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
> index c4de1363cb..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/pthread_mutex_trylock.c
> +++ /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>

Ok.


> diff --git a/sysdeps/unix/sysv/linux/x86/Makefile b/sysdeps/unix/sysv/linux/x86/Makefile
> index 6bfd6bec49..9dfdd689a9 100644
> --- a/sysdeps/unix/sysv/linux/x86/Makefile
> +++ b/sysdeps/unix/sysv/linux/x86/Makefile
> @@ -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

Ok.


> diff --git a/sysdeps/unix/sysv/linux/x86/elision-conf.c b/sysdeps/unix/sysv/linux/x86/elision-conf.c
> index e8ffe022f0..a5a4043d15 100644
> --- a/sysdeps/unix/sysv/linux/x86/elision-conf.c
> +++ b/sysdeps/unix/sysv/linux/x86/elision-conf.c
> @@ -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)

Ok.

> @@ -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
> -};

Ok.

> diff --git a/sysdeps/unix/sysv/linux/x86/elision-conf.h b/sysdeps/unix/sysv/linux/x86/elision-conf.h
> index bc5e73bd10..78f06ae602 100644
> --- a/sysdeps/unix/sysv/linux/x86/elision-conf.h
> +++ b/sysdeps/unix/sysv/linux/x86/elision-conf.h
> @@ -21,6 +21,9 @@
>  #include <pthread.h>
>  #include <time.h>
>  
> +#define HAVE_ELISION 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

Ok.

> diff --git a/sysdeps/unix/sysv/linux/x86/elision-lock.c b/sysdeps/unix/sysv/linux/x86/elision-lock.c
> index 16d4f6e4f1..ea5f373c67 100644
> --- a/sysdeps/unix/sysv/linux/x86/elision-lock.c
> +++ b/sysdeps/unix/sysv/linux/x86/elision-lock.c
> @@ -22,12 +22,6 @@
>  #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)

Ok.

> diff --git a/sysdeps/unix/sysv/linux/x86/elision-trylock.c b/sysdeps/unix/sysv/linux/x86/elision-trylock.c
> index ef9aa23819..5e689f577f 100644
> --- a/sysdeps/unix/sysv/linux/x86/elision-trylock.c
> +++ b/sysdeps/unix/sysv/linux/x86/elision-trylock.c
> @@ -73,3 +73,4 @@ __lll_trylock_elision (int *futex, short *adapt_count)
>  
>    return lll_trylock (*futex);
>  }
> +libc_hidden_def (__lll_trylock_elision)

Ok.

> diff --git a/sysdeps/unix/sysv/linux/x86/elision-unlock.c b/sysdeps/unix/sysv/linux/x86/elision-unlock.c
> index edd8b1fd08..eb877bc18c 100644
> --- a/sysdeps/unix/sysv/linux/x86/elision-unlock.c
> +++ b/sysdeps/unix/sysv/linux/x86/elision-unlock.c
> @@ -31,3 +31,4 @@ __lll_unlock_elision(int *lock, int private)
>      lll_unlock ((*lock), private);
>    return 0;
>  }
> +libc_hidden_def (__lll_unlock_elision)

Ok.

> diff --git a/sysdeps/unix/sysv/linux/x86/force-elision.h b/sysdeps/unix/sysv/linux/x86/force-elision.h
> deleted file mode 100644
> index 3c0a0e0ac5..0000000000
> --- a/sysdeps/unix/sysv/linux/x86/force-elision.h
> +++ /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;								\
> -	}								\
> -    }

Ok.

> diff --git a/sysdeps/unix/sysv/linux/x86/lowlevellock.h b/sysdeps/unix/sysv/linux/x86/lowlevellock.h
> index 435a190ec9..7205bcadfd 100644
> --- a/sysdeps/unix/sysv/linux/x86/lowlevellock.h
> +++ b/sysdeps/unix/sysv/linux/x86/lowlevellock.h
> @@ -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 */

Ok.

> 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
> index 7604f8706f..0000000000
> --- a/sysdeps/unix/sysv/linux/x86/pthread_mutex_cond_lock.c
> +++ /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>

Ok.

> 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
> index 3fbfe02690..0000000000
> --- a/sysdeps/unix/sysv/linux/x86/pthread_mutex_timedlock.c
> +++ /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"

Ok.

> 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
> index c7abb5ad4f..0000000000
> --- a/sysdeps/unix/sysv/linux/x86/pthread_mutex_trylock.c
> +++ /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"
> 

Ok.

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

* Re: [PATCH 6/6] nptl: Move elision implementations into libc
  2021-02-22 16:53   ` Adhemerval Zanella
@ 2021-02-22 17:02     ` Florian Weimer
  0 siblings, 0 replies; 15+ messages in thread
From: Florian Weimer @ 2021-02-22 17:02 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

>> +/* Automatically enable elision for existing user lock kinds.  */
>> +# define FORCE_ELISION(m, s)                                            \
>> +  if (__pthread_force_elision)                                          \
>> +    {                                                                   \

>> +      if ((mutex_kind & PTHREAD_MUTEX_ELISION_NP) != 0)                 \
>> +        {                                                               \
>> +          s;                                                            \
>> +        }                                                               \
>> +    }
>
> Maybe since you are refactoring it, to use a static inline instead of macro
> here?

That's not possible due to the way the s parameter is used.

>> diff --git a/sysdeps/unix/sysv/linux/powerpc/pthread_mutex_timedlock.c b/sysdeps/pthread/elision-conf.h
>> similarity index 64%
>> rename from sysdeps/unix/sysv/linux/powerpc/pthread_mutex_timedlock.c
>> rename to sysdeps/pthread/elision-conf.h
>> index 6f8b06d459..6635a7c56f 100644

>> +/* No elision support by default.  */
>> +#define HAVE_ELISION 0
>
> Maybe prepend the define with a string related to code it relates to,
> like 'ELISION_CONF_'? This links the define more directly to the
> implementation, since HAVE_* is usually defined by config.h.

Like ENABLE_ELISION_SUPPORT instead of HAVE_ELISION?  Fine.  I just
reused what was there.

The elision-conf.h file name is also not 100% appropriate given those
two defines.

Thanks for the review.

Florian


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

end of thread, other threads:[~2021-02-22 17:01 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-17 17:21 [PATCH 0/6] More libpthread removal preparations Florian Weimer
2021-02-17 17:21 ` [PATCH 1/6] nptl: Split libpthread-routines into one routine per line Florian Weimer
2021-02-22 14:23   ` Adhemerval Zanella
2021-02-17 17:21 ` [PATCH 2/6] nptl: Reformat Versions Florian Weimer
2021-02-22 16:31   ` Adhemerval Zanella
2021-02-17 17:21 ` [PATCH 3/6] nptl: Move futex-internal.c into main nptl directory Florian Weimer
2021-02-22 16:34   ` Adhemerval Zanella
2021-02-17 17:21 ` [PATCH 4/6] nptl: Move lowlevellock into libc Florian Weimer
2021-02-22 16:38   ` Adhemerval Zanella
2021-02-22 16:46     ` Florian Weimer
2021-02-17 17:21 ` [PATCH 5/6] nptl: Move futex-internal " Florian Weimer
2021-02-22 16:39   ` Adhemerval Zanella
2021-02-17 17:22 ` [PATCH 6/6] nptl: Move elision implementations " Florian Weimer
2021-02-22 16:53   ` Adhemerval Zanella
2021-02-22 17:02     ` 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).