battleblow / openjdk-jdk11u

BSD port of OpenJDK 11
GNU General Public License v2.0
9 stars 8 forks source link

XShare support not fully working on BSD #76

Open battleblow opened 5 years ago

battleblow commented 5 years ago

Only tested on FreeBSD so far. The test

test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java

fails. Relevant output appears to be

UseSharedSpaces: Unable to reserve shared space at required address 0x0000000819200000

battleblow commented 5 years ago

Note that the test runs three different commands.

The first command can be reproduced using (on a system that has built all of the test artifacts)

 ./build/bsd-x86_64-normal-server-release/images/jdk/bin/java -XX:+UnlockDiagnosticVMOptions -XX:SharedArchiveFile=./build/bsd-x86_64-normal-server-release/test-support/jtreg_test_hotspot_jtreg_tier1/runtime/CDSCompressedKPtrs/XShareAuto/XShareAuto.jsa -Xshare:dump

This appears to work correctly and contains the expected output.

The second command can be reproduced with:

./build/bsd-x86_64-normal-server-release/images/jdk/bin/java -XX:+UnlockDiagnosticVMOptions -XX:SharedArchiveFile=./build/bsd-x86_64-normal-server-release/test-support/jtreg_test_hotspot_jtreg_tier1/runtime/CDSCompressedKPtrs/XShareAuto/XShareAuto.jsa -Xlog:cds -Xshare:auto -version

This expects the output to include "sharing" unless it contains "Unable to map". The FreeBSD test contains the output "UseSharedSpaces: Unable to reserve shared space at required address 0x000000081cc00000" instead. It is relevant to note that the first command does not include this output and does successfully reserve and use shared space.

The third command can be reproduced with:

./build/bsd-x86_64-normal-server-release/images/jdk/bin/java -XX:+UnlockDiagnosticVMOptions -XX:SharedArchiveFile=./build/bsd-x86_64-normal-server-release/test-support/jtreg_test_hotspot_jtreg_tier1/runtime/CDSCompressedKPtrs/XShareAuto/XShareAuto.jsa -Xlog:cds -showversion -version

It produces the same output as the second command.

battleblow commented 5 years ago

Note that the "Unable to map" conditional has a comment that it may happen under ASLR. This happens when trying to map the archive into memory. The "Unable to reserve" output falls earlier when trying to reserve memory prior to attempt to map the archive into it.

battleblow commented 5 years ago

Some output from the first command:

narrow_klass_base = 0x000000081cc00000, narrow_klass_shift = 3
Allocated temporary class space: 1073741824 bytes at 0x00000008dcc00000
Allocated shared space: 3221225472 bytes at 0x000000081cc00000
Loading classes to share ...
Loading classes to share: done.

So it is clearly able to allocate shared space. I believe there are other tests which use -XShare that do succeed.

battleblow commented 5 years ago

Relevant code to investigate further is in:

src/hotspot/share/memory/filemap.cpp

In particular, line 797 is where we attempt to reserve space.