Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8297872: Non-local G1MonotonicArenaFreePool::_freelist_pool has non-t…
…rivial ctor/dtor

Co-authored-by: Thomas Schatzl <tschatzl@openjdk.org>
Reviewed-by: kbarrett, tschatzl
  • Loading branch information
Ivan Walulya and Thomas Schatzl committed Dec 5, 2022
1 parent 3b3bbe5 commit 61b7093
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Expand Up @@ -1466,6 +1466,7 @@ G1CollectedHeap::G1CollectedHeap() :
_hot_card_cache(NULL),
_rem_set(NULL),
_card_set_config(),
_card_set_freelist_pool(G1CardSetConfiguration::num_mem_object_types()),
_cm(NULL),
_cm_thread(NULL),
_cr(NULL),
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/gc/g1/g1CollectedHeap.hpp
Expand Up @@ -41,6 +41,7 @@
#include "gc/g1/g1HRPrinter.hpp"
#include "gc/g1/g1MonitoringSupport.hpp"
#include "gc/g1/g1MonotonicArenaFreeMemoryTask.hpp"
#include "gc/g1/g1MonotonicArenaFreePool.hpp"
#include "gc/g1/g1NUMA.hpp"
#include "gc/g1/g1SurvivorRegions.hpp"
#include "gc/g1/g1YoungGCEvacFailureInjector.hpp"
Expand Down Expand Up @@ -787,6 +788,8 @@ class G1CollectedHeap : public CollectedHeap {
// Global card set configuration
G1CardSetConfiguration _card_set_config;

G1MonotonicArenaFreePool _card_set_freelist_pool;

public:
// After a collection pause, reset eden and the collection set.
void clear_eden();
Expand Down Expand Up @@ -913,6 +916,9 @@ class G1CollectedHeap : public CollectedHeap {
// The remembered set.
G1RemSet* rem_set() const { return _rem_set; }

const G1MonotonicArenaFreePool* card_set_freelist_pool() const { return &_card_set_freelist_pool; }
G1MonotonicArenaFreePool* card_set_freelist_pool() { return &_card_set_freelist_pool; }

inline G1GCPhaseTimes* phase_times() const;

const G1CollectionSet* collection_set() const { return &_collection_set; }
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
Expand Up @@ -3052,8 +3052,10 @@ G1PrintRegionLivenessInfoClosure::~G1PrintRegionLivenessInfoClosure() {
return;
}

G1CollectedHeap* g1h = G1CollectedHeap::heap();
_total_remset_bytes += g1h->card_set_freelist_pool()->mem_size();
// add static memory usages to remembered set sizes
_total_remset_bytes += G1CardSetFreePool::free_list_pool()->mem_size() + HeapRegionRemSet::static_mem_size();
_total_remset_bytes += HeapRegionRemSet::static_mem_size();
// Print the footer of the output.
log_trace(gc, liveness)(G1PPRL_LINE_PREFIX);
log_trace(gc, liveness)(G1PPRL_LINE_PREFIX
Expand Down
7 changes: 5 additions & 2 deletions src/hotspot/share/gc/g1/g1MonotonicArenaFreeMemoryTask.cpp
Expand Up @@ -27,6 +27,7 @@
#include "gc/g1/g1CardSetMemory.inline.hpp"
#include "gc/g1/g1CollectedHeap.hpp"
#include "gc/g1/g1MonotonicArenaFreeMemoryTask.hpp"
#include "gc/g1/g1MonotonicArenaFreePool.hpp"
#include "gc/g1/g1_globals.hpp"
#include "gc/g1/heapRegionRemSet.hpp"
#include "gc/shared/gc_globals.hpp"
Expand All @@ -53,7 +54,9 @@ bool G1MonotonicArenaFreeMemoryTask::calculate_return_infos(jlong deadline) {
// Ignore the deadline in this step as it is very short.

G1MonotonicArenaMemoryStats used = _total_used;
G1MonotonicArenaMemoryStats free = G1MonotonicArenaFreePool::free_list_sizes();
G1CollectedHeap* g1h = G1CollectedHeap::heap();
G1MonotonicArenaFreePool* freelist_pool = g1h->card_set_freelist_pool();
G1MonotonicArenaMemoryStats free = freelist_pool->memory_sizes();

_return_info = new G1ReturnMemoryProcessorSet(used.num_pools());
for (uint i = 0; i < used.num_pools(); i++) {
Expand All @@ -69,7 +72,7 @@ bool G1MonotonicArenaFreeMemoryTask::calculate_return_infos(jlong deadline) {
_return_info->append(new G1ReturnMemoryProcessor(return_to_vm_size));
}

G1MonotonicArenaFreePool::update_unlink_processors(_return_info);
freelist_pool->update_unlink_processors(_return_info);
return false;
}

Expand Down
11 changes: 4 additions & 7 deletions src/hotspot/share/gc/g1/g1MonotonicArenaFreePool.cpp
Expand Up @@ -44,10 +44,9 @@ void G1MonotonicArenaMemoryStats::clear() {
}

void G1MonotonicArenaFreePool::update_unlink_processors(G1ReturnMemoryProcessorSet* unlink_processor) {
uint num_free_lists = _freelist_pool.num_free_lists();

for (uint i = 0; i < num_free_lists; i++) {
unlink_processor->at(i)->visit_free_list(_freelist_pool.free_list(i));
for (uint i = 0; i < num_free_lists(); i++) {
unlink_processor->at(i)->visit_free_list(free_list(i));
}
}

Expand Down Expand Up @@ -148,8 +147,6 @@ bool G1MonotonicArenaFreePool::G1ReturnMemoryProcessor::return_to_os(jlong deadl
return _first != nullptr;
}

G1MonotonicArenaFreePool G1MonotonicArenaFreePool::_freelist_pool(G1CardSetConfiguration::num_mem_object_types());

G1MonotonicArenaFreePool::G1MonotonicArenaFreePool(uint num_free_lists) :
_num_free_lists(num_free_lists) {

Expand Down Expand Up @@ -184,8 +181,8 @@ size_t G1MonotonicArenaFreePool::mem_size() const {
return result;
}

void G1MonotonicArenaFreePool::print_on(outputStream* out) {
out->print_cr(" Free Pool: size %zu", free_list_pool()->mem_size());
void G1MonotonicArenaFreePool::print_on(outputStream* out) const {
out->print_cr(" Free Pool: size %zu", mem_size());
for (uint i = 0; i < _num_free_lists; i++) {
FormatBuffer<> fmt(" %s", G1CardSetConfiguration::mem_object_type_name_str(i));
_free_lists[i].print_on(out, fmt);
Expand Down
9 changes: 2 additions & 7 deletions src/hotspot/share/gc/g1/g1MonotonicArenaFreePool.hpp
Expand Up @@ -58,20 +58,15 @@ class G1MonotonicArenaMemoryStats {
// e.g. G1CardSetAllocators::_arena
class G1MonotonicArenaFreePool {
using SegmentFreeList = G1MonotonicArena::SegmentFreeList;
// The global free pool.
static G1MonotonicArenaFreePool _freelist_pool;

const uint _num_free_lists;
SegmentFreeList* _free_lists;

public:
static G1MonotonicArenaFreePool* free_list_pool() { return &_freelist_pool; }
static G1MonotonicArenaMemoryStats free_list_sizes() { return _freelist_pool.memory_sizes(); }

class G1ReturnMemoryProcessor;
typedef GrowableArrayCHeap<G1ReturnMemoryProcessor*, mtGC> G1ReturnMemoryProcessorSet;

static void update_unlink_processors(G1ReturnMemoryProcessorSet* unlink_processors);
void update_unlink_processors(G1ReturnMemoryProcessorSet* unlink_processors);

explicit G1MonotonicArenaFreePool(uint num_free_lists);
~G1MonotonicArenaFreePool();
Expand All @@ -86,7 +81,7 @@ class G1MonotonicArenaFreePool {
G1MonotonicArenaMemoryStats memory_sizes() const;
size_t mem_size() const;

void print_on(outputStream* out);
void print_on(outputStream* out) const;
};

// Data structure containing current in-progress state for returning memory to the
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/gc/g1/g1RemSetSummary.cpp
Expand Up @@ -285,7 +285,8 @@ class HRRSStatsIter: public HeapRegionClosure {
rem_set->occupied());

HeapRegionRemSet::print_static_mem_size(out);
G1CardSetFreePool::free_list_pool()->print_on(out);
G1CollectedHeap* g1h = G1CollectedHeap::heap();
g1h->card_set_freelist_pool()->print_on(out);

// Code root statistics
HeapRegionRemSet* max_code_root_rem_set = max_code_root_mem_sz_region()->rem_set();
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/heapRegionRemSet.cpp
Expand Up @@ -59,7 +59,7 @@ HeapRegionRemSet::HeapRegionRemSet(HeapRegion* hr,
G1CardSetConfiguration* config) :
_m(Mutex::service - 1, FormatBuffer<128>("HeapRegionRemSet#%u_lock", hr->hrm_index())),
_code_roots(),
_card_set_mm(config, G1MonotonicArenaFreePool::free_list_pool()),
_card_set_mm(config, G1CollectedHeap::heap()->card_set_freelist_pool()),
_card_set(config, &_card_set_mm),
_hr(hr),
_state(Untracked) { }
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/heapRegionRemSet.hpp
Expand Up @@ -141,7 +141,7 @@ class HeapRegionRemSet : public CHeapObj<mtGC> {
// Returns the memory occupancy of all static data structures associated
// with remembered sets.
static size_t static_mem_size() {
return G1CardSet::static_mem_size() + G1CodeRootSet::static_mem_size() + sizeof(G1CardSetFreePool);
return G1CardSet::static_mem_size() + G1CodeRootSet::static_mem_size();
}

static void print_static_mem_size(outputStream* out);
Expand Down

1 comment on commit 61b7093

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.