From 21f35b33c21ae047b366c548d6d5b926a3d93f53 Mon Sep 17 00:00:00 2001
From: David Crawshaw <crawshaw@golang.org>
Date: Tue, 15 Sep 2015 12:22:46 -0400
Subject: [PATCH] runtime: use a 64kb system stack on arm

I went looking for an arm system whose stacks are by default smaller
than 64KB. In fact the smallest common linux target I could find was
Android, which like iOS uses 1MB stacks.

Fixes #11873

Change-Id: Ieeb66ad095b3da18d47ba21360ea75152a4107c6
Reviewed-on: https://go-review.googlesource.com/14602
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Minux Ma <minux@golang.org>
---
 src/runtime/asm_arm.s    | 3 ++-
 src/runtime/os1_linux.go | 5 ++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/runtime/asm_arm.s b/src/runtime/asm_arm.s
index 917cce81c3..8472090d8b 100644
--- a/src/runtime/asm_arm.s
+++ b/src/runtime/asm_arm.s
@@ -31,7 +31,8 @@ TEXT runtimečˇ¯rt0_go(SB),NOSPLIT,$-4
 	MOVW	R8, g_m(g)
 
 	// create istack out of the OS stack
-	MOVW	$(-8192+104)(R13), R0
+	// (1MB of system stack is available on iOS and Android)
+	MOVW	$(-64*1024+104)(R13), R0
 	MOVW	R0, g_stackguard0(g)
 	MOVW	R0, g_stackguard1(g)
 	MOVW	R0, (g_stack+stack_lo)(g)
diff --git a/src/runtime/os1_linux.go b/src/runtime/os1_linux.go
index c23dc30bc1..6410801d8e 100644
--- a/src/runtime/os1_linux.go
+++ b/src/runtime/os1_linux.go
@@ -76,14 +76,13 @@ func futexwakeup(addr *uint32, cnt uint32) {
 
 func getproccount() int32 {
 	// This buffer is huge (8 kB) but we are on the system stack
-	// and there should be plenty of space (64 kB) -- except on ARM where
-	// the system stack itself is only 8kb (see golang.org/issue/11873).
+	// and there should be plenty of space (64 kB).
 	// Also this is a leaf, so we're not holding up the memory for long.
 	// See golang.org/issue/11823.
 	// The suggested behavior here is to keep trying with ever-larger
 	// buffers, but we don't have a dynamic memory allocator at the
 	// moment, so that's a bit tricky and seems like overkill.
-	const maxCPUs = 64*1024*(1-goarch_arm) + 1024*goarch_arm
+	const maxCPUs = 64 * 1024
 	var buf [maxCPUs / (ptrSize * 8)]uintptr
 	r := sched_getaffinity(0, unsafe.Sizeof(buf), &buf[0])
 	n := int32(0)
-- 
2.30.9