Skip to content

8272480: Remove Mutex::access rank #5256

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

Closed
wants to merge 3 commits into from
Closed

Conversation

coleenp
Copy link
Contributor

@coleenp coleenp commented Aug 25, 2021

This change removes the 'access' rank since the last oop access lock has been removed (Shared_DirtyCardQ_lock). It might make sense to have a very low level access lock for oops but it should be added along with locks that might be introduced at that time, so that the rank is in the right place.
With this I moved tty back down in the rank hierarchy and added stackwatermark ranks. The latter is above tty, not below, and other locks like Service_lock are taken while holding the stackwatermark lock. There's one tty-1 ranked lock that is actually taken while the tty lock is held.
I moved MonitorDeflation_lock back to special rank because its low level was just copied from Service_lock, but that's not needed.
With this I removed most of the out-of-date comment above the rank enum. New comment to follow in future RFE.
Tested with tier1-6.


Progress

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

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5256/head:pull/5256
$ git checkout pull/5256

Update a local copy of the PR:
$ git checkout pull/5256
$ git pull https://git.openjdk.java.net/jdk pull/5256/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5256

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5256.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 25, 2021

👋 Welcome back coleenp! 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 rfr Pull request is ready for review label Aug 25, 2021
@openjdk
Copy link

openjdk bot commented Aug 25, 2021

@coleenp The following label will be automatically applied to this pull request:

  • hotspot-runtime

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

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Aug 25, 2021
@mlbridge
Copy link

mlbridge bot commented Aug 25, 2021

Webrevs

@coleenp
Copy link
Contributor Author

coleenp commented Aug 26, 2021

It turns out that ttyLock is held during stack walking for -XX:+PrintDeoptimizationDetails -XX:+UseZGC, so put the lock ranks back. Thanks @kimbarrett and @dholmes-ora

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

One query below and some commentary on the problems of the tty lock, but in terms of removing the access rank and adding the SWM rank, these changes seem fine.

Thanks,
David

Comment on lines +48 to +50
service = event + 3,
stackwatermark = service + 3,
tty = stackwatermark + 3,
Copy link
Member

Choose a reason for hiding this comment

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

So as we discussed on IM the tty lock is really a problem. The existing ranking means that you cannot use the tty when holding the Service_lock - and I'm very surprised that doesn't actually happen in our code. The tty really should be a leaf lock, but when we have sections of code that explicitly acquire it so that atomic logging output can be generated, then there is a risk of acquiring other locks while the tty lock is held. I'm not sure this can be solved as long as the tty lock is part of the ranking system.

Note this is just a comment as you haven't changed anything in that regard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the tty lock is in an unfortunate place in the hierarchy. The tty lock should not be held around the chunks of code it's held around. Or there should be a higher level lock that protects this logging and tty lock only protects the write. I don't know how to fix this right now.
Since changing to UL, we don't tty->print very much except in the compiler code so it's not surprising that nothing asserts for the Service_lock taking out tty lock.

@@ -320,7 +320,7 @@ void mutex_init() {
def(JfrMsg_lock , PaddedMonitor, leaf, true, _safepoint_check_always);
def(JfrBuffer_lock , PaddedMutex , leaf, true, _safepoint_check_never);
def(JfrStream_lock , PaddedMutex , nonleaf + 1, false, _safepoint_check_never);
def(JfrStacktrace_lock , PaddedMutex , tty-2, true, _safepoint_check_never);
def(JfrStacktrace_lock , PaddedMutex , stackwatermark-1, true, _safepoint_check_never);
Copy link
Member

Choose a reason for hiding this comment

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

Not clear why this one has to be less than the SWM rather than just remain less than tty?

Copy link
Contributor Author

@coleenp coleenp Aug 27, 2021

Choose a reason for hiding this comment

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

The reason this was tty-2 was that I assume that this lock is taken when the stackwatermark lock is held, when stackwatermark was tty-1, and not when the tty lock is held, since it's not compiler code.
When I make it the same rank as stackwatermark I get:
failed: Attempting to acquire lock JfrStacktrace_lock/6 out of order with lock StackWatermark_lock/6 -- possible deadlock
So I conclude that's why that lock ordering should be stackwatermark-1

@openjdk
Copy link

openjdk bot commented Aug 26, 2021

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

8272480: Remove Mutex::access rank

Reviewed-by: dholmes, eosterlund

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

  • 596b075: 8258465: Headless build fails due to missing X11 headers on linux
  • a49a0c5: 8273062: Generation::refs_discovery_is_xxx functions are unused
  • ebd62bc: 8272846: Move some runtime/Metaspace/elastic/ tests out of tier1
  • 46684a4: 8262386: resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java timed out
  • c925c7f: 8273020: LibraryCallKit::sharpen_unsafe_type does not handle narrow oop array
  • 76baace: 8273045: Fix misc javadoc bugs in the java.security and javax.net.ssl code
  • b16a04e: 8271186: Add UL option to replace newline char
  • d732c30: 8272863: Replace usages of Collections.sort with List.sort call in public java modules
  • fe7d708: 8272473: Parsing epoch seconds at a DST transition with a non-UTC parser is wrong
  • 845e1ce: 8272983: G1 Add marking details to eager reclaim logging
  • ... and 11 more: https://git.openjdk.java.net/jdk/compare/2ef6871118109b294e3148c8f15d4335039dd121...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 Aug 26, 2021
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.

Looks good! Good cleanup.

@coleenp
Copy link
Contributor Author

coleenp commented Aug 27, 2021

Thanks @dholmes-ora and @fisk for the code reviews!
/integrate

@openjdk
Copy link

openjdk bot commented Aug 27, 2021

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

  • 596b075: 8258465: Headless build fails due to missing X11 headers on linux
  • a49a0c5: 8273062: Generation::refs_discovery_is_xxx functions are unused
  • ebd62bc: 8272846: Move some runtime/Metaspace/elastic/ tests out of tier1
  • 46684a4: 8262386: resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java timed out
  • c925c7f: 8273020: LibraryCallKit::sharpen_unsafe_type does not handle narrow oop array
  • 76baace: 8273045: Fix misc javadoc bugs in the java.security and javax.net.ssl code
  • b16a04e: 8271186: Add UL option to replace newline char
  • d732c30: 8272863: Replace usages of Collections.sort with List.sort call in public java modules
  • fe7d708: 8272473: Parsing epoch seconds at a DST transition with a non-UTC parser is wrong
  • 845e1ce: 8272983: G1 Add marking details to eager reclaim logging
  • ... and 11 more: https://git.openjdk.java.net/jdk/compare/2ef6871118109b294e3148c8f15d4335039dd121...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Aug 27, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated labels Aug 27, 2021
@openjdk
Copy link

openjdk bot commented Aug 27, 2021

@coleenp Pushed as commit b92214a.

💡 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 Aug 27, 2021
@coleenp coleenp deleted the access branch August 27, 2021 13:57
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