diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2017-04-19 15:13:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 15:13:30 -0700 |
commit | 48ebab8270a96e505a2be128a4875f903ef1c4b2 (patch) | |
tree | 78313aeb604ebecf715e6f4a5c2cd8b3a1ee907b /src/utilcode | |
parent | 9b9989da73f4ee8de5d3c1257d46f8d7295dc44f (diff) | |
download | coreclr-48ebab8270a96e505a2be128a4875f903ef1c4b2.tar.gz coreclr-48ebab8270a96e505a2be128a4875f903ef1c4b2.tar.bz2 coreclr-48ebab8270a96e505a2be128a4875f903ef1c4b2.zip |
Add NUMA and thread affinity support for Unix (#10938)
* Add NUMA and thread affinity support for Unix
This change adds new PAL functions for NUMA and thread affinity support
for Unix and also enables related code in GC and VM for FEATURE_PAL.
It doesn't reflect the limits imposed by CGROUPS on systems with
CGROUPS enables yet.
Diffstat (limited to 'src/utilcode')
-rw-r--r-- | src/utilcode/util.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/utilcode/util.cpp b/src/utilcode/util.cpp index c215a49213..a8786def92 100644 --- a/src/utilcode/util.cpp +++ b/src/utilcode/util.cpp @@ -728,7 +728,7 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, //****************************************************************************** // NumaNodeInfo //****************************************************************************** -#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) /*static*/ NumaNodeInfo::PGNHNN NumaNodeInfo::m_pGetNumaHighestNodeNumber = NULL; /*static*/ NumaNodeInfo::PVAExN NumaNodeInfo::m_pVirtualAllocExNuma = NULL; @@ -748,15 +748,19 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, /*static*/ BOOL NumaNodeInfo::m_enableGCNumaAware = FALSE; /*static*/ BOOL NumaNodeInfo::InitNumaNodeInfoAPI() { -#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) //check for numa support if multiple heaps are used ULONG highest = 0; if (CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_GCNumaAware) == 0) return FALSE; +#ifndef FEATURE_PAL // check if required APIs are supported HMODULE hMod = GetModuleHandleW(WINDOWS_KERNEL32_DLLNAME_W); +#else + HMODULE hMod = GetCLRModule(); +#endif if (hMod == NULL) return FALSE; @@ -795,7 +799,7 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, //****************************************************************************** // NumaNodeInfo //****************************************************************************** -#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) /*static*/ CPUGroupInfo::PGLPIEx CPUGroupInfo::m_pGetLogicalProcessorInformationEx = NULL; /*static*/ CPUGroupInfo::PSTGA CPUGroupInfo::m_pSetThreadGroupAffinity = NULL; /*static*/ CPUGroupInfo::PGTGA CPUGroupInfo::m_pGetThreadGroupAffinity = NULL; @@ -848,8 +852,12 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, } CONTRACTL_END; -#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) +#ifndef FEATURE_PAL HMODULE hMod = GetModuleHandleW(WINDOWS_KERNEL32_DLLNAME_W); +#else + HMODULE hMod = GetCLRModule(); +#endif if (hMod == NULL) return FALSE; @@ -869,17 +877,19 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, if (m_pGetCurrentProcessorNumberEx == NULL) return FALSE; +#ifndef FEATURE_PAL m_pGetSystemTimes = (PGST)GetProcAddress(hMod, "GetSystemTimes"); if (m_pGetSystemTimes == NULL) return FALSE; - +#endif + return TRUE; #else return FALSE; #endif } -#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) // Calculate greatest common divisor DWORD GCD(DWORD u, DWORD v) { @@ -910,7 +920,7 @@ DWORD LCM(DWORD u, DWORD v) } CONTRACTL_END; -#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) BYTE *bBuffer = NULL; SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *pSLPIEx = NULL; SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *pRecord = NULL; @@ -985,7 +995,7 @@ DWORD LCM(DWORD u, DWORD v) { LIMITED_METHOD_CONTRACT; -#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) WORD begin = 0; WORD nr_proc = 0; @@ -1012,7 +1022,7 @@ DWORD LCM(DWORD u, DWORD v) } CONTRACTL_END; -#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) BOOL enableGCCPUGroups = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_GCCpuGroup) != 0; BOOL threadUseAllCpuGroups = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_Thread_UseAllCpuGroups) != 0; @@ -1095,7 +1105,7 @@ retry: { LIMITED_METHOD_CONTRACT; -#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) WORD bTemp = 0; WORD bDiff = processor_number - bTemp; @@ -1126,7 +1136,7 @@ retry: } CONTRACTL_END; -#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) // m_enableGCCPUGroups and m_threadUseAllCpuGroups must be TRUE _ASSERTE(m_enableGCCPUGroups && m_threadUseAllCpuGroups); @@ -1147,7 +1157,7 @@ retry: #endif } -#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) //Lock ThreadStore before calling this function, so that updates of weights/counts are consistent /*static*/ void CPUGroupInfo::ChooseCPUGroupAffinity(GROUP_AFFINITY *gf) { |