Skip to content

8356807: Change log_info(cds) to MetaspaceShared::report_loading_error() #26253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletions src/hotspot/share/cds/filemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class FileHeaderHelper {
assert(_archive_name != nullptr, "Archive name is null");
_fd = os::open(_archive_name, O_RDONLY | O_BINARY, 0);
if (_fd < 0) {
aot_log_info(aot)("Specified %s not found (%s)", CDSConfig::type_of_archive_being_loaded(), _archive_name);
MetaspaceShared::report_loading_error("Specified %s not found (%s)", CDSConfig::type_of_archive_being_loaded(), _archive_name);
return false;
}
return initialize(_fd);
Expand Down Expand Up @@ -1218,8 +1218,8 @@ MapArchiveResult FileMapInfo::map_region(int i, intx addr_delta, char* mapped_ba
// can't mmap into a ReservedSpace, so we just ::read() the data. We're going to patch all the
// regions anyway, so there's no benefit for mmap anyway.
if (!read_region(i, requested_addr, size, /* do_commit = */ true)) {
aot_log_info(aot)("Failed to read %s shared space into reserved space at " INTPTR_FORMAT,
shared_region_name[i], p2i(requested_addr));
MetaspaceShared::report_loading_error("Failed to read %s shared space into reserved space at " INTPTR_FORMAT,
shared_region_name[i], p2i(requested_addr));
return MAP_ARCHIVE_OTHER_FAILURE; // oom or I/O error.
} else {
assert(r->mapped_base() != nullptr, "must be initialized");
Expand All @@ -1232,8 +1232,8 @@ MapArchiveResult FileMapInfo::map_region(int i, intx addr_delta, char* mapped_ba
requested_addr, size, r->read_only(),
r->allow_exec(), mtClassShared);
if (base != requested_addr) {
aot_log_info(aot)("Unable to map %s shared space at " INTPTR_FORMAT,
shared_region_name[i], p2i(requested_addr));
MetaspaceShared::report_loading_error("Unable to map %s shared space at " INTPTR_FORMAT,
shared_region_name[i], p2i(requested_addr));
_memory_mapping_failed = true;
return MAP_ARCHIVE_MMAP_FAILURE;
}
Expand Down Expand Up @@ -1298,8 +1298,8 @@ bool FileMapInfo::map_aot_code_region(ReservedSpace rs) {
char* mapped_base;
if (MetaspaceShared::use_windows_memory_mapping()) {
if (!read_region(MetaspaceShared::ac, requested_base, r->used_aligned(), /* do_commit = */ true)) {
aot_log_info(aot)("Failed to read aot code shared space into reserved space at " INTPTR_FORMAT,
p2i(requested_base));
MetaspaceShared::report_loading_error("Failed to read aot code shared space into reserved space at " INTPTR_FORMAT,
p2i(requested_base));
return false;
}
mapped_base = requested_base;
Expand All @@ -1311,7 +1311,7 @@ bool FileMapInfo::map_aot_code_region(ReservedSpace rs) {
requested_base, r->used_aligned(), read_only, allow_exec, mtClassShared);
}
if (mapped_base == nullptr) {
aot_log_info(aot)("failed to map aot code region");
MetaspaceShared::report_loading_error("failed to map aot code region");
return false;
} else {
assert(mapped_base == requested_base, "must be");
Expand Down Expand Up @@ -1687,9 +1687,9 @@ bool FileMapInfo::map_heap_region_impl() {
r->allow_exec(), mtJavaHeap);
if (base == nullptr || base != addr) {
dealloc_heap_region();
aot_log_info(aot)("UseSharedSpaces: Unable to map at required address in java heap. "
INTPTR_FORMAT ", size = %zu bytes",
p2i(addr), _mapped_heap_memregion.byte_size());
MetaspaceShared::report_loading_error("UseSharedSpaces: Unable to map at required address in java heap. "
INTPTR_FORMAT ", size = %zu bytes",
p2i(addr), _mapped_heap_memregion.byte_size());
return false;
}

Expand Down Expand Up @@ -1925,16 +1925,16 @@ int FileMapHeader::compute_crc() {
bool FileMapHeader::validate() {
const char* file_type = CDSConfig::type_of_archive_being_loaded();
if (_obj_alignment != ObjectAlignmentInBytes) {
aot_log_info(aot)("The %s's ObjectAlignmentInBytes of %d"
" does not equal the current ObjectAlignmentInBytes of %d.",
file_type, _obj_alignment, ObjectAlignmentInBytes);
MetaspaceShared::report_loading_error("The %s's ObjectAlignmentInBytes of %d"
" does not equal the current ObjectAlignmentInBytes of %d.",
file_type, _obj_alignment, ObjectAlignmentInBytes);
return false;
}
if (_compact_strings != CompactStrings) {
aot_log_info(aot)("The %s's CompactStrings setting (%s)"
" does not equal the current CompactStrings setting (%s).", file_type,
_compact_strings ? "enabled" : "disabled",
CompactStrings ? "enabled" : "disabled");
MetaspaceShared::report_loading_error("The %s's CompactStrings setting (%s)"
" does not equal the current CompactStrings setting (%s).", file_type,
_compact_strings ? "enabled" : "disabled",
CompactStrings ? "enabled" : "disabled");
return false;
}
bool jvmci_compiler_is_enabled = CompilerConfig::is_jvmci_compiler_enabled();
Expand Down Expand Up @@ -2018,8 +2018,9 @@ bool FileMapHeader::validate() {
const char* prop = Arguments::get_property("java.system.class.loader");
if (prop != nullptr) {
if (has_aot_linked_classes()) {
aot_log_error(aot)("%s has aot-linked classes. It cannot be used when the "
"java.system.class.loader property is specified.", CDSConfig::type_of_archive_being_loaded());
MetaspaceShared::report_loading_error("%s has aot-linked classes. It cannot be used when the "
Copy link
Contributor

Choose a reason for hiding this comment

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

The alignment was changed here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Line 2022 already ends at column 115. If I indent it more to the right to align with line 2021, the line will end past column 125. I will leave it as is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed the indent per our offline discussion.

"java.system.class.loader property is specified.",
CDSConfig::type_of_archive_being_loaded());
return false;
}
aot_log_warning(aot)("Archived non-system classes are disabled because the "
Expand All @@ -2031,10 +2032,10 @@ bool FileMapHeader::validate() {

if (!_verify_local && BytecodeVerificationLocal) {
// we cannot load boot classes, so there's no point of using the CDS archive
aot_log_info(aot)("The %s's BytecodeVerificationLocal setting (%s)"
" does not equal the current BytecodeVerificationLocal setting (%s).", file_type,
_verify_local ? "enabled" : "disabled",
BytecodeVerificationLocal ? "enabled" : "disabled");
MetaspaceShared::report_loading_error("The %s's BytecodeVerificationLocal setting (%s)"
" does not equal the current BytecodeVerificationLocal setting (%s).", file_type,
_verify_local ? "enabled" : "disabled",
BytecodeVerificationLocal ? "enabled" : "disabled");
return false;
}

Expand All @@ -2055,8 +2056,8 @@ bool FileMapHeader::validate() {
// Note: _allow_archiving_with_java_agent is set in the shared archive during dump time
// while AllowArchivingWithJavaAgent is set during the current run.
if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
aot_log_warning(aot)("The setting of the AllowArchivingWithJavaAgent is different "
"from the setting in the %s.", file_type);
MetaspaceShared::report_loading_error("The setting of the AllowArchivingWithJavaAgent is different "
"from the setting in the %s.", file_type);
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/cds/metaspaceShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,20 +1428,20 @@ FileMapInfo* MetaspaceShared::open_dynamic_archive() {
MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, FileMapInfo* dynamic_mapinfo,
bool use_requested_addr) {
if (use_requested_addr && static_mapinfo->requested_base_address() == nullptr) {
aot_log_info(aot)("Archive(s) were created with -XX:SharedBaseAddress=0. Always map at os-selected address.");
report_loading_error("Archive(s) were created with -XX:SharedBaseAddress=0. Always map at os-selected address.");
return MAP_ARCHIVE_MMAP_FAILURE;
}

PRODUCT_ONLY(if (ArchiveRelocationMode == 1 && use_requested_addr) {
// For product build only -- this is for benchmarking the cost of doing relocation.
// For debug builds, the check is done below, after reserving the space, for better test coverage
// (see comment below).
aot_log_info(aot)("ArchiveRelocationMode == 1: always map archive(s) at an alternative address");
report_loading_error("ArchiveRelocationMode == 1: always map archive(s) at an alternative address");
return MAP_ARCHIVE_MMAP_FAILURE;
});

if (ArchiveRelocationMode == 2 && !use_requested_addr) {
aot_log_info(aot)("ArchiveRelocationMode == 2: never map archive(s) at an alternative address");
report_loading_error("ArchiveRelocationMode == 2: never map archive(s) at an alternative address");
return MAP_ARCHIVE_MMAP_FAILURE;
};

Expand Down
5 changes: 3 additions & 2 deletions test/hotspot/jtreg/runtime/cds/ServiceLoaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ public static void main(String[] args) throws Exception {
CDSTestUtils.createArchiveAndCheck(opts);

// Some mach5 tiers run with -vmoptions:-Xlog:cds=debug. This would cause the outputs to mismatch.
// Force the log level to warning for all tags to supressed the CDS logs. Also disable the timestamp.
// Force the log level to warning for all tags to suppress the CDS logs. Also disable the timestamp.
// Disable CDS error by turing off CDS logging.
opts.setUseVersion(false);
opts.addSuffix("-showversion", "-Xlog:all=warning::level,tags", "ServiceLoaderApp");
opts.addSuffix("-showversion", "-Xlog:all=warning::level,tags", "-Xlog:cds=off", "ServiceLoaderApp");
OutputAnalyzer out1 = CDSTestUtils.runWithArchive(opts);

opts.setXShareMode("off");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ private static void testArchivedModuleUsingImage(Path image)
customJava.toString(),
"-XX:SharedArchiveFile=./ArchivedModuleWithCustomImageTest.jsa",
"-Xshare:on",
"-Xlog:cds=off",
"--show-module-resolution",
"-version"};
printCommand(showModuleCmd2);
Expand Down