8302385: Remove MetaspaceReclaimPolicy=none

Reviewed-by: iklam, dholmes
This commit is contained in:
Thomas Stuefe 2023-02-16 07:01:10 +00:00
parent 6e2d3c6c45
commit 519229db3c
19 changed files with 98 additions and 252 deletions

@ -1,6 +1,6 @@
/*
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022 SAP SE. All rights reserved.
* Copyright (c) 2018, 2023 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
@ -206,11 +206,10 @@ Metachunk* ChunkManager::get_chunk_locked(chunklevel_t preferred_level, chunklev
split_chunk_and_add_splinters(c, preferred_level);
assert(c->level() == preferred_level, "split failed?");
}
// Attempt to commit the chunk (depending on settings, we either fully commit it or just
// commit enough to get the caller going). That may fail if we hit a commit limit. In
// Attempt to commit the chunk. That may fail if we hit a commit limit. In
// that case put the chunk back to the freelist (re-merging it with its neighbors if we
// did split it) and return null.
const size_t to_commit = Settings::new_chunks_are_fully_committed() ? c->word_size() : min_committed_words;
const size_t to_commit = min_committed_words;
if (c->committed_words() < to_commit) {
if (c->ensure_committed_locked(to_commit) == false) {
UL2(info, "failed to commit " SIZE_FORMAT " words on chunk " METACHUNK_FORMAT ".",
@ -343,17 +342,15 @@ void ChunkManager::purge() {
// free chunks and uncommit the backing memory of those large enough to
// contain one or multiple commit granules (chunks larger than a granule
// always cover a whole number of granules and start at a granule boundary).
if (Settings::uncommit_free_chunks()) {
const chunklevel_t max_level =
chunklevel::level_fitting_word_size(Settings::commit_granule_words());
for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL;
l <= max_level;
l++) {
// Since we uncommit all chunks at this level, we do not break the "committed chunks are
// at the front of the list" condition.
for (Metachunk* c = _chunks.first_at_level(l); c != nullptr; c = c->next()) {
c->uncommit_locked();
}
const chunklevel_t max_level =
chunklevel::level_fitting_word_size(Settings::commit_granule_words());
for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL;
l <= max_level;
l++) {
// Since we uncommit all chunks at this level, we do not break the "committed chunks are
// at the front of the list" condition.
for (Metachunk* c = _chunks.first_at_level(l); c != nullptr; c = c->next()) {
c->uncommit_locked();
}
}

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023 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
@ -52,15 +52,6 @@ namespace metaspace {
// committed word size. We stop searching at the first fully uncommitted
// chunk.
//
// Note that even though this is an O(n) search, partially committed chunks are
// very rare. A partially committed chunk is one spanning multiple commit
// granules, of which some are committed and some are not.
// If metaspace reclamation is on (MetaspaceReclaimPolicy=balanced|aggressive), these
// chunks will become uncommitted after they are returned to the ChunkManager.
// If metaspace reclamation is off (MetaspaceReclaimPolicy=none) they are fully
// committed when handed out and will not be uncommitted when returned to the
// ChunkManager.
//
// Therefore in all likelihood the chunk lists only contain fully committed or
// fully uncommitted chunks; either way search will stop at the first chunk.

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023 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
@ -316,9 +316,6 @@ MetaWord* MetaspaceArena::allocate_inner(size_t requested_word_size) {
METACHUNK_FORMAT_ARGS(new_chunk), requested_word_size);
assert(new_chunk->free_below_committed_words() >= raw_word_size, "Sanity");
if (Settings::new_chunks_are_fully_committed()) {
assert(new_chunk->is_fully_committed(), "Chunk should be fully committed.");
}
// We have a new chunk. Before making it the current chunk, retire the old one.
if (current_chunk() != nullptr) {

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023 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
@ -39,34 +39,19 @@ namespace metaspace {
size_t Settings::_commit_granule_bytes = 0;
size_t Settings::_commit_granule_words = 0;
bool Settings::_new_chunks_are_fully_committed = false;
bool Settings::_uncommit_free_chunks = false;
DEBUG_ONLY(bool Settings::_use_allocation_guard = false;)
void Settings::ergo_initialize() {
if (strcmp(MetaspaceReclaimPolicy, "none") == 0) {
log_info(metaspace)("Initialized with strategy: no reclaim.");
_commit_granule_bytes = MAX2(os::vm_page_size(), 64 * K);
_commit_granule_words = _commit_granule_bytes / BytesPerWord;
// In "none" reclamation mode, we do not uncommit, and we commit new chunks fully;
// that very closely mimics the behaviour of old Metaspace.
_new_chunks_are_fully_committed = true;
_uncommit_free_chunks = false;
} else if (strcmp(MetaspaceReclaimPolicy, "aggressive") == 0) {
if (strcmp(MetaspaceReclaimPolicy, "aggressive") == 0) {
log_info(metaspace)("Initialized with strategy: aggressive reclaim.");
// Set the granule size rather small; may increase
// mapping fragmentation but also increase chance to uncommit.
_commit_granule_bytes = MAX2(os::vm_page_size(), 16 * K);
_commit_granule_words = _commit_granule_bytes / BytesPerWord;
_new_chunks_are_fully_committed = false;
_uncommit_free_chunks = true;
} else if (strcmp(MetaspaceReclaimPolicy, "balanced") == 0) {
log_info(metaspace)("Initialized with strategy: balanced reclaim.");
_commit_granule_bytes = MAX2(os::vm_page_size(), 64 * K);
_commit_granule_words = _commit_granule_bytes / BytesPerWord;
_new_chunks_are_fully_committed = false;
_uncommit_free_chunks = true;
} else {
vm_exit_during_initialization("Invalid value for MetaspaceReclaimPolicy: \"%s\".", MetaspaceReclaimPolicy);
}
@ -87,8 +72,6 @@ void Settings::print_on(outputStream* st) {
st->print_cr(" - commit_granule_words: " SIZE_FORMAT ".", commit_granule_words());
st->print_cr(" - virtual_space_node_default_size: " SIZE_FORMAT ".", virtual_space_node_default_word_size());
st->print_cr(" - enlarge_chunks_in_place: %d.", (int)enlarge_chunks_in_place());
st->print_cr(" - new_chunks_are_fully_committed: %d.", (int)new_chunks_are_fully_committed());
st->print_cr(" - uncommit_free_chunks: %d.", (int)uncommit_free_chunks());
st->print_cr(" - use_allocation_guard: %d.", (int)use_allocation_guard());
}

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -56,15 +56,6 @@ class Settings : public AllStatic {
// the requested size, we attempt to double the chunk size in place...
static const bool _enlarge_chunks_in_place = true;
// Whether or not chunks handed out to an arena start out fully committed;
// if true, this deactivates committing-on-demand (regardless of whether
// we uncommit free chunks).
static bool _new_chunks_are_fully_committed;
// If true, chunks equal or larger than a commit granule are uncommitted
// after being returned to the freelist.
static bool _uncommit_free_chunks;
// If true, metablock allocations are guarded and periodically checked.
DEBUG_ONLY(static bool _use_allocation_guard;)
@ -72,11 +63,9 @@ public:
static size_t commit_granule_bytes() { return _commit_granule_bytes; }
static size_t commit_granule_words() { return _commit_granule_words; }
static bool new_chunks_are_fully_committed() { return _new_chunks_are_fully_committed; }
static size_t virtual_space_node_default_word_size() { return _virtual_space_node_default_word_size; }
static size_t virtual_space_node_reserve_alignment_words() { return _virtual_space_node_reserve_alignment_words; }
static bool enlarge_chunks_in_place() { return _enlarge_chunks_in_place; }
static bool uncommit_free_chunks() { return _uncommit_free_chunks; }
static bool use_allocation_guard() { return DEBUG_ONLY(_use_allocation_guard) NOT_DEBUG(false); }
static void ergo_initialize();

@ -1421,7 +1421,7 @@ const int ObjectAlignmentInBytes = 8;
"fails VM initialization (requires -Xshare=off.") \
\
product(ccstr, MetaspaceReclaimPolicy, "balanced", DIAGNOSTIC, \
"options: balanced, aggressive, none") \
"options: balanced, aggressive") \
\
product(bool, PrintMetaspaceStatisticsAtExit, false, DIAGNOSTIC, \
"Print metaspace statistics upon VM exit.") \

@ -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, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023 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
@ -66,9 +66,6 @@ void ChunkGtestContext::checked_alloc_chunk_0(Metachunk** p_return_value, chunkl
// Needs lock EXPECT_NULL(c->prev_in_vs());
ASSERT_TRUE(c->is_root_chunk() || c->is_leader());
}
if (Settings::new_chunks_are_fully_committed()) {
ASSERT_TRUE(c->is_fully_committed());
}
_num_chunks_allocated++;

@ -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, 2023 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -71,11 +71,6 @@ class ChunkManagerRandomChunkAllocTest {
// could it be commit limit hit?
if (Settings::new_chunks_are_fully_committed()) {
// For all we know we may have just failed to fully-commit a new root chunk.
additional_word_size = MAX_CHUNK_WORD_SIZE;
}
// Note that this is difficult to verify precisely, since there are
// several layers of truth:
// a) at the lowest layer (RootChunkArea) we have a bitmap of committed granules;

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2021 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -82,19 +82,6 @@ TEST_VM(metaspace, get_chunk_with_commit_limit) {
// When should commit work? As long as min_committed_words is smaller than commit_limit_words.
bool commit_should_work = min_committed_words <= commit_limit_words;
// Exception: MetaspaceReclaimPolicy=none. Here, chunks are fully committed from the get go and
// min_committed_words is effectively ignored. So commit would fail if the chunk is larger than
// the commit limit. Unfortunately, the chunk size is difficult to predict (it will be between
// [pref_lvl, max_lvl]. To make matters simple, we skip the test if we don't know the level for
// sure.
if (Settings::new_chunks_are_fully_committed()) {
if (pref_lvl == max_lvl) {
commit_should_work = word_size_for_level(max_lvl) <= commit_limit_words;
} else {
continue;
}
}
// printf("commit_limit: " SIZE_FORMAT ", min_committed_words: " SIZE_FORMAT
// ", max chunk level: " CHKLVL_FORMAT ", preferred chunk level: " CHKLVL_FORMAT ", should work: %d\n",
// commit_limit_words, min_committed_words, max_lvl, pref_lvl, commit_should_work);
@ -242,11 +229,6 @@ TEST_VM(metaspace, chunk_buddy_stuff) {
TEST_VM(metaspace, chunk_allocate_with_commit_limit) {
// This test does not make sense if commit-on-demand is off
if (Settings::new_chunks_are_fully_committed()) {
return;
}
const size_t granule_sz = Settings::commit_granule_words();
const size_t commit_limit = granule_sz * 3;
ChunkGtestContext context(commit_limit);

@ -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, 2023 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -151,10 +151,6 @@ TEST_VM(metaspace, freechunklist) {
// the retrieval-by-minimally-committed-words function.
TEST_VM(metaspace, freechunklist_retrieval) {
if (Settings::new_chunks_are_fully_committed()) {
return;
}
ChunkGtestContext context;
FreeChunkList fcl;
Metachunk* c = NULL;

@ -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, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023 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
@ -118,11 +118,7 @@ public:
size_t used_words_after = _used_words_counter.get();
size_t committed_words_after = limiter().committed_words();
ASSERT_0(used_words_after);
if (Settings::uncommit_free_chunks()) {
ASSERT_LE(committed_words_after, committed_words_before);
} else {
ASSERT_EQ(committed_words_after, committed_words_before);
}
ASSERT_LE(committed_words_after, committed_words_before);
}
}
@ -177,12 +173,7 @@ public:
if (p == NULL) {
// Allocation failed.
if (Settings::new_chunks_are_fully_committed()) {
ASSERT_LT(possible_expansion, MAX_CHUNK_WORD_SIZE);
} else {
ASSERT_LT(possible_expansion, word_size);
}
ASSERT_LT(possible_expansion, word_size);
ASSERT_EQ(used, used2);
ASSERT_EQ(committed, committed2);
ASSERT_EQ(capacity, capacity2);
@ -457,10 +448,6 @@ TEST_VM(metaspace, MetaspaceArena_deallocate) {
static void test_recover_from_commit_limit_hit() {
if (Settings::new_chunks_are_fully_committed()) {
return; // This would throw off the commit counting in this test.
}
// Test:
// - Multiple MetaspaceArena allocate (operating under the same commit limiter).
// - One, while attempting to commit parts of its current chunk on demand,
@ -565,12 +552,23 @@ static void test_controlled_growth(Metaspace::MetaspaceType type, bool is_class,
ASSERT_EQ(capacity, expected_starting_capacity);
if (!(Settings::new_chunks_are_fully_committed() && type == Metaspace::BootMetaspaceType)) {
// Initial commit charge for the whole context should be one granule
ASSERT_EQ(context.committed_words(), Settings::commit_granule_words());
// Initial commit number for the arena should be less since - apart from boot loader - no
// space type has large initial chunks.
ASSERT_LE(committed, Settings::commit_granule_words());
// What happens when we allocate, commit wise:
// Arena allocates from current chunk, committing needed memory from the chunk on demand.
// The chunk asks the underlying vsnode to commit the area it is located in. Since the
// chunk may be smaller than one commit granule, this may result in surrounding memory
// also getting committed.
// In reality we will commit in granule granularity, but arena can only know what its first
// chunk did commit. So what it thinks was committed depends on the size of its first chunk,
// which depends on ArenaGrowthPolicy.
{
const chunklevel_t expected_level_for_first_chunk =
ArenaGrowthPolicy::policy_for_space_type(type, is_class)->get_level_at_step(0);
const size_t what_arena_should_think_was_committed =
MIN2(Settings::commit_granule_words(), word_size_for_level(expected_level_for_first_chunk));
const size_t what_should_really_be_committed = Settings::commit_granule_words();
ASSERT_EQ(committed, what_arena_should_think_was_committed);
ASSERT_EQ(context.committed_words(), what_should_really_be_committed);
}
///// subsequent allocations //
@ -615,7 +613,7 @@ static void test_controlled_growth(Metaspace::MetaspaceType type, bool is_class,
ASSERT_GE(committed2, used2);
ASSERT_GE(committed2, committed);
const size_t committed_jump = committed2 - committed;
if (committed_jump > 0 && !Settings::new_chunks_are_fully_committed()) {
if (committed_jump > 0) {
ASSERT_LE(committed_jump, Settings::commit_granule_words());
}
committed = committed2;

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023 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
@ -29,26 +29,15 @@
*
*/
/* @test id=reclaim-none-debug
/* @test id=default-debug
* @bug 8251158
* @summary Run metaspace-related gtests for reclaim policy none (with verifications)
* @summary Run metaspace-related gtests with all default but verifications enabled
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.xml
* @requires vm.debug
* @requires vm.flagless
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:MetaspaceReclaimPolicy=none -XX:VerifyMetaspaceInterval=3
*/
/* @test id=reclaim-none-ndebug
* @bug 8251158
* @summary Run metaspace-related gtests for reclaim policy none
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.xml
* @requires vm.debug == false
* @requires vm.flagless
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:MetaspaceReclaimPolicy=none
* @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:VerifyMetaspaceInterval=3
*/

