From f7230b8163eac5b6af9b546f716c77ec1c42f18e Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Fri, 5 Aug 2022 18:22:20 -0700 Subject: [PATCH] Update heap hard limit for large pages --- src/coreclr/gc/gc.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index d84ac6cbc7fde2..c8412211d8a96f 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -13683,10 +13683,20 @@ HRESULT gc_heap::initialize_gc (size_t soh_segment_size, if (!reserve_initial_memory (soh_segment_size, loh_segment_size, poh_segment_size, number_of_heaps, use_large_pages_p, separated_poh_p, heap_no_to_numa_node)) return E_OUTOFMEMORY; - if (separated_poh_p) + if (use_large_pages_p) { - heap_hard_limit_oh[poh] = min_segment_size_hard_limit * number_of_heaps; - heap_hard_limit += heap_hard_limit_oh[poh]; + if (heap_hard_limit_oh[soh]) + { + heap_hard_limit_oh[soh] = soh_segment_size * number_of_heaps; + heap_hard_limit_oh[loh] = loh_segment_size * number_of_heaps; + heap_hard_limit_oh[poh] = poh_segment_size * number_of_heaps; + heap_hard_limit = heap_hard_limit_oh[soh] + heap_hard_limit_oh[loh] + heap_hard_limit_oh[poh]; + } + else + { + assert (heap_hard_limit); + heap_hard_limit = (soh_segment_size + loh_segment_size + poh_segment_size) * number_of_heaps; + } } #endif //USE_REGIONS @@ -45144,10 +45154,6 @@ HRESULT GCHeap::Initialize() #endif //HOST_64BIT GCConfig::SetGCLargePages(gc_heap::use_large_pages_p); - GCConfig::SetGCHeapHardLimit(static_cast(gc_heap::heap_hard_limit)); - GCConfig::SetGCHeapHardLimitSOH(static_cast(gc_heap::heap_hard_limit_oh[soh])); - GCConfig::SetGCHeapHardLimitLOH(static_cast(gc_heap::heap_hard_limit_oh[loh])); - GCConfig::SetGCHeapHardLimitPOH(static_cast(gc_heap::heap_hard_limit_oh[poh])); uint32_t nhp = 1; uint32_t nhp_from_config = 0; @@ -45332,6 +45338,11 @@ HRESULT GCHeap::Initialize() hr = gc_heap::initialize_gc (seg_size, large_seg_size, pin_seg_size); #endif //MULTIPLE_HEAPS + GCConfig::SetGCHeapHardLimit(static_cast(gc_heap::heap_hard_limit)); + GCConfig::SetGCHeapHardLimitSOH(static_cast(gc_heap::heap_hard_limit_oh[soh])); + GCConfig::SetGCHeapHardLimitLOH(static_cast(gc_heap::heap_hard_limit_oh[loh])); + GCConfig::SetGCHeapHardLimitPOH(static_cast(gc_heap::heap_hard_limit_oh[poh])); + if (hr != S_OK) return hr;