From aa54cd0a01a21d172e564d9e50b9e5cb0110e152 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 12 Jul 2019 16:20:52 -0700 Subject: [PATCH] Fixes when accessing fgn_maxgen_percent (dotnet/coreclr#25650) * Fixes when accessing fgn_maxgen_percent PR dotnet/coreclr#25350 changed `fgn_maxgen_percent` to be a per-heap property when `MULTIPLE_HEAPS` is set. A few uses need to be updated. * In `full_gc_wait`, must re-read `fgn_maxgen_percent` before the second test of `maxgen_percent == 0`. (Otherwise the second test is statically unreachable.) * In RegisterForFullGCNotification, must set `fgn_maxgen_percent` when `MULTIPLE_HEAPS` is not set * In CancelFullGCNotification, must set `fgn_maxgen_percent` for each heap separately when `MULTIPLE_HEAPS` is set. Fix dotnet/corefxdotnet/coreclr#39374 * Avoid duplicate code when getting fgn_maxgen_percent twice in full_gc_wait Commit migrated from https://github.com/dotnet/coreclr/commit/4b5ae70e341bad3c9f25d33cfee58d2bb93d3db7 --- src/coreclr/src/gc/gc.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/coreclr/src/gc/gc.cpp b/src/coreclr/src/gc/gc.cpp index f107b13..f493664 100644 --- a/src/coreclr/src/gc/gc.cpp +++ b/src/coreclr/src/gc/gc.cpp @@ -12377,13 +12377,13 @@ void gc_heap::send_full_gc_notification (int gen_num, BOOL due_to_alloc_p) wait_full_gc_status gc_heap::full_gc_wait (GCEvent *event, int time_out_ms) { - uint32_t maxgen_percent = 0; #ifdef MULTIPLE_HEAPS - maxgen_percent = g_heaps[0]->fgn_maxgen_percent; + gc_heap* hp = gc_heap::g_heaps[0]; #else - maxgen_percent = fgn_maxgen_percent; + gc_heap* hp = pGenGCHeap; #endif //MULTIPLE_HEAPS - if (maxgen_percent == 0) + + if (hp->fgn_maxgen_percent == 0) { return wait_full_gc_na; } @@ -12392,7 +12392,7 @@ wait_full_gc_status gc_heap::full_gc_wait (GCEvent *event, int time_out_ms) if ((wait_result == WAIT_OBJECT_0) || (wait_result == WAIT_TIMEOUT)) { - if (maxgen_percent == 0) + if (hp->fgn_maxgen_percent == 0) { return wait_full_gc_cancelled; } @@ -36900,6 +36900,7 @@ bool GCHeap::RegisterForFullGCNotification(uint32_t gen2Percentage, } #else //MULTIPLE_HEAPS pGenGCHeap->fgn_last_alloc = dd_new_allocation (pGenGCHeap->dynamic_data_of (0)); + pGenGCHeap->fgn_maxgen_percent = gen2Percentage; #endif //MULTIPLE_HEAPS pGenGCHeap->full_gc_approach_event.Reset(); @@ -36913,9 +36914,17 @@ bool GCHeap::RegisterForFullGCNotification(uint32_t gen2Percentage, bool GCHeap::CancelFullGCNotification() { +#ifdef MULTIPLE_HEAPS + for (int hn = 0; hn < gc_heap::n_heaps; hn++) + { + gc_heap* hp = gc_heap::g_heaps [hn]; + hp->fgn_maxgen_percent = 0; + } +#else //MULTIPLE_HEAPS pGenGCHeap->fgn_maxgen_percent = 0; - pGenGCHeap->fgn_loh_percent = 0; +#endif //MULTIPLE_HEAPS + pGenGCHeap->fgn_loh_percent = 0; pGenGCHeap->full_gc_approach_event.Set(); pGenGCHeap->full_gc_end_event.Set(); -- 2.7.4