Remove surplus mmap() call for stack guard page in init_private, it is done
in init_main_thread. Also don't initialize lock and lockuser again for initial thread, it is already done by _thr_alloc(). Reviewed by: deischen Approved by: re (scottl)
This commit is contained in:
parent
09f2522c7f
commit
e9f088c469
@ -319,8 +319,6 @@ _libpthread_init(struct pthread *curthread)
|
||||
static void
|
||||
init_main_thread(struct pthread *thread)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Setup the thread attributes. */
|
||||
thread->attr = _pthread_attr_default;
|
||||
thread->attr.flags |= PTHREAD_SCOPE_SYSTEM;
|
||||
@ -383,15 +381,6 @@ init_main_thread(struct pthread *thread)
|
||||
/* Initialize the mutex queue: */
|
||||
TAILQ_INIT(&thread->mutexq);
|
||||
|
||||
/* Initialize thread locking. */
|
||||
if (_lock_init(&thread->lock, LCK_ADAPTIVE,
|
||||
_thr_lock_wait, _thr_lock_wakeup) != 0)
|
||||
PANIC("Cannot initialize initial thread lock");
|
||||
for (i = 0; i < MAX_THR_LOCKLEVEL; i++) {
|
||||
_lockuser_init(&thread->lockusers[i], (void *)thread);
|
||||
_LCK_SET_PRIVATE2(&thread->lockusers[i], (void *)thread);
|
||||
}
|
||||
|
||||
/* Initialize hooks in the thread structure: */
|
||||
thread->specific = NULL;
|
||||
thread->cleanup = NULL;
|
||||
@ -420,20 +409,6 @@ init_private(void)
|
||||
len = sizeof (_usrstack);
|
||||
if (sysctl(mib, 2, &_usrstack, &len, NULL, 0) == -1)
|
||||
PANIC("Cannot get kern.usrstack from sysctl");
|
||||
|
||||
/*
|
||||
* Create a red zone below the main stack. All other
|
||||
* stacks are constrained to a maximum size by the
|
||||
* parameters passed to mmap(), but this stack is only
|
||||
* limited by 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 -
|
||||
_thr_guard_default, _thr_guard_default,
|
||||
0, MAP_ANON, -1, 0) == MAP_FAILED)
|
||||
PANIC("Cannot allocate red zone for initial thread");
|
||||
|
||||
/* Get the kernel clockrate: */
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_CLOCKRATE;
|
||||
|
@ -319,8 +319,6 @@ _libpthread_init(struct pthread *curthread)
|
||||
static void
|
||||
init_main_thread(struct pthread *thread)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Setup the thread attributes. */
|
||||
thread->attr = _pthread_attr_default;
|
||||
thread->attr.flags |= PTHREAD_SCOPE_SYSTEM;
|
||||
@ -383,15 +381,6 @@ init_main_thread(struct pthread *thread)
|
||||
/* Initialize the mutex queue: */
|
||||
TAILQ_INIT(&thread->mutexq);
|
||||
|
||||
/* Initialize thread locking. */
|
||||
if (_lock_init(&thread->lock, LCK_ADAPTIVE,
|
||||
_thr_lock_wait, _thr_lock_wakeup) != 0)
|
||||
PANIC("Cannot initialize initial thread lock");
|
||||
for (i = 0; i < MAX_THR_LOCKLEVEL; i++) {
|
||||
_lockuser_init(&thread->lockusers[i], (void *)thread);
|
||||
_LCK_SET_PRIVATE2(&thread->lockusers[i], (void *)thread);
|
||||
}
|
||||
|
||||
/* Initialize hooks in the thread structure: */
|
||||
thread->specific = NULL;
|
||||
thread->cleanup = NULL;
|
||||
@ -420,20 +409,6 @@ init_private(void)
|
||||
len = sizeof (_usrstack);
|
||||
if (sysctl(mib, 2, &_usrstack, &len, NULL, 0) == -1)
|
||||
PANIC("Cannot get kern.usrstack from sysctl");
|
||||
|
||||
/*
|
||||
* Create a red zone below the main stack. All other
|
||||
* stacks are constrained to a maximum size by the
|
||||
* parameters passed to mmap(), but this stack is only
|
||||
* limited by 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 -
|
||||
_thr_guard_default, _thr_guard_default,
|
||||
0, MAP_ANON, -1, 0) == MAP_FAILED)
|
||||
PANIC("Cannot allocate red zone for initial thread");
|
||||
|
||||
/* Get the kernel clockrate: */
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_CLOCKRATE;
|
||||
|
Loading…
Reference in New Issue
Block a user