This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use __pthread_get_minstack() when setting stack size in__aio_create_helper_thread().

The included patch is an extension to the following patch sets:

commit ee9e064083b7199fd2c680fa1b2dcf49ff52fedd
Author: Ulrich Drepper <>
Date:   Thu Dec 22 22:58:17 2011 -0500

    Use __pthread_get_minstack in more places

commit 2c1094bd700e63a8d7f547b3f5495bedb55c0a08
Author: Ulrich Drepper <>
Date:   Thu Dec 22 22:43:39 2011 -0500

    Create internal threads with sufficient stack size

When AIO is used in an application with heavy TLS usage, AIO worker
thread creation fails during pthread_create() due to the TLS
requirements of the application exceeding PTHREAD_STACK_MIN.

Adhemerval is on vacation so I'm submitting the included patch for him.

A similar change to what we propose for
nptl/sysdeps/unix/sysv/linux/aio_misc.h was made to
nptl/sysdeps/pthread/gai_misc.h as part of commit
ee9e064083b7199fd2c680fa1b2dcf49ff52fedd :

   /* The helper thread needs only very little resources.  */
  (void) pthread_attr_setstacksize (&attr,
                                   __pthread_get_minstack (&attr)
                                   + 4 * PTHREAD_STACK_MIN);

What's the reason that 4 * PTHREAD_STACK_MIN is added to the minstack in
this case?

Ryan S. Arnold
IBM Linux Technology Center

ChangeLog relative to nptl/

2011-12-30  Adhemerval Zanella  <>

	* sysdeps/unix/sysv/linux/aio_misc.h (__aio_create_helper_thread):
	Call pthread_attr_setstacksize() with result of
	__pthread_get_minstack() to account for application TLS usage.

diff --git a/nptl/sysdeps/unix/sysv/linux/aio_misc.h b/nptl/sysdeps/unix/sysv/linux/aio_misc.h
index 406d96e..3910b13 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 <>, 2004.
@@ -47,7 +47,7 @@ __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
   pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
   /* The helper thread needs only very little resources.  */
-  (void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
+  (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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]