diff options
author | Ulrich Drepper <drepper@redhat.com> | 2009-08-24 16:23:47 -0700 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2009-08-24 16:23:47 -0700 |
commit | b42a214c1807dc596cf3647fc35a0eb42ccc7e68 (patch) | |
tree | d5eb10baefc9c3e7097220bb81ada99438fa7859 /nptl/pthread_create.c | |
parent | 9a1ea1525eb8e02ce20eb93d65dc880186731bf7 (diff) | |
download | glibc-b42a214c1807dc596cf3647fc35a0eb42ccc7e68.tar.gz glibc-b42a214c1807dc596cf3647fc35a0eb42ccc7e68.tar.xz glibc-b42a214c1807dc596cf3647fc35a0eb42ccc7e68.zip |
Hint to kernel that thread stack memory can be removed.
Diffstat (limited to 'nptl/pthread_create.c')
-rw-r--r-- | nptl/pthread_create.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index c69397906f..89938b3fb8 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -377,6 +377,19 @@ start_thread (void *arg) } #endif + /* Mark the memory of the stack as usable to the kernel. We free + everything except for the space used for the TCB itself. */ + size_t pagesize_m1 = __getpagesize () - 1; +#ifdef _STACK_GROWS_DOWN + char *sp = CURRENT_STACK_FRAME; + size_t freesize = (sp - (char *) pd->stackblock) & ~pagesize_m1; +#else +# error "to do" +#endif + assert (freesize < pd->stackblock_size); + if (freesize > PTHREAD_STACK_MIN) + madvise (pd->stackblock, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED); + /* If the thread is detached free the TCB. */ if (IS_DETACHED (pd)) /* Free the TCB. */ |