@ -36,16 +36,6 @@ import jdk.test.lib.JDKToolFinder;
* @run main/othervm -Dwith-compressed-class-space -XX:MaxMetaspaceSize=201M -Xmx100M -XX:+UseCompressedOops -XX:+UseCompressedClassPointers PrintMetaspaceDcmd
*/
/*
* @test id=test-64bit-ccs-noreclaim
* @summary Test the VM.metaspace command
* @requires vm.bits == "64"
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @run main/othervm -Dwith-compressed-class-space -XX:MaxMetaspaceSize=201M -Xmx100M -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UnlockDiagnosticVMOptions -XX:MetaspaceReclaimPolicy=none PrintMetaspaceDcmd
*/
/*
* @test id=test-64bit-ccs-aggressivereclaim
* @summary Test the VM.metaspace command

@ -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, 2023, SAP SE. All rights reserved.
* Copyright (c) 2020, 2023 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

@ -1,3 +1,27 @@
/*
* Copyright (c) 2020, 2023 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
import jdk.test.whitebox.WhiteBox;
@ -149,15 +173,13 @@ public class MetaspaceTestContext {
throw new RuntimeException("Weirdness.");
}
// If no arenas are alive, usage should be zero and committed too (in reclaiming mode)
// If no arenas are alive, usage should be zero and committed too
if (numLiveArenas() == 0) {
if (usageMeasured > 0) {
throw new RuntimeException("Usage > 0, expected 0");
}
if (Settings.settings().doesReclaim()) {
if (committedMeasured > 0) {
throw new RuntimeException("Committed > 0, expected 0");
}
if (committedMeasured > 0) {
throw new RuntimeException("Committed > 0, expected 0");
}
}
@ -214,11 +236,7 @@ public class MetaspaceTestContext {
//
long expectedMaxCommitted = usageMeasured;
expectedMaxCommitted += Settings.rootChunkWordSize;
if (Settings.settings().doesReclaim()) {
expectedMaxCommitted *= 10.0;
} else {
expectedMaxCommitted *= 100.0;
}
expectedMaxCommitted *= 10.0;
if (committedMeasured > expectedMaxCommitted) {
throw new RuntimeException("Committed seems high: " + committedMeasured + " expected at most " + expectedMaxCommitted);

@ -1,6 +1,6 @@
/*
* Copyright (c) 2021 SAP SE. All rights reserved.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023 SAP SE. All rights reserved.
* Copyright (c) 2021, 2023, 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
@ -61,16 +61,12 @@ public class MetaspaceTestWithThreads {
// This deletes the arenas, which will cause them to return all their accumulated
// metaspace chunks into the context' chunk manager (freelist) before vanishing.
// It then purges the context.
// We may return memory to the operating system:
// - with -XX:MetaspaceReclaimPolicy=balanced|aggressive (balanced is the default),
// we will scourge the freelist for chunks larger than a commit granule, and uncommit
// their backing memory. Note that since we deleted all arenas, all their chunks are
// in the freelist, should have been maximally folded by the buddy allocator, and
// therefore should all be eligible for uncommitting. Meaning the context should
// retain no memory at all, its committed counter should be zero.
// - with -XX:MetaspaceReclaimPolicy=none, we omit the purging and retain memory in the
// metaspace allocator, so the context should retain its memory.
// It then purges the context. We will scourge the freelist for chunks larger than a
// commit granule, and uncommit their backing memory. Note that since we deleted all
// arenas, all their chunks are in the freelist, should have been maximally folded
// by the buddy allocator, and therefore should all be eligible for uncommitting.
// Meaning the context should retain no memory at all, its committed counter should
// be zero.
for (RandomAllocatorThread t: threads) {
if (t.allocator.arena.isLive()) {

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -35,7 +35,6 @@
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
*
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:VerifyMetaspaceInterval=10 TestMetaspaceAllocation
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:VerifyMetaspaceInterval=10 -XX:MetaspaceReclaimPolicy=none TestMetaspaceAllocation
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:VerifyMetaspaceInterval=10 -XX:MetaspaceReclaimPolicy=aggressive TestMetaspaceAllocation
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:VerifyMetaspaceInterval=10 -XX:+MetaspaceGuardAllocations TestMetaspaceAllocation
*
@ -53,7 +52,6 @@
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
*
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestMetaspaceAllocation
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:MetaspaceReclaimPolicy=none TestMetaspaceAllocation
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:MetaspaceReclaimPolicy=aggressive TestMetaspaceAllocation
*/

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -57,24 +57,6 @@
* TestMetaspaceAllocationMT1
*/
/*
* @test id=debug-none
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @build jdk.test.whitebox.WhiteBox
* @key randomness
* @requires (vm.debug == true)
*
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
*
* @run main/othervm/timeout=400
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:VerifyMetaspaceInterval=10
* -XX:MetaspaceReclaimPolicy=none
* TestMetaspaceAllocationMT1
*/
/*
* @test id=debug-aggressive
* @library /test/lib
@ -127,23 +109,6 @@
* TestMetaspaceAllocationMT1
*/
/*
* @test id=ndebug-none
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @build jdk.test.whitebox.WhiteBox
* @key randomness
* @requires (vm.debug == false)
*
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
*
* @run main/othervm/timeout=400
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:MetaspaceReclaimPolicy=none
* TestMetaspaceAllocationMT1
*/
/*
* @test id=ndebug-aggressive
* @library /test/lib

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023 SAP SE. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -57,24 +57,6 @@
* TestMetaspaceAllocationMT2
*/
/*
* @test id=debug-none
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @build jdk.test.whitebox.WhiteBox
* @key randomness
* @requires (vm.debug == true)
*
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
*
* @run main/othervm/timeout=400
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:VerifyMetaspaceInterval=10
* -XX:MetaspaceReclaimPolicy=none
* TestMetaspaceAllocationMT2
*/
/*
* @test id=debug-aggressive
* @library /test/lib
@ -127,23 +109,6 @@
* TestMetaspaceAllocationMT2
*/
/*
* @test id=ndebug-none
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @build jdk.test.whitebox.WhiteBox
* @key randomness
* @requires (vm.debug == false)
*
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
*
* @run main/othervm/timeout=400
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:MetaspaceReclaimPolicy=none
* TestMetaspaceAllocationMT2
*/
/*
* @test id=ndebug-aggressive
* @library /test/lib