[patch] pthread_create.3 : explicit default thread stack size for x86_64

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From e7de6cf99f73d1157bf384030eb395adcff56772 Mon Sep 17 00:00:00 2001
From: Frederic Brault <fbrault@xxxxxxxxxx>
Date: Mon, 12 Mar 2018 10:52:34 +0100
Subject: [PATCH] Explicit default thread stack size on x86_64

---
 man3/pthread_create.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man3/pthread_create.3 b/man3/pthread_create.3
index 2bfe58b..d8f386c 100644
--- a/man3/pthread_create.3
+++ b/man3/pthread_create.3
@@ -200,7 +200,7 @@ was set to create the thread in a detached state (using
 .PP
 .\" FIXME . Perhaps some of the following detail should be in
 .\" a future pthread_attr_setstacksize(3) page.
-On Linux/x86-32, the default stack size for a new thread is 2 megabytes.
+On Linux/x86-32 and Linux/x86_64, the default stack size for a new
thread is 2 megabytes.
 Under the NPTL threading implementation, if the
 .BR RLIMIT_STACK
 soft resource limit
-- 
2.3.3



On modern linux, ulimit -s unlimited paradoxically gives you a *SMALL*
stack size for threads (2MB).
I updated the NOTE to say that this applies not only for x86-32, but
also for x86_64, because of the following code in libc :


nptl-init.c, in function __pthread_initialize_minimal_internal (void) :

 if (__getrlimit (RLIMIT_STACK, &limit) != 0 || limit.rlim_cur ==
RLIM_INFINITY)
     /* The system limit is not usable.  Use an architecture-specific
default.  */
    limit.rlim_cur = ARCH_STACK_DEFAULT_SIZE;

And the different per-architecture values :

sysdeps/aarch64/nptl/pthreaddef.h #define ARCH_STACK_DEFAULT_SIZE (2 *
1024 * 1024)
sysdeps/alpha/nptl/pthreaddef.h #define ARCH_STACK_DEFAULT_SIZE (4 *
1024 * 1024)
sysdeps/arm/nptl/pthreaddef.h #define ARCH_STACK_DEFAULT_SIZE (2 * 1024
* 1024)
sysdeps/hppa/nptl/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE (8 *
1024 * 1024)
sysdeps/i386/nptl/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE (2 *
1024 * 1024)
sysdeps/ia64/nptl/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE (32 *
1024 * 1024)
sysdeps/m68k/nptl/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE (2 *
1024 * 1024)
sysdeps/microblaze/nptl/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE 
(2 * 1024 * 1024)
sysdeps/mips/nptl/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE (2 *
1024 * 1024)
sysdeps/nios2/nptl/pthreaddef.h #define ARCH_STACK_DEFAULT_SIZE (2 *
1024 * 1024)
sysdeps/powerpc/nptl/pthreaddef.h #define ARCH_STACK_DEFAULT_SIZE (4 *
1024 * 1024)
sysdeps/riscv/nptl/pthreaddef.h #define ARCH_STACK_DEFAULT_SIZE (2 *
1024 * 1024)
sysdeps/s390/nptl/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE (2 *
1024 * 1024)
sysdeps/sh/nptl/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE (2 * 1024
* 1024)
sysdeps/sparc/sparc32/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE (2 *
1024 * 1024)
sysdeps/sparc/sparc64/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE (4 *
1024 * 1024)
sysdeps/tile/nptl/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE (2 *
1024 * 1024)
sysdeps/x86_64/nptl/pthreaddef.h  #define ARCH_STACK_DEFAULT_SIZE (2 *
1024 * 1024)


Maybe a specific section in pthread_attr_setstacksize.3 would be
interesting, listing all archictecture.
I can do another patch with that if you think it makes sense.

Regards,

Frederic Brault
From e7de6cf99f73d1157bf384030eb395adcff56772 Mon Sep 17 00:00:00 2001
From: Frederic Brault <fbrault@xxxxxxxxxx>
Date: Mon, 12 Mar 2018 10:52:34 +0100
Subject: [PATCH] Explicit default thread stack size on x86_64

---
 man3/pthread_create.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man3/pthread_create.3 b/man3/pthread_create.3
index 2bfe58b..d8f386c 100644
--- a/man3/pthread_create.3
+++ b/man3/pthread_create.3
@@ -200,7 +200,7 @@ was set to create the thread in a detached state (using
 .PP
 .\" FIXME . Perhaps some of the following detail should be in
 .\" a future pthread_attr_setstacksize(3) page.
-On Linux/x86-32, the default stack size for a new thread is 2 megabytes.
+On Linux/x86-32 and Linux/x86_64, the default stack size for a new thread is 2 megabytes.
 Under the NPTL threading implementation, if the
 .BR RLIMIT_STACK
 soft resource limit
-- 
2.3.3


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux