diff options
author | Florian Weimer <fweimer@redhat.com> | 2021-06-28 15:48:58 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2021-06-28 16:41:58 +0200 |
commit | dd45734e322a03287d34d8af9b7da7b35cfddb8e (patch) | |
tree | 368647bd8c34ea5d1ea1f3cfa74ef52fb3271e67 /nptl | |
parent | fef400a2f976d1fd6a4639e6980f6c50ee13fbf5 (diff) | |
download | glibc-dd45734e322a03287d34d8af9b7da7b35cfddb8e.zip glibc-dd45734e322a03287d34d8af9b7da7b35cfddb8e.tar.gz glibc-dd45734e322a03287d34d8af9b7da7b35cfddb8e.tar.bz2 |
nptl: Add glibc.pthread.stack_cache_size tunable
The valgrind/helgrind test suite needs a way to make stack dealloction
more prompt, and this feature seems to be generally useful.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'nptl')
-rw-r--r-- | nptl/nptl-stack.c | 8 | ||||
-rw-r--r-- | nptl/nptl-stack.h | 3 | ||||
-rw-r--r-- | nptl/pthread_mutex_conf.c | 9 |
3 files changed, 16 insertions, 4 deletions
diff --git a/nptl/nptl-stack.c b/nptl/nptl-stack.c index 1a0c460..3f33a4c2 100644 --- a/nptl/nptl-stack.c +++ b/nptl/nptl-stack.c @@ -21,8 +21,7 @@ #include <ldsodefs.h> #include <pthreadP.h> -/* Maximum size in kB of cache. 40MiBi by default. */ -static const size_t stack_cache_maxsize = 40 * 1024 * 1024; +size_t __nptl_stack_cache_maxsize = 40 * 1024 * 1024; void __nptl_stack_list_del (list_t *elem) @@ -103,8 +102,9 @@ queue_stack (struct pthread *stack) __nptl_stack_list_add (&stack->list, &GL (dl_stack_cache)); GL (dl_stack_cache_actsize) += stack->stackblock_size; - if (__glibc_unlikely (GL (dl_stack_cache_actsize) > stack_cache_maxsize)) - __nptl_free_stacks (stack_cache_maxsize); + if (__glibc_unlikely (GL (dl_stack_cache_actsize) + > __nptl_stack_cache_maxsize)) + __nptl_free_stacks (__nptl_stack_cache_maxsize); } void diff --git a/nptl/nptl-stack.h b/nptl/nptl-stack.h index a6bd8df..8bcfde7 100644 --- a/nptl/nptl-stack.h +++ b/nptl/nptl-stack.h @@ -25,6 +25,9 @@ #include <list.h> #include <stdbool.h> +/* Maximum size of the cache, in bytes. 40 MiB by default. */ +extern size_t __nptl_stack_cache_maxsize attribute_hidden; + /* Check whether the stack is still used or not. */ static inline bool __nptl_stack_in_use (struct pthread *pd) diff --git a/nptl/pthread_mutex_conf.c b/nptl/pthread_mutex_conf.c index e6235de..c8f171c 100644 --- a/nptl/pthread_mutex_conf.c +++ b/nptl/pthread_mutex_conf.c @@ -23,6 +23,7 @@ #include <stdbool.h> #include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */ #include <elf/dl-tunables.h> +#include <nptl-stack.h> struct mutex_config __mutex_aconf = { @@ -38,10 +39,18 @@ TUNABLE_CALLBACK (set_mutex_spin_count) (tunable_val_t *valp) __mutex_aconf.spin_count = (int32_t) (valp)->numval; } +static void +TUNABLE_CALLBACK (set_stack_cache_size) (tunable_val_t *valp) +{ + __nptl_stack_cache_maxsize = valp->numval; +} + void __pthread_tunables_init (void) { TUNABLE_GET (mutex_spin_count, int32_t, TUNABLE_CALLBACK (set_mutex_spin_count)); + TUNABLE_GET (stack_cache_size, size_t, + TUNABLE_CALLBACK (set_stack_cache_size)); } #endif |