diff mbox

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

Message ID CAKOQZ8zOEYue4dU-t3p20qWwvwGRmZaPjdDzyOSuT8X5ozGbMA@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Oct. 16, 2014, 10:39 p.m. UTC
On Tue, Sep 9, 2014 at 5:58 AM, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> 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.

Thanks.  I think this whole idea was misguided, and was a leftover
from the time when gccgo put each goroutine on a separate thread.  Now
that goroutines are multiplexed onto threads, there aren't all that
many threads, and there is no particular reason to force them to have
small stacks.  We want goroutines to have small stacks, on systems
that support splitting that stack, but the goroutine stack is not the
thread stack.  The gc toolchain also does not put a limit on thread
stack size.

This patch simply removes the limit on thread stack size.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian


worker threads.
 //
@@ -481,7 +427,6 @@
 	g->m = m;

 	initcontext();
-	inittlssize();

 	runtime_sched.maxmcount = 10000;
 	runtime_precisestack = 0;
diff mbox

Patch

diff -r 4185806dae27 libgo/runtime/proc.c
--- a/libgo/runtime/proc.c	Thu Oct 16 12:54:41 2014 -0700
+++ b/libgo/runtime/proc.c	Thu Oct 16 15:17:39 2014 -0700
@@ -167,15 +167,11 @@ 
 	g = gp;
 }

-// The static TLS size.  See runtime_newm.
-static int tlssize;
-
 // Start a new thread.
 static void
 runtime_newosproc(M *mp)
 {
 	pthread_attr_t attr;
-	size_t stacksize;
 	sigset_t clear, old;
 	pthread_t tid;
 	int ret;
@@ -185,19 +181,6 @@ 
 	if(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
 		runtime_throw("pthread_attr_setdetachstate");

-	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;
-
-	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.
 	sigfillset(&clear);
@@ -306,43 +289,6 @@ 
 	}
 }

-#ifdef HAVE_DL_ITERATE_PHDR
-
-// Called via dl_iterate_phdr.
-
-static int
-addtls(struct dl_phdr_info* info, size_t size __attribute__
((unused)), void *data)
-{
-	size_t *total = (size_t *)data;
-	unsigned int i;
-
-	for(i = 0; i < info->dlpi_phnum; ++i) {
-		if(info->dlpi_phdr[i].p_type == PT_TLS)
-			*total += info->dlpi_phdr[i].p_memsz;
-	}
-	return 0;
-}
-
-// Set the total TLS size.
-
-static void
-inittlssize()
-{
-	size_t total = 0;
-
-	dl_iterate_phdr(addtls, (void *)&total);
-	tlssize = total;
-}
-
-#else
-
-static void
-inittlssize()
-{
-}
-
-#endif
-
 // Goroutine scheduler
 // The scheduler's job is to distribute ready-to-run goroutines over