mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Hint to kernel that thread stack memory can be removed.
This commit is contained in:
@ -1,3 +1,9 @@
|
||||
2009-08-24 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* pthread_create.c (start_thread): Hint to the kernel that memory for
|
||||
the stack can be reused. We do not mark all the memory. The part
|
||||
still in use and some reserve are kept.
|
||||
|
||||
2009-08-23 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* sysdeps/unix/sysv/linux/bits/posix_opt.h: Clean up namespace.
|
||||
|
@ -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. */
|
||||
|
Reference in New Issue
Block a user