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

8267653: Remove Mutex::_safepoint_check_sometimes #4184

Closed
wants to merge 2 commits into from

Conversation

@coleenp
Copy link
Contributor

@coleenp coleenp commented May 25, 2021

Since SR_lock is removed, this state of declaring locks as sometimes safepoint checking and not is no longer used. JavaThreads either always or never check for safepoint, depending on the lock. The Heap_lock was always a bit special because it's taken by a JavaThread after it exits, but the code in mutex::lock_contended already deals with this (ie doesn't safepoint check while exiting).
Tested with tier 2-3 and tier1 in progress.
Thanks to Zhengu for testing and confirming shenandoah (I built and ran shenandoah tests too).


Progress

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

Issue

  • JDK-8267653: Remove Mutex::_safepoint_check_sometimes

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4184

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented May 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.

Loading

@openjdk openjdk bot added the rfr label May 25, 2021
@openjdk
Copy link

@openjdk openjdk bot commented May 25, 2021

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

  • hotspot
  • 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 pull request command.

Loading

@mlbridge
Copy link

@mlbridge mlbridge bot commented May 25, 2021

Webrevs

Loading

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Hi Coleen,

This seems fine. Working through the thread and VM termination logic is always tricky. Just to be clear the condition for the mutex not checking safepoints is that the thread has terminated, not just that it is exiting, so I've suggested an additional assert before taking the Heap-lock.

Thanks,
David

Loading

Loading
src/hotspot/share/runtime/thread.cpp Show resolved Hide resolved
Loading
@openjdk
Copy link

@openjdk openjdk bot commented May 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:

8267653: Remove Mutex::_safepoint_check_sometimes

Reviewed-by: dholmes, pchilanomate

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

  • de91643: 8267611: Print more info when pointer_delta assert fails
  • a4c46e1: 8263202: Update Hebrew/Indonesian/Yiddish ISO 639 language codes to current
  • 9c346a1: 8266963: Remove safepoint poll introduced in 8262443 due to reentrance issue
  • 45e0597: 8264302: Create implementation for Accessibility native peer for Splitpane java role
  • 4343997: 8267708: Remove references to com.sun.tools.javadoc.**
  • f632254: 8267221: jshell feedback is incorrect when creating method with array varargs parameter
  • bf8d4a8: 8267583: jmod fails on symlink to class file
  • 083416d: 8267130: Memory Overflow in Disassembler::load_library
  • 9d305b9: 8252372: Check if cloning is required to move loads out of loops in PhaseIdealLoop::split_if_with_blocks_post()
  • 0394416: 8267468: Rename refill waster counters in ThreadLocalAllocBuffer
  • ... and 61 more: https://git.openjdk.java.net/jdk/compare/7b98400c81900a8c779394d549b5fb61f1dd8638...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.

Loading

@openjdk openjdk bot added the ready label May 26, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented May 26, 2021

Mailing list message from David Holmes on hotspot-dev:

On 26/05/2021 11:53 am, Coleen Phillimore wrote:

On Wed, 26 May 2021 00:38:00 GMT, David Holmes <dholmes at openjdk.org> wrote:

Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:

Add assert that the thread is terminated before taking Heap_lock

src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp line 543:

