public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe
@ 2021-05-03 21:00 Adhemerval Zanella
  2021-05-03 21:00 ` [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill Adhemerval Zanella
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-05-03 21:00 UTC (permalink / raw)
  To: libc-alpha

Changes from v2:
* Rebase against master.

Changes from v1:
* Move __libc_signal_block_all prior TID read.

---

Simiar to raise (BZ #15368), pthread_kill is also defined as
async-signal-safe (POSIX.1-2008 TC1).  However, similar to raise
it has the same issues relating to signal handling.

Different than raise, all the signal are blocked so it would be
possible to implement pthread_cancel (which also should be
async-cancel safe).

Checked on x86_64-linux-gnu.
---
 nptl/pthread_kill.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/nptl/pthread_kill.c b/nptl/pthread_kill.c
index ad7e011779..71c362adce 100644
--- a/nptl/pthread_kill.c
+++ b/nptl/pthread_kill.c
@@ -28,6 +28,11 @@ __pthread_kill (pthread_t threadid, int signo)
   if (__is_internal_signal (signo))
     return EINVAL;
 
+  sigset_t set;
+  __libc_signal_block_all (&set);
+
+  int val;
+
   /* Force load of pd->tid into local variable or register.  Otherwise
      if a thread exits between ESRCH test and tgkill, we might return
      EINVAL, because pd->tid would be cleared by the kernel.  */
@@ -35,14 +40,20 @@ __pthread_kill (pthread_t threadid, int signo)
   pid_t tid = atomic_forced_read (pd->tid);
   if (__glibc_unlikely (tid <= 0))
     /* Not a valid thread handle.  */
-    return ESRCH;
+    val = ESRCH;
+  else
+    {
+      /* We have a special syscall to do the work.  */
+      pid_t pid = __getpid ();
+
+      val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
+      val = (INTERNAL_SYSCALL_ERROR_P (val)
+	    ? INTERNAL_SYSCALL_ERRNO (val) : 0);
+    }
 
-  /* We have a special syscall to do the work.  */
-  pid_t pid = __getpid ();
+  __libc_signal_restore_set (&set);
 
-  int val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
-  return (INTERNAL_SYSCALL_ERROR_P (val)
-	  ? INTERNAL_SYSCALL_ERRNO (val) : 0);
+  return val;
 }
 versioned_symbol (libc, __pthread_kill, pthread_kill, GLIBC_2_34);
 
-- 
2.30.2


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

* [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill
  2021-05-03 21:00 [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe Adhemerval Zanella
@ 2021-05-03 21:00 ` Adhemerval Zanella
  2021-05-11 14:29   ` Florian Weimer
  2021-05-11 15:50   ` Florian Weimer
  2021-05-03 21:00 ` [PATCH v3 3/6] nptl: Move pthread_testcancel into libc Adhemerval Zanella
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-05-03 21:00 UTC (permalink / raw)
  To: libc-alpha

Changes from v2:
* Rebase against master.
* Do not added the versioned symbol for rtld.

Changes from v1:
* Handle vfork usage for raise and obtain the TID using a syscall
  instead of reading from TCB.

---

Now that pthread_kill is provided by libc.so and async-signal-safe,
it is possible to implement the generic POSIX implementation as
pthread_kill(pthread_self(), sig).

For Linux implementation, pthread_kill read the targetting TID from
the TCB.  For raise, this it not possible because it would make raise
fail when issue after vfork (where creates the resulting process
has a different TID from the parent, but its TCB is not updated as
for pthread_create).  For this case, gettid is called directly.

Checked on x86_64-linux-gnu.
---
 include/pthread.h               |  5 ++++
 nptl/pthreadP.h                 |  4 +--
 nptl/pthread_kill.c             | 42 +++++++++++++++-----------
 nptl/pthread_self.c             |  4 ++-
 sysdeps/htl/pthreadP.h          |  2 --
 sysdeps/posix/raise.c           | 11 +++++--
 sysdeps/unix/sysv/linux/raise.c | 52 ---------------------------------
 7 files changed, 44 insertions(+), 76 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/raise.c

diff --git a/include/pthread.h b/include/pthread.h
index 858c869a16..2623fb5e95 100644
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -13,4 +13,9 @@ extern int __pthread_barrier_wait (pthread_barrier_t *__barrier)
 
 /* This function is called to initialize the pthread library.  */
 extern void __pthread_initialize (void) __attribute__ ((weak));
+
+extern int __pthread_kill (pthread_t threadid, int signo);
+
+extern pthread_t __pthread_self (void);
+
 #endif
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 00d2cfe764..3e5aba74ed 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -559,11 +559,11 @@ extern int __pthread_once (pthread_once_t *once_control,
 libc_hidden_proto (__pthread_once)
 extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
 			     void (*child) (void));
-extern pthread_t __pthread_self (void);
+libc_hidden_proto (__pthread_self)
 extern int __pthread_equal (pthread_t thread1, pthread_t thread2);
 extern int __pthread_detach (pthread_t th);
 extern int __pthread_cancel (pthread_t th);
-extern int __pthread_kill (pthread_t threadid, int signo);
+libc_hidden_proto (__pthread_kill)
 extern void __pthread_exit (void *value) __attribute__ ((__noreturn__));
 libc_hidden_proto (__pthread_exit)
 extern int __pthread_join (pthread_t threadid, void **thread_return);
diff --git a/nptl/pthread_kill.c b/nptl/pthread_kill.c
index 71c362adce..d79531c10c 100644
--- a/nptl/pthread_kill.c
+++ b/nptl/pthread_kill.c
@@ -31,32 +31,40 @@ __pthread_kill (pthread_t threadid, int signo)
   sigset_t set;
   __libc_signal_block_all (&set);
 
-  int val;
-
-  /* Force load of pd->tid into local variable or register.  Otherwise
-     if a thread exits between ESRCH test and tgkill, we might return
-     EINVAL, because pd->tid would be cleared by the kernel.  */
+  pid_t tid;
   struct pthread *pd = (struct pthread *) threadid;
-  pid_t tid = atomic_forced_read (pd->tid);
-  if (__glibc_unlikely (tid <= 0))
-    /* Not a valid thread handle.  */
-    val = ESRCH;
+
+  if (pd == THREAD_SELF)
+    tid = INLINE_SYSCALL_CALL (gettid);
   else
-    {
-      /* We have a special syscall to do the work.  */
-      pid_t pid = __getpid ();
+    /* Force load of pd->tid into local variable or register.  Otherwise
+       if a thread exits between ESRCH test and tgkill, we might return
+       EINVAL, because pd->tid would be cleared by the kernel.  */
+    tid = atomic_forced_read (pd->tid);
+
+   int val;
+   if (__glibc_likely (tid > 0))
+     {
+       pid_t pid = __getpid ();
 
-      val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
-      val = (INTERNAL_SYSCALL_ERROR_P (val)
-	    ? INTERNAL_SYSCALL_ERRNO (val) : 0);
-    }
+       val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
+       val = (INTERNAL_SYSCALL_ERROR_P (val)
+	     ? INTERNAL_SYSCALL_ERRNO (val) : 0);
+     }
+   else
+     val = ESRCH;
 
   __libc_signal_restore_set (&set);
 
   return val;
 }
+/* Some architectures (for instance arm) might pull raise through libgcc, so
+   avoid the symbol version if it ends up being used on ld.so.  */
+#if !IS_IN(rtld)
+libc_hidden_def (__pthread_kill)
 versioned_symbol (libc, __pthread_kill, pthread_kill, GLIBC_2_34);
 
-#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34)
+# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34)
 compat_symbol (libc, __pthread_kill, pthread_kill, GLIBC_2_0);
+# endif
 #endif
diff --git a/nptl/pthread_self.c b/nptl/pthread_self.c
index f877a2e6bd..196d93fb8e 100644
--- a/nptl/pthread_self.c
+++ b/nptl/pthread_self.c
@@ -20,7 +20,9 @@
 #include <tls.h>
 
 pthread_t
-pthread_self (void)
+__pthread_self (void)
 {
   return (pthread_t) THREAD_SELF;
 }
+libc_hidden_def (__pthread_self)
+weak_alias (__pthread_self, pthread_self)
diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h
index 8e2cf2ce65..3b357b7bdc 100644
--- a/sysdeps/htl/pthreadP.h
+++ b/sysdeps/htl/pthreadP.h
@@ -31,8 +31,6 @@ extern void __pthread_init_static_tls (struct link_map *) attribute_hidden;
 
 /* These represent the interface used by glibc itself.  */
 
-extern pthread_t __pthread_self (void);
-extern int __pthread_kill (pthread_t threadid, int signo);
 extern struct __pthread **__pthread_threads;
 
 extern int __pthread_mutex_init (pthread_mutex_t *__mutex, const pthread_mutexattr_t *__attr);
diff --git a/sysdeps/posix/raise.c b/sysdeps/posix/raise.c
index 9fdb4d538b..4806c0cc63 100644
--- a/sysdeps/posix/raise.c
+++ b/sysdeps/posix/raise.c
@@ -16,13 +16,20 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <signal.h>
-#include <unistd.h>
+#include <errno.h>
+#include <pthread.h>
 
 /* Raise the signal SIG.  */
 int
 raise (int sig)
 {
-  return __kill (__getpid (), sig);
+  int ret = __pthread_kill (__pthread_self (), sig);
+  if (ret != 0)
+    {
+      __set_errno (ret);
+      ret = -1;
+    }
+  return ret;
 }
 libc_hidden_def (raise)
 weak_alias (raise, gsignal)
diff --git a/sysdeps/unix/sysv/linux/raise.c b/sysdeps/unix/sysv/linux/raise.c
deleted file mode 100644
index 9be3b37f53..0000000000
--- a/sysdeps/unix/sysv/linux/raise.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright (C) 2002-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
-
-   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 <signal.h>
-#include <sysdep.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <internal-signals.h>
-
-int
-raise (int sig)
-{
-  /* rt_sigprocmask may fail if:
-
-     1. sigsetsize != sizeof (sigset_t) (EINVAL)
-     2. a failure in copy from/to user space (EFAULT)
-     3. an invalid 'how' operation (EINVAL)
-
-     The first case is already handle in glibc syscall call by using the arch
-     defined _NSIG.  Second case is handled by using a stack allocated mask.
-     The last one should be handled by the block/unblock functions.  */
-
-  sigset_t set;
-  __libc_signal_block_app (&set);
-
-  pid_t pid = INTERNAL_SYSCALL_CALL (getpid);
-  pid_t tid = INTERNAL_SYSCALL_CALL (gettid);
-
-  int ret = INLINE_SYSCALL_CALL (tgkill, pid, tid, sig);
-
-  __libc_signal_restore_set (&set);
-
-  return ret;
-}
-libc_hidden_def (raise)
-weak_alias (raise, gsignal)
-- 
2.30.2


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

* [PATCH v3 3/6] nptl: Move pthread_testcancel into libc
  2021-05-03 21:00 [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe Adhemerval Zanella
  2021-05-03 21:00 ` [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill Adhemerval Zanella
@ 2021-05-03 21:00 ` Adhemerval Zanella
  2021-05-03 21:00 ` [PATCH v3 4/6] nptl: Move cancel state out of cancelhandling Adhemerval Zanella
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-05-03 21:00 UTC (permalink / raw)
  To: libc-alpha

It is added on GLIBC_PRIVATE since libpthread uses it.

The symbol was moved using scripts/move-symbol-to-libc.py.
---
 nptl/Makefile                                          |  2 +-
 nptl/Versions                                          |  6 ++++--
 nptl/pthreadP.h                                        |  2 +-
 nptl/pthread_testcancel.c                              | 10 ++++++++--
 sysdeps/unix/sysv/linux/aarch64/libc.abilist           |  2 ++
 sysdeps/unix/sysv/linux/aarch64/libpthread.abilist     |  1 -
 sysdeps/unix/sysv/linux/alpha/libc.abilist             |  2 ++
 sysdeps/unix/sysv/linux/alpha/libpthread.abilist       |  1 -
 sysdeps/unix/sysv/linux/arc/libc.abilist               |  2 ++
 sysdeps/unix/sysv/linux/arc/libpthread.abilist         |  1 -
 sysdeps/unix/sysv/linux/arm/be/libc.abilist            |  2 ++
 sysdeps/unix/sysv/linux/arm/be/libpthread.abilist      |  1 -
 sysdeps/unix/sysv/linux/arm/le/libc.abilist            |  2 ++
 sysdeps/unix/sysv/linux/arm/le/libpthread.abilist      |  1 -
 sysdeps/unix/sysv/linux/csky/libc.abilist              |  2 ++
 sysdeps/unix/sysv/linux/csky/libpthread.abilist        |  1 -
 sysdeps/unix/sysv/linux/hppa/libc.abilist              |  2 ++
 sysdeps/unix/sysv/linux/hppa/libpthread.abilist        |  1 -
 sysdeps/unix/sysv/linux/i386/libc.abilist              |  2 ++
 sysdeps/unix/sysv/linux/i386/libpthread.abilist        |  1 -
 sysdeps/unix/sysv/linux/ia64/libc.abilist              |  2 ++
 sysdeps/unix/sysv/linux/ia64/libpthread.abilist        |  1 -
 sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist     |  2 ++
 .../unix/sysv/linux/m68k/coldfire/libpthread.abilist   |  1 -
 sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist       |  2 ++
 sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist |  1 -
 sysdeps/unix/sysv/linux/microblaze/be/libc.abilist     |  2 ++
 .../unix/sysv/linux/microblaze/be/libpthread.abilist   |  1 -
 sysdeps/unix/sysv/linux/microblaze/le/libc.abilist     |  2 ++
 .../unix/sysv/linux/microblaze/le/libpthread.abilist   |  1 -
 sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist   |  2 ++
 sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist |  1 -
 sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist |  2 ++
 sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist   |  2 ++
 sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist   |  2 ++
 sysdeps/unix/sysv/linux/nios2/libc.abilist             |  2 ++
 sysdeps/unix/sysv/linux/nios2/libpthread.abilist       |  1 -
 .../unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist |  2 ++
 .../sysv/linux/powerpc/powerpc32/libpthread.abilist    |  1 -
 .../sysv/linux/powerpc/powerpc32/nofpu/libc.abilist    |  2 ++
 .../unix/sysv/linux/powerpc/powerpc64/be/libc.abilist  |  2 ++
 .../sysv/linux/powerpc/powerpc64/be/libpthread.abilist |  1 -
 .../unix/sysv/linux/powerpc/powerpc64/le/libc.abilist  |  2 ++
 .../sysv/linux/powerpc/powerpc64/le/libpthread.abilist |  1 -
 sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist        |  2 ++
 sysdeps/unix/sysv/linux/riscv/rv32/libpthread.abilist  |  1 -
 sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist        |  2 ++
 sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist  |  1 -
 sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist      |  2 ++
 .../unix/sysv/linux/s390/s390-32/libpthread.abilist    |  1 -
 sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist      |  2 ++
 .../unix/sysv/linux/s390/s390-64/libpthread.abilist    |  1 -
 sysdeps/unix/sysv/linux/sh/be/libc.abilist             |  2 ++
 sysdeps/unix/sysv/linux/sh/be/libpthread.abilist       |  1 -
 sysdeps/unix/sysv/linux/sh/le/libc.abilist             |  2 ++
 sysdeps/unix/sysv/linux/sh/le/libpthread.abilist       |  1 -
 sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist     |  2 ++
 .../unix/sysv/linux/sparc/sparc32/libpthread.abilist   |  1 -
 sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist     |  2 ++
 .../unix/sysv/linux/sparc/sparc64/libpthread.abilist   |  1 -
 sysdeps/unix/sysv/linux/x86_64/64/libc.abilist         |  2 ++
 sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist   |  1 -
 sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist        |  2 ++
 sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist  |  1 -
 65 files changed, 78 insertions(+), 35 deletions(-)

diff --git a/nptl/Makefile b/nptl/Makefile
index 38f2715c2c..884cb69bb4 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -148,6 +148,7 @@ routines = \
   pthread_spin_lock \
   pthread_spin_trylock \
   pthread_spin_unlock \
+  pthread_testcancel \
   pthread_yield \
   tpp \
   unwind \
@@ -199,7 +200,6 @@ libpthread-routines = \
   pthread_setname \
   pthread_setschedprio \
   pthread_sigqueue \
-  pthread_testcancel \
   pthread_timedjoin \
   pthread_tryjoin \
   sem_clockwait \
diff --git a/nptl/Versions b/nptl/Versions
index 0914630be3..b0c575e30f 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -61,6 +61,7 @@ libc {
     pthread_setschedparam;
     pthread_setspecific;
     pthread_sigmask;
+    pthread_testcancel;
   }
   GLIBC_2.1 {
     pthread_attr_init;
@@ -245,6 +246,7 @@ libc {
     pthread_spin_lock;
     pthread_spin_trylock;
     pthread_spin_unlock;
+    pthread_testcancel;
     thrd_exit;
     tss_create;
     tss_delete;
@@ -286,6 +288,7 @@ libc {
     __pthread_setcancelstate;
     __pthread_tpp_change_priority;
     __pthread_unwind;
+    __pthread_testcancel;
     __sched_fifo_max_prio;
     __sched_fifo_min_prio;
   }
@@ -307,7 +310,6 @@ libpthread {
     pthread_detach;
     pthread_join;
     pthread_sigmask;
-    pthread_testcancel;
     sem_destroy;
     sem_getvalue;
     sem_init;
@@ -439,4 +441,4 @@ ld {
   GLIBC_PRIVATE {
      __nptl_set_robust_list_avail;
   }
-}
\ No newline at end of file
+}
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 3e5aba74ed..4116970b77 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -572,6 +572,7 @@ libc_hidden_proto (__pthread_setcanceltype)
 extern int __pthread_enable_asynccancel (void) attribute_hidden;
 extern void __pthread_disable_asynccancel (int oldtype) attribute_hidden;
 extern void __pthread_testcancel (void);
+libc_hidden_proto (__pthread_testcancel)
 extern int __pthread_clockjoin_ex (pthread_t, void **, clockid_t,
 				   const struct __timespec64 *, bool)
   attribute_hidden;
@@ -581,7 +582,6 @@ libc_hidden_proto (__pthread_sigmask);
 
 #if IS_IN (libpthread)
 hidden_proto (__pthread_rwlock_unlock)
-hidden_proto (__pthread_testcancel)
 #endif
 
 extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);
diff --git a/nptl/pthread_testcancel.c b/nptl/pthread_testcancel.c
index 8ed2370afa..b6964904bb 100644
--- a/nptl/pthread_testcancel.c
+++ b/nptl/pthread_testcancel.c
@@ -18,6 +18,7 @@
 
 #include <stdlib.h>
 #include "pthreadP.h"
+#include <shlib-compat.h>
 
 
 void
@@ -25,5 +26,10 @@ __pthread_testcancel (void)
 {
   CANCELLATION_P (THREAD_SELF);
 }
-strong_alias (__pthread_testcancel, pthread_testcancel)
-hidden_def (__pthread_testcancel)
+libc_hidden_def (__pthread_testcancel)
+
+versioned_symbol (libc, __pthread_testcancel, pthread_testcancel, GLIBC_2_34);
+
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34)
+compat_symbol (libpthread, __pthread_testcancel, pthread_testcancel, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 29094366e3..3c79f614cf 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -1530,6 +1530,7 @@ GLIBC_2.17 pthread_spin_init F
 GLIBC_2.17 pthread_spin_lock F
 GLIBC_2.17 pthread_spin_trylock F
 GLIBC_2.17 pthread_spin_unlock F
+GLIBC_2.17 pthread_testcancel F
 GLIBC_2.17 pthread_yield F
 GLIBC_2.17 ptrace F
 GLIBC_2.17 ptsname F
@@ -2344,6 +2345,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
index c1f11e12df..839f2ff64a 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
@@ -37,7 +37,6 @@ GLIBC_2.17 pthread_setconcurrency F
 GLIBC_2.17 pthread_setname_np F
 GLIBC_2.17 pthread_setschedprio F
 GLIBC_2.17 pthread_sigqueue F
-GLIBC_2.17 pthread_testcancel F
 GLIBC_2.17 pthread_timedjoin_np F
 GLIBC_2.17 pthread_tryjoin_np F
 GLIBC_2.17 sem_close F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 74998fc5b0..3ae8eb0327 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -921,6 +921,7 @@ GLIBC_2.0 pthread_setcanceltype F
 GLIBC_2.0 pthread_setschedparam F
 GLIBC_2.0 pthread_setspecific F
 GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 ptrace F
 GLIBC_2.0 putc F
 GLIBC_2.0 putc_unlocked F
@@ -2425,6 +2426,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
index 5eae00fd6b..2633a1c816 100644
--- a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
@@ -9,7 +9,6 @@ GLIBC_2.0 pthread_cancel F
 GLIBC_2.0 pthread_create F
 GLIBC_2.0 pthread_detach F
 GLIBC_2.0 pthread_join F
-GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 sem_destroy F
 GLIBC_2.0 sem_getvalue F
 GLIBC_2.0 sem_init F
diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
index 8ce7184069..068e992c7d 100644
--- a/sysdeps/unix/sysv/linux/arc/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
@@ -1473,6 +1473,7 @@ GLIBC_2.32 pthread_spin_init F
 GLIBC_2.32 pthread_spin_lock F
 GLIBC_2.32 pthread_spin_trylock F
 GLIBC_2.32 pthread_spin_unlock F
+GLIBC_2.32 pthread_testcancel F
 GLIBC_2.32 pthread_yield F
 GLIBC_2.32 ptrace F
 GLIBC_2.32 ptsname F
@@ -2103,6 +2104,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/arc/libpthread.abilist b/sysdeps/unix/sysv/linux/arc/libpthread.abilist
index 8d12b93ff1..fbe2217064 100644
--- a/sysdeps/unix/sysv/linux/arc/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libpthread.abilist
@@ -40,7 +40,6 @@ GLIBC_2.32 pthread_setconcurrency F
 GLIBC_2.32 pthread_setname_np F
 GLIBC_2.32 pthread_setschedprio F
 GLIBC_2.32 pthread_sigqueue F
-GLIBC_2.32 pthread_testcancel F
 GLIBC_2.32 pthread_timedjoin_np F
 GLIBC_2.32 pthread_tryjoin_np F
 GLIBC_2.32 sem_clockwait F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index 3eb6816ffc..a1c40d02b7 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -251,6 +251,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
@@ -1719,6 +1720,7 @@ GLIBC_2.4 pthread_spin_init F
 GLIBC_2.4 pthread_spin_lock F
 GLIBC_2.4 pthread_spin_trylock F
 GLIBC_2.4 pthread_spin_unlock F
+GLIBC_2.4 pthread_testcancel F
 GLIBC_2.4 pthread_yield F
 GLIBC_2.4 ptrace F
 GLIBC_2.4 ptsname F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist b/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist
index e7907d89b8..bd82a85136 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist
@@ -45,7 +45,6 @@ GLIBC_2.4 pthread_join F
 GLIBC_2.4 pthread_setaffinity_np F
 GLIBC_2.4 pthread_setconcurrency F
 GLIBC_2.4 pthread_setschedprio F
-GLIBC_2.4 pthread_testcancel F
 GLIBC_2.4 pthread_timedjoin_np F
 GLIBC_2.4 pthread_tryjoin_np F
 GLIBC_2.4 sem_close F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index bd3a7c2830..11bc55d9e7 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -248,6 +248,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
@@ -1716,6 +1717,7 @@ GLIBC_2.4 pthread_spin_init F
 GLIBC_2.4 pthread_spin_lock F
 GLIBC_2.4 pthread_spin_trylock F
 GLIBC_2.4 pthread_spin_unlock F
+GLIBC_2.4 pthread_testcancel F
 GLIBC_2.4 pthread_yield F
 GLIBC_2.4 ptrace F
 GLIBC_2.4 ptsname F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist b/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist
index e7907d89b8..bd82a85136 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist
@@ -45,7 +45,6 @@ GLIBC_2.4 pthread_join F
 GLIBC_2.4 pthread_setaffinity_np F
 GLIBC_2.4 pthread_setconcurrency F
 GLIBC_2.4 pthread_setschedprio F
-GLIBC_2.4 pthread_testcancel F
 GLIBC_2.4 pthread_timedjoin_np F
 GLIBC_2.4 pthread_tryjoin_np F
 GLIBC_2.4 sem_close F
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 14dade3ad5..60c9fae933 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -1530,6 +1530,7 @@ GLIBC_2.29 pthread_spin_init F
 GLIBC_2.29 pthread_spin_lock F
 GLIBC_2.29 pthread_spin_trylock F
 GLIBC_2.29 pthread_spin_unlock F
+GLIBC_2.29 pthread_testcancel F
 GLIBC_2.29 pthread_yield F
 GLIBC_2.29 ptrace F
 GLIBC_2.29 ptsname F
@@ -2287,6 +2288,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/csky/libpthread.abilist b/sysdeps/unix/sysv/linux/csky/libpthread.abilist
index 4030a58e1a..c1e500ab59 100644
--- a/sysdeps/unix/sysv/linux/csky/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libpthread.abilist
@@ -39,7 +39,6 @@ GLIBC_2.29 pthread_setconcurrency F
 GLIBC_2.29 pthread_setname_np F
 GLIBC_2.29 pthread_setschedprio F
 GLIBC_2.29 pthread_sigqueue F
-GLIBC_2.29 pthread_testcancel F
 GLIBC_2.29 pthread_timedjoin_np F
 GLIBC_2.29 pthread_tryjoin_np F
 GLIBC_2.29 sem_close F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index 286ac0c44d..b4081bab82 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -1341,6 +1341,7 @@ GLIBC_2.2 pthread_spin_init F
 GLIBC_2.2 pthread_spin_lock F
 GLIBC_2.2 pthread_spin_trylock F
 GLIBC_2.2 pthread_spin_unlock F
+GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 pthread_yield F
 GLIBC_2.2 ptrace F
 GLIBC_2.2 ptsname F
@@ -2238,6 +2239,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
index af0359bd14..0d4dfb6328 100644
--- a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
@@ -31,7 +31,6 @@ GLIBC_2.2 pthread_getconcurrency F
 GLIBC_2.2 pthread_getcpuclockid F
 GLIBC_2.2 pthread_join F
 GLIBC_2.2 pthread_setconcurrency F
-GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 sem_close F
 GLIBC_2.2 sem_destroy F
 GLIBC_2.2 sem_getvalue F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index e33fe31138..a482370926 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -898,6 +898,7 @@ GLIBC_2.0 pthread_setcanceltype F
 GLIBC_2.0 pthread_setschedparam F
 GLIBC_2.0 pthread_setspecific F
 GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 ptrace F
 GLIBC_2.0 putc F
 GLIBC_2.0 putc_unlocked F
@@ -2415,6 +2416,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/i386/libpthread.abilist b/sysdeps/unix/sysv/linux/i386/libpthread.abilist
index 1fdd0c7758..7b43b9309b 100644
--- a/sysdeps/unix/sysv/linux/i386/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libpthread.abilist
@@ -9,7 +9,6 @@ GLIBC_2.0 pthread_cancel F
 GLIBC_2.0 pthread_create F
 GLIBC_2.0 pthread_detach F
 GLIBC_2.0 pthread_join F
-GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 sem_destroy F
 GLIBC_2.0 sem_getvalue F
 GLIBC_2.0 sem_init F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index eedd7293e2..8e9234969d 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -1362,6 +1362,7 @@ GLIBC_2.2 pthread_spin_init F
 GLIBC_2.2 pthread_spin_lock F
 GLIBC_2.2 pthread_spin_trylock F
 GLIBC_2.2 pthread_spin_unlock F
+GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 pthread_yield F
 GLIBC_2.2 ptrace F
 GLIBC_2.2 ptsname F
@@ -2272,6 +2273,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
index c6c1f7ac7b..cef26d71d6 100644
--- a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
@@ -31,7 +31,6 @@ GLIBC_2.2 pthread_getconcurrency F
 GLIBC_2.2 pthread_getcpuclockid F
 GLIBC_2.2 pthread_join F
 GLIBC_2.2 pthread_setconcurrency F
-GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 sem_close F
 GLIBC_2.2 sem_destroy F
 GLIBC_2.2 sem_getvalue F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index 0cf1c052db..0ff3a75d5c 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -252,6 +252,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
@@ -1699,6 +1700,7 @@ GLIBC_2.4 pthread_spin_init F
 GLIBC_2.4 pthread_spin_lock F
 GLIBC_2.4 pthread_spin_trylock F
 GLIBC_2.4 pthread_spin_unlock F
+GLIBC_2.4 pthread_testcancel F
 GLIBC_2.4 pthread_yield F
 GLIBC_2.4 ptrace F
 GLIBC_2.4 ptsname F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
index e7907d89b8..bd82a85136 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
@@ -45,7 +45,6 @@ GLIBC_2.4 pthread_join F
 GLIBC_2.4 pthread_setaffinity_np F
 GLIBC_2.4 pthread_setconcurrency F
 GLIBC_2.4 pthread_setschedprio F
-GLIBC_2.4 pthread_testcancel F
 GLIBC_2.4 pthread_timedjoin_np F
 GLIBC_2.4 pthread_tryjoin_np F
 GLIBC_2.4 sem_close F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 9a457376e2..ab29bb553c 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -897,6 +897,7 @@ GLIBC_2.0 pthread_setcanceltype F
 GLIBC_2.0 pthread_setschedparam F
 GLIBC_2.0 pthread_setspecific F
 GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 ptrace F
 GLIBC_2.0 putc F
 GLIBC_2.0 putc_unlocked F
@@ -2358,6 +2359,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
index 1fdd0c7758..7b43b9309b 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
@@ -9,7 +9,6 @@ GLIBC_2.0 pthread_cancel F
 GLIBC_2.0 pthread_create F
 GLIBC_2.0 pthread_detach F
 GLIBC_2.0 pthread_join F
-GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 sem_destroy F
 GLIBC_2.0 sem_getvalue F
 GLIBC_2.0 sem_init F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 540e503a0b..baa46ca8c2 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -1532,6 +1532,7 @@ GLIBC_2.18 pthread_spin_init F
 GLIBC_2.18 pthread_spin_lock F
 GLIBC_2.18 pthread_spin_trylock F
 GLIBC_2.18 pthread_spin_unlock F
+GLIBC_2.18 pthread_testcancel F
 GLIBC_2.18 pthread_yield F
 GLIBC_2.18 ptrace F
 GLIBC_2.18 ptsname F
@@ -2338,6 +2339,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist
index 785630fec3..6bfa410c44 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist
@@ -39,7 +39,6 @@ GLIBC_2.18 pthread_setconcurrency F
 GLIBC_2.18 pthread_setname_np F
 GLIBC_2.18 pthread_setschedprio F
 GLIBC_2.18 pthread_sigqueue F
-GLIBC_2.18 pthread_testcancel F
 GLIBC_2.18 pthread_timedjoin_np F
 GLIBC_2.18 pthread_tryjoin_np F
 GLIBC_2.18 sem_close F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index f630215296..b5640c3a40 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -1532,6 +1532,7 @@ GLIBC_2.18 pthread_spin_init F
 GLIBC_2.18 pthread_spin_lock F
 GLIBC_2.18 pthread_spin_trylock F
 GLIBC_2.18 pthread_spin_unlock F
+GLIBC_2.18 pthread_testcancel F
 GLIBC_2.18 pthread_yield F
 GLIBC_2.18 ptrace F
 GLIBC_2.18 ptsname F
@@ -2335,6 +2336,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist
index 785630fec3..6bfa410c44 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist
@@ -39,7 +39,6 @@ GLIBC_2.18 pthread_setconcurrency F
 GLIBC_2.18 pthread_setname_np F
 GLIBC_2.18 pthread_setschedprio F
 GLIBC_2.18 pthread_sigqueue F
-GLIBC_2.18 pthread_testcancel F
 GLIBC_2.18 pthread_timedjoin_np F
 GLIBC_2.18 pthread_tryjoin_np F
 GLIBC_2.18 sem_close F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index f4f2d706c0..f5193f5a30 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -894,6 +894,7 @@ GLIBC_2.0 pthread_setcanceltype F
 GLIBC_2.0 pthread_setschedparam F
 GLIBC_2.0 pthread_setspecific F
 GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 ptrace F
 GLIBC_2.0 putc F
 GLIBC_2.0 putc_unlocked F
@@ -2321,6 +2322,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
index 8df7179bd2..83434ae1b6 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
@@ -9,7 +9,6 @@ GLIBC_2.0 pthread_cancel F
 GLIBC_2.0 pthread_create F
 GLIBC_2.0 pthread_detach F
 GLIBC_2.0 pthread_join F
-GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 sem_destroy F
 GLIBC_2.0 sem_getvalue F
 GLIBC_2.0 sem_init F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index ee5b775cd0..a6c6ae308a 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -894,6 +894,7 @@ GLIBC_2.0 pthread_setcanceltype F
 GLIBC_2.0 pthread_setschedparam F
 GLIBC_2.0 pthread_setspecific F
 GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 ptrace F
 GLIBC_2.0 putc F
 GLIBC_2.0 putc_unlocked F
@@ -2319,6 +2320,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
index 8df7179bd2..83434ae1b6 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
@@ -9,7 +9,6 @@ GLIBC_2.0 pthread_cancel F
 GLIBC_2.0 pthread_create F
 GLIBC_2.0 pthread_detach F
 GLIBC_2.0 pthread_join F
-GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 sem_destroy F
 GLIBC_2.0 sem_getvalue F
 GLIBC_2.0 sem_init F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index 6d9798fb9a..cd24ac6fde 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -894,6 +894,7 @@ GLIBC_2.0 pthread_setcanceltype F
 GLIBC_2.0 pthread_setschedparam F
 GLIBC_2.0 pthread_setspecific F
 GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 ptrace F
 GLIBC_2.0 putc F
 GLIBC_2.0 putc_unlocked F
@@ -2327,6 +2328,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index e6d6053906..9a71aa83dd 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -892,6 +892,7 @@ GLIBC_2.0 pthread_setcanceltype F
 GLIBC_2.0 pthread_setschedparam F
 GLIBC_2.0 pthread_setspecific F
 GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 ptrace F
 GLIBC_2.0 putc F
 GLIBC_2.0 putc_unlocked F
@@ -2321,6 +2322,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 743d981081..c0225a9559 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -1575,6 +1575,7 @@ GLIBC_2.21 pthread_spin_init F
 GLIBC_2.21 pthread_spin_lock F
 GLIBC_2.21 pthread_spin_trylock F
 GLIBC_2.21 pthread_spin_unlock F
+GLIBC_2.21 pthread_testcancel F
 GLIBC_2.21 pthread_yield F
 GLIBC_2.21 ptrace F
 GLIBC_2.21 ptsname F
@@ -2377,6 +2378,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
index fb9c53ec2b..197827a386 100644
--- a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
@@ -39,7 +39,6 @@ GLIBC_2.21 pthread_setconcurrency F
 GLIBC_2.21 pthread_setname_np F
 GLIBC_2.21 pthread_setschedprio F
 GLIBC_2.21 pthread_sigqueue F
-GLIBC_2.21 pthread_testcancel F
 GLIBC_2.21 pthread_timedjoin_np F
 GLIBC_2.21 pthread_tryjoin_np F
 GLIBC_2.21 sem_close F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index e173d5a95c..c3e72afb9e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -905,6 +905,7 @@ GLIBC_2.0 pthread_setcanceltype F
 GLIBC_2.0 pthread_setschedparam F
 GLIBC_2.0 pthread_setspecific F
 GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 ptrace F
 GLIBC_2.0 putc F
 GLIBC_2.0 putc_unlocked F
@@ -2385,6 +2386,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
index c761c15e3a..79bc809cfa 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
@@ -9,7 +9,6 @@ GLIBC_2.0 pthread_cancel F
 GLIBC_2.0 pthread_create F
 GLIBC_2.0 pthread_detach F
 GLIBC_2.0 pthread_join F
-GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 sem_destroy F
 GLIBC_2.0 sem_getvalue F
 GLIBC_2.0 sem_init F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index b5e32bef98..b49aacf9a0 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -905,6 +905,7 @@ GLIBC_2.0 pthread_setcanceltype F
 GLIBC_2.0 pthread_setschedparam F
 GLIBC_2.0 pthread_setspecific F
 GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 ptrace F
 GLIBC_2.0 putc F
 GLIBC_2.0 putc_unlocked F
@@ -2418,6 +2419,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
index 20168d3df3..57029e940a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -1465,6 +1465,7 @@ GLIBC_2.3 pthread_spin_init F
 GLIBC_2.3 pthread_spin_lock F
 GLIBC_2.3 pthread_spin_trylock F
 GLIBC_2.3 pthread_spin_unlock F
+GLIBC_2.3 pthread_testcancel F
 GLIBC_2.3 pthread_yield F
 GLIBC_2.3 ptrace F
 GLIBC_2.3 ptsname F
@@ -2239,6 +2240,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist
index 037f0f2839..0c5ee381d2 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist
@@ -34,7 +34,6 @@ GLIBC_2.3 pthread_getconcurrency F
 GLIBC_2.3 pthread_getcpuclockid F
 GLIBC_2.3 pthread_join F
 GLIBC_2.3 pthread_setconcurrency F
-GLIBC_2.3 pthread_testcancel F
 GLIBC_2.3 sem_close F
 GLIBC_2.3 sem_destroy F
 GLIBC_2.3 sem_getvalue F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index 5f94b1ce64..65fcc483a6 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -1618,6 +1618,7 @@ GLIBC_2.17 pthread_spin_init F
 GLIBC_2.17 pthread_spin_lock F
 GLIBC_2.17 pthread_spin_trylock F
 GLIBC_2.17 pthread_spin_unlock F
+GLIBC_2.17 pthread_testcancel F
 GLIBC_2.17 pthread_yield F
 GLIBC_2.17 ptrace F
 GLIBC_2.17 ptsname F
@@ -2540,6 +2541,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist
index c1f11e12df..839f2ff64a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist
@@ -37,7 +37,6 @@ GLIBC_2.17 pthread_setconcurrency F
 GLIBC_2.17 pthread_setname_np F
 GLIBC_2.17 pthread_setschedprio F
 GLIBC_2.17 pthread_sigqueue F
-GLIBC_2.17 pthread_testcancel F
 GLIBC_2.17 pthread_timedjoin_np F
 GLIBC_2.17 pthread_tryjoin_np F
 GLIBC_2.17 sem_close F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
index 3fe5e16e5d..faddb79441 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
@@ -1475,6 +1475,7 @@ GLIBC_2.33 pthread_spin_init F
 GLIBC_2.33 pthread_spin_lock F
 GLIBC_2.33 pthread_spin_trylock F
 GLIBC_2.33 pthread_spin_unlock F
+GLIBC_2.33 pthread_testcancel F
 GLIBC_2.33 pthread_yield F
 GLIBC_2.33 ptrace F
 GLIBC_2.33 ptsname F
@@ -2105,6 +2106,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libpthread.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libpthread.abilist
index b06dfc1038..94fcac028c 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libpthread.abilist
@@ -40,7 +40,6 @@ GLIBC_2.33 pthread_setconcurrency F
 GLIBC_2.33 pthread_setname_np F
 GLIBC_2.33 pthread_setschedprio F
 GLIBC_2.33 pthread_sigqueue F
-GLIBC_2.33 pthread_testcancel F
 GLIBC_2.33 pthread_timedjoin_np F
 GLIBC_2.33 pthread_tryjoin_np F
 GLIBC_2.33 sem_clockwait F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index f9beb99367..0a3a366b43 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -1520,6 +1520,7 @@ GLIBC_2.27 pthread_spin_init F
 GLIBC_2.27 pthread_spin_lock F
 GLIBC_2.27 pthread_spin_trylock F
 GLIBC_2.27 pthread_spin_unlock F
+GLIBC_2.27 pthread_testcancel F
 GLIBC_2.27 pthread_yield F
 GLIBC_2.27 ptrace F
 GLIBC_2.27 ptsname F
@@ -2305,6 +2306,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
index 5a7d9561fd..fdab0f5ab4 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
@@ -39,7 +39,6 @@ GLIBC_2.27 pthread_setconcurrency F
 GLIBC_2.27 pthread_setname_np F
 GLIBC_2.27 pthread_setschedprio F
 GLIBC_2.27 pthread_sigqueue F
-GLIBC_2.27 pthread_testcancel F
 GLIBC_2.27 pthread_timedjoin_np F
 GLIBC_2.27 pthread_tryjoin_np F
 GLIBC_2.27 sem_close F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index bfa492a8c7..1a6f72ff1d 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -896,6 +896,7 @@ GLIBC_2.0 pthread_setcanceltype F
 GLIBC_2.0 pthread_setschedparam F
 GLIBC_2.0 pthread_setspecific F
 GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 ptrace F
 GLIBC_2.0 putc F
 GLIBC_2.0 putc_unlocked F
@@ -2383,6 +2384,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
index ddcff610d2..911048092d 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
@@ -9,7 +9,6 @@ GLIBC_2.0 pthread_cancel F
 GLIBC_2.0 pthread_create F
 GLIBC_2.0 pthread_detach F
 GLIBC_2.0 pthread_join F
-GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 sem_destroy F
 GLIBC_2.0 sem_getvalue F
 GLIBC_2.0 sem_init F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index 27e9b47768..f21fde6bca 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -1359,6 +1359,7 @@ GLIBC_2.2 pthread_spin_init F
 GLIBC_2.2 pthread_spin_lock F
 GLIBC_2.2 pthread_spin_trylock F
 GLIBC_2.2 pthread_spin_unlock F
+GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 pthread_yield F
 GLIBC_2.2 ptrace F
 GLIBC_2.2 ptsname F
@@ -2276,6 +2277,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
index ffe9d5fed1..c5c78cb049 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
@@ -32,7 +32,6 @@ GLIBC_2.2 pthread_getconcurrency F
 GLIBC_2.2 pthread_getcpuclockid F
 GLIBC_2.2 pthread_join F
 GLIBC_2.2 pthread_setconcurrency F
-GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 sem_close F
 GLIBC_2.2 sem_destroy F
 GLIBC_2.2 sem_getvalue F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index b5cd5109ad..15ee14939e 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -1345,6 +1345,7 @@ GLIBC_2.2 pthread_spin_init F
 GLIBC_2.2 pthread_spin_lock F
 GLIBC_2.2 pthread_spin_trylock F
 GLIBC_2.2 pthread_spin_unlock F
+GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 pthread_yield F
 GLIBC_2.2 ptrace F
 GLIBC_2.2 ptsname F
@@ -2245,6 +2246,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist b/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist
index af0359bd14..0d4dfb6328 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist
@@ -31,7 +31,6 @@ GLIBC_2.2 pthread_getconcurrency F
 GLIBC_2.2 pthread_getcpuclockid F
 GLIBC_2.2 pthread_join F
 GLIBC_2.2 pthread_setconcurrency F
-GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 sem_close F
 GLIBC_2.2 sem_destroy F
 GLIBC_2.2 sem_getvalue F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index 1b20c9fcb1..533822d194 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -1345,6 +1345,7 @@ GLIBC_2.2 pthread_spin_init F
 GLIBC_2.2 pthread_spin_lock F
 GLIBC_2.2 pthread_spin_trylock F
 GLIBC_2.2 pthread_spin_unlock F
+GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 pthread_yield F
 GLIBC_2.2 ptrace F
 GLIBC_2.2 ptsname F
@@ -2242,6 +2243,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist b/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist
index af0359bd14..0d4dfb6328 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist
@@ -31,7 +31,6 @@ GLIBC_2.2 pthread_getconcurrency F
 GLIBC_2.2 pthread_getcpuclockid F
 GLIBC_2.2 pthread_join F
 GLIBC_2.2 pthread_setconcurrency F
-GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 sem_close F
 GLIBC_2.2 sem_destroy F
 GLIBC_2.2 sem_getvalue F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index c99298c588..0116558e17 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -899,6 +899,7 @@ GLIBC_2.0 pthread_setcanceltype F
 GLIBC_2.0 pthread_setschedparam F
 GLIBC_2.0 pthread_setspecific F
 GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 ptrace F
 GLIBC_2.0 putc F
 GLIBC_2.0 putc_unlocked F
@@ -2374,6 +2375,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
index 5eae00fd6b..2633a1c816 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
@@ -9,7 +9,6 @@ GLIBC_2.0 pthread_cancel F
 GLIBC_2.0 pthread_create F
 GLIBC_2.0 pthread_detach F
 GLIBC_2.0 pthread_join F
-GLIBC_2.0 pthread_testcancel F
 GLIBC_2.0 sem_destroy F
 GLIBC_2.0 sem_getvalue F
 GLIBC_2.0 sem_init F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 19c6041c49..5bf6712979 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -1388,6 +1388,7 @@ GLIBC_2.2 pthread_spin_init F
 GLIBC_2.2 pthread_spin_lock F
 GLIBC_2.2 pthread_spin_trylock F
 GLIBC_2.2 pthread_spin_unlock F
+GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 pthread_yield F
 GLIBC_2.2 ptrace F
 GLIBC_2.2 ptsname F
@@ -2293,6 +2294,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
index c6c1f7ac7b..cef26d71d6 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
@@ -31,7 +31,6 @@ GLIBC_2.2 pthread_getconcurrency F
 GLIBC_2.2 pthread_getcpuclockid F
 GLIBC_2.2 pthread_join F
 GLIBC_2.2 pthread_setconcurrency F
-GLIBC_2.2 pthread_testcancel F
 GLIBC_2.2 sem_close F
 GLIBC_2.2 sem_destroy F
 GLIBC_2.2 sem_getvalue F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 9c5096c1d9..bceb606756 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -1356,6 +1356,7 @@ GLIBC_2.2.5 pthread_spin_init F
 GLIBC_2.2.5 pthread_spin_lock F
 GLIBC_2.2.5 pthread_spin_trylock F
 GLIBC_2.2.5 pthread_spin_unlock F
+GLIBC_2.2.5 pthread_testcancel F
 GLIBC_2.2.5 pthread_yield F
 GLIBC_2.2.5 ptrace F
 GLIBC_2.2.5 ptsname F
@@ -2254,6 +2255,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
index 540c8760ed..000cf018c7 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
@@ -31,7 +31,6 @@ GLIBC_2.2.5 pthread_getconcurrency F
 GLIBC_2.2.5 pthread_getcpuclockid F
 GLIBC_2.2.5 pthread_join F
 GLIBC_2.2.5 pthread_setconcurrency F
-GLIBC_2.2.5 pthread_testcancel F
 GLIBC_2.2.5 sem_close F
 GLIBC_2.2.5 sem_destroy F
 GLIBC_2.2.5 sem_getvalue F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 15bec846ec..ae2a8e54c7 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -1537,6 +1537,7 @@ GLIBC_2.16 pthread_spin_init F
 GLIBC_2.16 pthread_spin_lock F
 GLIBC_2.16 pthread_spin_trylock F
 GLIBC_2.16 pthread_spin_unlock F
+GLIBC_2.16 pthread_testcancel F
 GLIBC_2.16 pthread_yield F
 GLIBC_2.16 ptrace F
 GLIBC_2.16 ptsname F
@@ -2359,6 +2360,7 @@ GLIBC_2.34 pthread_spin_init F
 GLIBC_2.34 pthread_spin_lock F
 GLIBC_2.34 pthread_spin_trylock F
 GLIBC_2.34 pthread_spin_unlock F
+GLIBC_2.34 pthread_testcancel F
 GLIBC_2.34 thrd_exit F
 GLIBC_2.34 tss_create F
 GLIBC_2.34 tss_delete F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
index 01f6915331..068065e40c 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
@@ -37,7 +37,6 @@ GLIBC_2.16 pthread_setconcurrency F
 GLIBC_2.16 pthread_setname_np F
 GLIBC_2.16 pthread_setschedprio F
 GLIBC_2.16 pthread_sigqueue F
-GLIBC_2.16 pthread_testcancel F
 GLIBC_2.16 pthread_timedjoin_np F
 GLIBC_2.16 pthread_tryjoin_np F
 GLIBC_2.16 sem_close F
-- 
2.30.2


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

* [PATCH v3 4/6] nptl: Move cancel state out of cancelhandling
  2021-05-03 21:00 [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe Adhemerval Zanella
  2021-05-03 21:00 ` [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill Adhemerval Zanella
  2021-05-03 21:00 ` [PATCH v3 3/6] nptl: Move pthread_testcancel into libc Adhemerval Zanella
@ 2021-05-03 21:00 ` Adhemerval Zanella
  2021-05-03 21:00 ` [PATCH v3 5/6] nptl: Move cancel type " Adhemerval Zanella
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-05-03 21:00 UTC (permalink / raw)
  To: libc-alpha

Changes from v2:
* Rebased against master.

Changes from v1:
* Rebased against master.

---

The thread cancellation state is not accessed concurrently internally
neither the pthread interface allows changing the state of a different
thread than its own.

By removing the cancel state out of the internal thread cancel handling
state there is no need to check if cancelled bit was set in CAS
operation.

The code is also simplified: the CANCELLATION_P is replaced with a
internal pthread_testcancel call and the CANCELSTATE_BIT{MASK} is
removed.

The second part of this patchset also keeps the pthread_setcanceltype as
cancellation entrypoint by calling pthread_testcancel if the new type
is PTHREAD_CANCEL_ASYNCHRONOUS.

With this behavior pthread_setcancelstate does not require to act on
cancellation if cancel type is asynchronous (is already handled either
by pthread_setcanceltype or by the signal handler).

Checked on x86_64-linux-gnu.
---
 manual/pattern.texi           |  1 -
 manual/process.texi           |  3 +--
 nptl/allocatestack.c          |  1 +
 nptl/cancellation.c           |  3 ++-
 nptl/cleanup_defer.c          |  2 +-
 nptl/descr.h                  | 14 ++++++--------
 nptl/libc-cleanup.c           |  2 +-
 nptl/pthreadP.h               | 12 ------------
 nptl/pthread_cancel.c         |  3 ++-
 nptl/pthread_join_common.c    |  5 ++++-
 nptl/pthread_setcancelstate.c | 36 +++--------------------------------
 nptl/pthread_setcanceltype.c  |  3 ++-
 nptl/pthread_testcancel.c     | 11 ++++++++++-
 13 files changed, 33 insertions(+), 63 deletions(-)

diff --git a/manual/pattern.texi b/manual/pattern.texi
index 39ae97a3c4..4fa4c25525 100644
--- a/manual/pattern.texi
+++ b/manual/pattern.texi
@@ -1820,7 +1820,6 @@ the beginning of the vector.
 @c      (disable cancellation around exec_comm; it may do_cancel the
 @c       second time, if async cancel is enabled)
 @c     THREAD_ATOMIC_CMPXCHG_VAL dup ok
-@c     CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS dup ok
 @c     do_cancel @ascuplugin @ascuheap @acsmem
 @c      THREAD_ATOMIC_BIT_SET dup ok
 @c      pthread_unwind @ascuplugin @ascuheap @acsmem
diff --git a/manual/process.texi b/manual/process.texi
index 54e65f76c6..134d5c6143 100644
--- a/manual/process.texi
+++ b/manual/process.texi
@@ -68,7 +68,7 @@ until the subprogram terminates before you can do anything else.
 @c   CLEANUP_HANDLER @ascuplugin @ascuheap @acsmem
 @c    libc_cleanup_region_start @ascuplugin @ascuheap @acsmem
 @c     pthread_cleanup_push_defer @ascuplugin @ascuheap @acsmem
-@c      CANCELLATION_P @ascuplugin @ascuheap @acsmem
+@c      __pthread_testcancel @ascuplugin @ascuheap @acsmem
 @c       CANCEL_ENABLED_AND_CANCELED ok
 @c       do_cancel @ascuplugin @ascuheap @acsmem
 @c    cancel_handler ok
@@ -86,7 +86,6 @@ until the subprogram terminates before you can do anything else.
 @c  SINGLE_THREAD_P ok
 @c  LIBC_CANCEL_ASYNC @ascuplugin @ascuheap @acsmem
 @c   libc_enable_asynccancel @ascuplugin @ascuheap @acsmem
-@c    CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS dup ok
 @c    do_cancel dup @ascuplugin @ascuheap @acsmem
 @c  LIBC_CANCEL_RESET ok
 @c   libc_disable_asynccancel ok
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index f1270c3109..eb25a2a034 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -219,6 +219,7 @@ get_cached_stack (size_t *sizep, void **memp)
 
   /* Cancellation handling is back to the default.  */
   result->cancelhandling = 0;
+  result->cancelstate = PTHREAD_CANCEL_ENABLE;
   result->cleanup = NULL;
 
   /* No pending event.  */
diff --git a/nptl/cancellation.c b/nptl/cancellation.c
index 2ee633eabc..1ba94860fe 100644
--- a/nptl/cancellation.c
+++ b/nptl/cancellation.c
@@ -45,7 +45,8 @@ __pthread_enable_asynccancel (void)
 					      oldval);
       if (__glibc_likely (curval == oldval))
 	{
-	  if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
+	  if (self->cancelstate == PTHREAD_CANCEL_ENABLE
+	      && CANCEL_CANCELED_AND_ASYNCHRONOUS (newval))
 	    {
 	      THREAD_SETMEM (self, result, PTHREAD_CANCELED);
 	      __do_cancel ();
diff --git a/nptl/cleanup_defer.c b/nptl/cleanup_defer.c
index 08271e352f..3f7efc939f 100644
--- a/nptl/cleanup_defer.c
+++ b/nptl/cleanup_defer.c
@@ -86,6 +86,6 @@ __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *buf)
 	  cancelhandling = curval;
 	}
 
-      CANCELLATION_P (self);
+      __pthread_testcancel ();
     }
 }
