Skip to content
Permalink
Browse files
8260625: Rename MetaspaceExpand_lock
Reviewed-by: shade
  • Loading branch information
tstuefe committed Jan 29, 2021
1 parent 22bfa5b commit b7b391b2ac4208eabdee4e93acd5b0e364953f94
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020 SAP SE. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021 SAP SE. 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
@@ -47,7 +47,7 @@ namespace metaspace {

// Return a single chunk to the freelist and adjust accounting. No merge is attempted.
void ChunkManager::return_chunk_simple_locked(Metachunk* c) {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
DEBUG_ONLY(c->verify());
_chunks.add(c);
c->reset_used_words();
@@ -75,7 +75,7 @@ ChunkManager::ChunkManager(const char* name, VirtualSpaceList* space_list) :
// The committed areas within the original chunk carry over to the resulting
// chunks.
void ChunkManager::split_chunk_and_add_splinters(Metachunk* c, chunklevel_t target_level) {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
assert(c->is_free(), "chunk to be split must be free.");
assert(c->level() < target_level, "Target level must be higher than current level.");
assert(c->prev() == NULL && c->next() == NULL, "Chunk must be outside of any list.");
@@ -121,7 +121,7 @@ Metachunk* ChunkManager::get_chunk(chunklevel_t preferred_level, chunklevel_t ma
assert(preferred_level <= max_level, "Sanity");
assert(chunklevel::level_fitting_word_size(min_committed_words) >= max_level, "Sanity");

MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag);

DEBUG_ONLY(verify_locked();)
DEBUG_ONLY(chunklevel::check_valid_level(max_level);)
@@ -232,13 +232,13 @@ Metachunk* ChunkManager::get_chunk(chunklevel_t preferred_level, chunklevel_t ma
// !! Note: this may invalidate the chunk. Do not access the chunk after
// this function returns !!
void ChunkManager::return_chunk(Metachunk* c) {
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag);
return_chunk_locked(c);
}

// See return_chunk().
void ChunkManager::return_chunk_locked(Metachunk* c) {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
UL2(debug, ": returning chunk " METACHUNK_FORMAT ".", METACHUNK_FORMAT_ARGS(c));
DEBUG_ONLY(c->verify();)
assert(contains_chunk(c) == false, "A chunk to be added to the freelist must not be in the freelist already.");
@@ -286,7 +286,7 @@ void ChunkManager::return_chunk_locked(Metachunk* c) {
//
// On success, true is returned, false otherwise.
bool ChunkManager::attempt_enlarge_chunk(Metachunk* c) {
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag);
return c->vsnode()->attempt_enlarge_chunk(c, &_chunks);
}

@@ -311,7 +311,7 @@ static void print_word_size_delta(outputStream* st, size_t word_size_1, size_t w
}

void ChunkManager::purge() {
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag);
UL(info, ": reclaiming memory...");

const size_t reserved_before = _vslist->reserved_words();
@@ -384,18 +384,18 @@ ChunkManager* ChunkManager::chunkmanager_nonclass() {

// Calculates the total number of committed words over all chunks. Walks chunks.
size_t ChunkManager::calc_committed_word_size() const {
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag);
return calc_committed_word_size_locked();
}

size_t ChunkManager::calc_committed_word_size_locked() const {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
return _chunks.calc_committed_word_size();
}

// Update statistics.
void ChunkManager::add_to_statistics(ChunkManagerStats* out) const {
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag);
for (chunklevel_t l = chunklevel::ROOT_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) {
out->_num_chunks[l] += _chunks.num_chunks_at_level(l);
out->_committed_word_size[l] += _chunks.calc_committed_word_size_at_level(l);
@@ -406,12 +406,12 @@ void ChunkManager::add_to_statistics(ChunkManagerStats* out) const {
#ifdef ASSERT

void ChunkManager::verify() const {
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag);
verify_locked();
}

void ChunkManager::verify_locked() const {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
assert(_vslist != NULL, "No vslist");
_chunks.verify();
}
@@ -423,12 +423,12 @@ bool ChunkManager::contains_chunk(Metachunk* c) const {
#endif // ASSERT

void ChunkManager::print_on(outputStream* st) const {
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag);
print_on_locked(st);
}

void ChunkManager::print_on_locked(outputStream* st) const {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
st->print_cr("cm %s: %d chunks, total word size: " SIZE_FORMAT ".", _name,
total_num_chunks(), total_word_size());
_chunks.print_on(st);
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020 SAP SE. All rights reserved.
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021 SAP SE. 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
@@ -48,7 +48,7 @@ char Metachunk::get_state_char() const {

#ifdef ASSERT
void Metachunk::assert_have_expand_lock() {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
}
#endif

@@ -91,7 +91,7 @@ bool Metachunk::commit_up_to(size_t new_committed_words) {
#endif

// We should hold the expand lock at this point.
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);

const size_t commit_from = _committed_words;
const size_t commit_to = MIN2(align_up(new_committed_words, Settings::commit_granule_words()), word_size());
@@ -117,15 +117,15 @@ bool Metachunk::commit_up_to(size_t new_committed_words) {
bool Metachunk::ensure_committed(size_t new_committed_words) {
bool rc = true;
if (new_committed_words > committed_words()) {
MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker cl(Metaspace_lock, Mutex::_no_safepoint_check_flag);
rc = commit_up_to(new_committed_words);
}
return rc;
}

bool Metachunk::ensure_committed_locked(size_t new_committed_words) {
// the .._locked() variant should be called if we own the lock already.
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
bool rc = true;
if (new_committed_words > committed_words()) {
rc = commit_up_to(new_committed_words);
@@ -137,13 +137,13 @@ bool Metachunk::ensure_committed_locked(size_t new_committed_words) {
// commit granule size (in other words, we cannot uncommit chunks smaller than
// a commit granule size).
void Metachunk::uncommit() {
MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker cl(Metaspace_lock, Mutex::_no_safepoint_check_flag);
uncommit_locked();
}

void Metachunk::uncommit_locked() {
// Only uncommit chunks which are free, have no used words set (extra precaution) and are equal or larger in size than a single commit granule.
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
assert(_state == State::Free && _used_words == 0 && word_size() >= Settings::commit_granule_words(),
"Only free chunks equal or larger than commit granule size can be uncommitted "
"(chunk " METACHUNK_FULL_FORMAT ").", METACHUNK_FULL_FORMAT_ARGS(this));
@@ -184,7 +184,7 @@ void Metachunk::zap_header(uint8_t c) {
// Verifies linking with neighbors in virtual space.
// Can only be done under expand lock protection.
void Metachunk::verify_neighborhood() const {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
assert(!is_dead(), "Do not call on dead chunks.");
if (is_root_chunk()) {
// Root chunks are all alone in the world.
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2021 SAP SE. 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
@@ -377,7 +377,7 @@ bool RootChunkArea::is_free() const {
}

void RootChunkArea::verify() const {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
assert_is_aligned(_base, chunklevel::MAX_CHUNK_BYTE_SIZE);

// Iterate thru all chunks in this area. They must be ordered correctly,
@@ -415,7 +415,7 @@ void RootChunkArea::verify() const {
}

void RootChunkArea::verify_area_is_ideally_merged() const {
SOMETIMES(assert_lock_strong(MetaspaceExpand_lock);)
SOMETIMES(assert_lock_strong(Metaspace_lock);)
int num_chunk = 0;
for (const Metachunk* c = _first_chunk; c != NULL; c = c->next_in_vs()) {
if (!c->is_root_chunk() && c->is_free()) {
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2021 SAP SE. 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
@@ -82,7 +82,7 @@ MetaspaceTestContext::MetaspaceTestContext(const char* name, size_t commit_limit

MetaspaceTestContext::~MetaspaceTestContext() {
DEBUG_ONLY(verify();)
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag);
delete _context;
if (_rs.is_reserved()) {
_rs.release();
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020 SAP SE. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021 SAP SE. 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
@@ -73,7 +73,7 @@ VirtualSpaceList::VirtualSpaceList(const char* name, ReservedSpace rs, CommitLim
}

VirtualSpaceList::~VirtualSpaceList() {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
// Note: normally, there is no reason ever to delete a vslist since they are
// global objects, but for gtests it makes sense to allow this.
VirtualSpaceNode* vsn = _first_node;
@@ -90,7 +90,7 @@ VirtualSpaceList::~VirtualSpaceList() {
// List must be expandable for this to work.
void VirtualSpaceList::create_new_node() {
assert(_can_expand, "List is not expandable");
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);

VirtualSpaceNode* vsn = VirtualSpaceNode::create_node(Settings::virtual_space_node_default_word_size(),
_commit_limiter,
@@ -105,7 +105,7 @@ void VirtualSpaceList::create_new_node() {
// Hence, before using this chunk, it must be committed.
// Also, no limits are checked, since no committing takes place.
Metachunk* VirtualSpaceList::allocate_root_chunk() {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);

if (_first_node == NULL ||
_first_node->free_words() < chunklevel::MAX_CHUNK_WORD_SIZE) {
@@ -138,7 +138,7 @@ Metachunk* VirtualSpaceList::allocate_root_chunk() {
// The free chunks are removed from the freelists before the nodes are deleted.
// Return number of purged nodes.
int VirtualSpaceList::purge(FreeChunkListVector* freelists) {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
UL(debug, "purging.");

VirtualSpaceNode* vsn = _first_node;
@@ -173,7 +173,7 @@ int VirtualSpaceList::purge(FreeChunkListVector* freelists) {

// Print all nodes in this space list.
void VirtualSpaceList::print_on(outputStream* st) const {
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag);

st->print_cr("vsl %s:", _name);
const VirtualSpaceNode* vsn = _first_node;
@@ -190,7 +190,7 @@ void VirtualSpaceList::print_on(outputStream* st) const {

#ifdef ASSERT
void VirtualSpaceList::verify_locked() const {
assert_lock_strong(MetaspaceExpand_lock);
assert_lock_strong(Metaspace_lock);
assert(_name != NULL, "Sanity");

int n = 0;
@@ -216,7 +216,7 @@ void VirtualSpaceList::verify_locked() const {
}

void VirtualSpaceList::verify() const {
MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag);
verify_locked();
}
#endif
Loading

0 comments on commit b7b391b

Please sign in to comment.