mbox series

[00/19] Signal mask for timer helper thread

Message ID cover.1589884403.git.fweimer@redhat.com
Headers show
Series Signal mask for timer helper thread | expand

Message

Florian Weimer May 19, 2020, 10:43 a.m. UTC
This series cleans up various aspects of NPTL and eventually adds
functionality to explicitly block internal signals on new threads.

There is now a proper public interface (for non-internal signals) and
the awkward separate sigset_t * argument and a pthread_create variant is
no longer needed.

To avoid creating new symbols in libpthread, some dependent
functionality had to be moved into libc.  Since more parts of
pthread_attr_t are now dynamically allocated, it seemed prudent to
consolidate the copying of thread attributes.

Tested on x86_64-linux-gnu, i686-linux-gnu.  Built with
build-many-glibcs.py (also various intermediate steps).

Thanks,
Florian

Florian Weimer (19):
  manual: Add missing section and node for clockid_t wait functions
  nptl: Replace some stubs with the Linux implementation
  nptl: Move pthread_attr_setaffinity_np into libc
  nptl: Move pthread_getaffinity_np into libc
  nptl: Move pthread_gettattr_np into libc
  nptl: Make __pthread_attr_init, __pthread_attr_destroy available
    internally
  nptl: Add __pthread_attr_copy for copying pthread_attr_t objects
  nptl: Use __pthread_attr_copy in pthread_getattr_default_np (bug
    25999)
  nptl: Use __pthread_attr_copy in pthread_setattr_default_np
  <libc-symbols.h>: Add libpthread hidden alias support
  nptl: Add internal alias __pthread_getattr_default_np
  nptl: Use __pthread_getattr_default_np in pthread_create
  nptl: Use __pthread_attr_setaffinity_np in pthread_getattr_np
  nptl: Change type of __default_pthread_attr
  nptl: Destroy the default thread attribute as part of freeres
  nptl: Make pthread_attr_t dynamically extensible
  nptl: Add pthread_attr_setsigmask_np, pthread_attr_getsigmask_np
  manual: Add pthread_attr_setsigmask_np, pthread_attr_getsigmask_np
  Linux: Use __pthread_attr_setsigmask_internal for timer helper thread

 NEWS                                          |   4 +
 include/libc-symbols.h                        |  23 ++
 manual/threads.texi                           |  55 +++++
 nptl/Makefile                                 |  24 ++-
 nptl/Versions                                 |  29 ++-
 nptl/allocatestack.c                          |   2 +-
 nptl/libpthread-compat.c                      |   5 +
 nptl/nptl-init.c                              |   4 +-
 nptl/nptlfreeres.c                            |   1 +
 nptl/pthreadP.h                               |  35 ++-
 nptl/pthread_attr_copy.c                      |  64 ++++++
 nptl/pthread_attr_destroy.c                   |  15 +-
 nptl/pthread_attr_extension.c                 |  32 +++
 nptl/pthread_attr_getaffinity.c               |  14 +-
 nptl/pthread_attr_getsigmask.c                |  38 ++++
 nptl/pthread_attr_getstacksize.c              |   2 +-
 nptl/pthread_attr_init.c                      |   5 +-
 nptl/pthread_attr_setaffinity.c               |  45 ++--
 nptl/pthread_attr_setsigmask.c                |  34 +++
 nptl/pthread_attr_setsigmask_internal.c       |  45 ++++
 nptl/pthread_create.c                         |  63 +++---
 nptl/pthread_getaffinity.c                    |  45 +++-
 nptl/pthread_getattr_default_np.c             |  15 +-
 nptl/pthread_getattr_np.c                     |  43 ++--
 nptl/pthread_getname.c                        |  49 ++++-
 nptl/pthread_setaffinity.c                    |  37 +++-
 nptl/pthread_setattr_default_np.c             |  63 +++---
 nptl/pthread_setname.c                        |  43 +++-
 nptl/tst-pthread-attr-sigmask.c               | 204 ++++++++++++++++++
 nptl/tst-pthread-defaultattr-free.c           |  78 +++++++
 .../unix/sysv/linux => nptl}/tst-setgetname.c |   0
 .../tst-thread-affinity-pthread.c             |   0
 .../tst-thread-affinity-pthread2.c            |   0
 .../tst-thread-affinity-sched.c               |   0
 nptl/vars.c                                   |   2 +-
 sysdeps/nptl/internaltypes.h                  |  26 ++-
 sysdeps/nptl/pthread.h                        |  15 ++
 sysdeps/unix/sysv/linux/Makefile              |   5 +-
 sysdeps/unix/sysv/linux/aarch64/libc.abilist  |   8 +
 .../sysv/linux/aarch64/libpthread.abilist     |   3 -
 sysdeps/unix/sysv/linux/alpha/libc.abilist    |  10 +
 .../unix/sysv/linux/alpha/libpthread.abilist  |   6 +-
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |   8 +
 .../unix/sysv/linux/arm/be/libpthread.abilist |   3 -
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |   8 +
 .../unix/sysv/linux/arm/le/libpthread.abilist |   3 -
 sysdeps/unix/sysv/linux/createthread.c        |   9 +-
 sysdeps/unix/sysv/linux/csky/libc.abilist     |   8 +
 .../unix/sysv/linux/csky/libpthread.abilist   |   3 -
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |  10 +
 .../unix/sysv/linux/hppa/libpthread.abilist   |   6 +-
 sysdeps/unix/sysv/linux/i386/libc.abilist     |  10 +
 .../unix/sysv/linux/i386/libpthread.abilist   |   6 +-
 sysdeps/unix/sysv/linux/ia64/libc.abilist     |  10 +
 .../unix/sysv/linux/ia64/libpthread.abilist   |   6 +-
 .../sysv/linux/m68k/coldfire/libc.abilist     |   8 +
 .../linux/m68k/coldfire/libpthread.abilist    |   3 -
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  10 +
 .../sysv/linux/m68k/m680x0/libpthread.abilist |   6 +-
 .../sysv/linux/microblaze/be/libc.abilist     |   8 +
 .../linux/microblaze/be/libpthread.abilist    |   3 -
 .../sysv/linux/microblaze/le/libc.abilist     |   8 +
 .../linux/microblaze/le/libpthread.abilist    |   3 -
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  10 +
 .../sysv/linux/mips/mips32/libpthread.abilist |   6 +-
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |  10 +
 .../sysv/linux/mips/mips64/libpthread.abilist |   6 +-
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  10 +
 .../sysv/linux/mips/mips64/n64/libc.abilist   |  10 +
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |   8 +
 .../unix/sysv/linux/nios2/libpthread.abilist  |   3 -
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  10 +
 .../powerpc/powerpc32/libpthread.abilist      |   6 +-
 .../powerpc/powerpc32/nofpu/libc.abilist      |  10 +
 .../linux/powerpc/powerpc64/be/libc.abilist   |  10 +
 .../powerpc/powerpc64/be/libpthread.abilist   |   5 -
 .../linux/powerpc/powerpc64/le/libc.abilist   |   8 +
 .../powerpc/powerpc64/le/libpthread.abilist   |   3 -
 sysdeps/unix/sysv/linux/pthread_getaffinity.c |  58 -----
 sysdeps/unix/sysv/linux/pthread_getname.c     |  69 ------
 sysdeps/unix/sysv/linux/pthread_setaffinity.c |  53 -----
 sysdeps/unix/sysv/linux/pthread_setname.c     |  63 ------
 .../unix/sysv/linux/riscv/rv64/libc.abilist   |   8 +
 .../sysv/linux/riscv/rv64/libpthread.abilist  |   3 -
 .../unix/sysv/linux/s390/s390-32/libc.abilist |  10 +
 .../linux/s390/s390-32/libpthread.abilist     |   6 +-
 .../unix/sysv/linux/s390/s390-64/libc.abilist |  10 +
 .../linux/s390/s390-64/libpthread.abilist     |   6 +-
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  10 +
 .../unix/sysv/linux/sh/be/libpthread.abilist  |   6 +-
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  10 +
 .../unix/sysv/linux/sh/le/libpthread.abilist  |   6 +-
 .../sysv/linux/sparc/sparc32/libc.abilist     |  10 +
 .../linux/sparc/sparc32/libpthread.abilist    |   6 +-
 .../sysv/linux/sparc/sparc64/libc.abilist     |  10 +
 .../linux/sparc/sparc64/libpthread.abilist    |   6 +-
 sysdeps/unix/sysv/linux/timer_routines.c      |  19 +-
 .../unix/sysv/linux/x86_64/64/libc.abilist    |  10 +
 .../sysv/linux/x86_64/64/libpthread.abilist   |   5 -
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |   8 +
 .../sysv/linux/x86_64/x32/libpthread.abilist  |   3 -
 101 files changed, 1289 insertions(+), 551 deletions(-)
 create mode 100644 nptl/pthread_attr_copy.c
 create mode 100644 nptl/pthread_attr_extension.c
 create mode 100644 nptl/pthread_attr_getsigmask.c
 create mode 100644 nptl/pthread_attr_setsigmask.c
 create mode 100644 nptl/pthread_attr_setsigmask_internal.c
 create mode 100644 nptl/tst-pthread-attr-sigmask.c
 create mode 100644 nptl/tst-pthread-defaultattr-free.c
 rename {sysdeps/unix/sysv/linux => nptl}/tst-setgetname.c (100%)
 rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-pthread.c (100%)
 rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-pthread2.c (100%)
 rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-sched.c (100%)
 delete mode 100644 sysdeps/unix/sysv/linux/pthread_getaffinity.c
 delete mode 100644 sysdeps/unix/sysv/linux/pthread_getname.c
 delete mode 100644 sysdeps/unix/sysv/linux/pthread_setaffinity.c
 delete mode 100644 sysdeps/unix/sysv/linux/pthread_setname.c

