Skip to content

8303908: Add missing check in VTMS_transition_disable_for_all() for suspend mode#12956

Closed
pchilano wants to merge 1 commit intoopenjdk:masterfrom
pchilano:JDK-8303908
Closed

8303908: Add missing check in VTMS_transition_disable_for_all() for suspend mode#12956
pchilano wants to merge 1 commit intoopenjdk:masterfrom
pchilano:JDK-8303908

Conversation

@pchilano
Copy link
Contributor

@pchilano pchilano commented Mar 9, 2023

Please review this small fix. A suspender is a JvmtiVTMSTransitionDisabler monopolist, meaning VTMS_transition_disable_for_all() should not return while there is any active jvmtiVTMSTransitionDisabler. The code though is checking for active "all-disablers" but it's missing the check for active "single disablers".
I attached a simple reproducer to the bug which I used to test the patch. Not sure if it was worth adding a test so the patch contains just the fix.

Thanks,
Patricio


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8303908: Add missing check in VTMS_transition_disable_for_all() for suspend mode

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12956/head:pull/12956
$ git checkout pull/12956

Update a local copy of the PR:
$ git checkout pull/12956
$ git pull https://git.openjdk.org/jdk pull/12956/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12956

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12956.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 9, 2023

👋 Welcome back pchilanomate! 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 Mar 9, 2023

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

  • hotspot
  • serviceability

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.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Mar 9, 2023
@pchilano pchilano marked this pull request as ready for review March 9, 2023 19:14
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 9, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 9, 2023

Webrevs

Copy link
Contributor

@sspitsyn sspitsyn 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 good.
Thank you for catching and taking care about it!
Serguei

@openjdk
Copy link

openjdk bot commented Mar 10, 2023

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

8303908: Add missing check in VTMS_transition_disable_for_all() for suspend mode

Reviewed-by: sspitsyn, dholmes

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

  • c313e1a: 8303922: build-test-lib target is broken
  • fbc76c2: 8304017: ProblemList com/sun/jdi/InvokeHangTest.java on windows-x64 in vthread mode
  • a06426a: 8274400: HotSpot Style Guide should permit use of alignof
  • 98a7a60: 8303863: RISC-V: TestArrayStructs.java fails after JDK-8303604
  • 0a4d54f: 8299779: Test tools/jpackage/share/jdk/jpackage/tests/MainClassTest.java timed out
  • 2116928: 8303900: Rename BitMap search functions
  • d7f4221: 8304005: ProblemList serviceability/AsyncGetCallTrace/MyPackage/ASGCTBaseTest.java on linux-x64 in Xcomp mode
  • 94de0a7: 8302513: remove sun.awt.util.IdentityLinkedList
  • bf16b5b: 8303937: Corrupted heap dumps due to missing retries for os::write()
  • 6f54eda: 8299088: ClassLoader::defineClass2 throws OOME but JNI exception pending thrown by getUTF
  • ... and 30 more: https://git.openjdk.org/jdk/compare/1e9942aa112edca33f964db127df6c9ce41e86ff...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 Mar 10, 2023
MonitorLocker ml(JvmtiVTMSTransition_lock);
java_lang_Thread::dec_VTMS_transition_disable_count(vth());
Atomic::dec(&_VTMS_transition_disable_for_one_count);
if (_VTMS_transition_disable_for_one_count == 0 || _is_SR) {
Copy link
Member

@dholmes-ora dholmes-ora Mar 10, 2023

Choose a reason for hiding this comment

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

Sorry I don't understand why this _is_SR check was removed. I admit I can't really figure out what this field means anyway, but there is nothing in the issue description that suggests this also needs changing - and it is now different to VTMS_transition_enable_for_all.

Copy link
Contributor Author

@pchilano pchilano Mar 10, 2023

Choose a reason for hiding this comment

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

A JvmtiVTMSTransitionDisabler instance that is a "single disabler" only blocks other virtual threads trying to transition or JvmtiVTMSTransitionDisabler monopolists. Both of them will check for _VTMS_transition_disable_for_one_count (the JvmtiVTMSTransitionDisabler monopolist was missing that check) so just checking when that counter is zero is enough. In fact, for a "single disabler" _is_SR is always false so that check wasn't doing anything. Yes, this is not actually needed for the fix, but when looking at which condition we use to wait and which one to notify I caught this, sorry for not explaining that part.

And looking closer at VTMS_transition_enable_for_all() now I see the check for _is_SR is not doing anything too, because if _VTMS_transition_disable_for_all_count was not zero after the decrement then this can't be a JvmtiVTMSTransitionDisabler monopolist, i.e _is_SR will be false. When a monopolist is running all other "disable all" JvmtiVTMSTransitionDisabler instances if any will be waiting in the first "while (_SR_mode)" loop in VTMS_transition_disable_for_all(), so _VTMS_transition_disable_for_all_count will be one through the monopolist run. So this should be an assert after the decrement: assert(!_is_SR || _VTMS_transition_disable_for_all_count == 0, "").

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for clarifying - I was puzzled by the way is_SR was being used.

@pchilano
Copy link
Contributor Author

This looks good. Thank you for catching and taking care about it! Serguei

Thanks for the review Serguei!

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.

Looks good. Thanks.

@pchilano
Copy link
Contributor Author

Looks good. Thanks.

Thanks for the review David!

@pchilano
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Mar 13, 2023

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

  • 5685107: 8302491: NoClassDefFoundError omits the original cause of an error
  • 671a452: 8303606: Memory leaks in Arguments::parse_each_vm_init_arg
  • a95bc7a: 8294974: Convert jdk.jshell/jdk.jshell.execution.LocalExecutionControl to use the Classfile API to instrument classes
  • f835aaa: 8300727: java/awt/List/ListGarbageCollectionTest/AwtListGarbageCollectionTest.java failed with "List wasn't garbage collected"
  • 466ffeb: 8303965: java.net.http.HttpClient should reset the stream if response headers contain malformed header fields
  • 431e702: 8303213: Avoid AtomicReference in TextComponentPrintable
  • 4cf4c59: 8303824: Parallel: Use more strict card table API
  • 8e41bf2: 8303238: Create generalizations for existing LShift ideal transforms
  • 805a4e6: 8303883: Confusing parameter name in G1UpdateRemSetTrackingBeforeRebuild::distribute_marked_bytes
  • 25e7ac2: 8294966: Convert jdk.jartool/sun.tools.jar.FingerPrint to use the ClassFile API to parse JAR entries
  • ... and 46 more: https://git.openjdk.org/jdk/compare/1e9942aa112edca33f964db127df6c9ce41e86ff...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 13, 2023
@openjdk openjdk bot closed this Mar 13, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 13, 2023
@openjdk
Copy link

openjdk bot commented Mar 13, 2023

@pchilano Pushed as commit a8f662e.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

3 participants