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

8247281: migrate ObjectMonitor::_object to OopStorage #135

Closed
wants to merge 6 commits into from

Conversation

dcubed-ojdk
Copy link
Member

@dcubed-ojdk dcubed-ojdk commented Sep 11, 2020

This RFE is to migrate the following field to OopStorage:

class ObjectMonitor {

void* volatile _object; // backward object pointer - strong root

Unlike the previous patches in this series, there are a lot of collateral
changes so this is not a trivial review. Sorry for the tedious parts of
the review. Since Erik and I are both contributors to this patch, we
would like at least 1 GC team reviewer and 1 Runtime team reviewer.

This changeset was tested with Mach5 Tier[1-3],4,5,6,7,8 testing
along with JDK-8252980 and JDK-8252981. I also ran it through my
inflation stress kit for 48 hours on my Linux-X64 machine.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8247281: migrate ObjectMonitor::_object to OopStorage

Reviewers

Contributors

  • Erik Österlund <erik.osterlund@oracle.com>
  • Daniel Daugherty <daniel.daugherty@oracle.com>

Download

$ git fetch https://git.openjdk.java.net/jdk pull/135/head:pull/135
$ git checkout pull/135

@dcubed-ojdk
Copy link
Member Author

/contributor add Erik Österlund erik.osterlund@oracle.com
/contributor add Daniel Daugherty daniel.daugherty@oracle.com

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 11, 2020

👋 Welcome back dcubed! 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 Sep 11, 2020

@dcubed-ojdk Could not parse Erik Österlund erik.osterlund@oracle.com as a valid contributor.
Syntax: /contributor (add|remove) [@user | openjdk-user | Full Name <email@address>]. For example:

  • /contributor add @openjdk-bot
  • /contributor add duke
  • /contributor add J. Duke <duke@openjdk.org>

@openjdk
Copy link

openjdk bot commented Sep 11, 2020

@dcubed-ojdk Could not parse Daniel Daugherty daniel.daugherty@oracle.com as a valid contributor.
Syntax: /contributor (add|remove) [@user | openjdk-user | Full Name <email@address>]. For example:

  • /contributor add @openjdk-bot
  • /contributor add duke
  • /contributor add J. Duke <duke@openjdk.org>

@openjdk
Copy link

openjdk bot commented Sep 11, 2020

@dcubed-ojdk The following labels will be automatically applied to this pull request: hotspot serviceability shenandoah.

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 (add|remove) "label" command.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Sep 11, 2020
@dcubed-ojdk
Copy link
Member Author

dcubed-ojdk commented Sep 11, 2020

/contributor add Erik Österlund erik.osterlund@oracle.com
/contributor add Daniel Daugherty daniel.daugherty@oracle.com

@dcubed-ojdk
Copy link
Member Author

/label remove serviceability,hotspot
/label add hotspot-runtime,hotspot-gc

@openjdk openjdk bot removed serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Sep 11, 2020
@openjdk
Copy link

openjdk bot commented Sep 11, 2020

@dcubed-ojdk
The serviceability label was successfully removed.

The hotspot label was successfully removed.

@openjdk
Copy link

openjdk bot commented Sep 11, 2020

@dcubed-ojdk
Contributor Erik Österlund <erik.osterlund@oracle.com> successfully added.

@openjdk
Copy link

openjdk bot commented Sep 11, 2020

@dcubed-ojdk
Contributor Daniel Daugherty <daniel.daugherty@oracle.com> successfully added.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Sep 11, 2020
@openjdk
Copy link

openjdk bot commented Sep 11, 2020

@dcubed-ojdk
The hotspot-runtime label was successfully added.

The hotspot-gc label was successfully added.

@openjdk openjdk bot added the hotspot-gc hotspot-gc-dev@openjdk.org label Sep 11, 2020
@dcubed-ojdk
Copy link
Member Author

@fisk - Please chime in on this review when you get the chance.

@dcubed-ojdk dcubed-ojdk marked this pull request as ready for review September 11, 2020 18:52
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 11, 2020
@mlbridge
Copy link

mlbridge bot commented Sep 11, 2020

Webrevs

Copy link
Member Author

@dcubed-ojdk dcubed-ojdk left a comment

Choose a reason for hiding this comment

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

The vast majority of these changes came from @fisk so I'm actually a
reviewer and stress tester of these changes. Thumbs up!

Copy link
Contributor

@fisk fisk left a comment

Choose a reason for hiding this comment

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

This looks great Dan. I like your addition of is_chainmarker() - it makes this step a lot better, without having any special oops that are not oops. Thanks for sorting this out!

@openjdk
Copy link

openjdk bot commented Sep 11, 2020

@dcubed-ojdk This change now passes all automated pre-integration checks. In addition to the automated checks, the change must also fulfill all project specific requirements

After integration, the commit message will be:

8247281: migrate ObjectMonitor::_object to OopStorage

Co-authored-by: Erik Österlund <erik.osterlund@oracle.com>
Co-authored-by: Daniel Daugherty <daniel.daugherty@oracle.com>
Reviewed-by: eosterlund, coleenp, dholmes, stefank, kbarrett, rkennke, sspitsyn
  • If you would like to add a summary, use the /summary command.
  • To credit additional contributors, use the /contributor command.
  • To add additional solved issues, use the /issue command.

Since the source branch of this PR was last updated there have been 104 commits pushed to the master branch:

  • f800af9: 8241390: 'Deadlock' with VM_RedefineClasses::lock_classes()
  • 2e30ff6: 8253311: Cleanup relocInfo constructors
  • 43be5a3: 8230652: Improve verbose output
  • 5a7390b: 8253418: ZGC: Use pd_ prefix to denote platform dependent code
  • 7e49eae: 8253407: Move max_pow2 from test to src
  • fbfb62d: 8253332: ZGC: Make heap views reservation platform independent
  • dad6edb: 8253321: java.util.Locale.LanguageRange#equals is inconsistent after calling hashCode
  • edc14f9: 8253286: Use expand_exact() instead of expand_at() for fixed requests in G1
  • bba948f: 8253411: [BACKOUT] [REDO] G1 incorrectly limiting young gen size when using the reserve can result in repeated full gcs
  • 955c2e6: 8253303: G1: Move static initialization of G1FromCardCache to a proper location
  • ... and 94 more: https://git.openjdk.java.net/jdk/compare/952518640a50ce86ca6f295867cfde93f6ac8b26...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid automatic rebasing, please merge master into your branch, and then specify the current head hash when integrating, like this: /integrate f800af978c42c88170def1b4996ffa524aaed4bd.

➡️ 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 Sep 11, 2020
@dcubed-ojdk
Copy link
Member Author

@fisk - Thanks for the blinding fast review! (Pretty easy when you wrote almost
all of the code).

Re: is_chainmarker()
I figured you would appreciate getting rid of one more "special" oop value!
And its use just fits in with the whole AllocationState model. It also gets
removed quite easily with the part3 patch... Oh yeah, I gotta file a new RFE
for that one.

@@ -3017,13 +3017,6 @@ inline bool VM_HeapWalkOperation::collect_simple_roots() {
return false;
}

// Inflated monitors
blk.set_kind(JVMTI_HEAP_REFERENCE_MONITOR);
Copy link
Contributor

Choose a reason for hiding this comment

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

So we don't have to provide the equivalent of JVMTI_HEAP_REFERENCE_MONITOR?

Copy link
Contributor

Choose a reason for hiding this comment

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

The JVMTI roots are strong roots. This is no longer a strong root, so reporting them would be a bug after this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

The function is VM_HeapWalkOperation::collect_simple_roots()
and we no longer have a root in the ObjectMonitor so my take is
no we don't. I believe @fisk concurs with that reasoning.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, exactly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for confirmation.

Copy link
Member

Choose a reason for hiding this comment

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

From the spec I'm not clear on exactly what JVMTI_HEAP_REFERENCE_MONITOR is intended to be. Serviceability folk should be giving some input here though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've taken a first pass at creating a CSR:
JDK-8253121 migrate ObjectMonitor::_object to OopStorage
https://bugs.openjdk.java.net/browse/JDK-8253121

Copy link
Contributor

Choose a reason for hiding this comment

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

Just a minor comment.
The line 1754 can be deleted as the JVMTI_HEAP_REFERENCE_MONITOR reference type will be never encountered:

1750 static jvmtiHeapRootKind toJvmtiHeapRootKind(jvmtiHeapReferenceKind kind) {
1751 switch (kind) {
1752 case JVMTI_HEAP_REFERENCE_JNI_GLOBAL: return JVMTI_HEAP_ROOT_JNI_GLOBAL;
1753 case JVMTI_HEAP_REFERENCE_SYSTEM_CLASS: return JVMTI_HEAP_ROOT_SYSTEM_CLASS;
1754 case JVMTI_HEAP_REFERENCE_MONITOR: return JVMTI_HEAP_ROOT_MONITOR;
1755 case JVMTI_HEAP_REFERENCE_STACK_LOCAL: return JVMTI_HEAP_ROOT_STACK_LOCAL;
1756 case JVMTI_HEAP_REFERENCE_JNI_LOCAL: return JVMTI_HEAP_ROOT_JNI_LOCAL;
1757 case JVMTI_HEAP_REFERENCE_THREAD: return JVMTI_HEAP_ROOT_THREAD;
1758 case JVMTI_HEAP_REFERENCE_OTHER: return JVMTI_HEAP_ROOT_OTHER;
1759 default: ShouldNotReachHere(); return JVMTI_HEAP_ROOT_OTHER;
1760 }
1761 }

Other than that the update in this file looks okay to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

I cleaned that up. The only references to JVMTI_HEAP_REFERENCE_MONITOR and
JVMTI_HEAP_ROOT_MONITOR that remain are in the spec:

$ egrep -r 'JVMTI_HEAP_REFERENCE_MONITOR|JVMTI_HEAP_ROOT_MONITOR' src/hotspot
src/hotspot/share/prims/jvmti.xml:
src/hotspot/share/prims/jvmti.xml:
src/hotspot/share/prims/jvmti.xml: JVMTI_HEAP_ROOT_MONITOR,

src/hotspot/share/runtime/objectMonitor.cpp Outdated Show resolved Hide resolved
src/hotspot/share/runtime/objectMonitor.cpp Outdated Show resolved Hide resolved
src/hotspot/share/runtime/objectMonitor.cpp Show resolved Hide resolved
}
void do_oop(oop* obj_p) {
u4 size = 1 + sizeof(address);
writer()->start_sub_record(HPROF_GC_ROOT_MONITOR_USED, size);
Copy link
Contributor

Choose a reason for hiding this comment

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

I had a similar question to the jvmtiTagMap question above. Are there tools that are going to miss seeing this tag in the heap dump? I hope these tags are implementation defined and we can just remove them. Otherwise, should there be a loop through the OM list to print out these tags for live object monitors?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same answer as above. No longer a strong root, so can't report it as such.

Copy link
Member Author

Choose a reason for hiding this comment

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

We no longer have a root in the ObjectMonitor so no we don't have
to dump these is my take. I believe @fisk concurs with that reasoning.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, that's good then!

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for confirmation.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see anything in the HPROF format description that claims this is a strong root. At a minimum this seems to be a behavioural change that would warrant a CSR request. This also seems to be something that the serviceability folk should be made aware of and have a chance to comment on.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've taken a first pass at creating a CSR:
JDK-8253121 migrate ObjectMonitor::_object to OopStorage
https://bugs.openjdk.java.net/browse/JDK-8253121

Copy link
Contributor

Choose a reason for hiding this comment

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

I've looked at the CSR and added myself as a reviewer.
We had a slack chat with Dan, and I agree that with a weak handle it would be racy/unsafe for JVMTI_HEAP_REFERENCE_MONITOR calls back to be called. The ObjectMonitors do not pin objects anymore (there are no strong refs from them), so it has to be okay to skip reporting the JVMTI_HEAP_REFERENCE_MONITOR and and JVMTI_HEAP_ROOT_MONITOR (old Heap Walking API) reference types. The JVMTI does not need an update as other VM implementations can still report these reference types. Alan added a comment to the CSR saying that memory profiling tools that use the JVMTI functions (FollowReferences with jvmtiHeapReferenceCallback or IterateOverReachableObjects with jvmtiHeapRootCallback) to iterate over the heap should not have a compatibility impact as these reference types are just informational but adding a release note can be useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

Slight clarification. Serguei and I were discussing whether we could continue
to make JVMTI_HEAP_REFERENCE_MONITOR call backs or emit
HPROF_GC_ROOT_MONITOR_USED entries in heap dump output as a
way to ease the transition phase of getting used to these things going
away. My answer was that we could do that but it would racy and unsafe
due to the ObjectMonitor's object being GC'ed.

It's also incorrect to make JVMTI_HEAP_REFERENCE_MONITOR call backs
or emit HPROF_GC_ROOT_MONITOR_USED entries in heap dump once
the ObjectMonitor's object ref becomes a weak handle. That weak handle
no longer prevents the associated object from being GC'ed so it is no
longer a strong root.

See Erik's comment above: #135 (comment)

src/hotspot/share/runtime/synchronizer.cpp Show resolved Hide resolved
src/hotspot/share/runtime/synchronizer.cpp Show resolved Hide resolved
@dcubed-ojdk
Copy link
Member Author

@coleenp, @rkennke, and @kimbarrett - I believe all of the changes that you have requested
have been made. Please confirm by re-reviewing.

@dholmes-ora - I don't think you asked for any specific code changes. I've taken a first pass
at creating a CSR:
JDK-8253121 migrate ObjectMonitor::_object to OopStorage
https://bugs.openjdk.java.net/browse/JDK-8253121

Please look it over and feel free to edit as needed. Since I don't do
CSR's often, what I've done might be all wrong. :-)

@rkennke
Copy link
Contributor

rkennke commented Sep 14, 2020

@coleenp, @rkennke, and @kimbarrett - I believe all of the changes that you have requested
have been made. Please confirm by re-reviewing.

It looks good to me now! I've also build with Shenandoah GC, and run our sanity-tests (TEST=hotspot_gc_shenandoah) and all looks good. Thank you!

@dcubed-ojdk
Copy link
Member Author

@rkennke - Thanks for confirming that Shenandoah now builds with the changes
that you provided. Thanks for sending those.

@dholmes-ora
Copy link
Member

dholmes-ora commented Sep 15, 2020

/csr needed

Edit: I missed that this was already flagged.

@openjdk
Copy link

openjdk bot commented Sep 15, 2020

@dholmes-ora an approved CSR request is already required for this pull request.

@@ -241,13 +241,12 @@ void ObjectMonitor::operator delete[] (void *p) {
operator delete(p);
}

#ifdef ASSERT

Choose a reason for hiding this comment

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

There would be less #ifdef ASSERT clutter if just the body of check_object_context were conditionalized. Then the calls wouldn't need to be. Your call...

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll make that change.

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.

Thank you for removing it.

Copy link
Contributor

@rkennke rkennke 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 to me!

@@ -3017,13 +3017,6 @@ inline bool VM_HeapWalkOperation::collect_simple_roots() {
return false;
}

