8325132: CDS: Make sure the ArchiveRelocationMode is always printed in the log

Reviewed-by: shade, iklam
This commit is contained in:
Calvin Cheung 2025-03-27 15:34:56 +00:00
parent 50ac24eb0f
commit 2eeda64632
4 changed files with 18 additions and 8 deletions

View File

@ -1134,6 +1134,8 @@ void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() {
log_info(cds)("Core region alignment: %zu", static_mapinfo->core_region_alignment());
dynamic_mapinfo = open_dynamic_archive();
log_info(cds)("ArchiveRelocationMode: %d", ArchiveRelocationMode);
// First try to map at the requested address
result = map_archives(static_mapinfo, dynamic_mapinfo, true);
if (result == MAP_ARCHIVE_MMAP_FAILURE) {

View File

@ -61,8 +61,8 @@ public class ArchiveRelocationTest {
String appJar = ClassFileInstaller.getJarPath("hello.jar");
String mainClass = "Hello";
String forceRelocation = "-XX:ArchiveRelocationMode=1";
String runRelocArg = run_reloc ? forceRelocation : "-showversion";
String maybeRelocation = "-XX:ArchiveRelocationMode=0";
String runRelocArg = run_reloc ? "-showversion" : maybeRelocation;
String logArg = "-Xlog:cds=debug,cds+reloc=debug,cds+heap";
String unlockArg = "-XX:+UnlockDiagnosticVMOptions";
String nmtArg = "-XX:NativeMemoryTracking=detail";
@ -75,7 +75,10 @@ public class ArchiveRelocationTest {
TestCommon.run("-cp", appJar, unlockArg, runRelocArg, logArg, mainClass)
.assertNormalExit(output -> {
if (run_reloc) {
output.shouldContain("Try to map archive(s) at an alternative address");
output.shouldContain("ArchiveRelocationMode == 1: always map archive(s) at an alternative address")
.shouldContain("Try to map archive(s) at an alternative address");
} else {
output.shouldContain("ArchiveRelocationMode: 0");
}
});
}

View File

@ -128,14 +128,14 @@ public class TestSerialGCWithCDS {
"Hello");
out.shouldNotContain(errMsg);
System.out.println("2. Exec with " + execGC + " and test ArchiveRelocationMode");
System.out.println("2. Exec with " + execGC + " and test ArchiveRelocationMode=0");
out = TestCommon.exec(helloJar,
execGC,
small1,
small2,
coops,
"-Xlog:cds,cds+heap",
"-XX:ArchiveRelocationMode=1", // always relocate shared metadata
"-XX:ArchiveRelocationMode=0", // may relocate shared metadata
"Hello");
out.shouldNotContain(errMsg);

View File

@ -79,9 +79,9 @@ public class DynamicArchiveRelocationTest extends DynamicArchiveTestBase {
String appJar = ClassFileInstaller.getJarPath("hello.jar");
String mainClass = "Hello";
String forceRelocation = "-XX:ArchiveRelocationMode=1";
String dumpTopRelocArg = dump_top_reloc ? forceRelocation : "-showversion";
String runRelocArg = run_reloc ? forceRelocation : "-showversion";
String maybeRelocation = "-XX:ArchiveRelocationMode=0";
String dumpTopRelocArg = dump_top_reloc ? "-showversion" : maybeRelocation;
String runRelocArg = run_reloc ? "-showversion" : maybeRelocation;
String logArg = "-Xlog:cds=debug,cds+reloc=debug";
String baseArchiveName = getNewArchiveName("base");
@ -89,6 +89,7 @@ public class DynamicArchiveRelocationTest extends DynamicArchiveTestBase {
String runtimeMsg = "Try to map archive(s) at an alternative address";
String unlockArg = "-XX:+UnlockDiagnosticVMOptions";
String relocationModeMsg = "ArchiveRelocationMode: 0";
// (1) Dump base archive (static)
@ -105,6 +106,8 @@ public class DynamicArchiveRelocationTest extends DynamicArchiveTestBase {
.assertNormalExit(output -> {
if (dump_top_reloc) {
output.shouldContain(runtimeMsg);
} else {
output.shouldContain(relocationModeMsg);
}
});
@ -116,6 +119,8 @@ public class DynamicArchiveRelocationTest extends DynamicArchiveTestBase {
.assertNormalExit(output -> {
if (run_reloc) {
output.shouldContain(runtimeMsg);
} else {
output.shouldContain(relocationModeMsg);
}
});
}