about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>2011-12-30 15:41:20 -0500
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>2011-12-30 15:41:20 -0500
commit9aaaf1363c43f84c47ba6e35586a2ae8f8d44cba (patch)
treec7cea1c1c099a3f18e050559d54e25258653fa9b
parent3380772a3c7f5c5dfc23604c7699b1e02624f049 (diff)
downloadglibc-9aaaf1363c43f84c47ba6e35586a2ae8f8d44cba.tar.gz
glibc-9aaaf1363c43f84c47ba6e35586a2ae8f8d44cba.tar.xz
glibc-9aaaf1363c43f84c47ba6e35586a2ae8f8d44cba.zip
Fix for AIO stack size (backported from 'master' branch)
-rw-r--r--nptl/Versions2
-rw-r--r--nptl/nptl-init.c12
-rw-r--r--nptl/pthreadP.h1
-rw-r--r--nptl/sysdeps/unix/sysv/linux/aio_misc.h4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/timer_routines.c2
5 files changed, 16 insertions, 5 deletions
diff --git a/nptl/Versions b/nptl/Versions
index 5a884202f1..6a10375502 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -255,6 +255,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..7288ff1896 100644
--- a/nptl/sysdeps/unix/sysv/linux/aio_misc.h
+++ b/nptl/sysdeps/unix/sysv/linux/aio_misc.h
@@ -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