summaryrefslogtreecommitdiff
path: root/src/utilcode
diff options
context:
space:
mode:
authorMaoni Stephens <Maoni0@users.noreply.github.com>2019-07-05 12:48:34 -0700
committerGitHub <noreply@github.com>2019-07-05 12:48:34 -0700
commitc7d12d2b91f79802a12484d4d56c41ba355b7058 (patch)
tree823ab1ef9de13e8f5493fc219af7a5deaa118e13 /src/utilcode
parent41407b7d4a2eac4cae6a3c4855ba072cdd01f8b1 (diff)
downloadcoreclr-c7d12d2b91f79802a12484d4d56c41ba355b7058.tar.gz
coreclr-c7d12d2b91f79802a12484d4d56c41ba355b7058.tar.bz2
coreclr-c7d12d2b91f79802a12484d4d56c41ba355b7058.zip
many core (#25350)
Diffstat (limited to 'src/utilcode')
-rw-r--r--src/utilcode/util.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/utilcode/util.cpp b/src/utilcode/util.cpp
index e7091604af..0e142cf76c 100644
--- a/src/utilcode/util.cpp
+++ b/src/utilcode/util.cpp
@@ -738,6 +738,34 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr,
{
return ::GetNumaProcessorNodeEx(proc_no, node_no);
}
+/*static*/ bool NumaNodeInfo::GetNumaInfo(PUSHORT total_nodes, DWORD* max_procs_per_node)
+{
+ if (m_enableGCNumaAware)
+ {
+ DWORD currentProcsOnNode = 0;
+ for (int i = 0; i < m_nNodes; i++)
+ {
+ GROUP_AFFINITY processorMask;
+ if (GetNumaNodeProcessorMaskEx(i, &processorMask))
+ {
+ DWORD procsOnNode = 0;
+ uintptr_t mask = (uintptr_t)processorMask.Mask;
+ while (mask)
+ {
+ procsOnNode++;
+ mask &= mask - 1;
+ }
+
+ currentProcsOnNode = max(currentProcsOnNode, procsOnNode);
+ }
+ *max_procs_per_node = currentProcsOnNode;
+ *total_nodes = m_nNodes;
+ }
+ return true;
+ }
+
+ return false;
+}
#else // !FEATURE_PAL
/*static*/ BOOL NumaNodeInfo::GetNumaProcessorNodeEx(USHORT proc_no, PUSHORT node_no)
{
@@ -747,6 +775,7 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr,
#endif
/*static*/ BOOL NumaNodeInfo::m_enableGCNumaAware = FALSE;
+/*static*/ uint16_t NumaNodeInfo::m_nNodes = 0;
/*static*/ BOOL NumaNodeInfo::InitNumaNodeInfoAPI()
{
#if !defined(FEATURE_REDHAWK)
@@ -760,6 +789,8 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr,
if (!::GetNumaHighestNodeNumber(&highest) || (highest == 0))
return FALSE;
+ m_nNodes = (USHORT)(highest + 1);
+
return TRUE;
#else
return FALSE;
@@ -1058,6 +1089,7 @@ retry:
{
*group_number = i;
*group_processor_number = bDiff;
+
break;
}
bDiff = processor_number - bTemp;
@@ -1098,6 +1130,24 @@ retry:
#endif
}
+// There can be different numbers of procs in groups. We take the max.
+/*static*/ bool CPUGroupInfo::GetCPUGroupInfo(PUSHORT total_groups, DWORD* max_procs_per_group)
+{
+ if (m_enableGCCPUGroups)
+ {
+ *total_groups = m_nGroups;
+ DWORD currentProcsInGroup = 0;
+ for (WORD i = 0; i < m_nGroups; i++)
+ {
+ currentProcsInGroup = max(currentProcsInGroup, m_CPUGroupInfoArray[i].nr_active);
+ }
+ *max_procs_per_group = currentProcsInGroup;
+ return true;
+ }
+
+ return false;
+}
+
#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)