runtime: make NumCPU respect zone CPU cap on illumos

On illumos systems, check for the "zone.cpu-cap" resource control when
determining how many usable CPUs are available.  If the resource control
is not set, or we are unable to read it, ignore the failure and return
the value we used to return; i.e., the CPU count from
sysconf(_SC_NPROCESSORS_ONLN).

Fixes golang/go#35199

Change-Id: Ic8a408f84cd140d544d128f1281baad527fb5e35
Reviewed-on: https://go-review.googlesource.com/c/go/+/203758
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Joshua M. Clulow 2019-10-28 09:19:48 -07:00 committed by Brad Fitzpatrick
parent 503bccb5d9
commit 91f3997ec0
4 changed files with 164 additions and 8 deletions

View file

@ -119,14 +119,6 @@ var (
var sigset_all = sigset{[4]uint32{^uint32(0), ^uint32(0), ^uint32(0), ^uint32(0)}}
func getncpu() int32 {
n := int32(sysconf(__SC_NPROCESSORS_ONLN))
if n < 1 {
return 1
}
return n
}
func getPageSize() uintptr {
n := int32(sysconf(__SC_PAGESIZE))
if n <= 0 {