From 8d93bd9080f47efd87dc5420a6e600f8dc432659 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Thu, 25 Apr 2019 11:32:31 +0200 Subject: [PATCH] Fix NUMA node for heap when NUMA is not available The recent refactoring of the GCToOSInterface::GetProcessorForHeap has accidentally changed the NUMA node returned in case NUMA is disabled (either via the COMPlus_GCNumaAware or due to the fact that there is just a single NUMA node on the system) and the CPU groups are disabled. Before that refactoring, the code was incorrectly returning 0 as the NUMA node when CPU groups were disabled no matter whether NUMA was enabled or disabled. The refactoring fixed that by returning the current CPU group number for the case when NUMA was enabled, however it still returned incorrect value, this time GroupProcNo::NoGroup as the NUMA node number in case NUMA was disabled. This change fixes it by returning the current group number in this case. --- src/gc/windows/gcenv.windows.cpp | 26 +++++++++++++------------- src/vm/gcenv.os.cpp | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/gc/windows/gcenv.windows.cpp b/src/gc/windows/gcenv.windows.cpp index 5f6a0ff..e5c4d7a 100644 --- a/src/gc/windows/gcenv.windows.cpp +++ b/src/gc/windows/gcenv.windows.cpp @@ -1332,20 +1332,20 @@ bool GCToOSInterface::GetProcessorForHeap(uint16_t heap_number, uint16_t* proc_n GroupProcNo groupProcNo(gn, gpn); *proc_no = groupProcNo.GetCombinedValue(); - if (GCToOSInterface::CanEnableGCNumaAware()) - { - PROCESSOR_NUMBER procNumber; + PROCESSOR_NUMBER procNumber; - if (CanEnableGCCPUGroups()) - { - procNumber.Group = gn; - } - else - { - // Get the current processor group - GetCurrentProcessorNumberEx(&procNumber); - } + if (CanEnableGCCPUGroups()) + { + procNumber.Group = gn; + } + else + { + // Get the current processor group + GetCurrentProcessorNumberEx(&procNumber); + } + if (GCToOSInterface::CanEnableGCNumaAware()) + { procNumber.Number = (BYTE)gpn; procNumber.Reserved = 0; @@ -1356,7 +1356,7 @@ bool GCToOSInterface::GetProcessorForHeap(uint16_t heap_number, uint16_t* proc_n } else { // no numa setting, each cpu group is treated as a node - *node_no = groupProcNo.GetGroup(); + *node_no = procNumber.Group; } } diff --git a/src/vm/gcenv.os.cpp b/src/vm/gcenv.os.cpp index 6e3f775..884a81b 100644 --- a/src/vm/gcenv.os.cpp +++ b/src/vm/gcenv.os.cpp @@ -982,20 +982,20 @@ bool GCToOSInterface::GetProcessorForHeap(uint16_t heap_number, uint16_t* proc_n GroupProcNo groupProcNo(gn, gpn); *proc_no = groupProcNo.GetCombinedValue(); - if (GCToOSInterface::CanEnableGCNumaAware()) - { - PROCESSOR_NUMBER procNumber; + PROCESSOR_NUMBER procNumber; - if (CPUGroupInfo::CanEnableGCCPUGroups()) - { - procNumber.Group = gn; - } - else - { - // Get the current processor group - GetCurrentProcessorNumberEx(&procNumber); - } + if (CPUGroupInfo::CanEnableGCCPUGroups()) + { + procNumber.Group = gn; + } + else + { + // Get the current processor group + GetCurrentProcessorNumberEx(&procNumber); + } + if (GCToOSInterface::CanEnableGCNumaAware()) + { procNumber.Number = (BYTE)gpn; procNumber.Reserved = 0; @@ -1006,7 +1006,7 @@ bool GCToOSInterface::GetProcessorForHeap(uint16_t heap_number, uint16_t* proc_n } else { // no numa setting, each cpu group is treated as a node - *node_no = groupProcNo.GetGroup(); + *node_no = procNumber.Group; } #else // !FEATURE_PAL *proc_no = procIndex; -- 2.7.4