mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-12 14:29:28 +00:00
Increase the default stacksizes:
32-bit 64-bit main thread 2 MB 4 MB other threads 1 MB 2 MB Adapted from: libpthread Approved by: deischen
This commit is contained in:
parent
09fdd614d4
commit
d525de835f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=142808
@ -481,11 +481,9 @@ struct pthread_attr {
|
||||
/*
|
||||
* Miscellaneous definitions.
|
||||
*/
|
||||
#if !defined(__ia64__)
|
||||
#define PTHREAD_STACK_DEFAULT 65536
|
||||
#else
|
||||
#define PTHREAD_STACK_DEFAULT 0x40000
|
||||
#endif
|
||||
#define PTHREAD_STACK32_DEFAULT (1 * 1024 * 1024)
|
||||
#define PTHREAD_STACK64_DEFAULT (2 * 1024 * 1024)
|
||||
|
||||
/*
|
||||
* Size of default red zone at the end of each stack. In actuality, this "red
|
||||
* zone" is merely an unmapped region, except in the case of the initial stack.
|
||||
@ -498,16 +496,17 @@ extern int _pthread_guard_default;
|
||||
|
||||
extern int _pthread_page_size;
|
||||
|
||||
extern int _pthread_stack_default;
|
||||
|
||||
extern int _pthread_stack_initial;
|
||||
|
||||
/*
|
||||
* Maximum size of initial thread's stack. This perhaps deserves to be larger
|
||||
* than the stacks of other threads, since many applications are likely to run
|
||||
* almost entirely on this stack.
|
||||
*/
|
||||
#if !defined(__ia64__)
|
||||
#define PTHREAD_STACK_INITIAL 0x100000
|
||||
#else
|
||||
#define PTHREAD_STACK_INITIAL 0x400000
|
||||
#endif
|
||||
#define PTHREAD_STACK32_INITIAL (2 * 1024 * 1024)
|
||||
#define PTHREAD_STACK64_INITIAL (4 * 1024 * 1024)
|
||||
|
||||
/*
|
||||
* Define the different priority ranges. All applications have thread
|
||||
@ -1040,7 +1039,7 @@ SCLASS struct pthread_attr _pthread_attr_default
|
||||
#ifdef GLOBAL_PTHREAD_PRIVATE
|
||||
= { SCHED_RR, 0, TIMESLICE_USEC, PTHREAD_DEFAULT_PRIORITY,
|
||||
PTHREAD_CREATE_RUNNING, PTHREAD_CREATE_JOINABLE, NULL, NULL, NULL,
|
||||
PTHREAD_STACK_DEFAULT, -1 };
|
||||
-1, -1 };
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
@ -194,6 +194,8 @@ static pthread_func_t jmp_table[][2] = {
|
||||
|
||||
int _pthread_guard_default;
|
||||
int _pthread_page_size;
|
||||
int _pthread_stack_default;
|
||||
int _pthread_stack_initial;
|
||||
|
||||
/*
|
||||
* Threaded process initialization
|
||||
@ -223,8 +225,17 @@ _thread_init(void)
|
||||
_pthread_page_size = getpagesize();;
|
||||
_pthread_guard_default = _pthread_page_size;
|
||||
sched_stack_size = 4 * _pthread_page_size;
|
||||
if (sizeof(void *) == 8) {
|
||||
_pthread_stack_default = PTHREAD_STACK64_DEFAULT;
|
||||
_pthread_stack_initial = PTHREAD_STACK64_INITIAL;
|
||||
}
|
||||
else {
|
||||
_pthread_stack_default = PTHREAD_STACK32_DEFAULT;
|
||||
_pthread_stack_initial = PTHREAD_STACK32_INITIAL;
|
||||
}
|
||||
|
||||
_pthread_attr_default.guardsize_attr = _pthread_guard_default;
|
||||
_pthread_attr_default.stacksize_attr = _pthread_stack_default;
|
||||
|
||||
/*
|
||||
* Make gcc quiescent about {,libgcc_}references not being
|
||||
@ -361,17 +372,17 @@ _thread_init(void)
|
||||
* this stack needs an explicitly mapped red zone to protect the
|
||||
* thread stack that is just beyond.
|
||||
*/
|
||||
if (mmap(_usrstack - PTHREAD_STACK_INITIAL -
|
||||
if (mmap(_usrstack - _pthread_stack_initial -
|
||||
_pthread_guard_default, _pthread_guard_default, 0,
|
||||
MAP_ANON, -1, 0) == MAP_FAILED)
|
||||
PANIC("Cannot allocate red zone for initial thread");
|
||||
|
||||
/* Set the main thread stack pointer. */
|
||||
_thread_initial->stack = _usrstack - PTHREAD_STACK_INITIAL;
|
||||
_thread_initial->stack = _usrstack - _pthread_stack_initial;
|
||||
|
||||
/* Set the stack attributes: */
|
||||
_thread_initial->attr.stackaddr_attr = _thread_initial->stack;
|
||||
_thread_initial->attr.stacksize_attr = PTHREAD_STACK_INITIAL;
|
||||
_thread_initial->attr.stacksize_attr = _pthread_stack_initial;
|
||||
|
||||
/* Setup the context for the scheduler: */
|
||||
_setjmp(_thread_kern_sched_jb);
|
||||
|
@ -81,7 +81,7 @@ static LIST_HEAD(, stack) _mstackq = LIST_HEAD_INITIALIZER(_mstackq);
|
||||
* | Red Zone (guard page) | red zone for 2nd thread
|
||||
* | |
|
||||
* +-----------------------------------+
|
||||
* | stack 2 - PTHREAD_STACK_DEFAULT | top of 2nd thread stack
|
||||
* | stack 2 - _pthread_stack_default | top of 2nd thread stack
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
@ -92,7 +92,7 @@ static LIST_HEAD(, stack) _mstackq = LIST_HEAD_INITIALIZER(_mstackq);
|
||||
* | Red Zone | red zone for 1st thread
|
||||
* | |
|
||||
* +-----------------------------------+
|
||||
* | stack 1 - PTHREAD_STACK_DEFAULT | top of 1st thread stack
|
||||
* | stack 1 - _pthread_stack_default | top of 1st thread stack
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
@ -103,7 +103,7 @@ static LIST_HEAD(, stack) _mstackq = LIST_HEAD_INITIALIZER(_mstackq);
|
||||
* | Red Zone |
|
||||
* | | red zone for main thread
|
||||
* +-----------------------------------+
|
||||
* | USRSTACK - PTHREAD_STACK_INITIAL | top of main thread stack
|
||||
* | USRSTACK - _pthread_stack_initial | top of main thread stack
|
||||
* | | ^
|
||||
* | | |
|
||||
* | | |
|
||||
@ -140,7 +140,7 @@ _thread_stack_alloc(size_t stacksize, size_t guardsize)
|
||||
* If the stack and guard sizes are default, try to allocate a stack
|
||||
* from the default-size stack cache:
|
||||
*/
|
||||
if (stack_size == PTHREAD_STACK_DEFAULT &&
|
||||
if (stack_size == _pthread_stack_default &&
|
||||
guardsize == _pthread_guard_default) {
|
||||
/*
|
||||
* Use the garbage collector mutex for synchronization of the
|
||||
@ -190,7 +190,7 @@ _thread_stack_alloc(size_t stacksize, size_t guardsize)
|
||||
if (stack == NULL) {
|
||||
|
||||
if (last_stack == NULL)
|
||||
last_stack = _usrstack - PTHREAD_STACK_INITIAL -
|
||||
last_stack = _usrstack - _pthread_stack_initial -
|
||||
_pthread_guard_default;
|
||||
|
||||
/* Allocate a new stack. */
|
||||
@ -231,7 +231,7 @@ _thread_stack_free(void *stack, size_t stacksize, size_t guardsize)
|
||||
spare_stack->guardsize = guardsize;
|
||||
spare_stack->stackaddr = stack;
|
||||
|
||||
if (spare_stack->stacksize == PTHREAD_STACK_DEFAULT &&
|
||||
if (spare_stack->stacksize == _pthread_stack_default &&
|
||||
spare_stack->guardsize == _pthread_guard_default) {
|
||||
/* Default stack/guard size. */
|
||||
LIST_INSERT_HEAD(&_dstackq, spare_stack, qe);
|
||||
|
Loading…
Reference in New Issue
Block a user