diff options
author | Adhemerval Zanella <azanella@linux.vnet.ibm.com> | 2012-01-05 21:36:23 -0500 |
---|---|---|
committer | Adhemerval Zanella <azanella@linux.vnet.ibm.com> | 2012-01-05 21:36:23 -0500 |
commit | 0a08973fdfd081e959b3c42f8f95d27badb46423 (patch) | |
tree | e7880be2909f30d924eb5ace00e1f3651583318b | |
parent | b20eec6a2b7056d4a1737a92574cab6d15225796 (diff) | |
download | glibc-0a08973fdfd081e959b3c42f8f95d27badb46423.tar.gz glibc-0a08973fdfd081e959b3c42f8f95d27badb46423.tar.xz glibc-0a08973fdfd081e959b3c42f8f95d27badb46423.zip |
Fix for AIO stack size (backported from 'master' branch)
-rw-r--r-- | nptl/Versions | 2 | ||||
-rw-r--r-- | nptl/nptl-init.c | 12 | ||||
-rw-r--r-- | nptl/pthreadP.h | 1 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/aio_misc.h | 6 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/timer_routines.c | 2 |
5 files changed, 17 insertions, 6 deletions
diff --git a/nptl/Versions b/nptl/Versions index f74941fa92..333d4fa0eb 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -254,6 +254,6 @@ libpthread { GLIBC_PRIVATE { __pthread_initialize_minimal; __pthread_clock_gettime; __pthread_clock_settime; - __pthread_unwind; + __pthread_unwind; __pthread_get_minstack; } } diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index 851bab2bf1..628e7d7e70 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -408,7 +408,7 @@ __pthread_initialize_minimal_internal (void) /* Make sure it meets the minimum size that allocate_stack (allocatestack.c) will demand, which depends on the page size. */ - const uintptr_t pagesz = __sysconf (_SC_PAGESIZE); + const uintptr_t pagesz = GLRO(dl_pagesize); const size_t minstack = pagesz + __static_tls_size + MINIMAL_REST_STACK; if (limit.rlim_cur < minstack) limit.rlim_cur = minstack; @@ -450,3 +450,13 @@ __pthread_initialize_minimal_internal (void) } strong_alias (__pthread_initialize_minimal_internal, __pthread_initialize_minimal) + + +size_t +__pthread_get_minstack (const pthread_attr_t *attr) +{ + struct pthread_attr *iattr = (struct pthread_attr *) attr; + + return (GLRO(dl_pagesize) + __static_tls_size + PTHREAD_STACK_MIN + + iattr->guardsize); +} diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 43ca44c829..eb553a08fe 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -397,6 +397,7 @@ weak_function; extern void __pthread_init_static_tls (struct link_map *) attribute_hidden; +extern size_t __pthread_get_minstack (const pthread_attr_t *attr); /* Namespace save aliases. */ extern int __pthread_getschedparam (pthread_t thread_id, int *policy, diff --git a/nptl/sysdeps/unix/sysv/linux/aio_misc.h b/nptl/sysdeps/unix/sysv/linux/aio_misc.h index 2bf7c17aed..3910b13268 100644 --- a/nptl/sysdeps/unix/sysv/linux/aio_misc.h +++ b/nptl/sysdeps/unix/sysv/linux/aio_misc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2006, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2004. @@ -46,8 +46,8 @@ __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), pthread_attr_init (&attr); pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); - /* Don't set the stacksize to PTHREAD_STACK_MIN. Let it default, otherwise - the stack may be too small if TLS is in use. */ + /* The helper thread needs only very little resources. */ + (void) pthread_attr_setstacksize (&attr, __pthread_get_minstack (&attr)); /* Block all signals in the helper thread. To do this thoroughly we temporarily have to block all signals here. */ diff --git a/nptl/sysdeps/unix/sysv/linux/timer_routines.c b/nptl/sysdeps/unix/sysv/linux/timer_routines.c index b159316fb2..d75f45bc4e 100644 --- a/nptl/sysdeps/unix/sysv/linux/timer_routines.c +++ b/nptl/sysdeps/unix/sysv/linux/timer_routines.c @@ -165,7 +165,7 @@ __start_helper_thread (void) and should go away automatically when canceled. */ pthread_attr_t attr; (void) pthread_attr_init (&attr); - (void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN); + (void) pthread_attr_setstacksize (&attr, __pthread_get_minstack (&attr)); /* Block all signals in the helper thread but SIGSETXID. To do this thoroughly we temporarily have to block all signals here. The |