public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/9] nptl: pthread cancellation refactor
@ 2021-05-27 17:28 Adhemerval Zanella
  2021-05-27 17:28 ` [PATCH v2 1/9] nptl: Remove exit-thread.h Adhemerval Zanella
                   ` (8 more replies)
  0 siblings, 9 replies; 49+ messages in thread
From: Adhemerval Zanella @ 2021-05-27 17:28 UTC (permalink / raw)
  To: libc-alpha

Changes from v1 [1]:

  - Moved the __do_cancel call for the BZ #19511 fix to a place where
    the PD is held by the thread.
  - Fixed style issues.
  - Added the BZ#19366 fix.

--

This patchset refactor and simplifies the nptl cancellation code.  The
1st patch is a NFC change.

The 2nd patch fixes an memory leak issue when pthread_create fails to
setup either the scheduling or affinity parameter.  The asynchronous
cancellation is removed in favor of using a member to indicate the
setup has failed and letting the created thread to deallocate the
memory (similar on how detached threads do).

The 3rd patch moves the signal handler setup to pthread_cancel, now that
asynchronous cancellation is not used anymore on thread creation.

The 4th removes the CANCELING_BITMASK bit, since it is mainly used to
signal that a syscall that has returned should be cancelled (which is
a wrong assumption, since syscall with side-effects should *not* be
cancelled as per BZ#12683).

The 5th and 6th patches move both the cancel state and cancel type out
of 'cancelhandling' variable, since with CANCELING_BITMASK and
pthread_cancel change in previous patch they are not accessed in a
concurrent manner.

The 7th and 8th patchies consolidates the raise as
'pthread_kill(pthread_self())' and use pthread_kill() on
pthread_cancel().

Finally, the 9th fixes another cancellation synchronization issue
when async cancellation might early exit the process due wrong
__nptl_nthreads update.

[1] https://sourceware.org/pipermail/libc-alpha/2021-May/126852.html

Adhemerval Zanella (9):
  nptl: Remove exit-thread.h
  nptl: Deallocate the thread stack on setup failure (BZ #19511)
  nptl: Install cancellation handler on pthread_cancel
  nptl: Remove CANCELING_BITMASK
  nptl: Move cancel state out of cancelhandling
  nptl: Move cancel type out of cancelhandling
  nptl: Implement raise in terms of pthread_kill
  nptl: Use pthread_kill on pthread_cancel
  nptl: Avoid async cancellation to wrongly update __nptl_nthreads (BZ
    #19366)

 csu/libc-start.c                      |   1 -
 include/pthread.h                     |   5 +
 manual/pattern.texi                   |   1 -
 manual/process.texi                   |   3 +-
 nptl/Versions                         |   3 +-
 nptl/allocatestack.c                  |   3 +
 nptl/cancellation.c                   |  62 +++--------
 nptl/cleanup_defer.c                  |  46 +-------
 nptl/descr.h                          |  32 ++----
 nptl/libc-cleanup.c                   |  46 +-------
 nptl/pthreadP.h                       |  24 +----
 nptl/pthread_cancel.c                 | 145 ++++++++------------------
 nptl/pthread_create.c                 | 102 +++++++-----------
 nptl/pthread_join_common.c            |   7 +-
 nptl/pthread_kill.c                   |  52 ++++++---
 nptl/pthread_self.c                   |   4 +-
 nptl/pthread_setcancelstate.c         |  36 +------
 nptl/pthread_setcanceltype.c          |  41 +-------
 nptl/pthread_testcancel.c             |  11 +-
 sysdeps/generic/exit-thread.h         |  28 -----
 sysdeps/htl/pthreadP.h                |   2 -
 sysdeps/nptl/dl-tls_init_tp.c         |   3 +
 sysdeps/nptl/libc_start_call_main.h   |   5 +-
 sysdeps/posix/raise.c                 |  11 +-
 sysdeps/unix/sysv/linux/exit-thread.h |  37 -------
 sysdeps/unix/sysv/linux/raise.c       |  52 ---------
 26 files changed, 211 insertions(+), 551 deletions(-)
 delete mode 100644 sysdeps/generic/exit-thread.h
 delete mode 100644 sysdeps/unix/sysv/linux/exit-thread.h
 delete mode 100644 sysdeps/unix/sysv/linux/raise.c

-- 
2.30.2


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

end of thread, other threads:[~2021-06-09 17:07 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 17:28 [PATCH v2 0/9] nptl: pthread cancellation refactor Adhemerval Zanella
2021-05-27 17:28 ` [PATCH v2 1/9] nptl: Remove exit-thread.h Adhemerval Zanella
2021-06-01  7:51   ` Florian Weimer
2021-06-01 12:55     ` Adhemerval Zanella
2021-05-27 17:28 ` [PATCH v2 2/9] nptl: Deallocate the thread stack on setup failure (BZ #19511) Adhemerval Zanella
2021-06-01  8:32   ` Florian Weimer
2021-06-01 13:08     ` Adhemerval Zanella
2021-06-01 13:55       ` Adhemerval Zanella
2021-06-02 12:56   ` [PATCH v3] " Adhemerval Zanella
2021-06-02 13:08     ` Andreas Schwab
2021-06-02 13:39       ` Adhemerval Zanella
2021-06-02 13:41         ` Andreas Schwab
2021-06-02 14:01           ` Adhemerval Zanella
2021-06-02 14:07             ` Andreas Schwab
2021-06-02 14:15               ` Adhemerval Zanella
2021-06-02 14:30                 ` Andreas Schwab
2021-06-02 14:42                   ` Adhemerval Zanella
2021-06-02 18:20               ` Joseph Myers
2021-06-02 18:30                 ` Florian Weimer
2021-06-02 19:02                   ` Adhemerval Zanella
2021-06-02 19:11                     ` Florian Weimer
2021-06-08 10:56     ` Florian Weimer
2021-06-08 17:01       ` Adhemerval Zanella
2021-06-09 13:49         ` Florian Weimer
2021-06-09 17:07           ` Adhemerval Zanella
2021-05-27 17:28 ` [PATCH v2 3/9] nptl: Install cancellation handler on pthread_cancel Adhemerval Zanella
2021-05-31 18:18   ` Adhemerval Zanella
2021-06-01  8:38     ` Florian Weimer
2021-06-01 13:10       ` Adhemerval Zanella
2021-06-01  8:39   ` Florian Weimer
2021-05-27 17:28 ` [PATCH v2 4/9] nptl: Remove CANCELING_BITMASK Adhemerval Zanella
2021-06-01  9:03   ` Florian Weimer
2021-06-01 13:50     ` Adhemerval Zanella
2021-06-01 16:36       ` Adhemerval Zanella
2021-05-27 17:28 ` [PATCH v2 5/9] nptl: Move cancel state out of cancelhandling Adhemerval Zanella
2021-06-01  9:58   ` Florian Weimer
2021-06-02 13:09     ` Adhemerval Zanella
2021-05-27 17:28 ` [PATCH v2 6/9] nptl: Move cancel type " Adhemerval Zanella
2021-06-01 12:37   ` Florian Weimer
2021-06-02 13:11     ` Adhemerval Zanella
2021-06-09 17:06       ` Adhemerval Zanella
2021-05-27 17:28 ` [PATCH v2 7/9] nptl: Implement raise in terms of pthread_kill Adhemerval Zanella
2021-06-01 12:40   ` Florian Weimer
2021-06-02 13:14     ` Adhemerval Zanella
2021-05-27 17:28 ` [PATCH v2 8/9] nptl: Use pthread_kill on pthread_cancel Adhemerval Zanella
2021-06-01 12:41   ` Florian Weimer
2021-05-27 17:28 ` [PATCH v2 9/9] nptl: Avoid async cancellation to wrongly update __nptl_nthreads (BZ #19366) Adhemerval Zanella
2021-06-01 14:29   ` Florian Weimer
2021-06-02 13:15     ` 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).