public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH 0/3] Convenience function for allocating (alternate signal) stacks
@ 2021-05-24 15:42 Bruno Haible
  0 siblings, 0 replies; 2+ messages in thread
From: Bruno Haible @ 2021-05-24 15:42 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha

In reply to <https://sourceware.org/pipermail/libc-alpha/2021-May/126605.html>:

> I'll figure out a way to integrate this with
> threads, so that applications can request an alternate signal stack on
> thread creation that is automatically deallocated once the thread exits.

This would only be marginally useful. I would be much in favour of a
facility to automatically deallocate the alternate stack, that runs entirely
in the thread, without help from thread-creation time. Similar to what the
_pthread_cleanup_buffer chain is doing.

Rationale:

1) A thread function may well do a recursion or not, depending on circumstances
   that are not known at thread creation time.
2) Many big applications use thread pools. It would be silly to allocate an
   alternate stack ahead of time, and most of the time it's not needed because
   the thread does not do recursion and does not call sigaltstack().

In other words, the alternate stack is more tied to what the thread is doing.
The more freedom you leave to the thread while the thread is running, the
better. I understand that scheduling priorities and such are also a function
of what the thread is doing, and need to be specified ahead of time.
Nevertheless, the fewer interdependencies between the thread creation code
and the thread execution code, the better. Each such interdependency makes
application code harder to maintain.

Bruno


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

* [PATCH 0/3] Convenience function for allocating (alternate signal) stacks
@ 2021-05-20 12:11 Florian Weimer
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2021-05-20 12:11 UTC (permalink / raw)
  To: libc-alpha

This complements the _SC_MINSIGSTKSZ changes by wrapping the stack
allocation with its size computation in a helper function.  Guard pages
are also allocated.

If this is acceptable, I'll figure out a way to integrate this with
threads, so that applications can request an alternate signal stack on
thread creation that is automatically deallocated once the thread exits.

Thanks,
Florian

Florian Weimer (3):
  elf: Initialize GLRO (dl_minsigstacksize) after static dlopen
  Hurd: Define ARCH_MIN_GUARD_SIZE in internal <pthread.h>
  Misc: Add <sys/cstack.h> and the cstack_* family of functions

 NEWS                                          |   4 +
 elf/rtld_static_init.c                        |   2 +
 include/sys/cstack.h                          |  39 ++++++
 manual/memory.texi                            |  99 ++++++++++++++
 manual/signal.texi                            |   3 +
 misc/Makefile                                 |   8 +-
 misc/Versions                                 |   5 +
 misc/cstack_allocate.c                        | 125 ++++++++++++++++++
 misc/cstack_free.c                            |  30 +++++
 misc/cstack_get.c                             |  27 ++++
 misc/sys/cstack.h                             |  53 ++++++++
 misc/tst-cstack.c                             | 118 +++++++++++++++++
 sysdeps/htl/include/pthread.h                 |   3 +
 sysdeps/mach/hurd/i386/libc.abilist           |   3 +
 sysdeps/unix/sysv/linux/aarch64/libc.abilist  |   3 +
 sysdeps/unix/sysv/linux/alpha/libc.abilist    |   3 +
 sysdeps/unix/sysv/linux/arc/libc.abilist      |   3 +
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |   3 +
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |   3 +
 sysdeps/unix/sysv/linux/csky/libc.abilist     |   3 +
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |   3 +
 sysdeps/unix/sysv/linux/i386/libc.abilist     |   3 +
 sysdeps/unix/sysv/linux/ia64/libc.abilist     |   3 +
 .../sysv/linux/m68k/coldfire/libc.abilist     |   3 +
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |   3 +
 .../sysv/linux/microblaze/be/libc.abilist     |   3 +
 .../sysv/linux/microblaze/le/libc.abilist     |   3 +
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |   3 +
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |   3 +
 .../sysv/linux/mips/mips64/n32/libc.abilist   |   3 +
 .../sysv/linux/mips/mips64/n64/libc.abilist   |   3 +
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |   3 +
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |   3 +
 .../powerpc/powerpc32/nofpu/libc.abilist      |   3 +
 .../linux/powerpc/powerpc64/be/libc.abilist   |   3 +
 .../linux/powerpc/powerpc64/le/libc.abilist   |   3 +
 .../unix/sysv/linux/riscv/rv32/libc.abilist   |   3 +
 .../unix/sysv/linux/riscv/rv64/libc.abilist   |   3 +
 .../unix/sysv/linux/s390/s390-32/libc.abilist |   3 +
 .../unix/sysv/linux/s390/s390-64/libc.abilist |   3 +
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |   3 +
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |   3 +
 .../sysv/linux/sparc/sparc32/libc.abilist     |   3 +
 .../sysv/linux/sparc/sparc64/libc.abilist     |   3 +
 .../unix/sysv/linux/x86_64/64/libc.abilist    |   3 +
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |   3 +
 46 files changed, 612 insertions(+), 3 deletions(-)
 create mode 100644 include/sys/cstack.h
 create mode 100644 misc/cstack_allocate.c
 create mode 100644 misc/cstack_free.c
 create mode 100644 misc/cstack_get.c
 create mode 100644 misc/sys/cstack.h
 create mode 100644 misc/tst-cstack.c

-- 
2.31.1


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

end of thread, other threads:[~2021-05-24 15:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24 15:42 [PATCH 0/3] Convenience function for allocating (alternate signal) stacks Bruno Haible
  -- strict thread matches above, loose matches on Subject: below --
2021-05-20 12:11 Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).