]> Cypherpunks repositories - gostls13.git/commit
runtime: use cpuset_getaffinity for runtime.NumCPU() on FreeBSD
authorDavid NewHamlet <david@newhamlet.com>
Fri, 10 Mar 2017 20:13:20 +0000 (09:13 +1300)
committerIan Lance Taylor <iant@golang.org>
Fri, 10 Mar 2017 22:06:24 +0000 (22:06 +0000)
commite19f184b8f61529980c24973d5522dc67e3d8525
tree253572abfe37550316bd052889ffca6644705e07
parent135ce43c8731506d541329a1dfea2c737c6dd0b1
runtime: use cpuset_getaffinity for runtime.NumCPU() on FreeBSD

In FreeBSD when run Go proc under a given sub-list of
processors(e.g. 'cpuset -l 0 ./a.out' in multi-core system),
runtime.NumCPU() still return all physical CPUs from sysctl
hw.ncpu instead of account from sub-list.

Fix by use syscall cpuset_getaffinity to account the number of sub-list.

Fixes #15206

Change-Id: If87c4b620e870486efa100685db5debbf1210a5b
Reviewed-on: https://go-review.googlesource.com/29341
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
src/runtime/defs_freebsd.go
src/runtime/defs_freebsd_386.go
src/runtime/defs_freebsd_amd64.go
src/runtime/defs_freebsd_arm.go
src/runtime/numcpu_freebsd_test.go [new file with mode: 0644]
src/runtime/os_freebsd.go
src/runtime/sys_freebsd_386.s
src/runtime/sys_freebsd_amd64.s
src/runtime/sys_freebsd_arm.s
src/runtime/testdata/testprog/numcpu_freebsd.go [new file with mode: 0644]