RFR: 8236847: CDS archive with 4K alignment unusable on machines with 64k pages [v2]

Nick Gasson ngasson at openjdk.java.net
Wed Feb 24 02:21:44 UTC 2021


On Tue, 23 Feb 2021 21:41:07 GMT, Yumin Qi <minqi at openjdk.org> wrote:

>> Hi, Please review
>>   Usually most OSes are configured with page size of 4K, but some others are configured with 64K. If jdk binary is built on 4K platform and run on different configured platforms, CDS fails to be loaded due to region alignment mismatch:
>>   Unable to map CDS archive -- os::vm_allocation_granularity() expected: 4096 actual: 65536
>>   This change uses 64K as region alignment if OS page size is less than 64K. For most of the current OSes, means always use 64K as file map region alignment.
>>    The archive size will increase about 300K due to the change. 
>>    Tests: tier1-4
>>               Run MacOS/X64 binary on MacOS/aarch64 
>> 
>>    Thanks
>>    Yumin
>
> Yumin Qi has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Make 64K core region alignment only for specific platforms, also fixed comments as suggestions.

src/hotspot/share/memory/metaspaceShared.cpp line 137:

> 135:     // (a) Linux/aarch64 can be configured to have either 4KB or 64KB page sizes.
> 136:     // (b) macOS/x64 uses 4KB, but macOS/aarch64 uses 64KB (note: you can run a x64 JDK
> 137:     //     on a M1-based MacBook using Rosetta).

I think the page size on Apple silicon Macs is 16KB not 64KB:

$ sysctl vm.pagesize
vm.pagesize: 16384

This is also the value reported by `sun.misc.Unsafe.pageSize()` with a native JDK. Although some Linux distributions use a 64KB page size so rounding up is probably the right thing to do.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2651


More information about the hotspot-runtime-dev mailing list