]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix for AIO stack size (backported from 'master' branch)
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 6 Jan 2012 02:36:23 +0000 (21:36 -0500)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 6 Jan 2012 02:36:23 +0000 (21:36 -0500)
nptl/Versions
nptl/nptl-init.c
nptl/pthreadP.h
nptl/sysdeps/unix/sysv/linux/aio_misc.h
nptl/sysdeps/unix/sysv/linux/timer_routines.c

index f74941fa92bdf124cb7397de08fdaf98054d5534..333d4fa0ebc9b0d7241ff0405b41c276f9467c3d 100644 (file)
@@ -254,6 +254,6 @@ libpthread {
   GLIBC_PRIVATE {
     __pthread_initialize_minimal;
     __pthread_clock_gettime; __pthread_clock_settime;
-    __pthread_unwind;
+    __pthread_unwind; __pthread_get_minstack;
   }
 }
index 851bab2bf1998d4ef772768d39efddf76d13cad2..628e7d7e70c184fffb9b2a88dd6aacc70089eaf3 100644 (file)
@@ -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);
+}
index 43ca44c8296f17f97baeda18cf50f2367ff19651..eb553a08fe3664ee1d79b377e7fe07d294b23b72 100644 (file)
@@ -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,
index 2bf7c17aed92deb7630396b87b4deb01613bc09e..3910b13268f03a8be31a2f7508d55a954b8c0a18 100644 (file)
@@ -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.  */
index b159316fb208197b5397e0798cab7037b1530959..d75f45bc4e96a361b6fe749c97da6a8fa6e5d7de 100644 (file)
@@ -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