Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

tstuefe
Copy link
Member

@tstuefe tstuefe commented Oct 19, 2023

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.

/label remove core-libs
/label remove hotspot
/label add hotspot-runtime

Attention @iklam and @calvinccheung


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8318485: Narrow klass shift should be zero if encoding range extends to 0x1_0000_0000 (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16261/head:pull/16261
$ git checkout pull/16261

Update a local copy of the PR:
$ git checkout pull/16261
$ git pull https://git.openjdk.org/jdk.git pull/16261/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16261

View PR using the GUI difftool:
$ git pr show -t 16261

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16261.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 19, 2023

👋 Welcome back stuefe! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 19, 2023

@tstuefe The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added hotspot hotspot-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Oct 19, 2023
@tstuefe tstuefe marked this pull request as ready for review October 20, 2023 05:41
@openjdk openjdk bot added rfr Pull request is ready for review and removed core-libs core-libs-dev@openjdk.org labels Oct 20, 2023
@openjdk
Copy link

openjdk bot commented Oct 20, 2023

@tstuefe
The core-libs label was successfully removed.

@openjdk openjdk bot removed the hotspot hotspot-dev@openjdk.org label Oct 20, 2023
@openjdk
Copy link

openjdk bot commented Oct 20, 2023

@tstuefe
The hotspot label was successfully removed.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Oct 20, 2023
@openjdk
Copy link

openjdk bot commented Oct 20, 2023

@tstuefe
The hotspot-runtime label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Oct 20, 2023

Webrevs

Copy link
Member

@calvinccheung calvinccheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this. I've tried your patch on the CompressedClassPointers.java test. It also fixes the issue in JDK-8317610. Just have a couple of minor comments.

Comment on lines +790 to +791
LogStream ls(lt);
os::print_memory_mappings((char*)base, size, &ls);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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..."?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

// Expecting base=0, shift=0
test(4 * G - 128 * M, 128 * M, 0, 0);

// add more...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn 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?

Copy link
Member Author

@tstuefe tstuefe Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather expand this in a separate RFE. Second one should work on all platforms, but I am not 100% sure some would encode this with base=4g shift=0 instead. Probably not, but it is better to stay focused on one issue. Makes also for clearer backporting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine.

@tstuefe
Copy link
Member Author

tstuefe commented Oct 23, 2023

Thanks @calvinccheung . I fixed the output as requested.

Copy link
Member

@calvinccheung calvinccheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. It looks good.

@openjdk
Copy link

openjdk bot commented Oct 23, 2023

@tstuefe This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

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

Reviewed-by: ccheung, iklam

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 73 new commits pushed to the master branch:

  • 8d9a4b4: 8317678: Fix up hashCode() for ZipFile.Source.Key
  • 69c0ae2: 8318124: JFR: Rewrite instrumentation to use Class-File API
  • c1aeac7: 8318445: More broken bailout chains in C2
  • d888b26: 8318071: IgnoreUnrecognizedVMOptions flag still causes failure in ArchiveHeapTestClass
  • bea2d48: 8312475: org.jline.util.PumpReader signed byte problem
  • 9f767aa: 8318109: Writing JFR records while a CHT has taken its lock asserts in rank checking
  • bd22d23: 8318027: Support alternative name to jdk.internal.vm.compiler
  • c2efd77: 8295795: hsdis does not build with binutils 2.39+
  • 99de9bb: 8317807: JAVA_FLAGS removed from jtreg running in JDK-8317039
  • 704c6ea: 8303525: Refactor/cleanup open/test/jdk/javax/rmi/ssl/SSLSocketParametersTest.java
  • ... and 63 more: https://git.openjdk.org/jdk/compare/6fc35142315f1616fa35e415005c9483939c6920...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 23, 2023
Copy link
Member

@iklam iklam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tstuefe
Copy link
Member Author

tstuefe commented Oct 23, 2023

Thanks @calvinccheung and @iklam .

/integrate

@openjdk
Copy link

openjdk bot commented Oct 23, 2023

Going to push as commit 5ba9705.
Since your change was applied there have been 73 commits pushed to the master branch:

  • 8d9a4b4: 8317678: Fix up hashCode() for ZipFile.Source.Key
  • 69c0ae2: 8318124: JFR: Rewrite instrumentation to use Class-File API
  • c1aeac7: 8318445: More broken bailout chains in C2
  • d888b26: 8318071: IgnoreUnrecognizedVMOptions flag still causes failure in ArchiveHeapTestClass
  • bea2d48: 8312475: org.jline.util.PumpReader signed byte problem
  • 9f767aa: 8318109: Writing JFR records while a CHT has taken its lock asserts in rank checking
  • bd22d23: 8318027: Support alternative name to jdk.internal.vm.compiler
  • c2efd77: 8295795: hsdis does not build with binutils 2.39+
  • 99de9bb: 8317807: JAVA_FLAGS removed from jtreg running in JDK-8317039
  • 704c6ea: 8303525: Refactor/cleanup open/test/jdk/javax/rmi/ssl/SSLSocketParametersTest.java
  • ... and 63 more: https://git.openjdk.org/jdk/compare/6fc35142315f1616fa35e415005c9483939c6920...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 23, 2023
@openjdk openjdk bot closed this Oct 23, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 23, 2023
@openjdk
Copy link

openjdk bot commented Oct 23, 2023

@tstuefe Pushed as commit 5ba9705.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants