Increase the default stacksizes:
32-bit 64-bit main thread 2MB 4MB other threads 1MB 2MB
This commit is contained in:
parent
31d0686d2d
commit
36a1ac2c2e
@ -54,6 +54,7 @@ _pthread_attr_init(pthread_attr_t *attr)
|
||||
memcpy(pattr, &_pthread_attr_default,
|
||||
sizeof(struct pthread_attr));
|
||||
pattr->guardsize_attr = _thr_guard_default;
|
||||
pattr->stacksize_attr = _thr_stack_default;
|
||||
|
||||
/* Return a pointer to the attribute object: */
|
||||
*attr = pattr;
|
||||
|
@ -337,7 +337,7 @@ init_main_thread(struct pthread *thread)
|
||||
* resource limits, so this stack needs an explicitly mapped
|
||||
* red zone to protect the thread stack that is just beyond.
|
||||
*/
|
||||
if (mmap((void *)_usrstack - THR_STACK_INITIAL -
|
||||
if (mmap((void *)_usrstack - _thr_stack_initial -
|
||||
_thr_guard_default, _thr_guard_default, 0, MAP_ANON,
|
||||
-1, 0) == MAP_FAILED)
|
||||
PANIC("Cannot allocate red zone for initial thread");
|
||||
@ -351,8 +351,8 @@ init_main_thread(struct pthread *thread)
|
||||
* actually free() it; it just puts it in the free
|
||||
* stack queue for later reuse.
|
||||
*/
|
||||
thread->attr.stackaddr_attr = (void *)_usrstack - THR_STACK_INITIAL;
|
||||
thread->attr.stacksize_attr = THR_STACK_INITIAL;
|
||||
thread->attr.stackaddr_attr = (void *)_usrstack - _thr_stack_initial;
|
||||
thread->attr.stacksize_attr = _thr_stack_initial;
|
||||
thread->attr.guardsize_attr = _thr_guard_default;
|
||||
thread->attr.flags |= THR_STACK_USER;
|
||||
|
||||
@ -427,6 +427,14 @@ init_private(void)
|
||||
|
||||
_thr_page_size = getpagesize();
|
||||
_thr_guard_default = _thr_page_size;
|
||||
if (sizeof(void *) == 8) {
|
||||
_thr_stack_default = THR_STACK64_DEFAULT;
|
||||
_thr_stack_initial = THR_STACK64_INITIAL;
|
||||
}
|
||||
else {
|
||||
_thr_stack_default = THR_STACK32_DEFAULT;
|
||||
_thr_stack_initial = THR_STACK32_INITIAL;
|
||||
}
|
||||
init_once = 1; /* Don't do this again. */
|
||||
} else {
|
||||
/*
|
||||
|
@ -466,14 +466,16 @@ struct pthread_attr {
|
||||
/*
|
||||
* Miscellaneous definitions.
|
||||
*/
|
||||
#define THR_STACK_DEFAULT 65536
|
||||
#define THR_STACK32_DEFAULT (1 * 1024 * 1024)
|
||||
#define THR_STACK64_DEFAULT (2 * 1024 * 1024)
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#define THR_STACK_INITIAL 0x100000
|
||||
#define THR_STACK32_INITIAL (2 * 1024 * 1024)
|
||||
#define THR_STACK64_INITIAL (4 * 1024 * 1024)
|
||||
|
||||
/*
|
||||
* Define the different priority ranges. All applications have thread
|
||||
@ -1034,7 +1036,7 @@ SCLASS struct pthread_attr _pthread_attr_default
|
||||
SCLASS_PRESET({
|
||||
SCHED_RR, 0, TIMESLICE_USEC, THR_DEFAULT_PRIORITY,
|
||||
THR_CREATE_RUNNING, PTHREAD_CREATE_JOINABLE, NULL,
|
||||
NULL, NULL, THR_STACK_DEFAULT, /* guardsize */0
|
||||
NULL, NULL, /* stacksize */0, /* guardsize */0
|
||||
});
|
||||
|
||||
/* Default mutex attributes: */
|
||||
@ -1073,6 +1075,8 @@ SCLASS struct lock _rwlock_static_lock;
|
||||
SCLASS struct lock _keytable_lock;
|
||||
SCLASS struct lock _thread_list_lock;
|
||||
SCLASS int _thr_guard_default;
|
||||
SCLASS int _thr_stack_default;
|
||||
SCLASS int _thr_stack_initial;
|
||||
SCLASS int _thr_page_size;
|
||||
SCLASS pthread_t _thr_sig_daemon;
|
||||
SCLASS int _thr_debug_flags SCLASS_PRESET(0);
|
||||
|
@ -160,7 +160,7 @@ _thr_stack_alloc(struct pthread_attr *attr)
|
||||
* If the stack and guard sizes are default, try to allocate a stack
|
||||
* from the default-size stack cache:
|
||||
*/
|
||||
if ((stacksize == THR_STACK_DEFAULT) &&
|
||||
if ((stacksize == _thr_stack_default) &&
|
||||
(guardsize == _thr_guard_default)) {
|
||||
if ((spare_stack = LIST_FIRST(&dstackq)) != NULL) {
|
||||
/* Use the spare stack. */
|
||||
@ -191,7 +191,7 @@ _thr_stack_alloc(struct pthread_attr *attr)
|
||||
else {
|
||||
/* Allocate a stack from usrstack. */
|
||||
if (last_stack == NULL)
|
||||
last_stack = _usrstack - THR_STACK_INITIAL -
|
||||
last_stack = _usrstack - _thr_stack_initial -
|
||||
_thr_guard_default;
|
||||
|
||||
/* Allocate a new stack. */
|
||||
@ -245,7 +245,7 @@ _thr_stack_free(struct pthread_attr *attr)
|
||||
spare_stack->guardsize = round_up(attr->guardsize_attr);
|
||||
spare_stack->stackaddr = attr->stackaddr_attr;
|
||||
|
||||
if (spare_stack->stacksize == THR_STACK_DEFAULT &&
|
||||
if (spare_stack->stacksize == _thr_stack_default &&
|
||||
spare_stack->guardsize == _thr_guard_default) {
|
||||
/* Default stack/guard size. */
|
||||
LIST_INSERT_HEAD(&dstackq, spare_stack, qe);
|
||||
|
@ -54,6 +54,7 @@ _pthread_attr_init(pthread_attr_t *attr)
|
||||
memcpy(pattr, &_pthread_attr_default,
|
||||
sizeof(struct pthread_attr));
|
||||
pattr->guardsize_attr = _thr_guard_default;
|
||||
pattr->stacksize_attr = _thr_stack_default;
|
||||
|
||||
/* Return a pointer to the attribute object: */
|
||||
*attr = pattr;
|
||||
|
@ -337,7 +337,7 @@ init_main_thread(struct pthread *thread)
|
||||
* resource limits, so this stack needs an explicitly mapped
|
||||
* red zone to protect the thread stack that is just beyond.
|
||||
*/
|
||||
if (mmap((void *)_usrstack - THR_STACK_INITIAL -
|
||||
if (mmap((void *)_usrstack - _thr_stack_initial -
|
||||
_thr_guard_default, _thr_guard_default, 0, MAP_ANON,
|
||||
-1, 0) == MAP_FAILED)
|
||||
PANIC("Cannot allocate red zone for initial thread");
|
||||
@ -351,8 +351,8 @@ init_main_thread(struct pthread *thread)
|
||||
* actually free() it; it just puts it in the free
|
||||
* stack queue for later reuse.
|
||||
*/
|
||||
thread->attr.stackaddr_attr = (void *)_usrstack - THR_STACK_INITIAL;
|
||||
thread->attr.stacksize_attr = THR_STACK_INITIAL;
|
||||
thread->attr.stackaddr_attr = (void *)_usrstack - _thr_stack_initial;
|
||||
thread->attr.stacksize_attr = _thr_stack_initial;
|
||||
thread->attr.guardsize_attr = _thr_guard_default;
|
||||
thread->attr.flags |= THR_STACK_USER;
|
||||
|
||||
@ -427,6 +427,14 @@ init_private(void)
|
||||
|
||||
_thr_page_size = getpagesize();
|
||||
_thr_guard_default = _thr_page_size;
|
||||
if (sizeof(void *) == 8) {
|
||||
_thr_stack_default = THR_STACK64_DEFAULT;
|
||||
_thr_stack_initial = THR_STACK64_INITIAL;
|
||||
}
|
||||
else {
|
||||
_thr_stack_default = THR_STACK32_DEFAULT;
|
||||
_thr_stack_initial = THR_STACK32_INITIAL;
|
||||
}
|
||||
init_once = 1; /* Don't do this again. */
|
||||
} else {
|
||||
/*
|
||||
|
@ -466,14 +466,16 @@ struct pthread_attr {
|
||||
/*
|
||||
* Miscellaneous definitions.
|
||||
*/
|
||||
#define THR_STACK_DEFAULT 65536
|
||||
#define THR_STACK32_DEFAULT (1 * 1024 * 1024)
|
||||
#define THR_STACK64_DEFAULT (2 * 1024 * 1024)
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#define THR_STACK_INITIAL 0x100000
|
||||
#define THR_STACK32_INITIAL (2 * 1024 * 1024)
|
||||
#define THR_STACK64_INITIAL (4 * 1024 * 1024)
|
||||
|
||||
/*
|
||||
* Define the different priority ranges. All applications have thread
|
||||
@ -1034,7 +1036,7 @@ SCLASS struct pthread_attr _pthread_attr_default
|
||||
SCLASS_PRESET({
|
||||
SCHED_RR, 0, TIMESLICE_USEC, THR_DEFAULT_PRIORITY,
|
||||
THR_CREATE_RUNNING, PTHREAD_CREATE_JOINABLE, NULL,
|
||||
NULL, NULL, THR_STACK_DEFAULT, /* guardsize */0
|
||||
NULL, NULL, /* stacksize */0, /* guardsize */0
|
||||
});
|
||||
|
||||
/* Default mutex attributes: */
|
||||
@ -1073,6 +1075,8 @@ SCLASS struct lock _rwlock_static_lock;
|
||||
SCLASS struct lock _keytable_lock;
|
||||
SCLASS struct lock _thread_list_lock;
|
||||
SCLASS int _thr_guard_default;
|
||||
SCLASS int _thr_stack_default;
|
||||
SCLASS int _thr_stack_initial;
|
||||
SCLASS int _thr_page_size;
|
||||
SCLASS pthread_t _thr_sig_daemon;
|
||||
SCLASS int _thr_debug_flags SCLASS_PRESET(0);
|
||||
|
@ -160,7 +160,7 @@ _thr_stack_alloc(struct pthread_attr *attr)
|
||||
* If the stack and guard sizes are default, try to allocate a stack
|
||||
* from the default-size stack cache:
|
||||
*/
|
||||
if ((stacksize == THR_STACK_DEFAULT) &&
|
||||
if ((stacksize == _thr_stack_default) &&
|
||||
(guardsize == _thr_guard_default)) {
|
||||
if ((spare_stack = LIST_FIRST(&dstackq)) != NULL) {
|
||||
/* Use the spare stack. */
|
||||
@ -191,7 +191,7 @@ _thr_stack_alloc(struct pthread_attr *attr)
|
||||
else {
|
||||
/* Allocate a stack from usrstack. */
|
||||
if (last_stack == NULL)
|
||||
last_stack = _usrstack - THR_STACK_INITIAL -
|
||||
last_stack = _usrstack - _thr_stack_initial -
|
||||
_thr_guard_default;
|
||||
|
||||
/* Allocate a new stack. */
|
||||
@ -245,7 +245,7 @@ _thr_stack_free(struct pthread_attr *attr)
|
||||
spare_stack->guardsize = round_up(attr->guardsize_attr);
|
||||
spare_stack->stackaddr = attr->stackaddr_attr;
|
||||
|
||||
if (spare_stack->stacksize == THR_STACK_DEFAULT &&
|
||||
if (spare_stack->stacksize == _thr_stack_default &&
|
||||
spare_stack->guardsize == _thr_guard_default) {
|
||||
/* Default stack/guard size. */
|
||||
LIST_INSERT_HEAD(&dstackq, spare_stack, qe);
|
||||
|
Loading…
Reference in New Issue
Block a user