541: } else {
542: // Heap_lock protects external pending list
543: MonitorLocker ml(Heap_lock);

For performance you could leave the _no_safepoint_check flag.

I cannot leave it because there's an assert to verify that we don't try to take this lock without a safepoint check, since it was declared with safepoint_check_always.

But that assert only applies to JavaThreads and this is being taken by a
GC thread isn't it?

src/hotspot/share/runtime/thread.cpp line 3420:

3418: // we'll never emerge out of the safepoint before the VM exits.
3419:
3420: MutexLocker ml(Heap_lock);

Can you add an assert before this that the thread is_terminated() as that is the key to the mutex acquisition not doing a safepoint check.

Ok, I can add:
+ assert(thread->is_terminated(), "must be terminated before acquiring Heap_lock");
and rerun tests.

Thanks,
David

Loading

1 similar comment
@mlbridge
Copy link

@mlbridge mlbridge bot commented May 26, 2021

Mailing list message from David Holmes on hotspot-dev:

On 26/05/2021 11:53 am, Coleen Phillimore wrote:

On Wed, 26 May 2021 00:38:00 GMT, David Holmes <dholmes at openjdk.org> wrote:

Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:

Add assert that the thread is terminated before taking Heap_lock

src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp line 543:

541: } else {
542: // Heap_lock protects external pending list
543: MonitorLocker ml(Heap_lock);

For performance you could leave the _no_safepoint_check flag.

I cannot leave it because there's an assert to verify that we don't try to take this lock without a safepoint check, since it was declared with safepoint_check_always.

But that assert only applies to JavaThreads and this is being taken by a
GC thread isn't it?

src/hotspot/share/runtime/thread.cpp line 3420:

3418: // we'll never emerge out of the safepoint before the VM exits.
3419:
3420: MutexLocker ml(Heap_lock);

Can you add an assert before this that the thread is_terminated() as that is the key to the mutex acquisition not doing a safepoint check.

Ok, I can add:
+ assert(thread->is_terminated(), "must be terminated before acquiring Heap_lock");
and rerun tests.

Thanks,
David

Loading

@mlbridge
Copy link

@mlbridge mlbridge bot commented May 26, 2021

Mailing list message from Coleen Phillimore on hotspot-dev:

On 5/25/21 10:00 PM, David Holmes wrote:

On 26/05/2021 11:53 am, Coleen Phillimore wrote:

On Wed, 26 May 2021 00:38:00 GMT, David Holmes <dholmes at openjdk.org>
wrote:

Coleen Phillimore has updated the pull request incrementally with
one additional commit since the last revision:

?? Add assert that the thread is terminated before taking Heap_lock

src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp
line 543:

541:?? } else {
542:???? // Heap_lock protects external pending list
543:???? MonitorLocker ml(Heap_lock);

For performance you could leave the _no_safepoint_check flag.

I cannot leave it because there's an assert to verify that we don't
try to take this lock without a safepoint check, since it was
declared with safepoint_check_always.

But that assert only applies to JavaThreads and this is being taken by
a GC thread isn't it?

It's true that if this is a non-Java thread, it wouldn't fire the assert
that checks that the states are consistent.? I had to go study the code
a bit to see that, which I wouldn't want to do over again.? But it would
be very inconsistent in the code since all other Heap_lock acquisitions
are not made with _no_safepoint_check, we would have to look again to
see why this is special and other GC threads take Heap_lock without
no_safepoint_check.

And it wouldn't be a meaningful optimization.

thanks,
Coleen

src/hotspot/share/runtime/thread.cpp line 3420:

3418:???? // we'll never emerge out of the safepoint before the VM
exits.
3419:
3420:???? MutexLocker ml(Heap_lock);

Can you add an assert before this that the thread is_terminated() as
that is the key to the mutex acquisition not doing a safepoint check.

Ok, I can add:
+??? assert(thread->is_terminated(), "must be terminated before
acquiring Heap_lock");
and rerun tests.

Thanks,
David

Loading

1 similar comment
@mlbridge
Copy link

@mlbridge mlbridge bot commented May 26, 2021

Mailing list message from Coleen Phillimore on hotspot-dev:

On 5/25/21 10:00 PM, David Holmes wrote:

On 26/05/2021 11:53 am, Coleen Phillimore wrote:

On Wed, 26 May 2021 00:38:00 GMT, David Holmes <dholmes at openjdk.org>
wrote:

Coleen Phillimore has updated the pull request incrementally with
one additional commit since the last revision:

?? Add assert that the thread is terminated before taking Heap_lock

src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp
line 543:

541:?? } else {
542:???? // Heap_lock protects external pending list
543:???? MonitorLocker ml(Heap_lock);

For performance you could leave the _no_safepoint_check flag.

I cannot leave it because there's an assert to verify that we don't
try to take this lock without a safepoint check, since it was
declared with safepoint_check_always.

But that assert only applies to JavaThreads and this is being taken by
a GC thread isn't it?

It's true that if this is a non-Java thread, it wouldn't fire the assert
that checks that the states are consistent.? I had to go study the code
a bit to see that, which I wouldn't want to do over again.? But it would
be very inconsistent in the code since all other Heap_lock acquisitions
are not made with _no_safepoint_check, we would have to look again to
see why this is special and other GC threads take Heap_lock without
no_safepoint_check.

And it wouldn't be a meaningful optimization.

thanks,
Coleen

src/hotspot/share/runtime/thread.cpp line 3420:

3418:???? // we'll never emerge out of the safepoint before the VM
exits.
3419:
3420:???? MutexLocker ml(Heap_lock);

Can you add an assert before this that the thread is_terminated() as
that is the key to the mutex acquisition not doing a safepoint check.

Ok, I can add:
+??? assert(thread->is_terminated(), "must be terminated before
acquiring Heap_lock");
and rerun tests.

Thanks,
David

Loading

Copy link
Contributor

@pchilano pchilano left a comment

Looks good to me!

Thanks,
Patricio

Loading

@coleenp
Copy link
Contributor Author

@coleenp coleenp commented May 26, 2021

Thanks Patricio and David!
/integrate

Loading

@openjdk openjdk bot closed this May 26, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels May 26, 2021
@openjdk
Copy link

@openjdk openjdk bot commented May 26, 2021

@coleenp Since your change was applied there have been 71 commits pushed to the master branch:

  • de91643: 8267611: Print more info when pointer_delta assert fails
  • a4c46e1: 8263202: Update Hebrew/Indonesian/Yiddish ISO 639 language codes to current
  • 9c346a1: 8266963: Remove safepoint poll introduced in 8262443 due to reentrance issue
  • 45e0597: 8264302: Create implementation for Accessibility native peer for Splitpane java role
  • 4343997: 8267708: Remove references to com.sun.tools.javadoc.**
  • f632254: 8267221: jshell feedback is incorrect when creating method with array varargs parameter
  • bf8d4a8: 8267583: jmod fails on symlink to class file
  • 083416d: 8267130: Memory Overflow in Disassembler::load_library
  • 9d305b9: 8252372: Check if cloning is required to move loads out of loops in PhaseIdealLoop::split_if_with_blocks_post()
  • 0394416: 8267468: Rename refill waster counters in ThreadLocalAllocBuffer
  • ... and 61 more: https://git.openjdk.java.net/jdk/compare/7b98400c81900a8c779394d549b5fb61f1dd8638...master

Your commit was automatically rebased without conflicts.

Pushed as commit c59484e.

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

Loading

@coleenp coleenp deleted the sometimes branch May 26, 2021
@coleenp coleenp restored the sometimes branch May 26, 2021
@coleenp coleenp deleted the sometimes branch May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants