You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The second argument here is the number of bytes in the cpuset. Eight bytes is not very many and looking at how unix.CPUSet is defined in the source code suggests that there is supposed to be room for 1024 CPUs. However, inspection of the actual code making the system call in affinity_linux.go suggests that it is making a size of pointer versus size of object pointed to confusion. The set argument is a pointer to a CPUSet not a CPUSet, so unsafe.Sizeof(set) is the size of the pointer (8 bytes on a 64-bit machine) instead of the much larger size of the CPUSet.
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?go version devel +926f278 Tue Jan 30 15:22:28 2018 +0000 linux/amd64
And also the current version of golang.org/x/sys from git.
What operating system and processor architecture are you using (
go env
)?What did you do?
Here is a trivial program to call
unix.SchedGetaffinity()
to count the number of currently usable CPUs in the system:On many of our amd64 machines this will work fine. However, on some of them (with large CPU counts) it will fail with:
Using strace says that
sched_getaffinity()
is being called as follows:The second argument here is the number of bytes in the cpuset. Eight bytes is not very many and looking at how unix.CPUSet is defined in the source code suggests that there is supposed to be room for 1024 CPUs. However, inspection of the actual code making the system call in affinity_linux.go suggests that it is making a size of pointer versus size of object pointed to confusion. The
set
argument is a pointer to a CPUSet not a CPUSet, sounsafe.Sizeof(set)
is the size of the pointer (8 bytes on a 64-bit machine) instead of the much larger size of the CPUSet.The text was updated successfully, but these errors were encountered: