RFR: 8291106: ZPlatformGranuleSizeShift is redundant due to it can not be modified
Leslie Zhai
lzhai at openjdk.org
Wed Jul 27 07:39:46 UTC 2022
On Thu, 21 Jul 2022 02:17:33 GMT, Leslie Zhai <lzhai at openjdk.org> wrote:
> Hi,
>
> When I am tunning `ZPageSizeSmall` to 16 MB from 2MB:
>
>
> const size_t ZPlatformGranuleSizeShift = 24; // 16MB
>
> // Granule shift/size
> const size_t ZGranuleSizeShift = ZPlatformGranuleSizeShift;
>
> // Page size shifts
> const size_t ZPageSizeSmallShift = ZGranuleSizeShift;
>
> // Page sizes
> const size_t ZPageSizeSmall = (size_t)1 << ZPageSizeSmallShift;
>
>
> `zBitField` failed to work:
>
>
> Internal Error
> (/home/zhaixiang/jdk/src/hotspot/share/gc/z/zBitField.hpp:76), pid=923047, tid=923069
> # assert(((ContainerType)value & (FieldMask << ValueShift)) == (ContainerType)value) failed: Invalid value
> #
> # JRE version: OpenJDK Runtime Environment (20.0) (fastdebug build 20-internal-adhoc.root.jdk)
> # Java VM: OpenJDK 64-Bit Server VM (fastdebug 20-internal-adhoc.root.jdk, mixed mode, sharing, tiered, compressed class ptrs, z gc, linux-aarch64)
>
>
> Perhaps `mask` also need to be adjusted:
>
>
> static size_t object_index(oop obj) {
> const uintptr_t addr = ZOop::to_address(obj);
> const uintptr_t offset = ZAddress::offset(addr);
> const uintptr_t mask = ZGranuleSize - 1;
> return (offset & mask) >> ZObjectAlignmentSmallShift;
> }
>
>
> Back to the point: ZPlatformGranuleSizeShift is redundant due to it can not be modified, for example, `24`, so I removed the `ZPlatformGranuleSizeShift` from cpu backends, just keep it for debugging AArch64 to see the issue.
>
> Please review my patch.
>
> Thanks,
> Leslie Zhai
Hi Erik,
Thanks for your response!
> Do you have an AArch64 CPU that does not support 2M large pages, but does support 16M large pages?
Yup:
./build/linux-aarch64-server-fastdebug/images/jdk/bin/java -Xlog:gc*=debug -XX:+UseZGC -version
[0.007s][debug][gc,heap] Minimum heap 16777216 Initial heap 2147483648 Maximum heap 32178700288
[0.007s][info ][gc,init] Initializing The Z Garbage Collector
[0.007s][info ][gc,init] Version: 20-internal-adhoc.root.jdk (fastdebug)
[0.007s][info ][gc,init] Probing address space for the highest valid bit: 47
[0.007s][info ][gc,init] NUMA Support: Enabled
[0.007s][info ][gc,init] NUMA Nodes: 4
[0.007s][info ][gc,init] CPUs: 96 total, 96 available
[0.007s][info ][gc,init] Memory: 292969M
[0.007s][info ][gc,init] Large Page Support: Disabled
[0.007s][info ][gc,init] GC Workers: 24 (dynamic)
[0.009s][info ][gc,init] Address Space Type: Contiguous/Unrestricted/Complete
[0.009s][info ][gc,init] Address Space Size: 491008M x 3 = 1473024M
[0.009s][info ][gc,init] Heap Backing File: /memfd:java_heap
[0.009s][info ][gc,init] Heap Backing Filesystem: tmpfs (0x1021994)
[0.009s][info ][gc,init] Min Capacity: 16M
[0.009s][info ][gc,init] Initial Capacity: 2048M
[0.009s][info ][gc,init] Max Capacity: 30688M
[0.009s][info ][gc,init] Medium Page Size: 256M
[0.009s][info ][gc,init] Pre-touch: Disabled
[0.009s][info ][gc,init] Available space on backing filesystem: N/A
[0.009s][info ][gc,init] Uncommit: Enabled
[0.009s][info ][gc,init] Uncommit Delay: 300s
[0.036s][debug][gc,marking] Expanding mark stack space: 0M->32M
[0.036s][info ][gc,init ] Runtime Workers: 38
[0.039s][info ][gc ] Using The Z Garbage Collector
[0.039s][info ][gc,metaspace] CDS archive(s) mapped at: [0x0000000800000000-0x0000000800cf0000-0x0000000800cf0000), size 13565952, SharedBaseAddress: 0x0000000800000000, ArchiveRelocationMode: 0.
[0.039s][info ][gc,metaspace] Compressed class space mapped at: 0x0000000801000000-0x0000000841000000, reserved size: 1073741824
[0.039s][info ][gc,metaspace] Narrow klass base: 0x0000000800000000, Narrow klass shift: 0, Narrow klass range: 0x100000000
[0.088s][debug][gc,heap ] Uncommit Timeout: 301s
[0.094s][debug][gc,nmethod ] Rebuilding NMethod Table: 0->1024 entries, 0(0%->0%) registered, 0(0%->0%) unregistered
openjdk version "20-internal" 2023-03-21
OpenJDK Runtime Environment (fastdebug build 20-internal-adhoc.root.jdk)
OpenJDK 64-Bit Server VM (fastdebug build 20-internal-adhoc.root.jdk, mixed mode, sharing)
[0.132s][info ][gc,heap,exit] Heap
[0.132s][info ][gc,heap,exit] ZHeap used 16M, capacity 2048M, max capacity 30688M
[0.132s][info ][gc,heap,exit] Metaspace used 130K, committed 256K, reserved 1114112K
[0.132s][info ][gc,heap,exit] class space used 2K, committed 64K, reserved 1048576K
Created file descriptor successfully, see goto `Heap Backing File` line indicated from above xlog:
int ZPhysicalMemoryBacking::create_mem_fd(const char* name) const {
#ifdef AARCH64
assert(ZGranuleSize == 16 * M, "Granule size must match MFD_HUGE_16MB");
#else
assert(ZGranuleSize == 2 * M, "Granule size must match MFD_HUGE_2MB");
#endif
// Create file name
char filename[PATH_MAX];
snprintf(filename, sizeof(filename), "%s%s", name, ZLargePages::is_explicit() ? ".hugetlb" : "");
// Create file
#ifdef AARCH64
const int extra_flags = ZLargePages::is_explicit() ? (MFD_HUGETLB | MFD_HUGE_16MB) : 0;
#else
const int extra_flags = ZLargePages::is_explicit() ? (MFD_HUGETLB | MFD_HUGE_2MB) : 0;
#endif
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 || err == ENODEV)) ?
"Hugepages (2M) not available" : err.to_string());
return -1;
}
=> log_info_p(gc, init)("Heap Backing File: /memfd:%s", filename);
return fd;
}
> what is the actual problem that you are trying to solve?
Back to the topic: I just want to remove the `ZPlatformGranuleSizeShift` from cpu backends. And I will update the patch about AArch64 debugging part.
Thanks,
Leslie Zhai
-------------
PR: https://git.openjdk.org/jdk/pull/9582
More information about the hotspot-gc-dev
mailing list