diff options
author | Michael Hudson-Doyle <michael.hudson@canonical.com> | 2016-04-07 11:47:32 +1200 |
---|---|---|
committer | Andrew Gerrand <adg@golang.org> | 2016-04-19 04:49:31 +0000 |
commit | 5fdefe91da79eda584a30b6f32b9b841bbcc23dc (patch) | |
tree | 9113f922c3af5f51fbb4d1ef9d65d36b7b97eb85 | |
parent | 6fd563d32a73591d7ad9aba3d392df039265cab5 (diff) | |
download | go-5fdefe91da79eda584a30b6f32b9b841bbcc23dc.tar.gz go-5fdefe91da79eda584a30b6f32b9b841bbcc23dc.zip |
runtime: clamp OS-reported number of processors to _MaxGomaxprocs
So that all Go processes do not die on startup on a system with >256 CPUs.
I tested this by hacking osinit to set ncpu to 1000.
Updates #15131
Fixes #15160
Change-Id: I52e061a0de97be41d684dd8b748fa9087d6f1aef
Reviewed-on: https://go-review.googlesource.com/21599
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/22206
-rw-r--r-- | src/runtime/proc.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index d1f5088b50..47ccb37c9f 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -443,6 +443,9 @@ func schedinit() { sched.lastpoll = uint64(nanotime()) procs := int(ncpu) + if procs > _MaxGomaxprocs { + procs = _MaxGomaxprocs + } if n := atoi(gogetenv("GOMAXPROCS")); n > 0 { if n > _MaxGomaxprocs { n = _MaxGomaxprocs |