RFR: JDK-8318485: Narrow klass shift should be zero if encoding range extends to 0x1_0000_0000

Calvin Cheung ccheung at openjdk.org
Fri Oct 20 23:12:35 UTC 2023


On Thu, 19 Oct 2023 07:50:11 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> See JBS issue.
> 
> The real fix, trivial, is the comparison change in compressedKlass.cpp.
> 
> This patch then also adds a test that checks that for a given (forced) class space location the VM chose the correct encoding scheme. In this case, if class space nestles below and ends at 4G, we should use a shift of 0.
> 
> The test can be easily extended to test more narrow Klass encoding schemes. Note that the test is skipped if the VM could not map at the expected address to begin with.
> 
> Finally, to analyze test errors, I print out the mappings at the force address if metaspace logging is debug.
> 
> Tests: manual, GHA. x86 GHA errors unrelated.
> 
> 
> Attention @iklam and @calvinccheung

Thanks for fixing this. I've tried your patch on the CompressedClassPointers.java test. It also fixes the issue in [JDK-8317610](https://bugs.openjdk.org/browse/JDK-8317610). Just have a couple of minor comments.

src/hotspot/share/memory/metaspace.cpp line 791:

> 789:         if (lt.is_enabled()) {
> 790:           LogStream ls(lt);
> 791:           os::print_memory_mappings((char*)base, size, &ls);

I saw the above log message as follows:

java -XX:+UnlockDiagnosticVMOptions -XX:CompressedClassSpaceBaseAddress=0xa0000000 -XX:CompressedClassSpaceSize=1g -Xlog:metaspace=debug -Xlog:os+map=trace -Xshare:off -version
[0.001s][info][metaspace]  - commit_granule_bytes: 65536.
[0.001s][info][metaspace]  - commit_granule_words: 8192.
[0.001s][info][metaspace]  - virtual_space_node_default_size: 8388608.
[0.001s][info][metaspace]  - enlarge_chunks_in_place: 1.
[0.001s][info][metaspace]  - use_allocation_guard: 0.
[0.036s][debug][metaspace] Range [a0000000-e0000000) contains: 
[0.036s][debug][metaspace] a0000000-120000000 rw-p 00000000 00:00 0 
[0.036s][debug][metaspace] 
Error occurred during initialization of VM
CompressedClassSpaceBaseAddress=0x00000000a0000000 given, but reserving class space failed.

Is it easy to get rid of the blank line before the line begins with "Error occurred..."?

test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java line 78:

> 76:         test(4 * G - 128 * M, 128 * M, 0, 0);
> 77: 
> 78:         // add more...

The following works on my linux dev host.

        test(0xa0000000L, 1 * G, 0, 0);
        test(0x100000000L, 2 * G, 0, 3);

Maybe you can consider adding them to the test?

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

PR Review: https://git.openjdk.org/jdk/pull/16261#pullrequestreview-1690984404
PR Review Comment: https://git.openjdk.org/jdk/pull/16261#discussion_r1367541426
PR Review Comment: https://git.openjdk.org/jdk/pull/16261#discussion_r1367542125


More information about the hotspot-runtime-dev mailing list