From c303df56d32faa47ef163726357ed3ee5d075b88 Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Thu, 2 Nov 2023 11:48:25 -0400 Subject: 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 --- extra/Configs/Config.in | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'extra') diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index 49f561e5e..287db13d2 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -644,6 +644,15 @@ config PTHREADS_DEBUG_SUPPORT If you are doing development and want to debug applications using uClibc's pthread library, answer Y. Otherwise, answer N. +config PTHREADS_STACK_DEFAULT_SIZE + int "Default thread stack size" + default 4194304 if TARGET_alpha # 4 MiB + default 4194304 if TARGET_powerpc # 4 MiB + default 2097152 # 2 MiB + help + Set the default thread stack size. This option is useful on MMU-less + systems where the stack size is fixed and the default stack size may + be excessively large and waste memory. config UCLIBC_HAS_SYSLOG bool "Syslog support" -- cgit v1.2.3