-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8265753: Remove manual JavaThread transitions to blocked #3875
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
Conversation
👋 Welcome back rehn! A progress list of the required criteria for merging this PR into |
/label remove hotspot |
@robehn |
@robehn |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thumbs up on the over all logic. I only have minor nits and suggestions.
@robehn 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:
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 28 new commits pushed to the
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 |
Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Robbin,
I haven't found the time for a proper review yet but I've experimented a little bit with lambdas. I could not make it work because g++ created references to ::new which isn't allowed.
Thanks, Richard.
Hi Richard, Regarding ThreadClosure, we could use it, maybe that is preferable?! |
Yes, I'd think so too.
Personally I'd prefer it but I'm fine with the current version too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Robbin,
Sorry for the delay in getting through this.
Overall approach looks good. I have a few queries below and some requested naming changes to make things clearer.
Thanks,
David
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Robbin,
there seem to be issues in the jvmtiRawMonitor part of the change. Besides that it looks good.
Cheers, Richard.
_recursions = 0; | ||
_waiters++; | ||
ret = simple_wait(self, millis); | ||
_waiters--; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't own the monitor yet so you cannot modify _waiters
here.
Any reason you moved and duplicated this block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Even if the block wasn't moved we still no longer own the monitor after simple_wait.
This is going to be tricky to fix in a clear/clean way as the waiters count has to be maintained properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the field is unused.
The _entry_list is the list of waiters, which is the only thing we really care about.
If there was a reader of _waiter reading it without lock can only be used as some kind of hint.
If you have lock you can just check _entry_list.
I duplicated it because otherwise I would need two branchse on if (self->is_Java_thread()) which creates more complicated code.
Mailing list message from David Holmes on hotspot-runtime-dev: On 12/05/2021 8:56 pm, Robbin Ehn wrote:
Isn't a ThreadClosure for applying an operation to a set of threads? David |
No it isn't. A closure is just a set of variable bindings and a function that can be executed. And yes we're doing just that. A ThreadClosure is just an instance of this general concept. E.g. an AsyncHandshakeClosure (subclass of ThreadClosure) is a function (plus variable bindings) that is passed by a requesting thread to a target thread to be executed by it. Thanks, |
Mailing list message from David Holmes on hotspot-runtime-dev: On 17/05/2021 5:05 pm, Robbin Ehn wrote:
Only if the VMThread executes code that uses the same RM - which should David |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more, rather unimportant comment...
Either way: LGTM!
Thanks, Richard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates seem fine. Lucky _waiters was unused :)
Will take another full pass over the changes.
Thanks,
David
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Robbin,
Overall this looks good to me, but there is one issue that needs fixing (partially pre-existing but now also affecting ObjectMonitor::enter).
Other minor comments below.
Thanks,
David
Thanks! |
Mailing list message from David Holmes on hotspot-runtime-dev: On 20/05/2021 5:10 pm, Robbin Ehn wrote:
I'd say yes with two minor modifications:
+ // Now we need to re-enter the monitor. For JavaThread's
I think this extra block scope can also go. Cheers, |
Thanks! |
Fixed, thanks, Robbin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates mostly good but still a storestore issue to resolve.
Thanks,
David
Are we good to go? Thanks, Robbin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thumbs up.
I just have some minor questions about a couple of the details.
Nothing blocking.
// We cleared the pending monitor info since we've just gotten past | ||
// the enter-check-for-suspend dance and we now own the monitor free | ||
// and clear, i.e., it is no longer pending. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment explains why the set-pending-to-NULL code was here
(outside the loop). You moved the code, but now the comment is
misplaced and the code no longer works the same.
Update: I found this resolved comment below:
And I set current->set_current_pending_monitor(om); to OM again
in ExitOnSuspend if we exit the OM.
so that explains why we don't have a big change in behavior.
However, I think you still need to do something about this comment.
There is still an observable change in behavior in that the current
pending monitor can cycle between set->NULL->set->NULL when
we run into a suspend request. Previously, it did not cycle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we stop for a suspend request current pending monitor will always be set, so the cycling cannot be seen.
Updated comment(s).
Thanks Dan! |
Still looks good to me. Cheer's, Richard. |
Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing further from me.
Thanks,
David
Thank you David! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thumbs up.
Reviewed the incremental between v05 -> v06. Looks good.
Thanks! |
/integrate |
@robehn Since your change was applied there have been 54 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 97ec5ad. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Please consider this change which removes the manual transitions to blocked.
This adds a preprocess template/functor which is executed in the destructor of 'ThreadBlockInVM' if we are going to do any processing.
This gives us a way to backout of the object/raw monitor before suspend or other processing, such as a safepoint.
The object monitor code could be straight forward changed to use this instead of manual transitions.
Raw monitors on the other hand are a bit more complicated due to 'implicit' rules (consequences of the specs).
Added a comment in hpp trying to explain it; we cannot simply transition with a raw monitor held.
This caused the change in the destructor ~ThreadInVMfromNative() (this specific change have also been tested in unrelated exploration of transition), now this RAII does the same as we do when going to native from Java, just setting the state.
Since we are going from an unsafe state, in VM, to a safe state, in native, we do not need to check the poll.
That made it possible to careful use ThreadInVMfromNative in raw monitors.
I also remove the early CAS in raw_enter.
We lock a lock to do a CAS, in the uncontended case means CAS on lock then CAS raw monitor.
Now we instead do a transitions, in the uncontended case means fence, CAS raw monitor, fence.
(multiple fence (CAS is also a fence) very close to each other have little additional performance impact on contemporary hardware)
Passes t1-t7 and manual stressing relevant test groups.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3875/head:pull/3875
$ git checkout pull/3875
Update a local copy of the PR:
$ git checkout pull/3875
$ git pull https://git.openjdk.java.net/jdk pull/3875/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3875
View PR using the GUI difftool:
$ git pr show -t 3875
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3875.diff