diff --git a/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp b/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp index b87554fe94a..a417ed00328 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp +++ b/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp @@ -116,7 +116,6 @@ static void print_settings(outputStream* out, size_t scale) { print_human_readable_size(out, MetaspaceGC::capacity_until_GC(), scale); out->cr(); out->print_cr("CDS: %s", (UseSharedSpaces ? "on" : (DumpSharedSpaces ? "dump" : "off"))); - out->print_cr("MetaspaceReclaimPolicy: %s", MetaspaceReclaimPolicy); Settings::print_on(out); } diff --git a/src/hotspot/share/memory/metaspace/metaspaceSettings.cpp b/src/hotspot/share/memory/metaspace/metaspaceSettings.cpp index 0a3fb61d69c..7dc742755b6 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceSettings.cpp +++ b/src/hotspot/share/memory/metaspace/metaspaceSettings.cpp @@ -36,29 +36,15 @@ namespace metaspace { -size_t Settings::_commit_granule_bytes = 0; -size_t Settings::_commit_granule_words = 0; - DEBUG_ONLY(bool Settings::_use_allocation_guard = false;) void Settings::ergo_initialize() { - 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; - } 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; - } else { - vm_exit_during_initialization("Invalid value for MetaspaceReclaimPolicy: \"%s\".", MetaspaceReclaimPolicy); - } - // Sanity checks. + // Granules must be a multiple of page size, and a power-2-value. + assert(_commit_granule_bytes >= os::vm_page_size() && + is_aligned(_commit_granule_bytes, os::vm_page_size()), + "Granule size must be a page-size-aligned power-of-2 value"); assert(commit_granule_words() <= chunklevel::MAX_CHUNK_WORD_SIZE, "Too large granule size"); - assert(is_power_of_2(commit_granule_words()), "granule size must be a power of 2"); // Off for release builds, off by default - but switchable - for debug builds. DEBUG_ONLY(_use_allocation_guard = MetaspaceGuardAllocations;) diff --git a/src/hotspot/share/memory/metaspace/metaspaceSettings.hpp b/src/hotspot/share/memory/metaspace/metaspaceSettings.hpp index 159ba69d194..93be0eb6fe6 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceSettings.hpp +++ b/src/hotspot/share/memory/metaspace/metaspaceSettings.hpp @@ -35,10 +35,10 @@ namespace metaspace { class Settings : public AllStatic { // Granularity, in bytes, metaspace is committed with. - static size_t _commit_granule_bytes; + static constexpr size_t _commit_granule_bytes = 64 * K; // Granularity, in words, metaspace is committed with. - static size_t _commit_granule_words; + static constexpr size_t _commit_granule_words = _commit_granule_bytes / BytesPerWord; // The default size of a VirtualSpaceNode, unless created with an explicitly specified size. // Must be a multiple of the root chunk size. diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 67dfe8fb998..51d79037959 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -523,6 +523,7 @@ static SpecialFlag const special_jvm_flags[] = { { "G1UsePreventiveGC", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::jdk(22) }, { "G1ConcRSLogCacheSize", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() }, { "G1ConcRSHotCardLimit", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() }, + { "MetaspaceReclaimPolicy", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() }, #ifdef ASSERT { "DummyObsoleteTestFlag", JDK_Version::undefined(), JDK_Version::jdk(18), JDK_Version::undefined() }, diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 3422185e3fa..338c92db05e 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -1422,9 +1422,6 @@ const int ObjectAlignmentInBytes = 8; "Force the class space to be allocated at this address or " \ "fails VM initialization (requires -Xshare=off.") \ \ - product(ccstr, MetaspaceReclaimPolicy, "balanced", DIAGNOSTIC, \ - "options: balanced, aggressive") \ - \ product(bool, PrintMetaspaceStatisticsAtExit, false, DIAGNOSTIC, \ "Print metaspace statistics upon VM exit.") \ \ diff --git a/test/hotspot/jtreg/gtest/MetaspaceGtests.java b/test/hotspot/jtreg/gtest/MetaspaceGtests.java index 102b3122c01..3e816fa4ff5 100644 --- a/test/hotspot/jtreg/gtest/MetaspaceGtests.java +++ b/test/hotspot/jtreg/gtest/MetaspaceGtests.java @@ -40,34 +40,6 @@ * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:VerifyMetaspaceInterval=3 */ - - - -/* @test id=reclaim-aggressive-debug - * @bug 8251158 - * @summary Run metaspace-related gtests for reclaim policy aggressive (with verifications) - * @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=aggressive -XX:VerifyMetaspaceInterval=3 - */ - -/* @test id=reclaim-aggressive-ndebug - * @bug 8251158 - * @summary Run metaspace-related gtests for reclaim policy aggressive - * @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=aggressive - */ - - - - /* @test id=balanced-with-guards * @summary Run metaspace-related gtests with allocation guards enabled * @library /test/lib @@ -78,9 +50,6 @@ * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:VerifyMetaspaceInterval=3 -XX:+MetaspaceGuardAllocations */ - - - /* @test id=balanced-no-ccs * @summary Run metaspace-related gtests with compressed class pointers off * @library /test/lib @@ -88,5 +57,5 @@ * java.xml * @requires vm.bits == 64 * @requires vm.flagless - * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:MetaspaceReclaimPolicy=balanced -XX:-UseCompressedClassPointers + * @run main/native GTestWrapper --gtest_filter=metaspace* -XX:+UnlockDiagnosticVMOptions -XX:-UseCompressedClassPointers */ diff --git a/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java b/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java index 422090d39d7..56d9c2095b2 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java +++ b/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java @@ -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-aggressivereclaim - * @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=aggressive PrintMetaspaceDcmd - */ - /* * @test id=test-64bit-ccs-guarded * @summary Test the VM.metaspace command diff --git a/test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestManyArenasManyThreads.java b/test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestManyArenasManyThreads.java index 7e1c2678f4e..912f240a9f4 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestManyArenasManyThreads.java +++ b/test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestManyArenasManyThreads.java @@ -93,7 +93,7 @@ public class MetaspaceTestManyArenasManyThreads extends MetaspaceTestWithThreads // frees their metaspace arenas. All within CLDG::purge(). But since this test isolates the metaspace // context and does test it separately, GC and CLDG are not involved here. We need to purge manually. // - // Purging uncommits all free chunks >= 64K/16K (MetaspaceReclaimPolicy=standard/aggressive). + // Purging uncommits all free chunks >= 64K context.purge(); context.updateTotals(); diff --git a/test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestWithThreads.java b/test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestWithThreads.java index 4383f33d890..edf6da387ed 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestWithThreads.java +++ b/test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestWithThreads.java @@ -77,10 +77,8 @@ public class MetaspaceTestWithThreads { context.checkStatistics(); - if (Settings.settings().doesReclaim()) { - if (context.committedWords() > 0) { - throw new RuntimeException("Expected no committed words after purging empty metaspace context (was: " + context.committedWords() + ")"); - } + if (context.committedWords() > 0) { + throw new RuntimeException("Expected no committed words after purging empty metaspace context (was: " + context.committedWords() + ")"); } } diff --git a/test/hotspot/jtreg/runtime/Metaspace/elastic/Settings.java b/test/hotspot/jtreg/runtime/Metaspace/elastic/Settings.java index cca5b7f59ed..c6d69f341b9 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/elastic/Settings.java +++ b/test/hotspot/jtreg/runtime/Metaspace/elastic/Settings.java @@ -27,13 +27,8 @@ import jdk.test.whitebox.WhiteBox; public final class Settings { - public String reclaimPolicy = WhiteBox.getWhiteBox().getStringVMFlag("MetaspaceReclaimPolicy"); public boolean usesAllocationGuards = WhiteBox.getWhiteBox().getBooleanVMFlag("MetaspaceGuardAllocations"); - final public boolean doesReclaim() { - return reclaimPolicy.equals("balanced") || reclaimPolicy.equals("aggessive"); - } - final static long rootChunkWordSize = 2048 * 1024; static Settings theSettings; diff --git a/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocation.java b/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocation.java index e862a15538c..1ecde3f8376 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocation.java +++ b/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocation.java @@ -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=aggressive TestMetaspaceAllocation * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:VerifyMetaspaceInterval=10 -XX:+MetaspaceGuardAllocations TestMetaspaceAllocation * */ @@ -52,7 +51,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=aggressive TestMetaspaceAllocation */ public class TestMetaspaceAllocation { diff --git a/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocationMT1.java b/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocationMT1.java index 579d0a9f79a..6aaebe6f4d0 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocationMT1.java +++ b/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocationMT1.java @@ -57,24 +57,6 @@ * TestMetaspaceAllocationMT1 */ -/* - * @test id=debug-aggressive - * @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=aggressive - * TestMetaspaceAllocationMT1 - */ - /* * @test id=debug-guard * @library /test/lib @@ -109,23 +91,6 @@ * TestMetaspaceAllocationMT1 */ -/* - * @test id=ndebug-aggressive - * @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=aggressive - * TestMetaspaceAllocationMT1 - */ - public class TestMetaspaceAllocationMT1 { public static void main(String[] args) throws Exception { diff --git a/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocationMT2.java b/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocationMT2.java index 564d574fb71..873e2e0269a 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocationMT2.java +++ b/test/hotspot/jtreg/runtime/Metaspace/elastic/TestMetaspaceAllocationMT2.java @@ -57,24 +57,6 @@ * TestMetaspaceAllocationMT2 */ -/* - * @test id=debug-aggressive - * @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=aggressive - * TestMetaspaceAllocationMT2 - */ - /* * @test id=debug-guard * @library /test/lib @@ -109,23 +91,6 @@ * TestMetaspaceAllocationMT2 */ -/* - * @test id=ndebug-aggressive - * @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=aggressive - * TestMetaspaceAllocationMT2 - */ - public class TestMetaspaceAllocationMT2 { public static void main(String[] args) throws Exception {