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

Ioi Lam iklam at openjdk.java.net
Wed Feb 24 00:47:39 UTC 2021


On Tue, 23 Feb 2021 17:50:42 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>>> > How about changing the code to
>>> > ```
>>> >   if (DumpSharedSpaces) {
>>> >     _core_region_alignment = (size_t)os::vm_allocation_granularity();
>>> > #if (defined(LINUX) && defined(AARCH64)) || defined(__APPLE__)
>>> >     // If you create a CDS archive on one machine, and use it on another, and the two
>>> >     // machines have different page sizes, make sure the archive can be used
>>> >     // on both machines.
>>> >     // 
>>> >     // (a) Linux/aarch64 can be configured to have either 4KB or 64KB page sizes.
>>> >     // (b) macOS/x64 uses 4KB, but macOS/aarch64 uses 64KB (note: you can run an x64 JDK
>>> >     //     on an M1-based MacBook using Rosetta).
>>> >     if (_core_region_alignment < 64*K) {
>>> >       log_info(cds)("Force core region alignment to 64K");
>>> >       _core_region_alignment = 64*K;
>>> >     }
>>> > #endif
>>> >   } else {
>>> > ```
>>> 
>>> Yes. Good comments too.
>>> 
>>> I guess on Windows this does not matter, since allocation granularity is 64k anyway?
>> 
>> Is?
>> `#if (defined(LINUX) || defined(__APPLE__)) &&  defined(AARCH64)
>> or
>> #if (defined(LINUX) && defined(AARCH64)) || defined(__APPLE__)`
>
>> I guess on Windows this does not matter, since allocation granularity is 64k anyway?
> 
> I haven't heard of requirements to run Windows binaries across CPUs (in the style of Rosetta), so I guess we don't need to worry about it for now.

> _Mailing list message from [David Holmes](mailto:david.holmes at oracle.com) on [hotspot-runtime-dev](mailto:hotspot-runtime-dev at openjdk.java.net):_
> 
> On 24/02/2021 3:50 am, Ioi Lam wrote:
> 
> > On Tue, 23 Feb 2021 17:32:44 GMT, Yumin Qi <minqi at openjdk.org> wrote:
> > > Is?
> > > `#if (defined(LINUX) || defined(__APPLE__)) && defined(AARCH64) or #if (defined(LINUX) && defined(AARCH64)) || defined(__APPLE__)`
> > 
> > 
> > Actually, I think we should use
> > #if (defined(LINUX) && defined(AARCH64)) || (defined(__APPLE__) && defined(AMD64))`
> > For the macOS case, we are running an AMD64 binary inside Rosetta.
> > We don't need to worry about `(defined(__APPLE__) && defined(AARCH64))` because we cannot run M1 binaries on AMD64.
> 
> I'm confused. Is this about running binaries on different architectures
> or running binaries on machines with different page sizes? Or both? 

The latter.

The macOS case is logically running on the same architecture (AMD64), except one of them is a *real* AMD64, and the second one is emulated AMD64 on M1 silicon. As far as the JVM knows, it runs on AMD64.

> If
> the M1 machines support 4K or 64K then they would need this change - no?

No, M1 macs always use 64KB pages. You cannot execute macOS/aarch64 binaries on macOS/AMD.

> Regardless I'd rather see this hidden by some abstraction that captures
> whether a given platform supports multiple sizes rather than these
> explicit ifdefs.

How about a function like:

    os::cds_core_region_alignment()

This function would return 64KB in the affected cases, and os::vm_allocation_granularity() otherwise.
 
> Thanks,
> David

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

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


More information about the hotspot-runtime-dev mailing list