--- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2019-09-21 06:25:06.797962232 -0700 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2019-09-21 06:25:06.453962244 -0700 @@ -169,12 +169,15 @@ // Private methods. -HeapRegion* G1CollectedHeap::new_region(size_t word_size, HeapRegionType type, bool do_expand) { +HeapRegion* G1CollectedHeap::new_region(size_t word_size, + HeapRegionType type, + bool do_expand, + uint node_index) { assert(!is_humongous(word_size) || word_size <= HeapRegion::GrainWords, "the only time we use this to allocate a humongous region is " "when we are allocating a single humongous region"); - HeapRegion* res = _hrm->allocate_free_region(type); + HeapRegion* res = _hrm->allocate_free_region(type, node_index); if (res == NULL && do_expand && _expand_heap_after_alloc_failure) { // Currently, only attempts to allocate GC alloc regions set @@ -186,12 +189,12 @@ log_debug(gc, ergo, heap)("Attempt heap expansion (region allocation request failed). Allocation request: " SIZE_FORMAT "B", word_size * HeapWordSize); - if (expand(word_size * HeapWordSize)) { + if (expand(word_size * HeapWordSize, node_index)) { // Given that expand() succeeded in expanding the heap, and we // always expand the heap by an amount aligned to the heap // region size, the free list should in theory not be empty. // In either case allocate_free_region() will check for NULL. - res = _hrm->allocate_free_region(type); + res = _hrm->allocate_free_region(type, node_index); } else { _expand_heap_after_alloc_failure = false; } @@ -362,7 +365,7 @@ log_debug(gc, ergo, heap)("Attempt heap expansion (humongous allocation request failed). Allocation request: " SIZE_FORMAT "B", word_size * HeapWordSize); - _hrm->expand_at(first, obj_regions, workers()); + _hrm->expand_at(first, obj_regions, G1MemoryNodeManager::AnyNodeIndex, workers()); policy()->record_new_heap_size(num_regions()); #ifdef ASSERT @@ -1223,7 +1226,7 @@ "min_desired_capacity: " SIZE_FORMAT "B (" UINTX_FORMAT " %%)", capacity_after_gc, used_after_gc, used(), minimum_desired_capacity, MinHeapFreeRatio); - expand(expand_bytes, _workers); + expand(expand_bytes, G1MemoryNodeManager::AnyNodeIndex, _workers); // No expansion, now see if we want to shrink } else if (capacity_after_gc > maximum_desired_capacity) { @@ -1334,7 +1337,7 @@ word_size * HeapWordSize); - if (expand(expand_bytes, _workers)) { + if (expand(expand_bytes, G1MemoryNodeManager::AnyNodeIndex, _workers)) { _hrm->verify_optional(); _verifier->verify_region_sets_optional(); return attempt_allocation_at_safepoint(word_size, @@ -1343,7 +1346,7 @@ return NULL; } -bool G1CollectedHeap::expand(size_t expand_bytes, WorkGang* pretouch_workers, double* expand_time_ms) { +bool G1CollectedHeap::expand(size_t expand_bytes, uint node_index, WorkGang* pretouch_workers, double* expand_time_ms) { size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes); aligned_expand_bytes = align_up(aligned_expand_bytes, HeapRegion::GrainBytes); @@ -1360,7 +1363,7 @@ uint regions_to_expand = (uint)(aligned_expand_bytes / HeapRegion::GrainBytes); assert(regions_to_expand > 0, "Must expand by at least one region"); - uint expanded_by = _hrm->expand_by(regions_to_expand, pretouch_workers); + uint expanded_by = _hrm->expand_by(regions_to_expand, node_index, pretouch_workers); if (expand_time_ms != NULL) { *expand_time_ms = (os::elapsedTime() - expand_heap_start_time_sec) * MILLIUNITS; } @@ -1393,7 +1396,6 @@ uint num_regions_removed = _hrm->shrink_by(num_regions_to_remove); size_t shrunk_bytes = num_regions_removed * HeapRegion::GrainBytes; - log_debug(gc, ergo, heap)("Shrink the heap. requested shrinking amount: " SIZE_FORMAT "B aligned shrinking amount: " SIZE_FORMAT "B attempted shrinking amount: " SIZE_FORMAT "B", shrink_bytes, aligned_shrink_bytes, shrunk_bytes); if (num_regions_removed > 0) { @@ -1495,6 +1497,7 @@ _humongous_set("Humongous Region Set", new HumongousRegionSetChecker()), _bot(NULL), _listener(), + _mem_node_mgr(G1MemoryNodeManager::create()), _hrm(NULL), _allocator(NULL), _verifier(NULL), @@ -1778,6 +1781,8 @@ } _workers->initialize_workers(); + _mem_node_mgr->set_page_size(page_size); + // Create the G1ConcurrentMark data structure and thread. // (Must do this late, so that "max_regions" is defined.) _cm = new G1ConcurrentMark(this, prev_bitmap_storage, next_bitmap_storage); @@ -1788,7 +1793,7 @@ _cm_thread = _cm->cm_thread(); // Now expand into the initial heap size. - if (!expand(init_byte_size, _workers)) { + if (!expand(init_byte_size, G1MemoryNodeManager::AnyNodeIndex, _workers)) { vm_shutdown_during_initialization("Failed to allocate initial heap."); return JNI_ENOMEM; } @@ -2886,7 +2891,7 @@ // No need for an ergo logging here, // expansion_amount() does this when it returns a value > 0. double expand_ms; - if (!expand(expand_bytes, _workers, &expand_ms)) { + if (!expand(expand_bytes, G1MemoryNodeManager::AnyNodeIndex, _workers, &expand_ms)) { // We failed to expand the heap. Cannot do anything about it. } phase_times()->record_expand_heap_time(expand_ms); @@ -4547,13 +4552,15 @@ // Methods for the mutator alloc region HeapRegion* G1CollectedHeap::new_mutator_alloc_region(size_t word_size, - bool force) { + bool force, + uint node_index) { assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); bool should_allocate = policy()->should_allocate_mutator_region(); if (force || should_allocate) { HeapRegion* new_alloc_region = new_region(word_size, HeapRegionType::Eden, - false /* do_expand */); + false /* do_expand */, + node_index); if (new_alloc_region != NULL) { set_region_short_lived_locked(new_alloc_region); _hr_printer.alloc(new_alloc_region, !should_allocate);