mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8273872: ZGC: Explicitly use 2M large pages
Reviewed-by: eosterlund, tschatzl, stefank
This commit is contained in:
parent
54b456764b
commit
1890d85c0e
@ -58,6 +58,9 @@
|
||||
#ifndef MFD_HUGETLB
|
||||
#define MFD_HUGETLB 0x0004U
|
||||
#endif
|
||||
#ifndef MFD_HUGE_2MB
|
||||
#define MFD_HUGE_2MB 0x54000000U
|
||||
#endif
|
||||
|
||||
// open(2) flags
|
||||
#ifndef O_CLOEXEC
|
||||
@ -175,12 +178,6 @@ ZPhysicalMemoryBacking::ZPhysicalMemoryBacking(size_t max_capacity) :
|
||||
return;
|
||||
}
|
||||
|
||||
if (ZLargePages::is_explicit() && os::large_page_size() != ZGranuleSize) {
|
||||
log_error_p(gc)("Incompatible large page size configured " SIZE_FORMAT " (expected " SIZE_FORMAT ")",
|
||||
os::large_page_size(), ZGranuleSize);
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the filesystem block size is compatible
|
||||
if (ZGranuleSize % _block_size != 0) {
|
||||
log_error_p(gc)("Filesystem backing the heap has incompatible block size (" SIZE_FORMAT ")",
|
||||
@ -199,17 +196,20 @@ ZPhysicalMemoryBacking::ZPhysicalMemoryBacking(size_t max_capacity) :
|
||||
}
|
||||
|
||||
int ZPhysicalMemoryBacking::create_mem_fd(const char* name) const {
|
||||
assert(ZGranuleSize == 2 * M, "Granule size must match MFD_HUGE_2MB");
|
||||
|
||||
// Create file name
|
||||
char filename[PATH_MAX];
|
||||
snprintf(filename, sizeof(filename), "%s%s", name, ZLargePages::is_explicit() ? ".hugetlb" : "");
|
||||
|
||||
// Create file
|
||||
const int extra_flags = ZLargePages::is_explicit() ? MFD_HUGETLB : 0;
|
||||
const int extra_flags = ZLargePages::is_explicit() ? (MFD_HUGETLB | MFD_HUGE_2MB) : 0;
|
||||
const int fd = ZSyscall::memfd_create(filename, MFD_CLOEXEC | extra_flags);
|
||||
if (fd == -1) {
|
||||
ZErrno err;
|
||||
log_debug_p(gc, init)("Failed to create memfd file (%s)",
|
||||
((ZLargePages::is_explicit() && err == EINVAL) ? "Hugepages not supported" : err.to_string()));
|
||||
(ZLargePages::is_explicit() && (err == EINVAL || err == ENODEV)) ?
|
||||
"Hugepages (2M) not available" : err.to_string());
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ ZErrno ZPhysicalMemoryBacking::fallocate_compat_mmap_tmpfs(size_t offset, size_t
|
||||
}
|
||||
|
||||
// Advise mapping to use transparent huge pages
|
||||
os::realign_memory((char*)addr, length, os::large_page_size());
|
||||
os::realign_memory((char*)addr, length, ZGranuleSize);
|
||||
|
||||
// Touch the mapping (safely) to make sure it's backed by memory
|
||||
const bool backed = safe_touch_mapping(addr, length, _block_size);
|
||||
|
||||
@ -72,6 +72,13 @@ void ZArguments::initialize() {
|
||||
vm_exit_during_initialization("The flag -XX:+UseZGC can not be combined with -XX:ConcGCThreads=0");
|
||||
}
|
||||
|
||||
// Large page size must match granule size
|
||||
if (!FLAG_IS_DEFAULT(LargePageSizeInBytes) && LargePageSizeInBytes != ZGranuleSize) {
|
||||
vm_exit_during_initialization(err_msg("Incompatible -XX:LargePageSizeInBytes, only "
|
||||
SIZE_FORMAT "M large pages are supported by ZGC",
|
||||
ZGranuleSize / M));
|
||||
}
|
||||
|
||||
// The heuristics used when UseDynamicNumberOfGCThreads is
|
||||
// enabled defaults to using a ZAllocationSpikeTolerance of 1.
|
||||
if (UseDynamicNumberOfGCThreads && FLAG_IS_DEFAULT(ZAllocationSpikeTolerance)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user