]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: pass a smaller buffer to sched_getaffinity on ARM
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Fri, 24 Jul 2015 02:26:29 +0000 (14:26 +1200)
committerAustin Clements <austin@google.com>
Mon, 27 Jul 2015 01:04:10 +0000 (01:04 +0000)
The system stack is only around 8kb on ARM so one can't put an 8kb buffer on
the stack. More than 1024 ARM cores seems sufficiently unlikely for the
foreseeable future.

Fixes #11853

Change-Id: I7cb27c1250a6153f86e269c172054e9dfc218c72
Reviewed-on: https://go-review.googlesource.com/12622
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/os1_linux.go

index 6410801d8ed096a6f854b4c52a22275ef9600c49..c23dc30bc163b11630823b80a82f4a7dbd8f98e9 100644 (file)
@@ -76,13 +76,14 @@ 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).
+       // 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).
        // 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
+       const maxCPUs = 64*1024*(1-goarch_arm) + 1024*goarch_arm
        var buf [maxCPUs / (ptrSize * 8)]uintptr
        r := sched_getaffinity(0, unsafe.Sizeof(buf), &buf[0])
        n := int32(0)