< prev index next >
src/hotspot/os/posix/os_posix.cpp
Print this page
*** 237,247 ****
return posix_fallocate(fd, offset, len);
#endif
}
// Map the given address range to the provided file descriptor.
! char* os::map_memory_to_dax_file(char* base, size_t size, int fd) {
assert(fd != -1, "File descriptor is not valid");
// allocate space for the file
if (util_posix_fallocate(fd, 0, (off_t)size) != 0) {
vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory."));
--- 237,247 ----
return posix_fallocate(fd, offset, len);
#endif
}
// Map the given address range to the provided file descriptor.
! char* os::map_memory_to_file(char* base, size_t size, int fd) {
assert(fd != -1, "File descriptor is not valid");
// allocate space for the file
if (util_posix_fallocate(fd, 0, (off_t)size) != 0) {
vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory."));
*** 265,279 ****
return NULL;
}
return addr;
}
! char* os::replace_existing_mapping_with_dax_file_mapping(char* base, size_t size, int fd) {
assert(fd != -1, "File descriptor is not valid");
assert(base != NULL, "Base cannot be NULL");
! return map_memory_to_dax_file(base, size, fd);
}
// Multiple threads can race in this code, and can remap over each other with MAP_FIXED,
// so on posix, unmap the section at the start and at the end of the chunk that we mapped
// rather than unmapping and remapping the whole chunk to get requested alignment.
--- 265,279 ----
return NULL;
}
return addr;
}
! char* os::replace_existing_mapping_with_file_mapping(char* base, size_t size, int fd) {
assert(fd != -1, "File descriptor is not valid");
assert(base != NULL, "Base cannot be NULL");
! return map_memory_to_file(base, size, fd);
}
// Multiple threads can race in this code, and can remap over each other with MAP_FIXED,
// so on posix, unmap the section at the start and at the end of the chunk that we mapped
// rather than unmapping and remapping the whole chunk to get requested alignment.
*** 326,336 ****
os::release_memory(extra_base + begin_offset + size, end_offset);
}
if (file_desc != -1) {
// After we have an aligned address, we can replace anonymous mapping with file mapping
! if (replace_existing_mapping_with_dax_file_mapping(aligned_base, size, file_desc) == NULL) {
vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory"));
}
MemTracker::record_virtual_memory_commit((address)aligned_base, size, CALLER_PC);
}
return aligned_base;
--- 326,336 ----
os::release_memory(extra_base + begin_offset + size, end_offset);
}
if (file_desc != -1) {
// After we have an aligned address, we can replace anonymous mapping with file mapping
! if (replace_existing_mapping_with_file_mapping(aligned_base, size, file_desc) == NULL) {
vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory"));
}
MemTracker::record_virtual_memory_commit((address)aligned_base, size, CALLER_PC);
}
return aligned_base;
< prev index next >