Skip to content

Conversation

@tschatzl
Copy link
Contributor

@tschatzl tschatzl commented May 30, 2022

Hi all,

can I have reviews for this change that makes a few CLDG iterations no-keepalive during GC pauses?

This fixes a bug where the VerifyDuringGC verification otherwise kept alive all classes, effectively disabling class unloading during (g1) concurrent mark.

Afaict this verification code is only every called during GC pauses, so the change should be fine.

As for the change itself, I tried to avoid cluttering the code with ClassLoaderDataGraphIterator<> by using typedefs - unfortunately only C++ 17 allows omitting the <> if all template parameters are defaulted.

There is also a new test case for just this.

Testing: tier1-5

Thanks,
Thomas


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-8280454: G1: ClassLoaderData verification keeps CLDs live that causes problems with VerifyDuringGC during Remark

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 8949

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

Using diff file

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

@tschatzl
Copy link
Contributor Author

/label add hotspot-runtime

@bridgekeeper
Copy link

bridgekeeper bot commented May 30, 2022

👋 Welcome back tschatzl! 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 openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label May 30, 2022
@openjdk
Copy link

openjdk bot commented May 30, 2022

@tschatzl
The hotspot-runtime label was successfully added.

@tschatzl tschatzl marked this pull request as ready for review May 31, 2022 07:43
@openjdk openjdk bot added the rfr Pull request is ready for review label May 31, 2022
@mlbridge
Copy link

mlbridge bot commented May 31, 2022

Webrevs

Copy link
Member

@stefank stefank left a comment

Choose a reason for hiding this comment

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

It's unclear to me why this works. You've removed the "keep alive" property from the iterator, but it looks like the verification code still uses "keep alive" loads on the class loaders.

Could you explain how this patch prevents those class loaders from being kept alive?

ClassLoaderDataGraphIteratorNoKeepAlive iter;
while (ClassLoaderData* cld = iter.get_next()) {
if (cld->dictionary() != nullptr) {
cld->dictionary()->verify();
Copy link
Member

Choose a reason for hiding this comment

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

If I'm reading the code correctly, it seems like this function keeps the class loader alive:

void Dictionary::verify() {
  guarantee(number_of_entries() >= 0, "Verify of dictionary failed");

  ClassLoaderData* cld = loader_data();
  // class loader must be present;  a null class loader is the
  // bootstrap loader
  guarantee(cld != NULL &&
            (cld->the_null_class_loader_data() || cld->class_loader()->is_instance()),
            "checking type of class_loader");

The cld->class_loader() call resolves the OopHandle, which should keep it alive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That never happens because afaict cld->the_null_class_loader_data() is always non-NULL except during very early bootstrapping. I do not think it can ever be NULL for a java instantiated class loader, so the second clause is never executed there. Some additional logging in the test proved that.

I can find three where this idiom is used to see whether the null CLD is initialized - I could add a static is_null_class_loader_data_initialized() predicate to ClassLoaderData - preferably in a separate CR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, in this CR you should change "the_null_class_loader_data()" to "is_the_null_class_loader_data()" and verify that your test still works.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

This seems okay and worth adding the ClassLoaderdataGraphIteratorBase for this case. Please make the change in my comment though with this change, and retest your test.

ClassLoaderDataGraphIteratorNoKeepAlive iter;
while (ClassLoaderData* cld = iter.get_next()) {
if (cld->dictionary() != nullptr) {
cld->dictionary()->verify();
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, in this CR you should change "the_null_class_loader_data()" to "is_the_null_class_loader_data()" and verify that your test still works.

@openjdk
Copy link

openjdk bot commented Jun 1, 2022

@tschatzl 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:

8280454: G1: ClassLoaderData verification keeps CLDs live that causes problems with VerifyDuringGC during Remark

Reviewed-by: stefank, coleenp

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 190 new commits pushed to the master branch:

  • 900d967: 8287924: Avoid redundant HashMap.containsKey call in EnvHelp.mapToHashtable
  • d482d7f: 8286160: (fs) Files.exists returns unexpected results with C:\pagefile.sys because it's not readable
  • edff51e: 8284858: Start of release updates for JDK 20
  • 2671443: 8286171: HttpClient/2 : Expect:100-Continue blocks indefinitely when response is not 100
  • 59b0de6: 8288048: Build failure with GCC 6 after JDK-8286562
  • db4405d: 8288078: linux-aarch64-optimized build fails in Tier5 after JDK-8287567
  • 7e948f7: 8287903: Reduce runtime of java.math microbenchmarks
  • 3fa9984: 8287854: Dangling reference in ClassVerifier::verify_class
  • 4285e3d: 8288023: AArch64: disable PAC-RET when preview is enabled
  • 560e292: 8287738: [PPC64] jdk/incubator/vector/*VectorTests failing
  • ... and 180 more: https://git.openjdk.org/jdk/compare/73ba7fdce838ba8a2c227a972c176311e6cc0b41...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 Jun 1, 2022
Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

Still good.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you for fixing this.

@tschatzl
Copy link
Contributor Author

Thanks @stefank @coleenp for your reviews
/integrate

@openjdk
Copy link

openjdk bot commented Jun 10, 2022

Going to push as commit 94b473e.
Since your change was applied there have been 190 commits pushed to the master branch:

  • 900d967: 8287924: Avoid redundant HashMap.containsKey call in EnvHelp.mapToHashtable
  • d482d7f: 8286160: (fs) Files.exists returns unexpected results with C:\pagefile.sys because it's not readable
  • edff51e: 8284858: Start of release updates for JDK 20
  • 2671443: 8286171: HttpClient/2 : Expect:100-Continue blocks indefinitely when response is not 100
  • 59b0de6: 8288048: Build failure with GCC 6 after JDK-8286562
  • db4405d: 8288078: linux-aarch64-optimized build fails in Tier5 after JDK-8287567
  • 7e948f7: 8287903: Reduce runtime of java.math microbenchmarks
  • 3fa9984: 8287854: Dangling reference in ClassVerifier::verify_class
  • 4285e3d: 8288023: AArch64: disable PAC-RET when preview is enabled
  • 560e292: 8287738: [PPC64] jdk/incubator/vector/*VectorTests failing
  • ... and 180 more: https://git.openjdk.org/jdk/compare/73ba7fdce838ba8a2c227a972c176311e6cc0b41...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jun 10, 2022

@tschatzl Pushed as commit 94b473e.

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

@tschatzl tschatzl deleted the submit/8280454-cldg-iteration-verifyduringgc branch July 8, 2022 15:11
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