diff --git a/nptl/descr.h b/nptl/descr.h
index d423a53bbf..465af117e5 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -277,9 +277,6 @@ struct pthread
 
   /* Flags determining processing of cancellation.  */
   int cancelhandling;
-  /* Bit set if cancellation is disabled.  */
-#define CANCELSTATE_BIT		0
-#define CANCELSTATE_BITMASK	(0x01 << CANCELSTATE_BIT)
   /* Bit set if asynchronous cancellation mode is selected.  */
 #define CANCELTYPE_BIT		1
 #define CANCELTYPE_BITMASK	(0x01 << CANCELTYPE_BIT)
@@ -301,11 +298,8 @@ struct pthread
   /* Mask for the rest.  Helps the compiler to optimize.  */
 #define CANCEL_RESTMASK		0xffffff80
 
-#define CANCEL_ENABLED_AND_CANCELED(value) \
-  (((value) & (CANCELSTATE_BITMASK | CANCELED_BITMASK | EXITING_BITMASK	      \
-	       | CANCEL_RESTMASK | TERMINATED_BITMASK)) == CANCELED_BITMASK)
-#define CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS(value) \
-  (((value) & (CANCELSTATE_BITMASK | CANCELTYPE_BITMASK | CANCELED_BITMASK    \
+#define CANCEL_CANCELED_AND_ASYNCHRONOUS(value) \
+  (((value) & (CANCELTYPE_BITMASK | CANCELED_BITMASK    \
 	       | EXITING_BITMASK | CANCEL_RESTMASK | TERMINATED_BITMASK))     \
    == (CANCELTYPE_BITMASK | CANCELED_BITMASK))
 
@@ -409,6 +403,10 @@ struct pthread
   /* Used on strsignal.  */
   struct tls_internal_t tls_state;
 
+  /* Thread cancel state (PTHREAD_CANCEL_ENABLE or
+     PTHREAD_CANCEL_DISABLE).  */
+  unsigned char cancelstate;
+
   /* This member must be last.  */
   char end_padding[];
 
diff --git a/nptl/libc-cleanup.c b/nptl/libc-cleanup.c
index 14ccfe9285..6286b8b525 100644
--- a/nptl/libc-cleanup.c
+++ b/nptl/libc-cleanup.c
@@ -79,7 +79,7 @@ __libc_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer)
 	  cancelhandling = curval;
 	}
 
-      CANCELLATION_P (self);
+      __pthread_testcancel ();
     }
 }
 libc_hidden_def (__libc_cleanup_pop_restore)
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 4116970b77..7d2f33be0d 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -259,18 +259,6 @@ extern int __pthread_debug attribute_hidden;
 #endif
 
 
