--- old/src/hotspot/share/gc/g1/heapRegionSet.cpp 2019-11-01 16:13:23.876400470 -0700 +++ new/src/hotspot/share/gc/g1/heapRegionSet.cpp 2019-11-01 16:13:23.504400459 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" +#include "gc/g1/g1NUMA.hpp" #include "gc/g1/heapRegionRemSet.hpp" #include "gc/g1/heapRegionSet.inline.hpp" @@ -101,6 +102,9 @@ curr->set_next(NULL); curr->set_prev(NULL); curr->set_containing_set(NULL); + + decrease_length(curr->node_index()); + curr = next; } clear(); @@ -119,6 +123,10 @@ return; } + if (_node_info != NULL && from_list->_node_info != NULL) { + _node_info->add(from_list->_node_info); + } + #ifdef ASSERT FreeRegionListIterator iter(from_list); while (iter.more_available()) { @@ -220,6 +228,9 @@ remove(curr); count++; + + decrease_length(curr->node_index()); + curr = next; } @@ -267,6 +278,10 @@ _head = NULL; _tail = NULL; _last = NULL; + + if (_node_info!= NULL) { + _node_info->clear(); + } } void FreeRegionList::verify_list() { @@ -303,3 +318,40 @@ guarantee(_tail == NULL || _tail->next() == NULL, "_tail should not have a next"); guarantee(length() == count, "%s count mismatch. Expected %u, actual %u.", name(), length(), count); } + + +FreeRegionList::FreeRegionList(const char* name, HeapRegionSetChecker* checker): + HeapRegionSetBase(name, checker), + _node_info(G1NUMA::numa()->is_enabled() ? new NodeInfo() : NULL) { + clear(); +} + +FreeRegionList::~FreeRegionList() { + if (_node_info != NULL) { + delete _node_info; + } +} + +NodeInfo::NodeInfo() : _numa(G1NUMA::numa()), _length_of_node(NULL), + _num_nodes(_numa->num_active_nodes()) { + assert(UseNUMA, "Invariant"); + + _length_of_node = NEW_C_HEAP_ARRAY(uint, _num_nodes, mtGC); +} + +NodeInfo::~NodeInfo() { + FREE_C_HEAP_ARRAY(uint, _length_of_node); +} + +void NodeInfo::clear() { + for (uint i = 0; i < _num_nodes; ++i) { + _length_of_node[i] = 0; + } +} + +void NodeInfo::add(NodeInfo* info) { + for (uint i = 0; i < _num_nodes; ++i) { + _length_of_node[i] += info->_length_of_node[i]; + } +} +