]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: clamp OS-reported number of processors to _MaxGomaxprocs
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Wed, 6 Apr 2016 23:47:32 +0000 (11:47 +1200)
committerMichael Hudson-Doyle <michael.hudson@canonical.com>
Thu, 7 Apr 2016 00:11:25 +0000 (00:11 +0000)
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

Change-Id: I52e061a0de97be41d684dd8b748fa9087d6f1aef
Reviewed-on: https://go-review.googlesource.com/21599
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/runtime/proc.go

index 5145c84aea8bdbdfa716158065fd634f4e2bf9ca..1f55b0fa21a8ab804f4262ac34de36eadc8962d6 100644 (file)
@@ -449,6 +449,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