On Wed, 24 Feb 2021 18:46:06 GMT, Ioi Lam <ik...@openjdk.org> wrote:

>>> Thanks for review! Currently linux-aarch64, macos-aarch64(I don't know AIX) 
>>> can be configured with 4K/64K page size. To make one build compatible with 
>>> both, this change takes the 64K (or bigger) as the default region 
>>> alignment. It is hard to make it optional I think. Will check the 
>>> possibility of more options.
>> 
>> It's not even slightly hard to make it optional. It should be a build-time 
>> configure argument. In many cases there is no need to make one build 
>> compatible with both 64k and 4k. If you'd like the default to be 64k I'm 
>> fine with that, but it should be possible to build with 4k alignment.
>
>> > Thanks for review! Currently linux-aarch64, macos-aarch64(I don't know 
>> > AIX) can be configured with 4K/64K page size. To make one build compatible 
>> > with both, this change takes the 64K (or bigger) as the default region 
>> > alignment. It is hard to make it optional I think. Will check the 
>> > possibility of more options.
>> 
>> It's not even slightly hard to make it optional. It should be a build-time 
>> configure argument. In many cases there is no need to make one build 
>> compatible with both 64k and 4k. If you'd like the default to be 64k I'm 
>> fine with that, but it should be possible to build with 4k alignment.
> 
> How about this. We add a configure option like:
> 
> bash configure --with-cds-core-region-alignment=65536
> 
> and 
> 
> size_t MetaspaceShared::reserved_space_alignment()  {
> #ifdef CDS_CORE_REGION_ALIGNMENT
>   return CDS_CORE_REGION_ALIGNMENT;
> #else 
>   os::vm_allocation_granularity();
> #endif
> }
> 
> When we create or map the CDS archive, we need to ensure that the configured 
> value is compatible with `os::vm_allocation_granularity()`, with something 
> like:
> 
> if (MetaspaceShared::reserved_space_alignment() < 
> os::vm_allocation_granularity() ||
>     (MetaspaceShared::reserved_space_alignment() % 
> os::vm_allocation_granularity()) != 0) {
>     fail("CDS is disabled because ......");
> }

Before this fix, the alignment is defaulting to that of the build host. We 
would like to provide a way to produce a JDK distribution, with a pre generated 
CDS archive, where the alignment has the highest known value of any target host 
for maximum compatibility. The currently known such values are 64K for Linux 
and 16K for Mac. If we aren't going to allow the user (builder of OpenJDK) the 
free choice of any alignment anyway, would it make sense to limit the choice 
between something more abstract like "host" and "compatible" instead of listing 
explicit numbers?

Regardless of how the option is constructed, it will need some explanation in 
doc/building.md.

Finally there is the question of if "host" or "compatible" should be the 
default. I see good arguments for both sides, as long as there is an option to 
switch between the too that isn't too cryptic to understand.

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

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

Reply via email to