libpthread/nptl: make default stack size configurable
commitc303df56d32faa47ef163726357ed3ee5d075b88
authorBen Wolsieffer <ben.wolsieffer@hefring.com>
Thu, 2 Nov 2023 15:48:25 +0000 (2 11:48 -0400)
committerWaldemar Brodkorb <wbx@openadk.org>
Thu, 9 Nov 2023 15:48:33 +0000 (9 16:48 +0100)
treed00ee1101dd14b5c1bfbd712765a26d56b777845
parent8166707a3350ce1fdaf669fb3836810727379342
libpthread/nptl: make default stack size configurable

Threads currently have 2-4 MiB stacks by default (depending on the
platform). This is fine on MMU platforms, where this stack space is not
actually allocated until it is used, but tends to waste a large amount
of memory on no-MMU platforms.

This patch adds a PTHREADS_STACK_DEFAULT_SIZE Kconfig option that allows
the user to override the default stack size at build time. This allows
the user to select a reasonable default stack size for the software that
runs on their system, and avoids the need to patch every package to add
calls to pthread_attr_setstacksize().

An alternative to this patch would be to change the hardcoded default
stack size on no-MMU platforms, but it is difficult to choose an
appropriate value because the minimum required stack depends on the
software in use. This would also be a breaking change.

Signed-off-by: Ben Wolsieffer <ben.wolsieffer@hefring.com>
22 files changed:
extra/Configs/Config.in
libpthread/nptl/init.c
libpthread/nptl/sysdeps/aarch64/pthreaddef.h
libpthread/nptl/sysdeps/alpha/pthreaddef.h
libpthread/nptl/sysdeps/arc/pthreaddef.h
libpthread/nptl/sysdeps/arm/pthreaddef.h
libpthread/nptl/sysdeps/csky/pthreaddef.h
libpthread/nptl/sysdeps/i386/pthreaddef.h
libpthread/nptl/sysdeps/kvx/pthreaddef.h
libpthread/nptl/sysdeps/m68k/pthreaddef.h
libpthread/nptl/sysdeps/metag/pthreaddef.h
libpthread/nptl/sysdeps/microblaze/pthreaddef.h
libpthread/nptl/sysdeps/mips/pthreaddef.h
libpthread/nptl/sysdeps/nds32/pthreaddef.h
libpthread/nptl/sysdeps/nios2/pthreaddef.h
libpthread/nptl/sysdeps/or1k/pthreaddef.h
libpthread/nptl/sysdeps/powerpc/pthreaddef.h
libpthread/nptl/sysdeps/riscv64/pthreaddef.h
libpthread/nptl/sysdeps/sh/pthreaddef.h
libpthread/nptl/sysdeps/sparc/pthreaddef.h
libpthread/nptl/sysdeps/x86_64/pthreaddef.h
libpthread/nptl/sysdeps/xtensa/pthreaddef.h