// Inflated monitors
blk.set_kind(JVMTI_HEAP_REFERENCE_MONITOR);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a minor comment.
The line 1754 can be deleted as the JVMTI_HEAP_REFERENCE_MONITOR reference type will be never encountered:

1750 static jvmtiHeapRootKind toJvmtiHeapRootKind(jvmtiHeapReferenceKind kind) {
1751 switch (kind) {
1752 case JVMTI_HEAP_REFERENCE_JNI_GLOBAL: return JVMTI_HEAP_ROOT_JNI_GLOBAL;
1753 case JVMTI_HEAP_REFERENCE_SYSTEM_CLASS: return JVMTI_HEAP_ROOT_SYSTEM_CLASS;
1754 case JVMTI_HEAP_REFERENCE_MONITOR: return JVMTI_HEAP_ROOT_MONITOR;
1755 case JVMTI_HEAP_REFERENCE_STACK_LOCAL: return JVMTI_HEAP_ROOT_STACK_LOCAL;
1756 case JVMTI_HEAP_REFERENCE_JNI_LOCAL: return JVMTI_HEAP_ROOT_JNI_LOCAL;
1757 case JVMTI_HEAP_REFERENCE_THREAD: return JVMTI_HEAP_ROOT_THREAD;
1758 case JVMTI_HEAP_REFERENCE_OTHER: return JVMTI_HEAP_ROOT_OTHER;
1759 default: ShouldNotReachHere(); return JVMTI_HEAP_ROOT_OTHER;
1760 }
1761 }

