Pre-RFR 8236847 CDS archive with 4K alignment unusable on machines with 64k pages
Dmitry Samersoff
dms at samersoff.net
Sun Feb 23 16:35:55 UTC 2020
Hello Ioi,
Sorry for delay.
Patched version of JVM that was build on a machine with 4k page and than
moved to 64k one crashes on java -version.
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error
(/root/dsamersoff/esc/appcds/Alignment/jdk/src/hotspot/share/memory/metaspaceShared.cpp:2214),
pid=50272, tid=50273
# assert(is_aligned(end_offset, os::vm_allocation_granularity()))
failed: must be
#
# JRE version: (15.0) (fastdebug build )
# Java VM: OpenJDK 64-Bit Server VM (fastdebug
15-internal+0-adhoc.root.jdk, mixed mode, sharing, tiered, compressed
oops, g1 gc, linux-aarch64)
# Problematic frame:
# V [libjvm.so+0x102df78]
MetaspaceShared::reserve_address_space_for_archives(FileMapInfo*,
FileMapInfo*, bool, ReservedSpace&, ReservedSpace&, ReservedSpace&)+0x3d8
#
# Core dump will be written. Default location:
/home/dsamersoff/jdk/build/linux-aarch64-server-fastdebug/images/core
#
#
--------------- S U M M A R Y ------------
Command Line:
Host: SBR2s-77, AArch64, 256 cores, 1022G, Ubuntu 18.04.3 LTS
Time: Sun Feb 23 08:25:20 2020 PST elapsed time: 0 seconds (0d 0h 0m 0s)
--------------- T H R E A D ---------------
Current thread (0x0000ffff50032800): JavaThread "Unknown thread"
[_thread_in_vm, id=50273, stack(0x0000ffff57760000,0x0000ffff57960000)]
Stack: [0x0000ffff57760000,0x0000ffff57960000], sp=0x0000ffff5795e320,
free space=2040k
Native frames: (J=compiled Java code, A=aot compiled Java code,
j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x102df78]
MetaspaceShared::reserve_address_space_for_archives(FileMapInfo*,
FileMapInfo*, bool, ReservedSpace&, ReservedSpace&, ReservedSpace&)+0x3d8
V [libjvm.so+0x1030124] MetaspaceShared::map_archives(FileMapInfo*,
FileMapInfo*, bool)+0x104
V [libjvm.so+0x1030540]
MetaspaceShared::initialize_runtime_shared_and_meta_spaces()+0x48
V [libjvm.so+0x102731c] Metaspace::global_initialize()+0x35c
V [libjvm.so+0x1429c20] universe_init()+0xf0
V [libjvm.so+0xb33710] init_globals()+0x58
V [libjvm.so+0x13e3e50] Threads::create_vm(JavaVMInitArgs*, bool*)+0x2b0
V [libjvm.so+0xc96d38] JNI_CreateJavaVM+0xc8
C [libjli.so+0x42ec] JavaMain+0x7c
C [libjli.so+0x7c5c] ThreadJavaMain+0xc
C [libpthread.so.0+0x7088] start_thread+0xb0
Registers:
R0 =
[error occurred during error reporting (printing registers, top of
stack, instructions near pc), id 0xe0000000, Internal Error
(/root/dsamersoff/esc/appcds/Alignment/jdk/src/hotspot/share/gc/shared/oopStorage.cpp:345)]
-Dmitry
On 14.02.2020 0:59, Ioi Lam wrote:
> Hi Calvin,
>
> Thanks for your review. I've updated the patch with comments from you
> and Dmitry:
> http://cr.openjdk.java.net/~iklam/jdk15/8236847-SharedRegionAlignment.v03-delta/
>
>
> - Ioi
>
> On 2/13/2020 10:23 AM, Calvin Cheung wrote:
>> Hi Ioi,
>>
>> The v02 patch looks good. Just couple of comments:
>>
>> 1. In dynamicArchive.cpp:
>>
>> 727 size_t total = estimate_archive_size() + 3 *
>> MetaspaceShared::region_alignment();
>>
>> I think you can use MetaspaceShared::num_core_region instead of 3.
>>
>> 2. The testDump() method is not used in SharedRegionAlignmentTest.java.
>>
>> I don't need to see another webrev for the above changes.
>>
>> thanks,
>>
>> Calvin
>>
>> On 1/30/20 1:02 PM, Ioi Lam wrote:
>>> Hi Dmitry,
>>>
>>> The goal of my patch is to make it possible to use the CDS archive
>>> anywhere regardless of the OS page size of the build machine. In my
>>> v01 patch, I added SharedRegionAlignment for flexibility, but I guess
>>> that's more of a hassle.
>>>
>>> Here's a simplified v02 patch that removes the SharedRegionAlignment
>>> flag:
>>>
>>> http://cr.openjdk.java.net/~iklam/jdk15/8236847-SharedRegionAlignment.v02/
>>>
>>>
>>> Now, on AARCH64, we always dump with 64K alignment, even if the host
>>> has 4K pages -- see MetaspaceShared::init_alignments(). At run time,
>>> the check in MetaspaceShared::map_archive() is relaxed to allow
>>> mapping of 64K-aligned archives on a host with 4K page size.
>>>
>>> Could you try this and see if it works for you?
>>>
>>> I don't have access to aarch64 hosts with 64k pages, so I tested on
>>> x64 by changing the #if line in init_alignments to "#if 1". All tests
>>> passed.
>>>
>>> Thanks
>>> - Ioi
>>>
>>>
>>> On 1/30/20 12:34 AM, Dmitry Samersoff wrote:
>>>> Hello Ioi,
>>>>
>>>> I'm not sure that explicit specification of
>>>> SharedRegionAlignment=64k helps. The goal is to build JDK on a
>>>> build machine then use it smoothly on different test/production
>>>> machines with both 4k and 64k pages, ever if it's the same JDK that
>>>> resides in a shared network location.
>>>>
>>>> For a long term we may consider to revisit entire logic of default
>>>> archive dumping and dump CDS archive of JDK classes on the first JVM
>>>> run to $HOME/.cache but it requires more work and is out of scope of
>>>> this issue.
>>>>
>>>> So as a short term solution I would propose to implement following
>>>> logic:
>>>>
>>>> 1. Without any parameters
>>>>
>>>> - try to use existing CDS archive
>>>>
>>>> - if alignment doesn't match - disable CDS and continue execution.
>>>>
>>>> - if debug or fastdebug - issue a meaningful warning.
>>>>
>>>> 2. With explicit -Xshare:auto or -Xshare:on
>>>>
>>>> - try to use existing CDS archive
>>>>
>>>> - if alignment doesn't match - terminate VM with meaningful
>>>> message.
>>>>
>>>> -Dmitry
>>>>
>>>>
>>>> On 29.01.20 08:37, Ioi Lam wrote:
>>>>> https://bugs.openjdk.java.net/browse/JDK-8236847
>>>>> http://cr.openjdk.java.net/~iklam/jdk15/8236847-SharedRegionAlignment.v01/
>>>>>
>>>>>
>>>>> Hi Dmitry,
>>>>>
>>>>> Here's a proposal to make it possible to generate CDS archives that
>>>>> can be used on machines with different OS page alignments: generate
>>>>> the CDS archive with
>>>>>
>>>>> java -Xshare:dump -XX:SharedRegionAlignment=64k
>>>>>
>>>>> I want to be conservative, as this seems to affect only
>>>>> Linux/aarch64, so I have limited the range of this flag to be no
>>>>> more than 64KB. You can see checks for other invalid values in the
>>>>> new test case.
>>>>>
>>>>> If SharedRegionAlignment is not specified (as for most platforms),
>>>>> os::vm_allocation_granularity() will be used.
>>>>>
>>>>> For simplicity, -XX:SharedRegionAlignment can only be set when
>>>>> dumping the base archive (-Xshare:dump). The dynamic archive
>>>>> (-XX:DynamicDumpSharedSpaces) will always use the value as stored
>>>>> in the base archive.
>>>>>
>>>>> Please let me know if this solution will work for your situation.
>>>>> If so, I will file a CSR for the new flag and also write more test
>>>>> cases.
>>>>>
>>>>> (Also, the default CDS archive is created at JDK build time. I'll
>>>>> leave it to the ARM porting folks to do the makefile changes to
>>>>> pass the
>>>>> -XX:SharedRegionAlignment=64k flag to BUILD_CDS_ARCHIVE in Images.gmk)
>>>>>
>>>>> Thanks
>>>>> - Ioi
>>>
>
More information about the hotspot-runtime-dev
mailing list