diff options
-rw-r--r-- | src/gc/gc.cpp | 27 | ||||
-rw-r--r-- | src/inc/utilcode.h | 27 | ||||
-rw-r--r-- | src/utilcode/util.cpp | 44 | ||||
-rw-r--r-- | src/vm/threads.cpp | 12 | ||||
-rw-r--r-- | src/vm/threads.h | 4 | ||||
-rw-r--r-- | src/vm/win32threadpool.cpp | 2 | ||||
-rw-r--r-- | src/vm/win32threadpool.h | 12 |
7 files changed, 35 insertions, 93 deletions
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp index 0ad36aa2db..c0f60248c6 100644 --- a/src/gc/gc.cpp +++ b/src/gc/gc.cpp @@ -5100,7 +5100,7 @@ void gc_heap::destroy_thread_support () } } -#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_CORECLR) +#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL) void set_thread_group_affinity_for_heap(int heap_number, GCThreadAffinity* affinity) { affinity->Group = GCThreadAffinity::None; @@ -5114,7 +5114,7 @@ void set_thread_group_affinity_for_heap(int heap_number, GCThreadAffinity* affin { if (bit_number == gpn) { - dprintf(3, ("using processor group %d, mask %x%Ix for heap %d\n", gn, mask, heap_number)); + dprintf(3, ("using processor group %d, mask %Ix for heap %d\n", gn, mask, heap_number)); affinity->Processor = gpn; affinity->Group = gn; heap_select::set_cpu_group_for_heap(heap_number, (uint8_t)gn); @@ -5157,29 +5157,20 @@ void set_thread_affinity_mask_for_heap(int heap_number, GCThreadAffinity* affini { if (bit_number == heap_number) { - dprintf (3, ("Using processor %d for heap %d\n", proc_number, heap_number)); + dprintf (3, ("Using processor %d for heap %d", proc_number, heap_number)); affinity->Processor = proc_number; heap_select::set_proc_no_for_heap(heap_number, proc_number); if (NumaNodeInfo::CanEnableGCNumaAware()) - { // have the processor number, find the numa node -#if !defined(FEATURE_CORESYSTEM) - uint8_t node_no = 0; - if (NumaNodeInfo::GetNumaProcessorNode(proc_number, &node_no)) - heap_select::set_numa_node_for_heap(heap_number, node_no); -#else - uint16_t gn, gpn; + { uint16_t node_no = 0; - CPUGroupInfo::GetGroupForProcessor((uint16_t)heap_number, &gn, &gpn); - PROCESSOR_NUMBER proc_no; - proc_no.Group = gn; - proc_no.Number = (uint8_t)gpn; + proc_no.Group = 0; + proc_no.Number = (uint8_t)proc_number; proc_no.Reserved = 0; if (NumaNodeInfo::GetNumaProcessorNodeEx(&proc_no, &node_no)) { heap_select::set_numa_node_for_heap(heap_number, (uint8_t)node_no); } -#endif } return; } @@ -5199,7 +5190,7 @@ bool gc_heap::create_gc_thread () affinity.Group = GCThreadAffinity::None; affinity.Processor = GCThreadAffinity::None; -#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_CORECLR) +#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL) //We are about to set affinity for GC threads, it is a good place to setup NUMA and //CPU groups, because the process mask, processor number, group number are all //readyly available. @@ -5208,7 +5199,7 @@ bool gc_heap::create_gc_thread () else set_thread_affinity_mask_for_heap(heap_number, &affinity); -#endif // !FEATURE_REDHAWK && !FEATURE_CORECLR +#endif // !FEATURE_REDHAWK && !FEATURE_PAL return GCToOSInterface::CreateThread(gc_thread_stub, this, &affinity); } @@ -13172,7 +13163,7 @@ try_again: if ((max_hp == org_hp) && (end < finish)) { start = end; end = finish; - delta = dd_min_size(dd)/4; //Use the same threshold as tier 1 for now. Tune it later + delta = dd_min_size(dd)/2; // Make it twice as hard to balance to remote nodes on NUMA. goto try_again; } diff --git a/src/inc/utilcode.h b/src/inc/utilcode.h index fc3af0ecd5..f9d82c5460 100644 --- a/src/inc/utilcode.h +++ b/src/inc/utilcode.h @@ -47,15 +47,8 @@ const WCHAR kWatsonName2[] = W("drwtsn32"); #include "random.h" -// Windows CoreSystem has a different naming scheme for some dlls, which we must take account of when doing -// LoadLibrary and the like. -#if defined(FEATURE_CORESYSTEM) -#define WINDOWS_KERNEL32_DLLNAME_A "kernelbase" -#define WINDOWS_KERNEL32_DLLNAME_W W("kernelbase") -#elif !defined(FEATURE_CORESYSTEM) || defined(CROSS_COMPILE) #define WINDOWS_KERNEL32_DLLNAME_A "kernel32" #define WINDOWS_KERNEL32_DLLNAME_W W("kernel32") -#endif class StringArrayList; @@ -1544,11 +1537,6 @@ public: #if !defined(FEATURE_REDHAWK)&& !defined(FEATURE_PAL) private: // apis types -#if !defined(FEATURE_CORESYSTEM) - //GetNumaProcessorNode() - typedef BOOL - (WINAPI *PGNPN)(UCHAR, PUCHAR); -#endif //GetNumaHighestNodeNumber() typedef BOOL @@ -1558,21 +1546,14 @@ private: // apis types (WINAPI *PVAExN)(HANDLE,LPVOID,SIZE_T,DWORD,DWORD,DWORD); // api pfns and members -#if !defined(FEATURE_CORESYSTEM) - static PGNPN m_pGetNumaProcessorNode; -#endif static PGNHNN m_pGetNumaHighestNodeNumber; static PVAExN m_pVirtualAllocExNuma; public: // functions -#if !defined(FEATURE_CORESYSTEM) - static BOOL GetNumaProcessorNode(UCHAR proc_no, PUCHAR node_no); -#endif static LPVOID VirtualAllocExNuma(HANDLE hProc, LPVOID lpAddr, SIZE_T size, DWORD allocType, DWORD prot, DWORD node); -#if !defined(FEATURE_CORECLR) || defined(FEATURE_CORESYSTEM) private: //GetNumaProcessorNodeEx() typedef BOOL @@ -1582,7 +1563,6 @@ private: public: static BOOL GetNumaProcessorNodeEx(PPROCESSOR_NUMBER proc_no, PUSHORT node_no); #endif -#endif }; struct CPU_Group_Info @@ -1634,7 +1614,6 @@ private: //GetThreadGroupAffinity() typedef BOOL (WINAPI *PGTGA)(HANDLE, GROUP_AFFINITY *); -#if !defined(FEATURE_CORESYSTEM) && !defined(FEATURE_CORECLR) //GetCurrentProcessorNumberEx() typedef void (WINAPI *PGCPNEx)(PROCESSOR_NUMBER *); @@ -1644,16 +1623,12 @@ private: //NtQuerySystemInformationEx() //typedef int //(WINAPI *PNTQSIEx)(SYSTEM_INFORMATION_CLASS, PULONG, ULONG, PVOID, ULONG, PULONG); -#endif - static PGLPIEx m_pGetLogicalProcessorInformationEx; static PSTGA m_pSetThreadGroupAffinity; static PGTGA m_pGetThreadGroupAffinity; -#if !defined(FEATURE_CORESYSTEM) && !defined(FEATURE_CORECLR) static PGCPNEx m_pGetCurrentProcessorNumberEx; static PGST m_pGetSystemTimes; //static PNTQSIEx m_pNtQuerySystemInformationEx; -#endif public: static BOOL GetLogicalProcessorInformationEx(DWORD relationship, @@ -1661,12 +1636,10 @@ public: static BOOL SetThreadGroupAffinity(HANDLE h, GROUP_AFFINITY *groupAffinity, GROUP_AFFINITY *previousGroupAffinity); static BOOL GetThreadGroupAffinity(HANDLE h, GROUP_AFFINITY *groupAffinity); -#if !defined(FEATURE_CORESYSTEM) && !defined(FEATURE_CORECLR) static BOOL GetSystemTimes(FILETIME *idleTime, FILETIME *kernelTime, FILETIME *userTime); static void ChooseCPUGroupAffinity(GROUP_AFFINITY *gf); static void ClearCPUGroupAffinity(GROUP_AFFINITY *gf); #endif -#endif }; int GetCurrentProcessCpuCount(); diff --git a/src/utilcode/util.cpp b/src/utilcode/util.cpp index 50643d4a7e..bcfe74ace7 100644 --- a/src/utilcode/util.cpp +++ b/src/utilcode/util.cpp @@ -685,25 +685,14 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, // NumaNodeInfo //****************************************************************************** #if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL) -#if !defined(FEATURE_CORESYSTEM) -/*static*/ NumaNodeInfo::PGNPN NumaNodeInfo::m_pGetNumaProcessorNode = NULL; -#endif /*static*/ NumaNodeInfo::PGNHNN NumaNodeInfo::m_pGetNumaHighestNodeNumber = NULL; /*static*/ NumaNodeInfo::PVAExN NumaNodeInfo::m_pVirtualAllocExNuma = NULL; -#if !defined(FEATURE_CORESYSTEM) -/*static*/ BOOL NumaNodeInfo::GetNumaProcessorNode(UCHAR proc_no, PUCHAR node_no) -{ - return (*m_pGetNumaProcessorNode)(proc_no, node_no); -} -#endif - /*static*/ LPVOID NumaNodeInfo::VirtualAllocExNuma(HANDLE hProc, LPVOID lpAddr, SIZE_T dwSize, DWORD allocType, DWORD prot, DWORD node) { return (*m_pVirtualAllocExNuma)(hProc, lpAddr, dwSize, allocType, prot, node); } -#if !defined(FEATURE_CORECLR) || defined(FEATURE_CORESYSTEM) /*static*/ NumaNodeInfo::PGNPNEx NumaNodeInfo::m_pGetNumaProcessorNodeEx = NULL; /*static*/ BOOL NumaNodeInfo::GetNumaProcessorNodeEx(PPROCESSOR_NUMBER proc_no, PUSHORT node_no) @@ -711,7 +700,6 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, return (*m_pGetNumaProcessorNodeEx)(proc_no, node_no); } #endif -#endif /*static*/ BOOL NumaNodeInfo::m_enableGCNumaAware = FALSE; /*static*/ BOOL NumaNodeInfo::InitNumaNodeInfoAPI() @@ -736,17 +724,9 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, if (!m_pGetNumaHighestNodeNumber(&highest) || (highest == 0)) return FALSE; -#if !defined(FEATURE_CORESYSTEM) - m_pGetNumaProcessorNode = (PGNPN) GetProcAddress(hMod, "GetNumaProcessorNode"); - if (m_pGetNumaProcessorNode == NULL) - return FALSE; -#endif - -#if !defined(FEATURE_CORECLR) || defined(FEATURE_CORESYSTEM) m_pGetNumaProcessorNodeEx = (PGNPNEx) GetProcAddress(hMod, "GetNumaProcessorNodeEx"); if (m_pGetNumaProcessorNodeEx == NULL) return FALSE; -#endif m_pVirtualAllocExNuma = (PVAExN) GetProcAddress(hMod, "VirtualAllocExNuma"); if (m_pVirtualAllocExNuma == NULL) @@ -775,10 +755,8 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, /*static*/ CPUGroupInfo::PGLPIEx CPUGroupInfo::m_pGetLogicalProcessorInformationEx = NULL; /*static*/ CPUGroupInfo::PSTGA CPUGroupInfo::m_pSetThreadGroupAffinity = NULL; /*static*/ CPUGroupInfo::PGTGA CPUGroupInfo::m_pGetThreadGroupAffinity = NULL; -#if !defined(FEATURE_CORESYSTEM) && !defined(FEATURE_CORECLR) /*static*/ CPUGroupInfo::PGCPNEx CPUGroupInfo::m_pGetCurrentProcessorNumberEx = NULL; /*static*/ CPUGroupInfo::PGST CPUGroupInfo::m_pGetSystemTimes = NULL; -#endif /*static*/ //CPUGroupInfo::PNTQSIEx CPUGroupInfo::m_pNtQuerySystemInformationEx = NULL; /*static*/ BOOL CPUGroupInfo::GetLogicalProcessorInformationEx(DWORD relationship, @@ -801,14 +779,12 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, return (*m_pGetThreadGroupAffinity)(h, groupAffinity); } -#if !defined(FEATURE_CORESYSTEM) && !defined(FEATURE_CORECLR) /*static*/ BOOL CPUGroupInfo::GetSystemTimes(FILETIME *idleTime, FILETIME *kernelTime, FILETIME *userTime) { LIMITED_METHOD_CONTRACT; return (*m_pGetSystemTimes)(idleTime, kernelTime, userTime); } #endif -#endif /*static*/ BOOL CPUGroupInfo::m_enableGCCPUGroups = FALSE; /*static*/ BOOL CPUGroupInfo::m_threadUseAllCpuGroups = FALSE; @@ -845,7 +821,6 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, if (m_pGetThreadGroupAffinity == NULL) return FALSE; -#if !defined(FEATURE_CORESYSTEM) && !defined(FEATURE_CORECLR) m_pGetCurrentProcessorNumberEx = (PGCPNEx)GetProcAddress(hMod, "GetCurrentProcessorNumberEx"); if (m_pGetCurrentProcessorNumberEx == NULL) return FALSE; @@ -853,7 +828,6 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, m_pGetSystemTimes = (PGST)GetProcAddress(hMod, "GetSystemTimes"); if (m_pGetSystemTimes == NULL) return FALSE; -#endif return TRUE; #else @@ -973,10 +947,10 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, #if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) && !defined(FEATURE_PAL) BOOL enableGCCPUGroups = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_GCCpuGroup) != 0; - BOOL threadUseAllCpuGroups = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_Thread_UseAllCpuGroups) != 0; + BOOL threadUseAllCpuGroups = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_Thread_UseAllCpuGroups) != 0; - if (!enableGCCPUGroups) - return; + if (!enableGCCPUGroups) + return; if (!InitCPUGroupInfoAPI()) return; @@ -1085,7 +1059,7 @@ retry: } CONTRACTL_END; -#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_CORESYSTEM) && !defined(FEATURE_CORECLR) && defined(_TARGET_AMD64_) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) && defined(_TARGET_AMD64_) && !defined(FEATURE_PAL) // m_enableGCCPUGroups and m_threadUseAllCpuGroups must be TRUE _ASSERTE(m_enableGCCPUGroups && m_threadUseAllCpuGroups); @@ -1106,7 +1080,7 @@ retry: #endif } -#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_CORESYSTEM) && !defined(FEATURE_CORECLR) && !defined(FEATURE_PAL) +#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL) //Lock ThreadStore before calling this function, so that updates of weights/counts are consistent /*static*/ void CPUGroupInfo::ChooseCPUGroupAffinity(GROUP_AFFINITY *gf) { @@ -1203,7 +1177,7 @@ int GetCurrentProcessCpuCount() if (cCPUs != 0) return cCPUs; -#if !defined(FEATURE_CORESYSTEM) +#ifndef FEATURE_PAL DWORD_PTR pmask, smask; @@ -1238,14 +1212,14 @@ int GetCurrentProcessCpuCount() return count; -#else // !FEATURE_CORESYSTEM +#else // !FEATURE_PAL SYSTEM_INFO sysInfo; ::GetSystemInfo(&sysInfo); cCPUs = sysInfo.dwNumberOfProcessors; return sysInfo.dwNumberOfProcessors; -#endif // !FEATURE_CORESYSTEM +#endif // !FEATURE_PAL } DWORD_PTR GetCurrentProcessCpuMask() @@ -1258,7 +1232,7 @@ DWORD_PTR GetCurrentProcessCpuMask() } CONTRACTL_END; -#if !defined(FEATURE_CORESYSTEM) +#ifndef FEATURE_PAL DWORD_PTR pmask, smask; if (!GetProcessAffinityMask(GetCurrentProcess(), &pmask, &smask)) diff --git a/src/vm/threads.cpp b/src/vm/threads.cpp index 0bc7ba1843..1d7283e59b 100644 --- a/src/vm/threads.cpp +++ b/src/vm/threads.cpp @@ -608,16 +608,18 @@ void Thread::ChooseThreadCPUGroupAffinity() } CONTRACTL_END; -#if !defined(FEATURE_CORECLR) +#ifndef FEATURE_PAL if (!CPUGroupInfo::CanEnableGCCPUGroups() || !CPUGroupInfo::CanEnableThreadUseAllCpuGroups()) return; +#ifndef FEATURE_CORECLR // We only handle the non-hosted case here. If CLR is hosted, the hosting // process controls the physical OS Threads. If CLR is not hosted, we can // set thread group affinity on OS threads directly. HostComHolder<IHostTask> pHostTask (GetHostTaskWithAddRef()); if (pHostTask != NULL) return; +#endif //!FEATURE_CORECLR //Borrow the ThreadStore Lock here: Lock ThreadStore before distributing threads ThreadStoreLockHolder TSLockHolder(TRUE); @@ -634,7 +636,7 @@ void Thread::ChooseThreadCPUGroupAffinity() CPUGroupInfo::SetThreadGroupAffinity(GetThreadHandle(), &groupAffinity, NULL); m_wCPUGroup = groupAffinity.Group; m_pAffinityMask = groupAffinity.Mask; -#endif +#endif // !FEATURE_PAL } void Thread::ClearThreadCPUGroupAffinity() @@ -646,16 +648,18 @@ void Thread::ClearThreadCPUGroupAffinity() } CONTRACTL_END; -#if !defined(FEATURE_CORECLR) +#ifndef FEATURE_PAL if (!CPUGroupInfo::CanEnableGCCPUGroups() || !CPUGroupInfo::CanEnableThreadUseAllCpuGroups()) return; +#ifndef FEATURE_CORECLR // We only handle the non-hosted case here. If CLR is hosted, the hosting // process controls the physical OS Threads. If CLR is not hosted, we can // set thread group affinity on OS threads directly. HostComHolder<IHostTask> pHostTask (GetHostTaskWithAddRef()); if (pHostTask != NULL) return; +#endif //!FEATURE_CORECLR ThreadStoreLockHolder TSLockHolder(TRUE); @@ -670,7 +674,7 @@ void Thread::ClearThreadCPUGroupAffinity() m_wCPUGroup = 0; m_pAffinityMask = 0; -#endif +#endif // !FEATURE_PAL } DWORD Thread::StartThread() diff --git a/src/vm/threads.h b/src/vm/threads.h index 8b07a09ad4..e704c2b4f0 100644 --- a/src/vm/threads.h +++ b/src/vm/threads.h @@ -5546,11 +5546,11 @@ public: // object associated with them (e.g., the bgc thread). void SetGCSpecial(bool fGCSpecial); -#if !defined(FEATURE_CORECLR) +#ifndef FEATURE_PAL private: WORD m_wCPUGroup; DWORD_PTR m_pAffinityMask; -#endif +#endif // !FEATURE_PAL public: void ChooseThreadCPUGroupAffinity(); diff --git a/src/vm/win32threadpool.cpp b/src/vm/win32threadpool.cpp index 0fa06db559..35c2b64ac4 100644 --- a/src/vm/win32threadpool.cpp +++ b/src/vm/win32threadpool.cpp @@ -4328,7 +4328,7 @@ int ThreadpoolMgr::GetCPUBusyTime_NT(PROCESS_CPU_INFORMATION* pOldInfo) if (CPUGroupInfo::CanEnableGCCPUGroups() && CPUGroupInfo::CanEnableThreadUseAllCpuGroups()) { -#if !defined(FEATURE_CORECLR) +#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL) FILETIME newIdleTime, newKernelTime, newUserTime; CPUGroupInfo::GetSystemTimes(&newIdleTime, &newKernelTime, &newUserTime); diff --git a/src/vm/win32threadpool.h b/src/vm/win32threadpool.h index 5c51ed4e63..943c3581be 100644 --- a/src/vm/win32threadpool.h +++ b/src/vm/win32threadpool.h @@ -1022,12 +1022,12 @@ public: { LIMITED_METHOD_CONTRACT; - if (CPUGroupInfo::CanEnableGCCPUGroups() && CPUGroupInfo::CanEnableThreadUseAllCpuGroups()) - return pRecycledListPerProcessor[CPUGroupInfo::CalculateCurrentProcessorNumber()][memType]; - 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. - return pRecycledListPerProcessor[GetCurrentProcessorNumber()%NumberOfProcessors][memType]; + if (CPUGroupInfo::CanEnableGCCPUGroups() && CPUGroupInfo::CanEnableThreadUseAllCpuGroups()) + return pRecycledListPerProcessor[CPUGroupInfo::CalculateCurrentProcessorNumber()][memType]; + 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. + return pRecycledListPerProcessor[GetCurrentProcessorNumber()%NumberOfProcessors][memType]; } }; |