summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_init.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2014-08-16 08:38:53 +0000
committerkib <kib@FreeBSD.org>2014-08-16 08:38:53 +0000
commit9cb3300d8873288618caa26042799d0bbbdfce49 (patch)
tree8a66b6dc583fede70780e314a93a3b4ab8bfb036 /lib/libthr/thread/thr_init.c
parent6f9f1bcfb80d50fe7cd46c63ecb4c5fbad2a59ed (diff)
downloadFreeBSD-src-9cb3300d8873288618caa26042799d0bbbdfce49.zip
FreeBSD-src-9cb3300d8873288618caa26042799d0bbbdfce49.tar.gz
MFC r269909:
Add a knob LIBPTHREAD_BIGSTACK_MAIN, which instructs libthr to leave the whole RLIMIT_STACK-sized region of the kernel-allocated stack as the stack of main thread.
Diffstat (limited to 'lib/libthr/thread/thr_init.c')
-rw-r--r--lib/libthr/thread/thr_init.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
index 937d83f..9bf0e29 100644
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -37,6 +37,7 @@
#include <sys/types.h>
#include <sys/signalvar.h>
#include <sys/ioctl.h>
+#include <sys/resource.h>
#include <sys/sysctl.h>
#include <sys/ttycom.h>
#include <sys/mman.h>
@@ -441,6 +442,7 @@ init_main_thread(struct pthread *thread)
static void
init_private(void)
{
+ struct rlimit rlim;
size_t len;
int mib[2];
char *env;
@@ -471,6 +473,12 @@ init_private(void)
len = sizeof (_usrstack);
if (sysctl(mib, 2, &_usrstack, &len, NULL, 0) == -1)
PANIC("Cannot get kern.usrstack from sysctl");
+ env = getenv("LIBPTHREAD_BIGSTACK_MAIN");
+ if (env != NULL) {
+ if (getrlimit(RLIMIT_STACK, &rlim) == -1)
+ PANIC("Cannot get stack rlimit");
+ _thr_stack_initial = rlim.rlim_cur;
+ }
len = sizeof(_thr_is_smp);
sysctlbyname("kern.smp.cpus", &_thr_is_smp, &len, NULL, 0);
_thr_is_smp = (_thr_is_smp > 1);
OpenPOWER on IntegriCloud