Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/coreclr/vm/win32threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,17 +752,23 @@ class ThreadpoolMgr

#ifndef TARGET_UNIX
if (CPUGroupInfo::CanEnableThreadUseAllCpuGroups())
processorNumber = CPUGroupInfo::CalculateCurrentProcessorNumber();
{
// The current processor number may not be within the total number of active processors determined at
// initialization time.
processorNumber = CPUGroupInfo::CalculateCurrentProcessorNumber() % CPUGroupInfo::GetNumActiveProcessors();
}
else
{
// Turns out GetCurrentProcessorNumber can return a value greater than the number of processors reported by
// GetSystemInfo, if we're running in WOW64 on a machine with >32 processors.
processorNumber = GetCurrentProcessorNumber()%NumberOfProcessors;
processorNumber = GetCurrentProcessorNumber() % g_SystemInfo.dwNumberOfProcessors;
}
#else // !TARGET_UNIX
if (PAL_HasGetCurrentProcessorNumber())
{
// On linux, GetCurrentProcessorNumber which uses sched_getcpu() can return a value greater than the number
// of processors reported by sysconf(_SC_NPROCESSORS_ONLN) when using OpenVZ kernel.
processorNumber = GetCurrentProcessorNumber()%NumberOfProcessors;
processorNumber = GetCurrentProcessorNumber() % PAL_GetTotalCpuCount();
}
#endif // !TARGET_UNIX
return pRecycledListPerProcessor[processorNumber][memType];
Expand Down