Fix initial thread affinity on Linux (#24801)
authorJan Vorlicek <janvorli@microsoft.com>
Tue, 28 May 2019 16:06:38 +0000 (18:06 +0200)
committerGitHub <noreply@github.com>
Tue, 28 May 2019 16:06:38 +0000 (18:06 +0200)
commit3489e56c875c6144c729b51063300c7d60b1ae31
treed00230bcefd3855b81197d1392ad64d749834ba1
parent9f3e89dd8634781f425a60f9a635787d0820d63d
Fix initial thread affinity on Linux (#24801)

* Fix initial thread affinity on Linux

On Linux, a new thread inherits the affinity mask of the thread
that created the new thread. This is a problem for background GC
threads that are created by one of the server GC threads that are
affinitized to single core.
This change adds resetting each new thread affinity to match the
current process affinity.
In addition to that, I've also fixed the extraction of the CPU count
that was using PID 0. While the doc says that 0 represents current process,
it in fact means current thread.
And as a small bonus, I've added caching of the value returned by
the PAL_GetLogicalCpuCountFromOS, since it cannot change during runtime.
src/gc/unix/gcenv.unix.cpp
src/pal/src/config.h.in
src/pal/src/configure.cmake
src/pal/src/misc/sysinfo.cpp
src/pal/src/thread/thread.cpp