-/* Cancellation test.  */
-#define CANCELLATION_P(self) \
-  do {									      \
-    int cancelhandling = THREAD_GETMEM (self, cancelhandling);		      \
-    if (CANCEL_ENABLED_AND_CANCELED (cancelhandling))			      \
-      {									      \
-	THREAD_SETMEM (self, result, PTHREAD_CANCELED);			      \
-	__do_cancel ();							      \
-      }									      \
-  } while (0)
-
-
 extern void __pthread_unwind (__pthread_unwind_buf_t *__buf)
      __cleanup_fct_attribute __attribute ((__noreturn__))
 #if !defined SHARED && !IS_IN (libpthread)
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
index 060484cdc8..b3dbf26843 100644
--- a/nptl/pthread_cancel.c
+++ b/nptl/pthread_cancel.c
@@ -64,7 +64,8 @@ __pthread_cancel (pthread_t th)
       /* If the cancellation is handled asynchronously just send a
 	 signal.  We avoid this if possible since it's more
 	 expensive.  */
-      if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
+      if (pd->cancelstate == PTHREAD_CANCEL_ENABLE
+	  && CANCEL_CANCELED_AND_ASYNCHRONOUS (newval))
 	{
 	  /* Mark the cancellation as "in progress".  */
 	  if (atomic_compare_and_exchange_bool_acq (&pd->cancelhandling,
diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c
index a99c26e27e..e4efd83715 100644
--- a/nptl/pthread_join_common.c
+++ b/nptl/pthread_join_common.c
@@ -59,7 +59,10 @@ __pthread_clockjoin_ex (pthread_t threadid, void **thread_return,
 	   && (pd->cancelhandling
 	       & (CANCELING_BITMASK | CANCELED_BITMASK | EXITING_BITMASK
 		  | TERMINATED_BITMASK)) == 0))
-      && !CANCEL_ENABLED_AND_CANCELED (self->cancelhandling))
+      && !(self->cancelstate == PTHREAD_CANCEL_ENABLE
+	   && (pd->cancelhandling & (CANCELED_BITMASK | EXITING_BITMASK
+				     | TERMINATED_BITMASK))
+	       == CANCELED_BITMASK))
     /* This is a deadlock situation.  The threads are waiting for each
        other to finish.  Note that this is a "may" error.  To be 100%
        sure we catch this error we would have to lock the data
diff --git a/nptl/pthread_setcancelstate.c b/nptl/pthread_setcancelstate.c
index e3696ca348..7e2b6e4974 100644
--- a/nptl/pthread_setcancelstate.c
+++ b/nptl/pthread_setcancelstate.c
@@ -31,39 +31,9 @@ __pthread_setcancelstate (int state, int *oldstate)
 
   self = THREAD_SELF;
 
-  int oldval = THREAD_GETMEM (self, cancelhandling);
-  while (1)
-    {
-      int newval = (state == PTHREAD_CANCEL_DISABLE
-		    ? oldval | CANCELSTATE_BITMASK
-		    : oldval & ~CANCELSTATE_BITMASK);
-
-      /* Store the old value.  */
-      if (oldstate != NULL)
-	*oldstate = ((oldval & CANCELSTATE_BITMASK)
-		     ? PTHREAD_CANCEL_DISABLE : PTHREAD_CANCEL_ENABLE);
-
-      /* Avoid doing unnecessary work.  The atomic operation can
-	 potentially be expensive if the memory has to be locked and
-	 remote cache lines have to be invalidated.  */
-      if (oldval == newval)
-	break;
-
-      /* Update the cancel handling word.  This has to be done
-	 atomically since other bits could be modified as well.  */
-      int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
-					      oldval);
-      if (__glibc_likely (curval == oldval))
-	{
-	  if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
-	    __do_cancel ();
-
-	  break;
-	}
-
-      /* Prepare for the next round.  */
-      oldval = curval;
-    }
+  if (oldstate != NULL)
+    *oldstate = self->cancelstate;
+  self->cancelstate = state;
 
   return 0;
 }
diff --git a/nptl/pthread_setcanceltype.c b/nptl/pthread_setcanceltype.c
index 5f061d512b..ae5df1d591 100644
--- a/nptl/pthread_setcanceltype.c
+++ b/nptl/pthread_setcanceltype.c
@@ -53,7 +53,8 @@ __pthread_setcanceltype (int type, int *oldtype)
 					      oldval);
       if (__glibc_likely (curval == oldval))
 	{
-	  if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
+	  if (self->cancelstate == PTHREAD_CANCEL_ENABLE
+	      && CANCEL_CANCELED_AND_ASYNCHRONOUS (newval))
 	    {
 	      THREAD_SETMEM (self, result, PTHREAD_CANCELED);
 	      __do_cancel ();
diff --git a/nptl/pthread_testcancel.c b/nptl/pthread_testcancel.c
index b6964904bb..c0d22eb77c 100644
--- a/nptl/pthread_testcancel.c
+++ b/nptl/pthread_testcancel.c
@@ -24,7 +24,16 @@
 void
 __pthread_testcancel (void)
 {
-  CANCELLATION_P (THREAD_SELF);
+  struct pthread *self = THREAD_SELF;
+  int cancelhandling = THREAD_GETMEM (self, cancelhandling);
+  if (self->cancelstate == PTHREAD_CANCEL_ENABLE
+      && (cancelhandling & CANCELED_BITMASK)
+      && !(cancelhandling & EXITING_BITMASK)
+      && !(cancelhandling & TERMINATED_BITMASK))
+    {
+      THREAD_SETMEM (self, result, PTHREAD_CANCELED);
+      __do_cancel ();
+    }
 }
 libc_hidden_def (__pthread_testcancel)
 
-- 
2.30.2


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

* [PATCH v3 5/6] nptl: Move cancel type out of cancelhandling
  2021-05-03 21:00 [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2021-05-03 21:00 ` [PATCH v3 4/6] nptl: Move cancel state out of cancelhandling Adhemerval Zanella
@ 2021-05-03 21:00 ` Adhemerval Zanella
  2021-05-03 21:00 ` [PATCH v3 6/6] nptl: Use pthread_kill on pthread_cancel Adhemerval Zanella
  2021-05-11 14:25 ` [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe Florian Weimer
  5 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-05-03 21:00 UTC (permalink / raw)
  To: libc-alpha

Changes from v2:
* Rebased against master.

Changes from v1:
* Rebased against master.

---

The thread cancellation type is not accessed concurrently internally
neither its pthread interface allows changing the state of a different
thread than its own.

By removing the cancel state out of the internal thread cancel handling
state there is no need to check if cancelled bit was set in CAS
operation.

It allows simplifing the cancellation wrappers and the
CANCEL_CANCELED_AND_ASYNCHRONOUS is removed.

Checked on x86_64-linux-gnu.
---
 nptl/allocatestack.c         |  1 +
 nptl/cancellation.c          | 60 ++++++++++--------------------------
 nptl/cleanup_defer.c         | 46 +++------------------------
 nptl/descr.h                 | 14 +++------
 nptl/libc-cleanup.c          | 44 +++-----------------------
 nptl/nptl-init.c             |  2 +-
 nptl/pthread_cancel.c        |  5 ++-
 nptl/pthread_setcanceltype.c | 42 +++----------------------
 8 files changed, 41 insertions(+), 173 deletions(-)

diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index eb25a2a034..53444e2870 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -220,6 +220,7 @@ get_cached_stack (size_t *sizep, void **memp)
   /* Cancellation handling is back to the default.  */
   result->cancelhandling = 0;
   result->cancelstate = PTHREAD_CANCEL_ENABLE;
+  result->canceltype = PTHREAD_CANCEL_DEFERRED;
   result->cleanup = NULL;
 
   /* No pending event.  */
diff --git a/nptl/cancellation.c b/nptl/cancellation.c
index 1ba94860fe..d039f424fb 100644
--- a/nptl/cancellation.c
+++ b/nptl/cancellation.c
@@ -32,31 +32,19 @@ attribute_hidden
 __pthread_enable_asynccancel (void)
 {
   struct pthread *self = THREAD_SELF;
-  int oldval = THREAD_GETMEM (self, cancelhandling);
 
-  while (1)
-    {
-      int newval = oldval | CANCELTYPE_BITMASK;
-
-      if (newval == oldval)
-	break;
-
-      int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
-					      oldval);
-      if (__glibc_likely (curval == oldval))
-	{
-	  if (self->cancelstate == PTHREAD_CANCEL_ENABLE
-	      && CANCEL_CANCELED_AND_ASYNCHRONOUS (newval))
-	    {
-	      THREAD_SETMEM (self, result, PTHREAD_CANCELED);
-	      __do_cancel ();
-	    }
+  int oldval = THREAD_GETMEM (self, canceltype);
+  THREAD_SETMEM (self, canceltype, PTHREAD_CANCEL_ASYNCHRONOUS);
 
-	  break;
-	}
+  int ch = THREAD_GETMEM (self, cancelhandling);
 
-      /* Prepare the next round.  */
-      oldval = curval;
+  if (self->cancelstate == PTHREAD_CANCEL_ENABLE
+      && (ch & CANCELED_BITMASK)
+      && !(ch & EXITING_BITMASK)
+      && !(ch & TERMINATED_BITMASK))
+    {
+      THREAD_SETMEM (self, result, PTHREAD_CANCELED);
+      __do_cancel ();
     }
 
   return oldval;
@@ -70,36 +58,22 @@ __pthread_disable_asynccancel (int oldtype)
 {
   /* If asynchronous cancellation was enabled before we do not have
      anything to do.  */
-  if (oldtype & CANCELTYPE_BITMASK)
+  if (oldtype == PTHREAD_CANCEL_ASYNCHRONOUS)
     return;
 
   struct pthread *self = THREAD_SELF;
-  int newval;
-
-  int oldval = THREAD_GETMEM (self, cancelhandling);
-
-  while (1)
-    {
-      newval = oldval & ~CANCELTYPE_BITMASK;
-
-      int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
-					      oldval);
-      if (__glibc_likely (curval == oldval))
-	break;
-
-      /* Prepare the next round.  */
-      oldval = curval;
-    }
+  THREAD_SETMEM (self, canceltype, PTHREAD_CANCEL_DEFERRED);
 
   /* We cannot return when we are being canceled.  Upon return the
      thread might be things which would have to be undone.  The
      following loop should loop until the cancellation signal is
      delivered.  */
-  while (__builtin_expect ((newval & (CANCELING_BITMASK | CANCELED_BITMASK))
-			   == CANCELING_BITMASK, 0))
+  int ch = THREAD_GETMEM (self, cancelhandling);
+  while (__glibc_unlikely ((ch & CANCELING_BITMASK)
+			    && !(ch & CANCELED_BITMASK)))
     {
-      futex_wait_simple ((unsigned int *) &self->cancelhandling, newval,
+      futex_wait_simple ((unsigned int *) &self->cancelhandling, ch,
 			 FUTEX_PRIVATE);
-      newval = THREAD_GETMEM (self, cancelhandling);
+      ch = THREAD_GETMEM (self, cancelhandling);
     }
 }
diff --git a/nptl/cleanup_defer.c b/nptl/cleanup_defer.c
index 3f7efc939f..8a41069ebf 100644
--- a/nptl/cleanup_defer.c
+++ b/nptl/cleanup_defer.c
@@ -31,27 +31,9 @@ __pthread_register_cancel_defer (__pthread_unwind_buf_t *buf)
   ibuf->priv.data.prev = THREAD_GETMEM (self, cleanup_jmp_buf);
   ibuf->priv.data.cleanup = THREAD_GETMEM (self, cleanup);
 
-  int cancelhandling = THREAD_GETMEM (self, cancelhandling);
-
   /* Disable asynchronous cancellation for now.  */
-  if (__glibc_unlikely (cancelhandling & CANCELTYPE_BITMASK))
-    while (1)
-      {
-	int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling,
-						cancelhandling
-						& ~CANCELTYPE_BITMASK,
-						cancelhandling);
-	if (__glibc_likely (curval == cancelhandling))
-	  /* Successfully replaced the value.  */
-	  break;
-
-	/* Prepare for the next round.  */
-	cancelhandling = curval;
-      }
-
-  ibuf->priv.data.canceltype = (cancelhandling & CANCELTYPE_BITMASK
-				? PTHREAD_CANCEL_ASYNCHRONOUS
-				: PTHREAD_CANCEL_DEFERRED);
+  ibuf->priv.data.canceltype = THREAD_GETMEM (self, canceltype);
+  THREAD_SETMEM (self, canceltype, PTHREAD_CANCEL_DEFERRED);
 
   /* Store the new cleanup handler info.  */
   THREAD_SETMEM (self, cleanup_jmp_buf, (struct pthread_unwind_buf *) buf);
@@ -67,25 +49,7 @@ __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *buf)
 
   THREAD_SETMEM (self, cleanup_jmp_buf, ibuf->priv.data.prev);
 
-  int cancelhandling;
-  if (ibuf->priv.data.canceltype != PTHREAD_CANCEL_DEFERRED
-      && ((cancelhandling = THREAD_GETMEM (self, cancelhandling))
-	  & CANCELTYPE_BITMASK) == 0)
-    {
-      while (1)
-	{
-	  int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling,
-						  cancelhandling
-						  | CANCELTYPE_BITMASK,
-						  cancelhandling);
-	  if (__glibc_likely (curval == cancelhandling))
-	    /* Successfully replaced the value.  */
-	    break;
-
-	  /* Prepare for the next round.  */
-	  cancelhandling = curval;
-	}
-
-      __pthread_testcancel ();
-    }
+  THREAD_SETMEM (self, canceltype, ibuf->priv.data.canceltype);
+  if (ibuf->priv.data.canceltype == PTHREAD_CANCEL_ASYNCHRONOUS)
+    __pthread_testcancel ();
 }
diff --git a/nptl/descr.h b/nptl/descr.h
index 465af117e5..8ef877b1cd 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -277,9 +277,6 @@ struct pthread
 
   /* Flags determining processing of cancellation.  */
   int cancelhandling;
-  /* Bit set if asynchronous cancellation mode is selected.  */
-#define CANCELTYPE_BIT		1
-#define CANCELTYPE_BITMASK	(0x01 << CANCELTYPE_BIT)
   /* Bit set if canceling has been initiated.  */
 #define CANCELING_BIT		2
 #define CANCELING_BITMASK	(0x01 << CANCELING_BIT)
@@ -295,13 +292,6 @@ struct pthread
   /* Bit set if thread is supposed to change XID.  */
 #define SETXID_BIT		6
 #define SETXID_BITMASK		(0x01 << SETXID_BIT)
-  /* Mask for the rest.  Helps the compiler to optimize.  */
-#define CANCEL_RESTMASK		0xffffff80
-
-#define CANCEL_CANCELED_AND_ASYNCHRONOUS(value) \
-  (((value) & (CANCELTYPE_BITMASK | CANCELED_BITMASK    \
-	       | EXITING_BITMASK | CANCEL_RESTMASK | TERMINATED_BITMASK))     \
-   == (CANCELTYPE_BITMASK | CANCELED_BITMASK))
 
   /* Flags.  Including those copied from the thread attribute.  */
   int flags;
@@ -407,6 +397,10 @@ struct pthread
      PTHREAD_CANCEL_DISABLE).  */
   unsigned char cancelstate;
 
