diff mbox

[6/9] Gccgo port to s390[x] -- part I

Message ID 20140909125840.GG25290@linux.vnet.ibm.com
State New
Headers show

Commit Message

Dominik Vogt Sept. 9, 2014, 12:58 p.m. UTC
Eases the rediculously tight minimum stack size for goprocesses on
64 bit systems.

ChangeLog
2014-09-05  Dominik Vogt  <vogt@linux.vnet.ibm.com>

        * libgo/runtime/proc.c (runtime_newosproc): Set the thread stack size
        explicitly only on 32 bit systems.

Ciao

Dominik ^_^  ^_^
diff mbox

Patch

From a1691a4c61114124a4d41754bca5a47bf7102b71 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Fri, 5 Sep 2014 07:30:52 +0100
Subject: [PATCH 6/9] LIBGO: Set a small default stack size only for 32 bit.

On 64 bit systems there should be plenty of space in the memory map to give
each thread the maximum possible stack size.  This is the default when unsing
glibc.
---
 libgo/runtime/proc.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c
index 6f656d8..f67849f 100644
--- a/libgo/runtime/proc.c
+++ b/libgo/runtime/proc.c
@@ -175,7 +175,6 @@  static void
 runtime_newosproc(M *mp)
 {
 	pthread_attr_t attr;
-	size_t stacksize;
 	sigset_t clear, old;
 	pthread_t tid;
 	int ret;
@@ -185,18 +184,26 @@  runtime_newosproc(M *mp)
 	if(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
 		runtime_throw("pthread_attr_setdetachstate");
 
-	stacksize = PTHREAD_STACK_MIN;
+	// For 32 bit systems, start with a small stack size and rely on the
+	// split stack feature to increase the stack on demand.  This conserves
+	// the available space in the memory map.
+	if (sizeof(char *) < 8)
+	{
+		size_t stacksize;
+
+		stacksize = PTHREAD_STACK_MIN;
 
-	// With glibc before version 2.16 the static TLS size is taken
-	// out of the stack size, and we get an error or a crash if
-	// there is not enough stack space left.  Add it back in if we
-	// can, in case the program uses a lot of TLS space.  FIXME:
-	// This can be disabled in glibc 2.16 and later, if the bug is
-	// indeed fixed then.
-	stacksize += tlssize;
+		// With glibc before version 2.16 the static TLS size is taken
+		// out of the stack size, and we get an error or a crash if
+		// there is not enough stack space left.  Add it back in if we
+		// can, in case the program uses a lot of TLS space.  FIXME:
+		// This can be disabled in glibc 2.16 and later, if the bug is
+		// indeed fixed then.
+		stacksize += tlssize;
 
-	if(pthread_attr_setstacksize(&attr, stacksize) != 0)
-		runtime_throw("pthread_attr_setstacksize");
+		if(pthread_attr_setstacksize(&attr, stacksize) != 0)
+			runtime_throw("pthread_attr_setstacksize");
+	}
 
 	// Block signals during pthread_create so that the new thread
 	// starts with signals disabled.  It will enable them in minit.
-- 
1.8.4.2