diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2019-05-28 18:06:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-28 18:06:38 +0200 |
commit | 3489e56c875c6144c729b51063300c7d60b1ae31 (patch) | |
tree | d00230bcefd3855b81197d1392ad64d749834ba1 /src/gc | |
parent | 9f3e89dd8634781f425a60f9a635787d0820d63d (diff) | |
download | coreclr-3489e56c875c6144c729b51063300c7d60b1ae31.tar.gz coreclr-3489e56c875c6144c729b51063300c7d60b1ae31.tar.bz2 coreclr-3489e56c875c6144c729b51063300c7d60b1ae31.zip |
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.
Diffstat (limited to 'src/gc')
-rw-r--r-- | src/gc/unix/gcenv.unix.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gc/unix/gcenv.unix.cpp b/src/gc/unix/gcenv.unix.cpp index 2828c949c4..3d7442ada9 100644 --- a/src/gc/unix/gcenv.unix.cpp +++ b/src/gc/unix/gcenv.unix.cpp @@ -289,7 +289,7 @@ bool GCToOSInterface::Initialize() g_currentProcessCpuCount = 0; cpu_set_t cpuSet; - int st = sched_getaffinity(0, sizeof(cpu_set_t), &cpuSet); + int st = sched_getaffinity(getpid(), sizeof(cpu_set_t), &cpuSet); if (st == 0) { |