+  /* Thread cancel type (PTHREAD_CANCEL_DEFERRED or
+     PTHREAD_CANCEL_ASYNCHRONOUS).  */
+  unsigned char canceltype;
+
   /* This member must be last.  */
   char end_padding[];
 
diff --git a/nptl/libc-cleanup.c b/nptl/libc-cleanup.c
index 6286b8b525..180d15bc9e 100644
--- a/nptl/libc-cleanup.c
+++ b/nptl/libc-cleanup.c
@@ -27,27 +27,9 @@ __libc_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer)
 
   buffer->__prev = THREAD_GETMEM (self, cleanup);
 
-  int cancelhandling = THREAD_GETMEM (self, cancelhandling);
-
   /* Disable asynchronous cancellation for now.  */
-  if (__glibc_unlikely (cancelhandling & CANCELTYPE_BITMASK))
-    while (1)
-      {
-	int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling,
-						cancelhandling
-						& ~CANCELTYPE_BITMASK,
-						cancelhandling);
-	if (__glibc_likely (curval == cancelhandling))
-	  /* Successfully replaced the value.  */
-	  break;
-
-	/* Prepare for the next round.  */
-	cancelhandling = curval;
-      }
-
-  buffer->__canceltype = (cancelhandling & CANCELTYPE_BITMASK
-			  ? PTHREAD_CANCEL_ASYNCHRONOUS
-			  : PTHREAD_CANCEL_DEFERRED);
+  buffer->__canceltype = THREAD_GETMEM (self, canceltype);
+  THREAD_SETMEM (self, canceltype, PTHREAD_CANCEL_DEFERRED);
 
   THREAD_SETMEM (self, cleanup, buffer);
 }
