-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
8331911: Reconsider locking for recently disarmed nmethods #19285
base: master
Are you sure you want to change the base?
Conversation
Hi @neethu-prasad, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user neethu-prasad" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
@neethu-prasad 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 145 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@shipilev) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
@neethu-prasad The following labels will be automatically applied to this pull request:
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. |
/covered |
Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
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.
I like this. Some stylistic comments.
@@ -36,6 +36,13 @@ | |||
#include "runtime/threadWXSetters.inline.hpp" | |||
|
|||
bool ShenandoahBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) { | |||
|
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.
Here and later: no need for new line at the beginning of the method.
@@ -1,5 +1,5 @@ | |||
/* | |||
* Copyright (c) 2019, 2022, Red Hat, Inc. All rights reserved. | |||
* Copyright (c) 2019, 2024, Red Hat, Inc. All rights reserved. |
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 update is unnecessary.
@@ -37,6 +37,14 @@ | |||
#include "runtime/threadWXSetters.inline.hpp" | |||
|
|||
bool ZBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) { | |||
|
|||
if (!is_armed(nm)) { | |||
log_develop_trace(gc, nmethod)("nmethod: " PTR_FORMAT " visited by entry (disarmed)", p2i(nm)); |
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.
Should it be "(disarmed before lock)" to disambiguate against "(disarmed)" later?
// Some other thread got here first and healed the oops | ||
// and disarmed the nmethod. |
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.
Suggestion for the comment (here and later):
// Some other thread got here first and healed the oops
// and disarmed the nmethod. No need to continue.
...and then later, under the lock:
// Some other thread managed to complete while we were
// waiting for lock. No need to continue.
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.
I think this is good.
Yes, we could have restructured the code so that nmethod_entry_barrier
was not called when nmethod is already disarmed. There are already some places where we check it externally, but the reproducer in the bug shows that it is easy to miss. So checking right here in the method looks appropriate.
@fisk might want to take a look as well.
|
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.
It seems fine to me that the GC backends are responsible for checking if the nmethod is disarmed outside the lock. However, we have some callers that now check it redundantly. I think those callers should stop doing that now. Otherwise, this looks good to me.
Thanks for the feedback! Looking around the code, I think there are a few places where we can do more changes. First, remove check here: jdk/src/hotspot/share/code/nmethod.cpp Lines 852 to 855 in bc7d9e3
This would force us to add the check in super-class implementation here:
Second, we can remove the check here: jdk/src/hotspot/share/gc/shared/barrierSetNMethod.cpp Lines 175 to 181 in bc7d9e3
But it does not seem straightforward, because we currently skip cross-modification fence based on is_armed(...) check. Unfortunately, we cannot easily know if nmethod_entry_barrier acted or not, we only know if method is safe or not. Can we / should we do these refactoring separately? |
I see your point. However, this PR is refactoring the code to iron out who is responsible for checking is_armed, so I would prefer if we got that right in this PR. We say it should be the backend code doing that, so the callers shouldn't. I agree with all the changes you just listed and if you make them I would be happy. Regarding the cross modifying fence, I strongly prefer to not try and be clever. Just run the cross modifying fence unconditionally after calling the backend code. We get there because the barrier was armed anyway. |
Notes
We are spending significant time on acquiring the per-nmethod as all the
threads are in same nmethod.
Adding double-check lock by calling is_armed before lock acquisition.
Verification
Shenendoah
ZGC
Issue
https://bugs.openjdk.org/browse/JDK-8331911
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19285/head:pull/19285
$ git checkout pull/19285
Update a local copy of the PR:
$ git checkout pull/19285
$ git pull https://git.openjdk.org/jdk.git pull/19285/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 19285
View PR using the GUI difftool:
$ git pr show -t 19285
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19285.diff
Webrev
Link to Webrev Comment