Comments

Carlos O'Donell May 20, 2020, 1:11 p.m. UTC | #1
On 5/19/20 6:43 AM, Florian Weimer via Libc-alpha wrote:
> This series cleans up various aspects of NPTL and eventually adds
> functionality to explicitly block internal signals on new threads.

Great! I think that's a useful feature when integrated into the attributes
for the thread.

> There is now a proper public interface (for non-internal signals) and
> the awkward separate sigset_t * argument and a pthread_create variant is
> no longer needed.

Sounds great... but this patch set has gotten much bigger! :-)

> To avoid creating new symbols in libpthread, some dependent
> functionality had to be moved into libc.  Since more parts of
> pthread_attr_t are now dynamically allocated, it seemed prudent to
> consolidate the copying of thread attributes.

Agreed.

> Tested on x86_64-linux-gnu, i686-linux-gnu.  Built with
> build-many-glibcs.py (also various intermediate steps).

Testing in progress for x86_64 and i686 on my side.

I'll start reviewing some of the easy patches.

> Thanks,
> Florian
> 
> Florian Weimer (19):
>   manual: Add missing section and node for clockid_t wait functions
>   nptl: Replace some stubs with the Linux implementation
>   nptl: Move pthread_attr_setaffinity_np into libc
>   nptl: Move pthread_getaffinity_np into libc
>   nptl: Move pthread_gettattr_np into libc
>   nptl: Make __pthread_attr_init, __pthread_attr_destroy available
>     internally
>   nptl: Add __pthread_attr_copy for copying pthread_attr_t objects
>   nptl: Use __pthread_attr_copy in pthread_getattr_default_np (bug
>     25999)
>   nptl: Use __pthread_attr_copy in pthread_setattr_default_np
>   <libc-symbols.h>: Add libpthread hidden alias support
>   nptl: Add internal alias __pthread_getattr_default_np
>   nptl: Use __pthread_getattr_default_np in pthread_create
>   nptl: Use __pthread_attr_setaffinity_np in pthread_getattr_np
>   nptl: Change type of __default_pthread_attr
>   nptl: Destroy the default thread attribute as part of freeres
>   nptl: Make pthread_attr_t dynamically extensible
>   nptl: Add pthread_attr_setsigmask_np, pthread_attr_getsigmask_np
>   manual: Add pthread_attr_setsigmask_np, pthread_attr_getsigmask_np
>   Linux: Use __pthread_attr_setsigmask_internal for timer helper thread
> 
>  NEWS                                          |   4 +
>  include/libc-symbols.h                        |  23 ++
>  manual/threads.texi                           |  55 +++++
>  nptl/Makefile                                 |  24 ++-
>  nptl/Versions                                 |  29 ++-
>  nptl/allocatestack.c                          |   2 +-
>  nptl/libpthread-compat.c                      |   5 +
>  nptl/nptl-init.c                              |   4 +-
>  nptl/nptlfreeres.c                            |   1 +
>  nptl/pthreadP.h                               |  35 ++-
>  nptl/pthread_attr_copy.c                      |  64 ++++++
>  nptl/pthread_attr_destroy.c                   |  15 +-
>  nptl/pthread_attr_extension.c                 |  32 +++
>  nptl/pthread_attr_getaffinity.c               |  14 +-
>  nptl/pthread_attr_getsigmask.c                |  38 ++++
>  nptl/pthread_attr_getstacksize.c              |   2 +-
>  nptl/pthread_attr_init.c                      |   5 +-
>  nptl/pthread_attr_setaffinity.c               |  45 ++--
>  nptl/pthread_attr_setsigmask.c                |  34 +++
>  nptl/pthread_attr_setsigmask_internal.c       |  45 ++++
>  nptl/pthread_create.c                         |  63 +++---
>  nptl/pthread_getaffinity.c                    |  45 +++-
>  nptl/pthread_getattr_default_np.c             |  15 +-
>  nptl/pthread_getattr_np.c                     |  43 ++--
>  nptl/pthread_getname.c                        |  49 ++++-
>  nptl/pthread_setaffinity.c                    |  37 +++-
>  nptl/pthread_setattr_default_np.c             |  63 +++---
>  nptl/pthread_setname.c                        |  43 +++-
>  nptl/tst-pthread-attr-sigmask.c               | 204 ++++++++++++++++++
>  nptl/tst-pthread-defaultattr-free.c           |  78 +++++++
>  .../unix/sysv/linux => nptl}/tst-setgetname.c |   0
>  .../tst-thread-affinity-pthread.c             |   0
>  .../tst-thread-affinity-pthread2.c            |   0
>  .../tst-thread-affinity-sched.c               |   0
>  nptl/vars.c                                   |   2 +-
>  sysdeps/nptl/internaltypes.h                  |  26 ++-
>  sysdeps/nptl/pthread.h                        |  15 ++
>  sysdeps/unix/sysv/linux/Makefile              |   5 +-
>  sysdeps/unix/sysv/linux/aarch64/libc.abilist  |   8 +
>  .../sysv/linux/aarch64/libpthread.abilist     |   3 -
>  sysdeps/unix/sysv/linux/alpha/libc.abilist    |  10 +
>  .../unix/sysv/linux/alpha/libpthread.abilist  |   6 +-
>  sysdeps/unix/sysv/linux/arm/be/libc.abilist   |   8 +
>  .../unix/sysv/linux/arm/be/libpthread.abilist |   3 -
>  sysdeps/unix/sysv/linux/arm/le/libc.abilist   |   8 +
>  .../unix/sysv/linux/arm/le/libpthread.abilist |   3 -
>  sysdeps/unix/sysv/linux/createthread.c        |   9 +-
>  sysdeps/unix/sysv/linux/csky/libc.abilist     |   8 +
>  .../unix/sysv/linux/csky/libpthread.abilist   |   3 -
>  sysdeps/unix/sysv/linux/hppa/libc.abilist     |  10 +
>  .../unix/sysv/linux/hppa/libpthread.abilist   |   6 +-
>  sysdeps/unix/sysv/linux/i386/libc.abilist     |  10 +
>  .../unix/sysv/linux/i386/libpthread.abilist   |   6 +-
>  sysdeps/unix/sysv/linux/ia64/libc.abilist     |  10 +
>  .../unix/sysv/linux/ia64/libpthread.abilist   |   6 +-
>  .../sysv/linux/m68k/coldfire/libc.abilist     |   8 +
>  .../linux/m68k/coldfire/libpthread.abilist    |   3 -
>  .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  10 +
>  .../sysv/linux/m68k/m680x0/libpthread.abilist |   6 +-
>  .../sysv/linux/microblaze/be/libc.abilist     |   8 +
>  .../linux/microblaze/be/libpthread.abilist    |   3 -
>  .../sysv/linux/microblaze/le/libc.abilist     |   8 +
>  .../linux/microblaze/le/libpthread.abilist    |   3 -
>  .../sysv/linux/mips/mips32/fpu/libc.abilist   |  10 +
>  .../sysv/linux/mips/mips32/libpthread.abilist |   6 +-
>  .../sysv/linux/mips/mips32/nofpu/libc.abilist |  10 +
>  .../sysv/linux/mips/mips64/libpthread.abilist |   6 +-
>  .../sysv/linux/mips/mips64/n32/libc.abilist   |  10 +
>  .../sysv/linux/mips/mips64/n64/libc.abilist   |  10 +
>  sysdeps/unix/sysv/linux/nios2/libc.abilist    |   8 +
>  .../unix/sysv/linux/nios2/libpthread.abilist  |   3 -
>  .../linux/powerpc/powerpc32/fpu/libc.abilist  |  10 +
>  .../powerpc/powerpc32/libpthread.abilist      |   6 +-
>  .../powerpc/powerpc32/nofpu/libc.abilist      |  10 +
>  .../linux/powerpc/powerpc64/be/libc.abilist   |  10 +
>  .../powerpc/powerpc64/be/libpthread.abilist   |   5 -
>  .../linux/powerpc/powerpc64/le/libc.abilist   |   8 +
>  .../powerpc/powerpc64/le/libpthread.abilist   |   3 -
>  sysdeps/unix/sysv/linux/pthread_getaffinity.c |  58 -----
>  sysdeps/unix/sysv/linux/pthread_getname.c     |  69 ------
>  sysdeps/unix/sysv/linux/pthread_setaffinity.c |  53 -----
>  sysdeps/unix/sysv/linux/pthread_setname.c     |  63 ------
>  .../unix/sysv/linux/riscv/rv64/libc.abilist   |   8 +
>  .../sysv/linux/riscv/rv64/libpthread.abilist  |   3 -
>  .../unix/sysv/linux/s390/s390-32/libc.abilist |  10 +
>  .../linux/s390/s390-32/libpthread.abilist     |   6 +-
>  .../unix/sysv/linux/s390/s390-64/libc.abilist |  10 +
>  .../linux/s390/s390-64/libpthread.abilist     |   6 +-
>  sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  10 +
>  .../unix/sysv/linux/sh/be/libpthread.abilist  |   6 +-
>  sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  10 +
>  .../unix/sysv/linux/sh/le/libpthread.abilist  |   6 +-
>  .../sysv/linux/sparc/sparc32/libc.abilist     |  10 +
>  .../linux/sparc/sparc32/libpthread.abilist    |   6 +-
>  .../sysv/linux/sparc/sparc64/libc.abilist     |  10 +
>  .../linux/sparc/sparc64/libpthread.abilist    |   6 +-
>  sysdeps/unix/sysv/linux/timer_routines.c      |  19 +-
>  .../unix/sysv/linux/x86_64/64/libc.abilist    |  10 +
>  .../sysv/linux/x86_64/64/libpthread.abilist   |   5 -
>  .../unix/sysv/linux/x86_64/x32/libc.abilist   |   8 +
>  .../sysv/linux/x86_64/x32/libpthread.abilist  |   3 -
>  101 files changed, 1289 insertions(+), 551 deletions(-)
>  create mode 100644 nptl/pthread_attr_copy.c
>  create mode 100644 nptl/pthread_attr_extension.c
>  create mode 100644 nptl/pthread_attr_getsigmask.c
>  create mode 100644 nptl/pthread_attr_setsigmask.c
>  create mode 100644 nptl/pthread_attr_setsigmask_internal.c
>  create mode 100644 nptl/tst-pthread-attr-sigmask.c
>  create mode 100644 nptl/tst-pthread-defaultattr-free.c
>  rename {sysdeps/unix/sysv/linux => nptl}/tst-setgetname.c (100%)
>  rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-pthread.c (100%)
>  rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-pthread2.c (100%)
>  rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-sched.c (100%)
>  delete mode 100644 sysdeps/unix/sysv/linux/pthread_getaffinity.c
>  delete mode 100644 sysdeps/unix/sysv/linux/pthread_getname.c
>  delete mode 100644 sysdeps/unix/sysv/linux/pthread_setaffinity.c
>  delete mode 100644 sysdeps/unix/sysv/linux/pthread_setname.c
>