@@ -60,26 +42,8 @@ __libc_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer)
 
   THREAD_SETMEM (self, cleanup, buffer->__prev);
 
-  int cancelhandling;
-  if (__builtin_expect (buffer->__canceltype != PTHREAD_CANCEL_DEFERRED, 0)
-      && ((cancelhandling = THREAD_GETMEM (self, cancelhandling))
-	  & CANCELTYPE_BITMASK) == 0)
-    {
-      while (1)
-	{
-	  int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling,
-						  cancelhandling
-						  | CANCELTYPE_BITMASK,
-						  cancelhandling);
-	  if (__glibc_likely (curval == cancelhandling))
-	    /* Successfully replaced the value.  */
-	    break;
-
-	  /* Prepare for the next round.  */
-	  cancelhandling = curval;
-	}
-
+  THREAD_SETMEM (self, canceltype, buffer->__canceltype);
+  if (buffer->__canceltype == PTHREAD_CANCEL_ASYNCHRONOUS)
       __pthread_testcancel ();
-    }
 }
 libc_hidden_def (__libc_cleanup_pop_restore)
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index b0879bd87e..82f0284979 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -84,7 +84,7 @@ sigcancel_handler (int sig, siginfo_t *si, void *ctx)
 	  THREAD_SETMEM (self, result, PTHREAD_CANCELED);
 
 	  /* Make sure asynchronous cancellation is still enabled.  */
