diff options
author | David NewHamlet <david@newhamlet.com> | 2017-03-11 09:13:20 +1300 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2017-03-10 22:06:24 +0000 |
commit | e19f184b8f61529980c24973d5522dc67e3d8525 (patch) | |
tree | 253572abfe37550316bd052889ffca6644705e07 /src/runtime/sys_freebsd_arm.s | |
parent | 135ce43c8731506d541329a1dfea2c737c6dd0b1 (diff) | |
download | go-e19f184b8f61529980c24973d5522dc67e3d8525.tar.gz go-e19f184b8f61529980c24973d5522dc67e3d8525.zip |
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>
Diffstat (limited to 'src/runtime/sys_freebsd_arm.s')
-rw-r--r-- | src/runtime/sys_freebsd_arm.s | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/runtime/sys_freebsd_arm.s b/src/runtime/sys_freebsd_arm.s index 97aea65074..2851587b0d 100644 --- a/src/runtime/sys_freebsd_arm.s +++ b/src/runtime/sys_freebsd_arm.s @@ -39,8 +39,9 @@ #define SYS_thr_kill (SYS_BASE + 433) #define SYS__umtx_op (SYS_BASE + 454) #define SYS_thr_new (SYS_BASE + 455) -#define SYS_mmap (SYS_BASE + 477) - +#define SYS_mmap (SYS_BASE + 477) +#define SYS_cpuset_getaffinity (SYS_BASE + 487) + TEXT runtime·sys_umtx_op(SB),NOSPLIT,$0 MOVW addr+0(FP), R0 MOVW mode+4(FP), R1 @@ -376,3 +377,17 @@ TEXT ·publicationBarrier(SB),NOSPLIT,$-4-0 TEXT runtime·read_tls_fallback(SB),NOSPLIT,$-4 WORD $0xee1d0f70 // mrc p15, 0, r0, c13, c0, 3 RET + +// func cpuset_getaffinity(level int, which int, id int64, size int, mask *byte) int32 +TEXT runtime·cpuset_getaffinity(SB), NOSPLIT, $0-28 + MOVW level+0(FP), R0 + MOVW which+4(FP), R1 + MOVW id_lo+8(FP), R2 + MOVW id_hi+12(FP), R3 + ADD $20, R13 // Pass size and mask on stack. + MOVW $SYS_cpuset_getaffinity, R7 + SWI $0 + RSB.CS $0, R0 + SUB $20, R13 + MOVW R0, ret+24(FP) + RET |