mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
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>
This commit is contained in:
parent
fef400a2f9
commit
dd45734e32
3
NEWS
3
NEWS
@ -49,6 +49,9 @@ Major new features:
|
||||
with names ending with .conf to logically classify the converter modules in
|
||||
that directory.
|
||||
|
||||
* On Linux, a new tunable, glibc.pthread.stack_cache_size, can be used
|
||||
to configure the size of the thread stack cache.
|
||||
|
||||
Deprecated and removed features, and other changes affecting compatibility:
|
||||
|
||||
* The function pthread_mutex_consistent_np has been deprecated; programs
|
||||
|
@ -402,6 +402,15 @@ is acquired.
|
||||
The default value of this tunable is @samp{100}.
|
||||
@end deftp
|
||||
|
||||
@deftp Tunable glibc.pthread.stack_cache_size
|
||||
This tunable configures the maximum size of the stack cache. Once the
|
||||
stack cache exceeds this size, unused thread stacks are returned to
|
||||
the kernel, to bring the cache size below this limit.
|
||||
|
||||
The value is measured in bytes. The default is @samp{41943040}
|
||||
(fourty mibibytes).
|
||||
@end deftp
|
||||
|
||||
@node Hardware Capability Tunables
|
||||
@section Hardware Capability Tunables
|
||||
@cindex hardware capability tunables
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -23,5 +23,9 @@ glibc {
|
||||
maxval: 32767
|
||||
default: 100
|
||||
}
|
||||
stack_cache_size {
|
||||
type: SIZE_T
|
||||
default: 41943040
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user