-	  if ((newval & CANCELTYPE_BITMASK) != 0)
+	  if (self->canceltype == PTHREAD_CANCEL_ASYNCHRONOUS)
 	    /* Run the registered destructors and terminate the thread.  */
 	    __do_cancel ();
 
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
index b3dbf26843..d48d04881c 100644
--- a/nptl/pthread_cancel.c
+++ b/nptl/pthread_cancel.c
@@ -65,7 +65,10 @@ __pthread_cancel (pthread_t th)
 	 signal.  We avoid this if possible since it's more
 	 expensive.  */
       if (pd->cancelstate == PTHREAD_CANCEL_ENABLE
-	  && CANCEL_CANCELED_AND_ASYNCHRONOUS (newval))
+	  && pd->canceltype == PTHREAD_CANCEL_ASYNCHRONOUS
+	  && (newval & CANCELED_BITMASK)
+	  && !(newval & EXITING_BITMASK)
+	  && !(newval & TERMINATED_BITMASK))
 	{
 	  /* Mark the cancellation as "in progress".  */
 	  if (atomic_compare_and_exchange_bool_acq (&pd->cancelhandling,
diff --git a/nptl/pthread_setcanceltype.c b/nptl/pthread_setcanceltype.c
index ae5df1d591..e7b24ae733 100644
--- a/nptl/pthread_setcanceltype.c
+++ b/nptl/pthread_setcanceltype.c
@@ -29,43 +29,11 @@ __pthread_setcanceltype (int type, int *oldtype)
 
   volatile struct pthread *self = THREAD_SELF;
 
-  int oldval = THREAD_GETMEM (self, cancelhandling);
-  while (1)
-    {
-      int newval = (type == PTHREAD_CANCEL_ASYNCHRONOUS
-		    ? oldval | CANCELTYPE_BITMASK
-		    : oldval & ~CANCELTYPE_BITMASK);
-
-      /* Store the old value.  */
-      if (oldtype != NULL)
-	*oldtype = ((oldval & CANCELTYPE_BITMASK)
-		    ? PTHREAD_CANCEL_ASYNCHRONOUS : PTHREAD_CANCEL_DEFERRED);
-
-      /* Avoid doing unnecessary work.  The atomic operation can
-	 potentially be expensive if the memory has to be locked and
-	 remote cache lines have to be invalidated.  */
-      if (oldval == newval)
-	break;
-
-      /* Update the cancel handling word.  This has to be done
-	 atomically since other bits could be modified as well.  */
-      int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
-					      oldval);
-      if (__glibc_likely (curval == oldval))
-	{
-	  if (self->cancelstate == PTHREAD_CANCEL_ENABLE
-	      && CANCEL_CANCELED_AND_ASYNCHRONOUS (newval))
-	    {
-	      THREAD_SETMEM (self, result, PTHREAD_CANCELED);
-	      __do_cancel ();
-	    }
-
-	  break;
-	}
-
-      /* Prepare for the next round.  */
-      oldval = curval;
-    }
+  if (oldtype != NULL)
+    *oldtype = self->canceltype;
+  self->canceltype = type;
+  if (type == PTHREAD_CANCEL_ASYNCHRONOUS)
+    __pthread_testcancel ();
 
   return 0;
 }
-- 
2.30.2


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

* [PATCH v3 6/6] nptl: Use pthread_kill on pthread_cancel
  2021-05-03 21:00 [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2021-05-03 21:00 ` [PATCH v3 5/6] nptl: Move cancel type " Adhemerval Zanella
@ 2021-05-03 21:00 ` Adhemerval Zanella
  2021-05-11 14:25 ` [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe Florian Weimer
  5 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-05-03 21:00 UTC (permalink / raw)
  To: libc-alpha

Changes from v2:
* Rebased against master.

---

It consolidates the tgkill call and it is the first step of making
pthread_cancel async-signal-safe.

Checked on x86_64-linux-gnu.
---
 nptl/Versions         |  2 ++
 nptl/pthreadP.h       |  2 ++
 nptl/pthread_cancel.c |  7 +------
 nptl/pthread_kill.c   | 19 +++++++++++++------
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/nptl/Versions b/nptl/Versions
index b0c575e30f..42a07c9ca3 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -291,6 +291,8 @@ libc {
     __pthread_testcancel;
     __sched_fifo_max_prio;
     __sched_fifo_min_prio;
+    # Used for thread cancellation.
+    __pthread_kill_internal;
   }
 }
 
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 7d2f33be0d..ee92217598 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -552,6 +552,8 @@ extern int __pthread_equal (pthread_t thread1, pthread_t thread2);
 extern int __pthread_detach (pthread_t th);
 extern int __pthread_cancel (pthread_t th);
 libc_hidden_proto (__pthread_kill)
+extern int __pthread_kill_internal (pthread_t threadid, int signo);
+libc_hidden_proto (__pthread_kill_internal);
 extern void __pthread_exit (void *value) __attribute__ ((__noreturn__));
 libc_hidden_proto (__pthread_exit)
 extern int __pthread_join (pthread_t threadid, void **thread_return);
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
index d48d04881c..8dc1f23fdb 100644
--- a/nptl/pthread_cancel.c
+++ b/nptl/pthread_cancel.c
@@ -78,12 +78,7 @@ __pthread_cancel (pthread_t th)
 
 	  /* The cancellation handler will take care of marking the
 	     thread as canceled.  */
-	  pid_t pid = __getpid ();
-
-	  int val = INTERNAL_SYSCALL_CALL (tgkill, pid, pd->tid,
-					   SIGCANCEL);
-	  if (INTERNAL_SYSCALL_ERROR_P (val))
-	    result = INTERNAL_SYSCALL_ERRNO (val);
+	  __pthread_kill_internal (th, SIGCANCEL);
 
 	  break;
 	}
diff --git a/nptl/pthread_kill.c b/nptl/pthread_kill.c
index d79531c10c..b1411f46b6 100644
--- a/nptl/pthread_kill.c
+++ b/nptl/pthread_kill.c
@@ -21,13 +21,8 @@
 #include <shlib-compat.h>
 
 int
-__pthread_kill (pthread_t threadid, int signo)
+__pthread_kill_internal (pthread_t threadid, int signo)
 {
-  /* Disallow sending the signal we use for cancellation, timers,
-     for the setxid implementation.  */
-  if (__is_internal_signal (signo))
-    return EINVAL;
-
   sigset_t set;
   __libc_signal_block_all (&set);
 
@@ -58,6 +53,18 @@ __pthread_kill (pthread_t threadid, int signo)
 
   return val;
 }
+libc_hidden_def (__pthread_kill_internal)
+
+int
+__pthread_kill (pthread_t threadid, int signo)
+{
+  /* Disallow sending the signal we use for cancellation, timers,
+     for the setxid implementation.  */
+  if (__is_internal_signal (signo))
+    return EINVAL;
+
+  return __pthread_kill_internal (threadid, signo);
+}
 /* Some architectures (for instance arm) might pull raise through libgcc, so
    avoid the symbol version if it ends up being used on ld.so.  */
 #if !IS_IN(rtld)
-- 
2.30.2


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

* Re: [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe
  2021-05-03 21:00 [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2021-05-03 21:00 ` [PATCH v3 6/6] nptl: Use pthread_kill on pthread_cancel Adhemerval Zanella
@ 2021-05-11 14:25 ` Florian Weimer
  2021-05-11 14:41   ` Adhemerval Zanella
  5 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-05-11 14:25 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella via Libc-alpha:

> Changes from v2:
> * Rebase against master.
>
> Changes from v1:
> * Move __libc_signal_block_all prior TID read.
>
> ---
>
> Simiar to raise (BZ #15368), pthread_kill is also defined as
> async-signal-safe (POSIX.1-2008 TC1).  However, similar to raise
> it has the same issues relating to signal handling.
>
> Different than raise, all the signal are blocked so it would be
> possible to implement pthread_cancel (which also should be
> async-cancel safe).

I think it would make sense to spell out what the actual bug fix is.

It's hard to tell whether pthread_kill is now truly async-signal-safe,
given that there is still a race with regards to thread exit and TID
reuse.

Thanks,
Florian


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

* Re: [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill
  2021-05-03 21:00 ` [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill Adhemerval Zanella
@ 2021-05-11 14:29   ` Florian Weimer
  2021-05-11 14:43     ` Adhemerval Zanella
  2021-05-11 15:50   ` Florian Weimer
  1 sibling, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-05-11 14:29 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella via Libc-alpha:

> Now that pthread_kill is provided by libc.so and async-signal-safe,
> it is possible to implement the generic POSIX implementation as
> pthread_kill(pthread_self(), sig).

This part no longer matches the patch, I think.

> For Linux implementation, pthread_kill read the targetting TID from
> the TCB.  For raise, this it not possible because it would make raise
> fail when issue after vfork (where creates the resulting process
> has a different TID from the parent, but its TCB is not updated as
> for pthread_create).  For this case, gettid is called directly.
>
> Checked on x86_64-linux-gnu.
> ---
>  include/pthread.h               |  5 ++++
>  nptl/pthreadP.h                 |  4 +--
>  nptl/pthread_kill.c             | 42 +++++++++++++++-----------
>  nptl/pthread_self.c             |  4 ++-
>  sysdeps/htl/pthreadP.h          |  2 --
>  sysdeps/posix/raise.c           | 11 +++++--
>  sysdeps/unix/sysv/linux/raise.c | 52 ---------------------------------

The new raise doesn't use pthread_kill but direct system calls, so the
libpthread changes are unnecessary, and the implementation should remain
as sysdeps/unix/sysv/linux/raise.c.

Thanks,
Florian


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

* Re: [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe
  2021-05-11 14:25 ` [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe Florian Weimer
@ 2021-05-11 14:41   ` Adhemerval Zanella
  2021-05-11 14:44     ` Florian Weimer
  0 siblings, 1 reply; 15+ messages in thread
From: Adhemerval Zanella @ 2021-05-11 14:41 UTC (permalink / raw)
  To: Florian Weimer, Adhemerval Zanella via Libc-alpha



On 11/05/2021 11:25, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> Changes from v2:
>> * Rebase against master.
>>
>> Changes from v1:
>> * Move __libc_signal_block_all prior TID read.
>>
>> ---
>>
>> Simiar to raise (BZ #15368), pthread_kill is also defined as
>> async-signal-safe (POSIX.1-2008 TC1).  However, similar to raise
>> it has the same issues relating to signal handling.
>>
>> Different than raise, all the signal are blocked so it would be
>> possible to implement pthread_cancel (which also should be
>> async-cancel safe).
> 
> I think it would make sense to spell out what the actual bug fix is.
> 
> It's hard to tell whether pthread_kill is now truly async-signal-safe,
> given that there is still a race with regards to thread exit and TID
> reuse.

But this is another issue [1] and it would require a different fix
than this one (possibly a additional per-thread lock to synchronize
with pthread_create and pthread_kill).

Blocking the signal help regarding cancellation, but we will need a
different to handle the pthread_exit.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=12889

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

* Re: [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill
  2021-05-11 14:29   ` Florian Weimer
@ 2021-05-11 14:43     ` Adhemerval Zanella
  2021-05-11 14:47       ` Florian Weimer
  0 siblings, 1 reply; 15+ messages in thread
From: Adhemerval Zanella @ 2021-05-11 14:43 UTC (permalink / raw)
  To: Florian Weimer, Adhemerval Zanella via Libc-alpha



On 11/05/2021 11:29, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> Now that pthread_kill is provided by libc.so and async-signal-safe,
>> it is possible to implement the generic POSIX implementation as
>> pthread_kill(pthread_self(), sig).
> 
> This part no longer matches the patch, I think.

We should be since b76658451c81, no?

> 
>> For Linux implementation, pthread_kill read the targetting TID from
>> the TCB.  For raise, this it not possible because it would make raise
>> fail when issue after vfork (where creates the resulting process
>> has a different TID from the parent, but its TCB is not updated as
>> for pthread_create).  For this case, gettid is called directly.
>>
>> Checked on x86_64-linux-gnu.
>> ---
>>  include/pthread.h               |  5 ++++
>>  nptl/pthreadP.h                 |  4 +--
>>  nptl/pthread_kill.c             | 42 +++++++++++++++-----------
>>  nptl/pthread_self.c             |  4 ++-
>>  sysdeps/htl/pthreadP.h          |  2 --
>>  sysdeps/posix/raise.c           | 11 +++++--
>>  sysdeps/unix/sysv/linux/raise.c | 52 ---------------------------------
> 
> The new raise doesn't use pthread_kill but direct system calls, so the
> libpthread changes are unnecessary, and the implementation should remain
> as sysdeps/unix/sysv/linux/raise.c.
> 

But the new sysdeps/posix/raise.c does uses, this patch change it to:

 int
 raise (int sig)
 {
  int ret = __pthread_kill (__pthread_self (), sig);
  if (ret != 0)
    {
      __set_errno (ret);
      ret = -1;
    }
  return ret;
 }

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

* Re: [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe
  2021-05-11 14:41   ` Adhemerval Zanella
@ 2021-05-11 14:44     ` Florian Weimer
  2021-05-11 14:48       ` Adhemerval Zanella
  0 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-05-11 14:44 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella:

> On 11/05/2021 11:25, Florian Weimer wrote:
>> * Adhemerval Zanella via Libc-alpha:
>> 
>>> Changes from v2:
>>> * Rebase against master.
>>>
>>> Changes from v1:
>>> * Move __libc_signal_block_all prior TID read.
>>>
>>> ---
>>>
>>> Simiar to raise (BZ #15368), pthread_kill is also defined as
>>> async-signal-safe (POSIX.1-2008 TC1).  However, similar to raise
>>> it has the same issues relating to signal handling.
>>>
>>> Different than raise, all the signal are blocked so it would be
>>> possible to implement pthread_cancel (which also should be
>>> async-cancel safe).
>> 
>> I think it would make sense to spell out what the actual bug fix is.
>> 
>> It's hard to tell whether pthread_kill is now truly async-signal-safe,
>> given that there is still a race with regards to thread exit and TID
>> reuse.
>
> But this is another issue [1] and it would require a different fix
> than this one (possibly a additional per-thread lock to synchronize
> with pthread_create and pthread_kill).
>
> Blocking the signal help regarding cancellation, but we will need a
> different to handle the pthread_exit.
>
> [1] https://sourceware.org/bugzilla/show_bug.cgi?id=12889

Sure, but I don't really see how this improves async-signal-safety given
that we do not block signals around fork (which we should perhaps do; I
think there's nothing preventing us from doing that).

Thanks,
Florian


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

* Re: [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill
  2021-05-11 14:43     ` Adhemerval Zanella
@ 2021-05-11 14:47       ` Florian Weimer
  0 siblings, 0 replies; 15+ messages in thread
From: Florian Weimer @ 2021-05-11 14:47 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella:

> On 11/05/2021 11:29, Florian Weimer wrote:
>> * Adhemerval Zanella via Libc-alpha:
>> 
>>> Now that pthread_kill is provided by libc.so and async-signal-safe,
>>> it is possible to implement the generic POSIX implementation as
>>> pthread_kill(pthread_self(), sig).
>> 
>> This part no longer matches the patch, I think.
>
> We should be since b76658451c81, no?
>
>> 
>>> For Linux implementation, pthread_kill read the targetting TID from
>>> the TCB.  For raise, this it not possible because it would make raise
>>> fail when issue after vfork (where creates the resulting process
>>> has a different TID from the parent, but its TCB is not updated as
>>> for pthread_create).  For this case, gettid is called directly.
>>>
>>> Checked on x86_64-linux-gnu.
>>> ---
>>>  include/pthread.h               |  5 ++++
>>>  nptl/pthreadP.h                 |  4 +--
>>>  nptl/pthread_kill.c             | 42 +++++++++++++++-----------
>>>  nptl/pthread_self.c             |  4 ++-
>>>  sysdeps/htl/pthreadP.h          |  2 --
>>>  sysdeps/posix/raise.c           | 11 +++++--
>>>  sysdeps/unix/sysv/linux/raise.c | 52 ---------------------------------
>> 
>> The new raise doesn't use pthread_kill but direct system calls, so the
>> libpthread changes are unnecessary, and the implementation should remain
>> as sysdeps/unix/sysv/linux/raise.c.
>> 
>
> But the new sysdeps/posix/raise.c does uses, this patch change it to:
>
>  int
>  raise (int sig)
>  {
>   int ret = __pthread_kill (__pthread_self (), sig);
>   if (ret != 0)
>     {
>       __set_errno (ret);
>       ret = -1;
>     }
>   return ret;
>  }

Hmm, I may have been confused.  Let me re-review.

Florian


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

* Re: [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe
  2021-05-11 14:44     ` Florian Weimer
@ 2021-05-11 14:48       ` Adhemerval Zanella
  0 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-05-11 14:48 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Adhemerval Zanella via Libc-alpha



On 11/05/2021 11:44, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> On 11/05/2021 11:25, Florian Weimer wrote:
>>> * Adhemerval Zanella via Libc-alpha:
>>>
>>>> Changes from v2:
>>>> * Rebase against master.
>>>>
>>>> Changes from v1:
>>>> * Move __libc_signal_block_all prior TID read.
>>>>
>>>> ---
>>>>
>>>> Simiar to raise (BZ #15368), pthread_kill is also defined as
>>>> async-signal-safe (POSIX.1-2008 TC1).  However, similar to raise
>>>> it has the same issues relating to signal handling.
>>>>
>>>> Different than raise, all the signal are blocked so it would be
>>>> possible to implement pthread_cancel (which also should be
>>>> async-cancel safe).
>>>
>>> I think it would make sense to spell out what the actual bug fix is.
>>>
>>> It's hard to tell whether pthread_kill is now truly async-signal-safe,
>>> given that there is still a race with regards to thread exit and TID
>>> reuse.
>>
>> But this is another issue [1] and it would require a different fix
>> than this one (possibly a additional per-thread lock to synchronize
>> with pthread_create and pthread_kill).
>>
>> Blocking the signal help regarding cancellation, but we will need a
>> different to handle the pthread_exit.
>>
>> [1] https://sourceware.org/bugzilla/show_bug.cgi?id=12889
> 
> Sure, but I don't really see how this improves async-signal-safety given
> that we do not block signals around fork (which we should perhaps do; I
> think there's nothing preventing us from doing that).

Right, I think this patch came from a previous attempt to fix
bz12889, but thinking twice it does not add much without fixing
the race condition in pthread_kill first.

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

* Re: [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill
  2021-05-03 21:00 ` [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill Adhemerval Zanella
  2021-05-11 14:29   ` Florian Weimer
@ 2021-05-11 15:50   ` Florian Weimer
  2021-05-13 16:17     ` Adhemerval Zanella
  1 sibling, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-05-11 15:50 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella via Libc-alpha:

> Now that pthread_kill is provided by libc.so and async-signal-safe,
> it is possible to implement the generic POSIX implementation as
> pthread_kill(pthread_self(), sig).

Second try: I think the comment about async-signal-safety is
unnecessary.

Furthermore, pthread_kill is not available in Hurd's libc.so, so I'm not
quite sure how this will build there.

> For Linux implementation, pthread_kill read the targetting TID from
> the TCB.  For raise, this it not possible because it would make raise
> fail when issue after vfork (where creates the resulting process
> has a different TID from the parent, but its TCB is not updated as
> for pthread_create).  For this case, gettid is called directly.

I think this should just say that pthread_kill is made ready for use
from vfork.  The mechanical details of doing that should be captured in
a comment.

> diff --git a/nptl/pthread_kill.c b/nptl/pthread_kill.c
> index 71c362adce..d79531c10c 100644
> --- a/nptl/pthread_kill.c
> +++ b/nptl/pthread_kill.c
> @@ -31,32 +31,40 @@ __pthread_kill (pthread_t threadid, int signo)
>    sigset_t set;
>    __libc_signal_block_all (&set);
>  
> -  int val;
> -
> -  /* Force load of pd->tid into local variable or register.  Otherwise
> -     if a thread exits between ESRCH test and tgkill, we might return
> -     EINVAL, because pd->tid would be cleared by the kernel.  */
> +  pid_t tid;
>    struct pthread *pd = (struct pthread *) threadid;
> -  pid_t tid = atomic_forced_read (pd->tid);
> -  if (__glibc_unlikely (tid <= 0))
> -    /* Not a valid thread handle.  */
> -    val = ESRCH;
> +
> +  if (pd == THREAD_SELF)
> +    tid = INLINE_SYSCALL_CALL (gettid);

This should have a comment referencing vfork.

>    else
> -    {
> -      /* We have a special syscall to do the work.  */
> -      pid_t pid = __getpid ();
> +    /* Force load of pd->tid into local variable or register.  Otherwise
> +       if a thread exits between ESRCH test and tgkill, we might return
> +       EINVAL, because pd->tid would be cleared by the kernel.  */
> +    tid = atomic_forced_read (pd->tid);
> +
> +   int val;
> +   if (__glibc_likely (tid > 0))
> +     {
> +       pid_t pid = __getpid ();
>  
> -      val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
> -      val = (INTERNAL_SYSCALL_ERROR_P (val)
> -	    ? INTERNAL_SYSCALL_ERRNO (val) : 0);
> -    }
> +       val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
> +       val = (INTERNAL_SYSCALL_ERROR_P (val)
> +	     ? INTERNAL_SYSCALL_ERRNO (val) : 0);
> +     }
> +   else
> +     val = ESRCH;
>  
>    __libc_signal_restore_set (&set);
>  
>    return val;
>  }
> +/* Some architectures (for instance arm) might pull raise through libgcc, so
> +   avoid the symbol version if it ends up being used on ld.so.  */
> +#if !IS_IN(rtld)
> +libc_hidden_def (__pthread_kill)
>  versioned_symbol (libc, __pthread_kill, pthread_kill, GLIBC_2_34);
>  
> -#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34)
> +# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34)
>  compat_symbol (libc, __pthread_kill, pthread_kill, GLIBC_2_0);
> +# endif
>  #endif

Rest of the pthread_kill change looks okay.

> diff --git a/nptl/pthread_self.c b/nptl/pthread_self.c
> index f877a2e6bd..196d93fb8e 100644
> --- a/nptl/pthread_self.c
> +++ b/nptl/pthread_self.c
> @@ -20,7 +20,9 @@
>  #include <tls.h>
>  
>  pthread_t
> -pthread_self (void)
> +__pthread_self (void)
>  {
>    return (pthread_t) THREAD_SELF;
>  }
> +libc_hidden_def (__pthread_self)
> +weak_alias (__pthread_self, pthread_self)
> diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h
> index 8e2cf2ce65..3b357b7bdc 100644

THREAD_SELF is now available on Hurd, too.  So any reference to
__pthread_self should use THREAD_SELF directly, I think.

Thanks,
Florian


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

* Re: [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill
  2021-05-11 15:50   ` Florian Weimer
@ 2021-05-13 16:17     ` Adhemerval Zanella
  0 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2021-05-13 16:17 UTC (permalink / raw)
  To: Florian Weimer, Adhemerval Zanella via Libc-alpha



On 11/05/2021 12:50, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> Now that pthread_kill is provided by libc.so and async-signal-safe,
>> it is possible to implement the generic POSIX implementation as
>> pthread_kill(pthread_self(), sig).
> 
> Second try: I think the comment about async-signal-safety is
> unnecessary.

Fair enough. 

> 
> Furthermore, pthread_kill is not available in Hurd's libc.so, so I'm not
> quite sure how this will build there.

Hurd uses sysdeps/hurd/htl/pt-kill.c instead.

> 
>> For Linux implementation, pthread_kill read the targetting TID from
>> the TCB.  For raise, this it not possible because it would make raise
>> fail when issue after vfork (where creates the resulting process
>> has a different TID from the parent, but its TCB is not updated as
>> for pthread_create).  For this case, gettid is called directly.
> 
> I think this should just say that pthread_kill is made ready for use
> from vfork.  The mechanical details of doing that should be captured in
> a comment.

What about:

  Now that pthread_kill is provided by libc.so it is possible to implement 
  the generic POSIX implementation as pthread_kill(pthread_self(), sig).

  For Linux implementation, pthread_kill read the targeting TID from
  the TCB.  For raise, this it not possible because it would make raise
  fail when issue after vfork (where creates the resulting process
  has a different TID from the parent, but its TCB is not updated as
  for pthread_create).  To make raise use pthread_kill, it is make
  usable from vfork by getting the target thread id through gettid
  syscall.


> 
>> diff --git a/nptl/pthread_kill.c b/nptl/pthread_kill.c
>> index 71c362adce..d79531c10c 100644
>> --- a/nptl/pthread_kill.c
>> +++ b/nptl/pthread_kill.c
>> @@ -31,32 +31,40 @@ __pthread_kill (pthread_t threadid, int signo)
>>    sigset_t set;
>>    __libc_signal_block_all (&set);
>>  
>> -  int val;
>> -
>> -  /* Force load of pd->tid into local variable or register.  Otherwise
>> -     if a thread exits between ESRCH test and tgkill, we might return
>> -     EINVAL, because pd->tid would be cleared by the kernel.  */
>> +  pid_t tid;
>>    struct pthread *pd = (struct pthread *) threadid;
>> -  pid_t tid = atomic_forced_read (pd->tid);
>> -  if (__glibc_unlikely (tid <= 0))
>> -    /* Not a valid thread handle.  */
>> -    val = ESRCH;
>> +
>> +  if (pd == THREAD_SELF)
>> +    tid = INLINE_SYSCALL_CALL (gettid);
> 
> This should have a comment referencing vfork.

Ack.

> 
>>    else
>> -    {
>> -      /* We have a special syscall to do the work.  */
>> -      pid_t pid = __getpid ();
>> +    /* Force load of pd->tid into local variable or register.  Otherwise
>> +       if a thread exits between ESRCH test and tgkill, we might return
>> +       EINVAL, because pd->tid would be cleared by the kernel.  */
>> +    tid = atomic_forced_read (pd->tid);
>> +
>> +   int val;
>> +   if (__glibc_likely (tid > 0))
>> +     {
>> +       pid_t pid = __getpid ();
>>  
>> -      val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
>> -      val = (INTERNAL_SYSCALL_ERROR_P (val)
>> -	    ? INTERNAL_SYSCALL_ERRNO (val) : 0);
>> -    }
>> +       val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
>> +       val = (INTERNAL_SYSCALL_ERROR_P (val)
>> +	     ? INTERNAL_SYSCALL_ERRNO (val) : 0);
>> +     }
>> +   else
>> +     val = ESRCH;
>>  
>>    __libc_signal_restore_set (&set);
>>  
>>    return val;
>>  }
>> +/* Some architectures (for instance arm) might pull raise through libgcc, so
>> +   avoid the symbol version if it ends up being used on ld.so.  */
>> +#if !IS_IN(rtld)
>> +libc_hidden_def (__pthread_kill)
>>  versioned_symbol (libc, __pthread_kill, pthread_kill, GLIBC_2_34);
>>  
>> -#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34)
>> +# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34)
>>  compat_symbol (libc, __pthread_kill, pthread_kill, GLIBC_2_0);
>> +# endif
>>  #endif
> 
> Rest of the pthread_kill change looks okay.
> 
>> diff --git a/nptl/pthread_self.c b/nptl/pthread_self.c
>> index f877a2e6bd..196d93fb8e 100644
>> --- a/nptl/pthread_self.c
>> +++ b/nptl/pthread_self.c
>> @@ -20,7 +20,9 @@
>>  #include <tls.h>
>>  
>>  pthread_t
>> -pthread_self (void)
>> +__pthread_self (void)
>>  {
>>    return (pthread_t) THREAD_SELF;
>>  }
>> +libc_hidden_def (__pthread_self)
>> +weak_alias (__pthread_self, pthread_self)
>> diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h
>> index 8e2cf2ce65..3b357b7bdc 100644
> 
> THREAD_SELF is now available on Hurd, too.  So any reference to
> __pthread_self should use THREAD_SELF directly, I think.

In that case maybe move the consolidation to signal/raise.c instead
of sysdeps/posix/raise.c. 

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

end of thread, other threads:[~2021-05-13 16:17 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03 21:00 [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe Adhemerval Zanella
2021-05-03 21:00 ` [PATCH v3 2/6] nptl: Implement raise in terms of pthread_kill Adhemerval Zanella
2021-05-11 14:29   ` Florian Weimer
2021-05-11 14:43     ` Adhemerval Zanella
2021-05-11 14:47       ` Florian Weimer
2021-05-11 15:50   ` Florian Weimer
2021-05-13 16:17     ` Adhemerval Zanella
2021-05-03 21:00 ` [PATCH v3 3/6] nptl: Move pthread_testcancel into libc Adhemerval Zanella
2021-05-03 21:00 ` [PATCH v3 4/6] nptl: Move cancel state out of cancelhandling Adhemerval Zanella
2021-05-03 21:00 ` [PATCH v3 5/6] nptl: Move cancel type " Adhemerval Zanella
2021-05-03 21:00 ` [PATCH v3 6/6] nptl: Use pthread_kill on pthread_cancel Adhemerval Zanella
2021-05-11 14:25 ` [PATCH v3 1/6] nptl: Make pthread_kill async-signal-safe Florian Weimer
2021-05-11 14:41   ` Adhemerval Zanella
2021-05-11 14:44     ` Florian Weimer
2021-05-11 14:48       ` Adhemerval Zanella

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