Other than that the update in this file looks okay to me.

@fisk
Copy link
Contributor

fisk commented Sep 16, 2020

I added a release note (https://bugs.openjdk.java.net/browse/JDK-8253225) describing that these roots are now weak, and hence won't be reported. Please have a look at that, to make sure what I am describing makes sense.

@dcubed-ojdk
Copy link
Member Author

@kimbarrett - Thanks for the cleanup suggestion.
@sspitsyn - Thanks for the review.
I've gone ahead and "resolved" the comments that were addressed by previous commits.
I've made changes for both Kim and Serguei's reviews. Building those bits now.

@dcubed-ojdk
Copy link
Member Author

@kimbarrett and @sspitsyn - Your most recent comments should be resolved via 215084a.

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Sep 21, 2020
@dcubed-ojdk
Copy link
Member Author

/integrate

@openjdk openjdk bot closed this Sep 21, 2020
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated labels Sep 21, 2020
@openjdk
Copy link

openjdk bot commented Sep 21, 2020

@dcubed-ojdk Since your change was applied there have been 104 commits pushed to the master branch:

  • f800af9: 8241390: 'Deadlock' with VM_RedefineClasses::lock_classes()
  • 2e30ff6: 8253311: Cleanup relocInfo constructors
  • 43be5a3: 8230652: Improve verbose output
  • 5a7390b: 8253418: ZGC: Use pd_ prefix to denote platform dependent code
  • 7e49eae: 8253407: Move max_pow2 from test to src
  • fbfb62d: 8253332: ZGC: Make heap views reservation platform independent
  • dad6edb: 8253321: java.util.Locale.LanguageRange#equals is inconsistent after calling hashCode
  • edc14f9: 8253286: Use expand_exact() instead of expand_at() for fixed requests in G1
  • bba948f: 8253411: [BACKOUT] [REDO] G1 incorrectly limiting young gen size when using the reserve can result in repeated full gcs
  • 955c2e6: 8253303: G1: Move static initialization of G1FromCardCache to a proper location
  • ... and 94 more: https://git.openjdk.java.net/jdk/compare/952518640a50ce86ca6f295867cfde93f6ac8b26...master

Your commit was automatically rebased without conflicts.

Pushed as commit d8921ed.

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

@openjdk openjdk bot removed the rfr Pull request is ready for review label Sep 21, 2020
@dcubed-ojdk dcubed-ojdk deleted the JDK-8247281 branch September 22, 2020 16:12
robehn pushed a commit to robehn/jdk that referenced this pull request Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-gc hotspot-gc-dev@openjdk.org hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

8 participants