diff options
Diffstat (limited to 'src/gc/windows/gcenv.windows.cpp')
-rw-r--r-- | src/gc/windows/gcenv.windows.cpp | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/gc/windows/gcenv.windows.cpp b/src/gc/windows/gcenv.windows.cpp index 86bd7038c0..5f6a0ff291 100644 --- a/src/gc/windows/gcenv.windows.cpp +++ b/src/gc/windows/gcenv.windows.cpp @@ -1286,19 +1286,6 @@ bool GCToOSInterface::CanEnableGCNumaAware() return g_fEnableGCNumaAware; } -bool GCToOSInterface::GetNumaProcessorNode(uint16_t proc_no, uint16_t *node_no) -{ - GroupProcNo groupProcNo(proc_no); - - PROCESSOR_NUMBER procNumber; - procNumber.Group = groupProcNo.GetGroup(); - procNumber.Number = (BYTE)groupProcNo.GetProcIndex(); - procNumber.Reserved = 0; - - assert(g_fEnableGCNumaAware); - return ::GetNumaProcessorNodeEx(&procNumber, node_no) != FALSE; -} - // Get processor number and optionally its NUMA node number for the specified heap number // Parameters: // heap_number - heap number to get the result for @@ -1310,53 +1297,66 @@ bool GCToOSInterface::GetProcessorForHeap(uint16_t heap_number, uint16_t* proc_n { bool success = false; - if (CanEnableGCCPUGroups()) + // Locate heap_number-th available processor + uint16_t procIndex; + size_t cnt = heap_number; + for (uint16_t i = 0; i < GCToOSInterface::GetTotalProcessorCount(); i++) { - uint16_t gn, gpn; - GetGroupForProcessor((uint16_t)heap_number, &gn, &gpn); - - *proc_no = GroupProcNo(gn, gpn).GetCombinedValue(); - - if (GCToOSInterface::CanEnableGCNumaAware()) + if (g_processAffinitySet.Contains(i)) { - if (!GCToOSInterface::GetNumaProcessorNode(*proc_no, node_no)) + if (cnt == 0) { - *node_no = NUMA_NODE_UNDEFINED; + procIndex = i; + success = true; + break; } + + cnt--; + } + } + + if (success) + { + WORD gn, gpn; + + if (CanEnableGCCPUGroups()) + { + GetGroupForProcessor(procIndex, &gn, &gpn); } else - { // no numa setting, each cpu group is treated as a node - *node_no = gn; + { + gn = GroupProcNo::NoGroup; + gpn = procIndex; } - success = true; - } - else - { - int bit_number = 0; - uint8_t proc_number = 0; - for (uintptr_t mask = 1; mask != 0; mask <<= 1) + GroupProcNo groupProcNo(gn, gpn); + *proc_no = groupProcNo.GetCombinedValue(); + + if (GCToOSInterface::CanEnableGCNumaAware()) { - if (g_processAffinitySet.Contains(proc_number)) + PROCESSOR_NUMBER procNumber; + + if (CanEnableGCCPUGroups()) { - if (bit_number == heap_number) - { - *proc_no = GroupProcNo(GroupProcNo::NoGroup, proc_number).GetCombinedValue(); + procNumber.Group = gn; + } + else + { + // Get the current processor group + GetCurrentProcessorNumberEx(&procNumber); + } - if (GCToOSInterface::CanEnableGCNumaAware()) - { - if (!GCToOSInterface::GetNumaProcessorNode(proc_number, node_no)) - { - *node_no = NUMA_NODE_UNDEFINED; - } - } + procNumber.Number = (BYTE)gpn; + procNumber.Reserved = 0; - success = true; - break; - } - bit_number++; + if (!GetNumaProcessorNodeEx(&procNumber, node_no)) + { + *node_no = NUMA_NODE_UNDEFINED; } - proc_number++; + } + else + { // no numa setting, each cpu group is treated as a node + *node_no = groupProcNo.GetGroup(); } } |